Skip to content

Commit 4bf8ad0

Browse files
committed
Renaming some GL functions in preparation for their Metal counterparts.
1 parent e86030e commit 4bf8ad0

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

cocos2d/CCNoARC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ @implementation CCRenderStateGL
242242
NSDictionary *globalShaderUniforms = renderer->_globalShaderUniforms;
243243
NSDictionary *setters = self->_shader->_uniformSetters;
244244
for(NSString *uniformName in setters){
245-
CCUniformSetter setter = setters[uniformName];
245+
CCGLUniformSetter setter = setters[uniformName];
246246
setter(renderer, self->_shaderUniforms, globalShaderUniforms);
247247
}
248248
}

cocos2d/CCShader.m

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ @implementation CCShader {
198198
BOOL _ownsProgram;
199199
}
200200

201-
//MARK: Uniform Setters:
201+
//MARK: GL Uniform Setters:
202202

203-
static CCUniformSetter
204-
SetFloat(NSString *name, GLint location)
203+
static CCGLUniformSetter
204+
GLUniformSetFloat(NSString *name, GLint location)
205205
{
206206
return ^(CCRenderer *renderer, NSDictionary *shaderUniforms, NSDictionary *globalShaderUniforms){
207207
NSNumber *value = shaderUniforms[name] ?: globalShaderUniforms[name] ?: @(0.0);
@@ -211,8 +211,8 @@ @implementation CCShader {
211211
};
212212
}
213213

214-
static CCUniformSetter
215-
SetVec2(NSString *name, GLint location)
214+
static CCGLUniformSetter
215+
GLUniformSetVec2(NSString *name, GLint location)
216216
{
217217
NSString *textureName = nil;
218218
bool pixelSize = [name hasSuffix:@"PixelSize"];
@@ -254,8 +254,8 @@ @implementation CCShader {
254254
};
255255
}
256256

257-
static CCUniformSetter
258-
SetVec3(NSString *name, GLint location)
257+
static CCGLUniformSetter
258+
GLUniformSetVec3(NSString *name, GLint location)
259259
{
260260
return ^(CCRenderer *renderer, NSDictionary *shaderUniforms, NSDictionary *globalShaderUniforms){
261261
NSValue *value = shaderUniforms[name] ?: globalShaderUniforms[name] ?: [NSValue valueWithGLKVector3:GLKVector3Make(0.0f, 0.0f, 0.0f)];
@@ -267,8 +267,8 @@ @implementation CCShader {
267267
};
268268
}
269269

270-
static CCUniformSetter
271-
SetVec4(NSString *name, GLint location)
270+
static CCGLUniformSetter
271+
GLUniformSetVec4(NSString *name, GLint location)
272272
{
273273
return ^(CCRenderer *renderer, NSDictionary *shaderUniforms, NSDictionary *globalShaderUniforms){
274274
NSValue *value = shaderUniforms[name] ?: globalShaderUniforms[name] ?: [NSValue valueWithGLKVector4:GLKVector4Make(0.0f, 0.0f, 0.0f, 1.0f)];
@@ -287,8 +287,8 @@ @implementation CCShader {
287287
};
288288
}
289289

290-
static CCUniformSetter
291-
SetMat4(NSString *name, GLint location)
290+
static CCGLUniformSetter
291+
GLUniformSetMat4(NSString *name, GLint location)
292292
{
293293
return ^(CCRenderer *renderer, NSDictionary *shaderUniforms, NSDictionary *globalShaderUniforms){
294294
NSValue *value = shaderUniforms[name] ?: globalShaderUniforms[name] ?: [NSValue valueWithGLKMatrix4:GLKMatrix4Identity];
@@ -301,7 +301,7 @@ @implementation CCShader {
301301
}
302302

303303
static NSDictionary *
304-
UniformSettersForProgram(GLuint program)
304+
GLUniformSettersForProgram(GLuint program)
305305
{
306306
NSMutableDictionary *uniformSetters = [NSMutableDictionary dictionary];
307307

@@ -327,11 +327,11 @@ @implementation CCShader {
327327
// Setup a block that is responsible for binding that uniform variable's value.
328328
switch(type){
329329
default: NSCAssert(NO, @"Uniform type not supported. (yet?)");
330-
case GL_FLOAT: uniformSetters[name] = SetFloat(name, location); break;
331-
case GL_FLOAT_VEC2: uniformSetters[name] = SetVec2(name, location); break;
332-
case GL_FLOAT_VEC3: uniformSetters[name] = SetVec3(name, location); break;
333-
case GL_FLOAT_VEC4: uniformSetters[name] = SetVec4(name, location); break;
334-
case GL_FLOAT_MAT4: uniformSetters[name] = SetMat4(name, location); break;
330+
case GL_FLOAT: uniformSetters[name] = GLUniformSetFloat(name, location); break;
331+
case GL_FLOAT_VEC2: uniformSetters[name] = GLUniformSetVec2(name, location); break;
332+
case GL_FLOAT_VEC3: uniformSetters[name] = GLUniformSetVec3(name, location); break;
333+
case GL_FLOAT_VEC4: uniformSetters[name] = GLUniformSetVec4(name, location); break;
334+
case GL_FLOAT_MAT4: uniformSetters[name] = GLUniformSetMat4(name, location); break;
335335
case GL_SAMPLER_2D: {
336336
// Sampler setters are handled a differently since the real work is binding the texture and not setting the uniform value.
337337
uniformSetters[name] = ^(CCRenderer *renderer, NSDictionary *shaderUniforms, NSDictionary *globalShaderUniforms){
@@ -413,7 +413,7 @@ -(instancetype)initWithVertexShaderSource:(NSString *)vertexSource fragmentShade
413413

414414
CCGL_DEBUG_POP_GROUP_MARKER();
415415

416-
blockself = [blockself initWithGLProgram:program uniformSetters:UniformSettersForProgram(program) ownsProgram:YES];
416+
blockself = [blockself initWithGLProgram:program uniformSetters:GLUniformSettersForProgram(program) ownsProgram:YES];
417417
});
418418

419419
return blockself;

cocos2d/CCShader_Private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#import "CCShader.h"
88

99
@class CCRenderer;
10-
typedef void (^CCUniformSetter)(
10+
11+
typedef void (^CCGLUniformSetter)(
1112
__unsafe_unretained CCRenderer *renderer,
1213
__unsafe_unretained NSDictionary *shaderUniforms,
1314
__unsafe_unretained NSDictionary *globalShaderUniforms

0 commit comments

Comments
 (0)