Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. QT5 OpenGL include[SOLVED]
QtWS25 Last Chance

QT5 OpenGL include[SOLVED]

Scheduled Pinned Locked Moved Game Development
13 Posts 5 Posters 26.7k Views
  • 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.
  • O Offline
    O Offline
    obab30
    wrote on last edited by
    #1

    Hi folks,

    i have a problem. I'm currently developing a project in qt 4.8.4 under windows (mingw).
    I include the following files to use OpenGL:

    @
    #include <QtOpenGL>
    #include <GL/glext.h>
    #include <GL/glu.h>
    @

    That works perfect.
    Now i want to use Qt5 (msvc2010). First of all there is no <GL/glext.h> header file. I've read about a #define which would manage to include the glext functions: #define GL_GLEXT_PROTOTYPES
    If I do it that way I'll get the some "already defined" errors like: "glDouble already defined".
    It seems that the define QT_OPENGL_ES_2 is always set, even if I undef it. Is there any reason for that? But I want to use OpenGL4.2.

    So that's what I tried in Qt5:

    @
    #define GL_GLEXT_PROTOTYPES
    #include <QtOpenGL>
    #include <GL/glu.h>
    @

    Is there any preferred way to include OpenGL?

    thanks in advance!

    obab

    1 Reply Last reply
    0
    • F Offline
      F Offline
      FreddeB
      wrote on last edited by
      #2

      Hi !

      I think You can find what You want at ..

      http://qt-project.org/doc/qt-5.0/qtopengl/qglformat.html

      Regards
      Fredrik

      Regards
      Fredrik

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Seraph
        wrote on last edited by
        #3

        Hmm.. I think he just wants to know what to include and define to use GL ext.
        The preprocessor just includes OpenGL_ES_2 stuff by default. Got the same here.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          obab30
          wrote on last edited by
          #4

          Yes right, Seraph!
          I want to use OpenGL defines such as GLfloat in independent classes (not derived from any other class). How can i manage that?

          Thanks,

          obab

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Seraph
            wrote on last edited by
            #5

            Hello Obab,

            It seems that in Qt 5 are still the old QGLXXX classes and new ones with the prefix QOpenGLXXX.
            I had a look in the QGLXXX header files which include GL_ES_2 stuff and the QOpenGLXXX classes include the normal open gl stuff.

            Maybe you should just replace your QGLXXX classes with the new QOpenGLXXX classes. Give it a try.

            I hope this will help you.

            1 Reply Last reply
            0
            • O Offline
              O Offline
              obab30
              wrote on last edited by
              #6

              Okay all the OpenGL 3.3 Stuff is working when i use

              @
              #define GL_GLEXT_PROTOTYPES
              #include <QtOpenGL>
              @

              But how do i get all the deprecated stuff to work? Stuff like "GL_POLYGON" or "GL_QUAD_STRIP".
              Is there a special define for that?

              Thanks,

              obab

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                OK first of all, are you using the pre-built Qt5 packages or did you compile Qt5 yourself? If you compiled it yourself what configure line did you use?

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  obab30
                  wrote on last edited by
                  #8

                  Hey ZapB,

                  i just used the pre-build msvc2010 package!

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    ZapB
                    wrote on last edited by
                    #9

                    [quote author="obab30" date="1356019442"]Hey ZapB,

                    i just used the pre-build msvc2010 package!

                    [/quote]

                    OK that is the source of your issues then. The pre-compiled Windows desktop version of Qt5 is built against ANGLE which only provides OpenGL ES 2 support by implementing it on top of DirectX 9.

                    This was done to ensure that QtQuick2 works on all windows systems, including those with crappy Intel OpenGL drivers ;)

                    OpenGL ES 2 does not support the legacy fixed function pipeline, only a shader-based one.

                    There is a bug open to provide a build of Qt 5 using the native desktop OpenGL implementation for Qt 5.0.1. Please go vote for https://bugreports.qt-project.org/browse/QTBUG-28715 to see this happen.

                    For now, you have two choices:

                    • Live with OpenGL ES 2 support and don't use legacy OpenGL
                    • Build your own copy of Qt 5 to use the native OpenGL drivers by passing in

                    @
                    -opengl desktop
                    @

                    to configure.

                    With the 2nd option you should have access to OpenGL from 1.0 up to 4.3 (if your card/driver support it).

                    Nokia Certified Qt Specialist
                    Interested in hearing about Qt related work

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Seraph
                      wrote on last edited by
                      #10

                      OK that should solve my "thread":http://qt-project.org/forums/viewthread/22915/, too! Thanks ZapB!
                      I'll give it a try. Obab would you please respond here again if it worked?

                      Thanks and merry x mas to everyone

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        obab30
                        wrote on last edited by
                        #11

                        Okay thank you very much ZapB! You're really helped me out! The second option worked for me :)

                        Merry X Mas!

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          longlong
                          wrote on last edited by
                          #12

                          I do as ZapB told but meet some problems when configure -opengl desktop.
                          My Qt version is 5.0.2.
                          I run the cmd.exe in windows and in the directory of D:\Qt\Qt5.0.2\5.0.2\Src\qtbase.
                          In order to compile Qt,
                          I input the commend "configure -opengl desktop". But it didn't work and no makefiles was got.
                          Could you tell me why? Dear ZapB?

                          1 Reply Last reply
                          0
                          • Z Offline
                            Z Offline
                            ZapB
                            wrote on last edited by
                            #13

                            Which compiler are you trying to build with? If it's MSVC then you need to make sure that the environment is setup correctly by executing the MSVC Command Prompt rather than cmd.exe directly. This executes a batch script that correctly sets up the path to your compiler etc.

                            Can you paste the exact configure line and output that you get please?

                            Nokia Certified Qt Specialist
                            Interested in hearing about Qt related work

                            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