Thanks for the replys, I really appreciate it. This problem has been frustrating me for a while now. Just to make things clearer, here is the entire vertex shader after preprocessing by cocos2d-x:
#version 120
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
attribute vec4 a_position;
uniform float u_size;
#ifdef GL_ES
varying lowp vec4 v_fragmentColor;
#else
varying vec4 v_fragmentColor;
#endif
void main() {
gl_Position = CC_PMatrix * CC_MVMatrix * a_position;
gl_PointSize = CC_MVMatrix[0][0] * u_size * 1.5;
v_fragmentColor = vec4(1, 1, 1, 1);
}
And the fragment shader:
#version 120
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
varying vec4 v_fragmentColor;
void main() {
gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, gl_PointCoord);
// gl_FragColor = texture2D(CC_Texture0, gl_PointCoord); // Produces the texture as expected, no problems!
// gl_FragColor = v_fragmentColor; // Produces a white box as expected, no problems!
}
Now to your responses:
Try compiling your shaders with the reference compiler to see if they comply with the spec.
Thanks for showing me this, I had never seen it before. I tried running it on the above shaders and it didn't seem to find anything.
I see that "gl_FragColor = v_fragmentColor; // Produces a white box as expected, no problems!"
I wouldn't be so sure about that. Try a better colour, like (0.6, 0.4, 0.2, 1.0) (orange).
If something goes wrong the driver may fallback to an all white or an all black pixel shader.
Also, needless to say running behind a VM with OpenGL is far from optimal (rather... extremely suboptimal).
Another problem is that this isn't the code you're executing because from what you're saying cocos-2d is adding more code. It's possible these additions are causing the shader to be non-standard compliant.
For example some ancient code we had in our OGRE engine added code before the user declared #extension; but by spec #extensions must be declared before anything else. We never noticed until Mesa SW implementation (also the Mesa Intel drivers) started complaining because it was the only OpenGL implementation that actually enforced it, the others silently accepted the faulty shader.
I tried (0.6, 0.4, 0.2, 1.0) instead of white and it indeed produces an orange box. So if my shader is compliant and I've gotten it working inside one VM (albeit with a different graphics card), do I have any other options to get it working on this one specific platform?
Thanks again for responses.