Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Using older OpenGL versions (QOpenGLFunctions_3_0 compile error)
Joel Bodenmann last edited by
I'm currently trying to make a small proof-of-concept demonstration that shows that Qt can be used to render to an OculusRift using the OculusSDK and OpenGL.
It has been quite a while since I last played with OpenGL and it seems that a lot of stuff changed, especially with OpenGL ES and stuff like that.
The OculusSDK comes with an OpenGL example that runs fine. However, it's not using Qt - it's a bare Windows application. I'd like to just render a simple cube to the Oculus.
So far, the integration of the Oculus stuff has not been any problem at all. I'm able to talk to the goggles and retrieve sensor values. I'm a bit stuck with the rendering though: The OculusSDK provides a function that basically returns an OpenGL texture I can render to. I assume that once I retrieved that texture I can just render to it using OpenGL like I'm used to (after binding using
My big problem right now is the OpenGL + Qt combination. Right now I have a custom class that inherits from
QOpenGLFunctions. However, it seems that
QOpenGLFunctionsuses/exposes the OpenGL ES 2.0 API. The Oculus examples use something like OpenGL 2.0 or 3.0 (non-ES). There are no shaders being programmed and stuff like that. There are also simple calls to
glEnd()which seem to have disappeared in more recent OpenGL versions.
So I digged a bit through the Qt documentation and it seems that
QOpenGLFunctions_3_0provides the API I'm looking for. I hoped that this would be quite easy: Instead of inheriting from
QOpenGLFunctionsI modified my class to inherit from
QOpenGLFunctions_3_0but I'm unable to compile. I get tons of "strange" compile errors: http://paste.ugfx.io/show/9ff63943c3
My question: How can I write a Qt application using Qt 5.9 and MSVC 2015 32-bit using an older OpenGL API? Am I missing something obvious here?
I'd appreciate any kind of help.
A Former User last edited by A Former User
Hi! You don't need to use
QOpenGLFunctionsat all. Just create a
QOpenGLWindow, override the needed virtual functions and use the OpenGL C API as always. You might also need to change the settings for the default surface type in
main.cpp. I've just posted example code for the latter here.
Joel Bodenmann last edited by
Thank you a lot for your reply, much appreciated!
The reason I'm using
QOpenGLFunctionsis because I don't want to render to a window/widget on the desktop machine. As far as I know, using
QOpenGLWindowwould mean that I render to a window/widget on the desktop rather than to the buffer that the OculusSDK will use to render to the VR goggles. Or am I mistaken here?
A Former User last edited by
If you don't need to render to anything else but to that texture you receive from the Oculus SDK, then you actually don't need anything Qt-related. Just use OpenGL C API provided by the platform.