skynet
08-11-2009, 12:37 PM
it would work except that you need to change the GL context handle that Qt is using to the one you get back from wgl/glxCreateContextAttribARB, whose value (and type!)
I think, the purpose of using GL3 with Qt is not to make Qt using GL3 for its rendering, but instead to be able to render your own stuff with GL3 into a Qt widget.
This is possible, I did this in the same fashion with other GUI frameworks already.
Even though Qt is hiding the handles to its DC and RC, you can retrieve these via wglGetCurrentDC() and wglGetCurrentContext(), once Qt made its context current.
Then you do
HDC qtDC=wglGetCurrentDC();
// you need to retrieve the function pointer before
HGLRC myGL3RC= wglCreateContextAttribsARB( qtDC, NULL, *attribList);
and somewhere in your repaint() function, you do:
// store original context
HDC qtDC=wglGetCurrentDC();
HGLRC qtRC=wglGetCurrentContext();
//make your GL3 context current and let it render into the Qt window
wglMakeCurrent(qtDC, myGL3RC);
...render your stuff...
// restore original context
wglMakeCurrent(qtDC, qtRC);
Disclaimer: I did not actually test this with Qt, but it _should_ work.
I think, the purpose of using GL3 with Qt is not to make Qt using GL3 for its rendering, but instead to be able to render your own stuff with GL3 into a Qt widget.
This is possible, I did this in the same fashion with other GUI frameworks already.
Even though Qt is hiding the handles to its DC and RC, you can retrieve these via wglGetCurrentDC() and wglGetCurrentContext(), once Qt made its context current.
Then you do
HDC qtDC=wglGetCurrentDC();
// you need to retrieve the function pointer before
HGLRC myGL3RC= wglCreateContextAttribsARB( qtDC, NULL, *attribList);
and somewhere in your repaint() function, you do:
// store original context
HDC qtDC=wglGetCurrentDC();
HGLRC qtRC=wglGetCurrentContext();
//make your GL3 context current and let it render into the Qt window
wglMakeCurrent(qtDC, myGL3RC);
...render your stuff...
// restore original context
wglMakeCurrent(qtDC, qtRC);
Disclaimer: I did not actually test this with Qt, but it _should_ work.