I am looking for help/information concerning this issue :
My work: I have an opengl es2 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 first, then 5.0 since today) app with a QGLWidget. To support es2 function set my widget also inherits QGLFunctions (QtOpenGLFunctions with qt 5.0.0).
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 QOpenGLShader 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 that gl_PointSize is not taken into account.
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 ). The hello-gl-es2 example did not help me because glsl version also returns 1.20.
I’ll happily receive any hints, thank you !
My shaders, working well on iOS but not on Qt:
const GLchar vShaderStr[] = #ifdef __BUILD_DESKTOP__ "#version 120\n" // necessary for Qt to compile shaders #endif //__BUILD_DESKTOP__ "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 __BUILD_DESKTOP__ "#version 120\n" // necessary for Qt to compile shaders #endif //__BUILD_DESKTOP__ "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"; Edit : replaced preprocessor QT_OPENGL_LIB with custom BUILD_DESKTOP as the first is no more declared in qt5.