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. [Solved] Qt and ANGLE woes
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt and ANGLE woes

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 8.6k 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.
  • M Offline
    M Offline
    Martell Malone
    wrote on last edited by
    #1

    Hi guys,

    I'm trying to combine qt with some direct opengl functions on windows.
    The project compiles fine but when it comes to linking I get all the __imp_glblablabla errors.

    Now when on other platforms I can just link in the opengl library and it runs fine
    I want to do this on windows with the standard packaged ANGLE version.
    I could link in libangle I'm guessing but I'm sure qt has a better way of doing this?

    Any tips?

    Kind Regards,
    Martell Malone

    Edit: forgot to mention I'm on qt5 and I'm using gles functions

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Compile Qt5 yourself with "-desktop opengl" flag passed to configure. This way Angle will not be used at all (but you need to ensure users will have OpenGL driver installed).

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Martell Malone
        wrote on last edited by
        #3

        Hi sierdzio,

        I've done that already but I'm using GLES functions so I'll have o change up the code.
        The problem here is that I want it to use ANGLE.
        I was just wondering if qt5 exposes opengl functions to us.
        The headers are there but link time is where the errors occur.

        The reason being is that I'm creating a qt version of the cococs2d-x game engine with directx for windows

        I had a look at qgl.h and qglinked.h in quake3 but couldnt get that to work

        "http://github.com/id-Software/Quake-III-Arena/blob/master/code/renderer"

        here is my header atm

        @
        #ifndef CCGL_H
        #define CCGL_H

        #define glClearDepth glClearDepthf
        #define glDeleteVertexArrays glDeleteVertexArraysOES
        #define glGenVertexArrays glGenVertexArraysOES
        #define glBindVertexArray glBindVertexArrayOES

        #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES

        #include <GLES2/gl2platform.h>
        #ifndef GL_GLEXT_PROTOTYPES
        #define GL_GLEXT_PROTOTYPES 1
        #endif

        // normal process
        #include <GLES2/gl2.h>
        #include <GLES2/gl2ext.h>

        typedef char GLchar;

        #endif // CCGL_H
        @

        here is a typical error I receive.

        note that this is not on compiling the cocoslib itself but when linking it to an exe( eg. a game)

        cocos2dx.lib(CCTexturePVR.cpp.obj) : error LNK2019: unresolved external symbol _
        _imp__glGetError@0 referenced in function "private: bool __thiscall cocos2d::CCT
        exturePVR::createGLTexture(void)" (?createGLTexture@CCTexturePVR@cocos2d@@AAE_NX
        Z)

        also I noticed this as I had a opengl glew version of this header but I don't know if it is relevant
        https://codereview.qt-project.org/#change,35408
        although it does say it exposes opengl functions

        Many Thanks
        Martell Malone

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

          Sorry if I'm being dumb. You said you compiled Qt using -opengl desktop but then you go on to say that you wish to use ANGLE. Which do you want to use?

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            "ZapB":http://qt-project.org/member/3246 is maintainer for OpenGL stuff, IIRC. Please ping him (hope he does not mind), I'm not using OpenGL directly in my projects, so I can't help much more.

            Edit seems I was a tad too late ;)

            (Z(:^

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Martell Malone
              wrote on last edited by
              #6

              Sorry Zap about the confusion.

              I want to use angle.

              I first tried compiling qt with -opengl desktop but then it wont compile because I'm using GLES headers
              I then changed the header to the opengl version of cocos which requires glew.
              I then got a load of redefine errors which you probably have seen before.

              So the best solution for me is to use ANGLE for now until qt makes including glew unnecessary.

              On that note...
              Is there a define I can use to detect if angle is being used?
              #ifdef USING_ANGLE or something of that sort?

              That way at a later point I can support both versions.

              Hope that makes sense :)

              Thanks sierdzio I sent him a pm earlier :)

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

                OK then. First thing, forget about the existence of ANGLE ;) It's an implementation detail in this case. What you are really saying is that you want to use OpenGL ES 2.

                You can just use the pre-compiled release packages for Qt5 in this case. No need to build your own.

                To be able to use OpenGL ES 2 functions just #include <qopengl.h> and if that doesn't get you access to them you can get a pointer to a QOpenGLFunctions object from the QOpenGLContext::functions() function. This object contains member functions for the remainder of the ES 2 functions - well I think it catches them all.

                To answer yoru other question about a #define to conditionally compile code you need something like:

                @
                #include <qopengl.h>

                #ifdef QT_OPENGL
                #ifdef QT_OPENGL_ES_2
                // OpenGL ES 2 code goes here
                #else
                // Desktop OpenGL code goes here
                #endif
                #endif
                @

                By the way, the gerrit patch you linked to above can still be applied cleanly on top of the Qt 5.0.0 release (I think). I will be pushing a new version of that patch series soon (maybe this weekend if I get time between kids and decorating) ;)

                Hope this helps!

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Martell Malone
                  wrote on last edited by
                  #8

                  Man you guys at the qt are fast to reply. :)

                  Thanks ZapB this should get me back on the road to a linked library xD
                  Ill post back if I run into any other qt related issues.

                  Hopefully something like this should work.
                  @
                  #ifndef CCGL_H
                  #define CCGL_H

                  #include <qopengl.h>

                  #ifdef QT_OPENGL
                  #ifdef QT_OPENGL_ES_2

                  #define glClearDepth glClearDepthf
                  #define glDeleteVertexArrays glDeleteVertexArraysOES
                  #define glGenVertexArrays glGenVertexArraysOES
                  #define glBindVertexArray glBindVertexArrayOES
                  #ifdef Q_OS_SYMBIAN
                  #define GL_DEPTH24_STENCIL8_OES 0x88F0
                  #endif

                  #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES

                  #include <GLES2/gl2platform.h>
                  #ifndef GL_GLEXT_PROTOTYPES
                  #define GL_GLEXT_PROTOTYPES 1
                  #endif

                  // normal process
                  #include <GLES2/gl2.h>
                  #include <GLES2/gl2ext.h>

                  typedef char GLchar;

                  #else

                  #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8

                  #define ccglOrtho glOrtho
                  #define ccglClearDepth glClearDepth
                  #define ccglTranslate glTranslated
                  #define ccglGenerateMipmap glGenerateMipmap
                  #define ccglGenFramebuffers glGenFramebuffers
                  #define ccglBindFramebuffer glBindFramebuffer
                  #define ccglFramebufferTexture2D glFramebufferTexture2D
                  #define ccglDeleteFramebuffers glDeleteFramebuffers
                  #define ccglCheckFramebufferStatus glCheckFramebufferStatus

                  #define ccglFrustum glFrustum

                  #define ccglGenBuffers glGenBuffers
                  #define ccglBindBuffer glBindBuffer
                  #define ccglBufferData glBufferData
                  #define ccglBufferSubData glBufferSubData
                  #define ccglDeleteBuffers glDeleteBuffers
                  #define ccglglPointSizePointer glPointSizePointer

                  #define CC_GL_FRAMEBUFFER GL_FRAMEBUFFER
                  #define CC_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
                  #define CC_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
                  #define CC_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
                  #define CC_GL_POINT_SPRITE GL_POINT_SPRITE_ARB
                  #define CC_GL_COORD_REPLACE GL_COORD_REPLACE_ARB
                  #define CC_GL_POINT_SIZE_ARRAY GL_POINT_SIZE

                  #include <GL/glew.h>
                  #ifdef _WIN32
                  #include <GL/wglew.h>
                  #else
                  #include <GL/glxew.h>
                  #endif

                  #endif
                  #endif

                  #endif // CCGL_H
                  @

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

                    You're welcome. Please note that #include <qopengl.h> already takes care of including the GLES/* headers and typdef'ing GLchar etc. for you. Open up the header to see the hoops we jump through to be nice to you guys ;)

                    Good luck and happy hacking!

                    Nokia Certified Qt Specialist
                    Interested in hearing about Qt related work

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Martell Malone
                      wrote on last edited by
                      #10

                      Hi Zap funnily enough I just noticed that earlier. :)

                      Unfortunately I still have link time errors.

                      http://pastie.org/private/yajk8kppvhtw77ieysa :/

                      here is the implementation of the class CCTexturePVR which is in the last error in the compile log.
                      it calls glGetError
                      http://pastie.org/private/pxvtzrjpyo7evheul60pa

                      Question do I have to inherit some qt class to use opengl functions?
                      http://qt.developpez.com/doc/5.0-snapshot/qopenglfunctions/
                      That would be a very dirty way of implementing it

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

                        Hmm weird. From the linker command and errors that you pasted it looks like your application/lib is not linking against libEGL.dll or libGLES2.dll which should be provided by ANGLE. Do these libraries exist under your Qt installation? Does your Makefile mention them? I notice you're using CMake and ninja. It could well be a build system issue.

                        Nokia Certified Qt Specialist
                        Interested in hearing about Qt related work

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Martell Malone
                          wrote on last edited by
                          #12

                          In cmake I have.

                          find_package(Qt5Widgets REQUIRED)
                          find_package(Qt5Gui REQUIRED)
                          find_package(Qt5Core REQUIRED)
                          find_package(Qt5OpenGL REQUIRED)

                          set(EXTERNAL_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5OpenGL_LIBRARIES}

                          Qt5OpenGL_LIBRARIES only appears as Qt5::Opengl

                          I dont know how to link in libEGL or libGLES2. I dont want to do it the dirty way :)
                          they are both in qtbase/lib

                          are the referenced in the cmake modules of qt?

                          EDIT: Actually I'll do the work for this myself.
                          I'll create another issue if I cant solve it because cmake probably isn't your problem to deal with.
                          and I'm basically asking you to hold my hand at this stage lol

                          Thanks again dude I think I will have it built shortly :)

                          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