QOpenGLFunctions_2_0 suddenly fails to load functions related to OpenGL's Shaders
-
I am coding an application using Qt 5 and OpenGL 2.0
I tried to build GLSL-Debugger (which I failed). But it involved a lot of manipulation, and now my code do not work anymore, event when I build&run certified running snapshots on my version control system. I tried regular debugging a long time, and after installing the Qt source from the package manager and linking them to be readable for debugging, I noticed that QOpenGLFunctions_2_0 does not have a valid resolution for any function related to OpenGL shaders. This involves glCreateProgram, glCreateShader and glShaderSource. Here is a picture of the variables at the top frame, just before executing the fatal line that makes everything crash
!http://oi61.tinypic.com/m8dwfp.jpg!
This is the failing code, in qopenglfunctions.cpp :
@template <typename Base, typename FuncType, int Policy> template <typename P1>
void Resolver<Base, FuncType, Policy, void>::operator()(P1 p1)
{
RESOLVER_COMMON_VOID(funcs->*funcPointerName)(p1);
}@
Note : the debugger does not explicitely gives this line as failing, rather it says it fails on function ig4icd32!DrvCreateLayerContext of file C:\Windows\system32\ig4icd32.dll, without any stack frame.
!http://oi58.tinypic.com/2sb69l2.jpg!
The “true” failing function was spotted by careful use of next/step/finish commands of the debugger.
-
Are you sure your card (ig4icd32 is Intel graphics) supports OpenGL 2.0?
Do you have up to date drivers?
Have you checked that the created OpenGL context is >= 2.0? -
Yes I've installed OpenGL Extension Viewer and my card supports OpenGL 2.0 and even 2.1. I reinstalled the graphic card driver, to no avail.
Anyway, the code that worked previously do not work anymore. Changing to OpenGL2.1 did not worked
Also, I use QOpenGLFunctions_2_0 so guess a wrong context would fail at the initialization of the class, not at rendering.
-
Yes, but did you check? :) Sorry, to quote a bad movie "assumption is the mother of all fuckups".
If it worked previously then do you use a version control? You could check what changed.
If not then I'd need to know more to try and help. How do you create OpenGL context and do you specifically ask for 2.0 context? If not then check the version of the context that you actually get. It might not be what you assume. How do you initialize QOpenGLFunctions_2_0 class ? Does initializeOpenGLFunctions() call return true?
-
I use svn, and even when svn revert-ing to a previous version, the build fails.
I realize I do not call initializeOpenGLFunctions() in my main widget, since all calls are done in other objects that also inherits QOpenGLFunctions_2_0. initializeOpenGLFunctions() returns true for these, and initialize most openGL functions like I show in the picture, but not shader-related ones.
But initializeOpenGLFunctions() crashes for my main widget inheriting QGLWidget (since there is no QOpenGLWidget). I just noticed this assert failure :
@ASSERT: "context" in file opengl\qopenglfunctions_2_1.cpp, @How do you check precisely what is my OpenGL context more precisely ?
Nevertheless I do not understand while it was working previously then.
-
If it was working then either you changed something in your program or the system config changed. No other option ;)
How you get context version depends on which OpenGL route you chose (Qt guys can't seem to make up their mind and introduce new and new ways to make a OpenGL window).
If you used QGLWidget then you get it like this:
@
yourGLWidget->context()->format()->majorVersion();
yourGLWidget->context()->format()->minorVersion();
@
For QWindow with OpenGL surface this would be something like:
@
yourWindow->format()->majorVersion();
yourWindow->format()->minorVersion();
@I don't think it's a good idea to have multiple classes inheriting QOpenGLFunctions_2_0. And if they do you should call initializeOpenGLFunctions() in every of them.
-
I do call initializeOpenGLFunctions() in every class inheriting QOpenGLFunctions_2_1 (I switched…). I do not like inheriting QOpenGLFunctions_2_1 in every classes either; but I do not see another way to have access to qOpenGLFunctions in each of them. Maybe I should use a global singleton QOpenGLFunctions_2_1.
Anyway my context returns 2 and 1 correctly ; the issue is elsewhere. And as it the previous image it seems specifically to target shaders :/
-
Hm, could you try to run "glewinfo":http://glew.sourceforge.net/ or similar program to check if it gets the function pointers? This way we'll at least know if it's a Qt problem or general OpenGL problem.
-
I ran it. It seems to be OK (for OpenGL until 2.1) :
@---------------------------
GLEW Extension InfoGLEW version 1.10.0
Reporting capabilities of pixelformat 3
Running on a Mobile Intel(R) 4 Series Express Chipset Family from Intel
OpenGL version 2.1.0 - Build 6.14.10.5420 is supportedGL_VERSION_1_1: OK
...
GL_VERSION_2_0: OKglAttachShader: OK
glBindAttribLocation: OK
glBlendEquationSeparate: OK
glCompileShader: OK
glCreateProgram: OK
glCreateShader: OK
glDeleteProgram: OK
glDeleteShader: OK
glDetachShader: OK
glDisableVertexAttribArray: OK
glDrawBuffers: OK
glEnableVertexAttribArray: OK
glGetActiveAttrib: OK
glGetActiveUniform: OK
glGetAttachedShaders: OK
...
glVertexAttribPointer: OKGL_VERSION_2_1: OK
glUniformMatrix2x3fv: OK
glUniformMatrix2x4fv: OK
glUniformMatrix3x2fv: OK
glUniformMatrix3x4fv: OK
glUniformMatrix4x2fv: OK
glUniformMatrix4x3fv: OK@