Important: Please read the Qt Code of Conduct -

Using older OpenGL versions (QOpenGLFunctions_3_0 compile error)

  • Hello folks,

    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 glBindTexture() or similar).

    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 QOpenGLFunctions uses/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 glBegin() and 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_0 provides the API I'm looking for. I hoped that this would be quite easy: Instead of inheriting from QOpenGLFunctions I modified my class to inherit from QOpenGLFunctions_3_0 but I'm unable to compile. I get tons of "strange" compile errors:

    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.

  • Hi! You don't need to use QOpenGLFunctions at all. Just create a QOpenGLWidget or 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.

  • Thank you a lot for your reply, much appreciated!

    The reason I'm using QOpenGLFunctions is because I don't want to render to a window/widget on the desktop machine. As far as I know, using QOpenGLWidget or QOpenGLWindow would 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?

  • 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.

Log in to reply