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. How to connect OpenGL 3-4 to OpenGLWidget?
Forum Updated to NodeBB v4.3 + New Features

How to connect OpenGL 3-4 to OpenGLWidget?

Scheduled Pinned Locked Moved General and Desktop
openglqopenglwidget
8 Posts 3 Posters 2.2k Views 2 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.
  • Q Offline
    Q Offline
    QtNewUser
    wrote on last edited by QtNewUser
    #1

    Hi everyone! I had a one annoying problem. I'm trying connect a modern OpenGL to QOpenGLwidget which appeared in the modern version of Qt. Nothing happens. Yes, I can create an OpenGL window but unfortunately without ui elements. All you do is add turns QOpenGLWidget an empty window. Then I just have no idea how to work with it.

    I am writing on Windows 8, Qt 5.5.

    Before the question of how to set the I walk around almost the entire Internet, but to no avail. Nowhere is rising this topic. The documentation did not help, since I am not an expert on Qt.

    I would be very grateful for any help. I think this question quite a few worries.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yoavmil
      wrote on last edited by
      #2

      post your code. this sounds like a very basic issue. compare your code to the example

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

        I have not written any code. I just added the OpenGLwidget to MainWindow.

        An example of an interesting, but it does not contain the ui elements.

        My problem is that I can't work with the built-in ui interface. If there are any interesting examples of implementation I will be very happy.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Something's not clear, what are you expecting from QOpenGLWidget ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            Something's not clear, what are you expecting from QOpenGLWidget ?

            Q Offline
            Q Offline
            QtNewUser
            wrote on last edited by
            #5

            @SGaist said:

            Hi and welcome to devnet,

            Something's not clear, what are you expecting from QOpenGLWidget ?

            I just need to move on OpenGL to Qt platform. I do not understand how to do it. OpenGLWidget it seems to be a component for working with OpenGL? But I had no ideas how to use it.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What OpenGL code do you already have ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              Q 1 Reply Last reply
              0
              • SGaistS SGaist

                What OpenGL code do you already have ?

                Q Offline
                Q Offline
                QtNewUser
                wrote on last edited by QtNewUser
                #7

                @SGaist

                This is part of my code. I don't think what it help to somebody. I'm still no understand how to attach OpenGL to OpenGLWidget.

                #ifndef OPENGLRENDER_H
                #define OPENGLRENDER_H
                #include <QOpenGLFunctions>

                class OpenGLrender : public QOpenGLWidget, protected QOpenGLFunctions
                {
                public:
                OpenGLrender(QWidget *parent) : QOpenGLWidget(parent) { }

                protected:
                void initializeGL()
                {
                QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
                f->glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
                }

                void resizeGL(int w, int h)
                {
                    m_projection.setToIdentity();
                    m_projection.perspective(45.0f, w / float(h), 0.01f, 100.0f);
                }
                
                void paintGL()
                {
                    QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
                    f->glClear(GL_COLOR_BUFFER_BIT);
                }
                

                };

                #endif // OPENGLRENDER_H

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You should take a look at the OpenGL examples in the Qt sources, you'll have a better understanding of how it works

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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