- I have a render engine that works on an iOS app.
- I almost managed to make it work by calling the same openGL rendering engine from a qt(4.8) app with a QGLWidget. To support es2 function set my widget also inherits QGLFunctions.
However I still have issues with shaders : I could not compile them on qt with glCompileShader because of almost every keywords (lowp, vec4, vec2 …) were returning compilations errors. So I compiled it with QGLShader program, but I had to specify “#version 120”, the closest to es2. But still, my sprites don’t show up the right size and the only potentially influencing different pieces of code with iOS are in shader compilation / version. I think the issue in the shader is gl_PointSize not changing anything in qt’s compilation of the vertex shader.
Is there any better way for me to have shaders compiled on qt like they are on iOS ?
( I know glsl es2 version is coming from version 120 but I don’t know to what extent they differ ).
My shaders, working well on iOS but not on Qt:
const GLchar vShaderStr[] =
#ifdef QT_OPENGL_LIB
"#version 120\n"
#endif //QT_OPENGL_LIB
"attribute lowp vec4 Position;\n"
"attribute mediump vec2 TextureCoord;\n"
"attribute lowp float Weight;\n"
"uniform mat4 MVP;\n"
"varying mediump vec2 TextureCoordOut;\n"
"void main(void)\n"
"{\n"
" gl_Position = MVP * Position;\n"
" TextureCoordOut = TextureCoord;\n"
" gl_PointSize = Weight;\n"
"}\n";
const GLchar fShaderStr[] =
#ifdef QT_OPENGL_LIB
"#version 120\n"
#endif //QT_OPENGL_LIB
"varying mediump vec2 TextureCoordOut;\n"
"uniform sampler2D Sampler;\n"
"uniform bool IsSprite;\n"
"uniform lowp vec3 TextureColor;\n"
"uniform lowp float Opacity;\n"
"void main(void)\n"
"{\n"
" lowp vec4 textureColorResult;\n"
" textureColorResult = texture2D(Sampler, IsSprite ? gl_PointCoord : TextureCoordOut);\n"
" gl_FragColor = IsSprite ? vec4(mix(textureColorResult.rgb,TextureColor, 1.0),\n"
" textureColorResult.a * Opacity) : textureColorResult;\n"
"}\n";
Finally solved this issue !
I kept the #version 120 and found what was missing for it to work as it does on device.
On desktop with qt(5.0 now) you have to activate following gl functions that seem to be default on iOS: