I have written a Qt based dll with some OpenGL calls. If I load my DLL from my Qt application with QGLWidget used for rendering, a call to QGLContext::currentContext from the DLL returns the correct context. But if use my DLL in a non Qt based program there is no QGLContext returned. As a result I couldn’t use QGLShaderProgram in non Qt based apps.
What I am doing wrong?
P.S. Direct calls to glCreateProgram and so on in my library seem to work fine, but I want to use Qt classes.
Then you should use your DLL in an application that uses Qt. By requiring the Qt classes, your DLL now requires Qt. If you want your DLL to work when Qt isn’t available, then you shouldn’t use Qt.
Besides, the Qt classes for shaders and programs aren’t anything you couldn’t whip up in 30 minutes.