Skip to content

Commit 87c9c79

Browse files
committed
Configuration for shader precision defaults.
1 parent 4b5495c commit 87c9c79

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

cocos2d/CCShader.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
"uniform highp vec4 cc_SinTime;\n"
7979
"uniform highp vec4 cc_CosTime;\n"
8080
"uniform highp vec4 cc_Random01;\n\n"
81-
"uniform lowp sampler2D cc_MainTexture;\n\n"
82-
"varying lowp vec4 cc_FragColor;\n"
81+
"uniform " XSTR(CC_SHADER_COLOR_PRECISION) " sampler2D cc_MainTexture;\n\n"
82+
"varying " XSTR(CC_SHADER_COLOR_PRECISION) " vec4 cc_FragColor;\n"
8383
"varying highp vec2 cc_FragTexCoord1;\n"
8484
"varying highp vec2 cc_FragTexCoord2;\n\n"
8585
"// End Cocos2D shader header.\n\n";
@@ -97,7 +97,7 @@
9797

9898
static const GLchar *CCFragmentShaderHeader =
9999
"#ifdef GL_ES\n"
100-
"precision mediump float;\n\n"
100+
"precision " XSTR(CC_SHADER_DEFAULT_FRAGMENT_PRECISION) " float;\n"
101101
"#endif\n\n"
102102
"// End Cocos2D fragment shader header.\n\n";
103103

cocos2d/ccConfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@
130130
#define CC_SPRITE_DEBUG_DRAW 0
131131
#endif
132132

133+
#ifndef CC_SHADER_COLOR_PRECISION
134+
#define CC_SHADER_COLOR_PRECISION lowp
135+
#endif
136+
137+
#ifndef CC_SHADER_DEFAULT_FRAGMENT_PRECISION
138+
#define CC_SHADER_DEFAULT_FRAGMENT_PRECISION mediump
139+
#endif
140+
133141
#ifndef CC_ENABLE_EXPERIMENTAL_EFFECTS
134142
#define CC_ENABLE_EXPERIMENTAL_EFFECTS 1
135143
#endif

0 commit comments

Comments
 (0)