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 with shaders in QT4 or 5 on windows
Forum Updated to NodeBB v4.3 + New Features

OpenGL with shaders in QT4 or 5 on windows

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k 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.
  • T Offline
    T Offline
    TimLuther
    wrote on 5 Jul 2013, 12:43 last edited by
    #1

    Hi,
    I'm trying to get OpenGL working with QT 5 on windows. I have similar code working on Linux just fine but on Windows using visual studio, I've had troubles for days with linker errors and have run out of ideas.

    Specifically, when trying to use shader related functions like 'glCreateProgram()', I get linker errors (cannot find *_*glCreateProgram()). I am linking against opengl32.lib and Qt5OpenGL.lib.

    Also, I cannot find an opengl template application when trying to create a test project in QT5 so I haven't got anything canonical to test against.

    I should add that I need the opengl functions where they should be, in the global namespace as this code is shared between Qt and non Qt projects - this seems to be a problem as the QGLFunctions is in its own namespace.

    Has anybody else got this working in QT5 on windows in this way?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TimLuther
      wrote on 5 Jul 2013, 14:54 last edited by
      #2

      I've managed to get this to work but in a rather tortuous way which doesn't feel right. Calling the gl functions in the same scope as a QGLFunctions object works out of the box - fine if you're developing Qt applications from scratch and all your GL calls are within that object. I need those functions in global scope so I had to write a wrapper around all the gl functions that points to the QGLFunctions object. Like I said, it's not a nice solution but it does appear to work.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on 8 Jul 2013, 11:26 last edited by
        #3

        Windows only exports symbols for OpenGL <=1.1. All other gl functions have to be resolved dynamically at run time. This is what QOpenGLFunctions and the new set of QOpenGLFunctions_<MAJOR>_<MINOR>[_PROFILE] classes do for you. Once you have obtained and initialized such a function object just expose it somewhere convenient rather than calling global functions.

        There should be no need to link to libQt5OpenGL at all unless you are using QGLWidget. Linking to the opengl32.lib should be done for you as it is a dependency of QtGui.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0

        1/3

        5 Jul 2013, 12:43

        • Login

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