Closed dabingnn closed 7 years ago
Yes, gl_PointCoord
is available on OpenGL ES 2.0, and it is available on OpenGL as well, but only with the shading language version 1.1 or newer.
https://www.opengl.org/sdk/docs/man/html/gl_PointCoord.xhtml
So, the way to fix it is by adding `
`
at the very beginning of the shader... but only on OpenGL shaders (not OpenGL ES).
Since cocos2d pre-pends some code to all shaders, probably we should add a function that says something like:
GLProgram::setOpenGLSLversion(foat version);
of something like that.
I have add #version 110
at the beginnig of the shader only to check the crash on win32 , like this
bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source)
{
...
const GLchar *sources[] = {
"#version 110 \n"
...
}
And the test case still crashed.
what error did you get ? have you tried on Mac ?
The errors on the win32 as follows:
cocos2d: ERROR: Failed to compile shader:
#version 110
uniform mat4 CC_PMatrix;
uniform mat4 CC_MVMatrix;
uniform mat4 CC_MVPMatrix;
uniform mat3 CC_NormalMatrix;
uniform vec4 CC_Time;
uniform vec4 CC_SinTime;
uniform vec4 CC_CosTime;
uniform vec4 CC_Random01;
uniform sampler2D CC_Texture0;
uniform sampler2D CC_Texture1;
uniform sampler2D CC_Texture2;
uniform sampler2D CC_Texture3;
//CC INCLUDES END
#ifdef GL_ES precision lowp float; #endif void main() { gl_FragColor = texture2D(CC_Texture0, gl_PointCoord); }
First-chance exception at 0x62AE8F20 (glew32.dll) in LiquidFun-EyeCandy.exe: 0xC0000005: Access violation executing location 0x62AE8F20.
Unhandled exception at 0x62AE8F20 (glew32.dll) in LiquidFun-EyeCandy.exe: 0xC0000005: Access violation executing location 0x62AE8F20.
The errors on the Mac as follows:
ocos2d: cocos2d: ERROR: Failed to compile shader:
#version 110
uniform mat4 CC_PMatrix;
uniform mat4 CC_MVMatrix;
uniform mat4 CC_MVPMatrix;
uniform mat3 CC_NormalMatrix;
uniform vec4 CC_Time;
uniform vec4 CC_SinTime;
uniform vec4 CC_CosTime;
uniform vec4 CC_Random01;
uniform sampler2D CC_Texture0;
uniform sampler2D CC_Texture1;
uniform sampler2D CC_Texture2;
uniform sampler2D CC_Texture3;
//CC INCLUDES END
void main() { gl_FragColor = texture2D(CC_Texture0, gl_PointCoord); }
cocos2d: cocos2d: ERROR: 0:17: Use of undeclared identifier 'gl_PointCoord'
cocos2d: cocos2d: ERROR: Failed to compile fragment shader
cocos2d: Assert failed: invalid shader
I have the same problem when compile shader
I had a similar problem. For me, it was resolved by specifying version 1.2, not 1.1:
#version 120
I can not find where is gl_PointCoord
being used in latest codes. @octachrome could you please show me where it is used? Thanks.
@minggo Sorry, I am not actually using cocos2d. My post was a general solution for how to compile a shader which uses gl_PointCoord
. There is a mistake in the OpenGL docs which state that gl_PointCoord
is a 1.1 feature, whereas in fact it was introduced in 1.2.
@octachrome good to know, thanks.
I will close this issue since gl_PointCoord
is not used anymore.
@ricardoquesada Heard from minggo, that you have a solution for this. Could you please take a look at it?