Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL without QGLWidget?
Qt 6.11 is out! See what's new in the release blog

OpenGL without QGLWidget?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Gentlefolk -

    Perhaps this is sacrilegious, but I would like to use OpenGL in a Qt program, without using the QGLWidget. Initially, this would be in Windows, but eventually on OS X as well. Does anyone have any trivial example code that they'd be willing to toss my way? Have searched around quite a bit, and just cannot find anything...

    Thanks!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Sorry, I don't understand your problem fully.

      If you are meant to use OpenGL without using Qt OpenGL module, it would be complex.

      If you are meant to use OpenGL native command in QWidget rather than QGLWidget, how about QPainter::beginNativePainting()?
      "http://doc.qt.nokia.com/stable/qpainter.html#beginNativePainting":http://doc.qt.nokia.com/stable/qpainter.html#beginNativePainting

      But you still have to set QGLWidget for viewport anyway.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        May be link below can be helpful too
        "Tutorial":http://www.cs.uccs.edu/~semwal/indexGLTutorial.html

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          [quote author="diro" date="1321586303"]Sorry, I don't understand your problem fully.

          If you are meant to use OpenGL without using Qt OpenGL module, it would be complex.

          If you are meant to use OpenGL native command in QWidget rather than QGLWidget, how about QPainter::beginNativePainting()?
          "http://doc.qt.nokia.com/stable/qpainter.html#beginNativePainting":http://doc.qt.nokia.com/stable/qpainter.html#beginNativePainting

          But you still have to set QGLWidget for viewport anyway.[/quote]

          I want to be able to use OpenGL inside a widget, with no involvement whatsoever of the QOpenGLWidget. I have used the QOpenGLWidget extensively, but the "favors" it does come at a price. Hence, the motivation.

          One should be able to obtain the Window-system-specific window (e.g. HWND on Windows), set up an OpenGL context appropriately, and then call OpenGL functions in the paint method. Unfortunately, when I've done this, I get nothing displayed. Surely this is just some simple error, and in truth, I've not spent a lot of time trying to figure out what I've done wrong. Hence, my question :-)

          Perhaps this native painting scheme might do the trick, but I don't understand your last comment about having to use a QOpenGLWidget to set the viewport - I can get the window's size from any QWidget, and so I should be able to set the OpenGL viewport with that info, right?

          I was hoping I could just obtain a simple "Hello, world" type program from someone who's already figured this out :-)

          In any case, thanks much for your response...

          -- Philip

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            What exactly is your motivation not to use QGLWidget? Portability? I assume you're using Qt's other services anyway (loading textures etc) so what's the harm in using QGLWidget?

            For reference, I wrote an OpenGL app that uses only portable standard OpenGL (none of those classes provided by Qt such as QGLShaderProgram) and QGLWidget just to provide the OpenGL context. I put 90% of my code in portable C++ and use a following class setup:

            @class MyPortableOpenGlStuff { .. }

            class MyGLWidget : public QGLWidget, public MyPortableOpenGlStuff { .. }@

            To port the software, only stuff such as the context + image loading would have to be rewritten. And since most of the platforms run Qt code (damn you Apple, thank you Necessitas) nicely, I havent even had to port anything yet..

            • Matti
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved