Qt 5 - OpenGL Problem



  • Hello.

    My problem is that I cannot use OpenGL 2 functions, some which I can use are glClear, glClearColor, but I cant use glBegin for example.

    I added QT += opengl in project file.

    Can anyone help? Thanks



  • What do you mean by "can't use"? Do you get a compile error, link error, runtime error?



  • [quote author="ZapB" date="1357633595"]What do you mean by "can't use"? Do you get a compile error, link error, runtime error?[/quote]

    When I use glBegin, glVertex3f I get identifer 'X' not found.

    X - function which I want to call (OpenGL function).



  • Oh boy this really needs to go into an FAQ somewhere. Let me guess, you are using the pre-compiled Qt5 SDK on Windows? If so that is the cause of your problem. Let me explain.

    The precompiled binary packages ship with Qt5 configured for OpenGL ES 2 and using the ANGLE layer which implements ES 2 on top of DirectX. This was done to ensure that QtQuick2 works on all windows machines, even those with crappy Intel OpenGL drivers.

    To get access to glBegin() etc which are not part of OpenGL ES 2 you need to build your own Qt5 and pass in the -opengl desktop option to configure.

    Qt 5.0.1 should hopefully also ship with such a pre-compiled Qt. Please go and vote for this bug https://bugreports.qt-project.org/browse/QTBUG-28715



  • [quote author="ZapB" date="1357809361"]Oh boy this really needs to go into an FAQ somewhere. Let me guess, you are using the pre-compiled Qt5 SDK on Windows? If so that is the cause of your problem. Let me explain.

    The precompiled binary packages ship with Qt5 configured for OpenGL ES 2 and using the ANGLE layer which implements ES 2 on top of DirectX. This was done to ensure that QtQuick2 works on all windows machines, even those with crappy Intel OpenGL drivers.

    To get access to glBegin() etc which are not part of OpenGL ES 2 you need to build your own Qt5 and pass in the -opengl desktop option to configure.

    Qt 5.0.1 should hopefully also ship with such a pre-compiled Qt. Please go and vote for this bug https://bugreports.qt-project.org/browse/QTBUG-28715

    [/quote]

    Ok thanks, I will try to compile it by myself, Thank again :-)



  • People still use glBegin? Don't!!!



  • [quote author="utcenter" date="1357848726"]People still use glBegin? Don't!!![/quote]

    Often I use modern opengl (3.2), but for simple 2d editor, I should be allright with VA and fixed OpenGL 2.1.



  • The fixed function pipeline is left only for the sake of backward compatibility, only for code that already exists, if you write new code, it is very counter-productive to use it. You don't really gain anything by using it, you lose out on many features that are beneficial even in 2d, and in many cases, performance is actually worse, plus you lose portability.



  • If you are writing new code then I would also recommend avoiding the old fixed function pipeline stuff. Note that some vendors (notably Apple) do not implement the compatibility profile. So if you need a 3.2 context on OS X you can only use the Core profile. Just something to bear in mind.



  • [quote author="ZapB" date="1357849860"]If you are writing new code then I would also recommend avoiding the old fixed function pipeline stuff. Note that some vendors (notably Apple) do not implement the compatibility profile. So if you need a 3.2 context on OS X you can only use the Core profile. Just something to bear in mind.[/quote]

    Anyway if i want to use OpenGL 3.2+, i need compiile qt by myself.



  • Hi guys!

    I've got exactly the same problem as DamianPrg.

    Maybe this is a stupid question, but I am a very beginner, anyway : what do you mean by saying that you need to compile Qt by yourself ?



  • [quote author="mgonzalo" date="1358338826"]Hi guys!

    I've got exactly the same problem as DamianPrg.

    Maybe this is a stupid question, but I am a very beginner, anyway : what do you mean by saying that you need to compile Qt by yourself ?

    [/quote]

    You can compile it by yourself, I tried but didn't work. Some problem with configure.
    Or you can wait for next release of Qt 5, and maybe there will be OpenGL desktop instead of GL ES 2.

    Note: If you want compile it by yourself, it will take some time, on good machine about 1h :-)



  • Well, just that you need to compile your own build of the Qt libraries to enable Desktop OpenGL on windows at present. Helpful instructions can be found at http://qt-project.org/wiki/Building_Qt_5_from_Git



  • http://www.youtube.com/watch?v=K0O6mvD6uk4 - It also can help you :-)


  • Moderators

    Qt is a set of libraries and tools. What you download from Qt Project web site is - most probably - a pack of precompiled libraries, ready to be used. Necessarily, this general package is compiled with default, fit-for-all settings.

    However, Qt is a big project, and can be compiled in thousands of ways (by passing flags to configure script) and for some usages it's better to define those flags as you want to.

    Qt Project is open sourced, you can download sources yourself and take a look ("link":http://qt-project.org/wiki/Building_Qt_5_from_Git).

    EDIT whoosh, I was waaaay too slow on this one ;)



  • @

    C:\qt5>configure -developer-build -opensource -opengl desktop -nomake examples -
    nomake tests

    • C:/qt5/qtbase/configure -developer-build -opensource -opengl desktop -nomake e
      xamples -nomake tests
      'C:\qt5\qtbase\configure.exe' is not recognized as an internal or external comm
      and,
      operable program or batch file.
      *** qtbase/configure exited with non-zero status.

    C:\qt5>
    @

    This is what I get when I try to configure. Note that i have Perl, Python installed. Source code is downloaded from http://qt-project.org/downloads


  • Moderators

    On Windows, you need to rdowload the .zip file, not tarball. Also, I think you need to run configure.exe, not the configure script. I'm using Linux, though, this info is second-hand at best ;)



  • Probably best to get a git clone as it is easier to get back to a clean state. Also it makes sure you have the same exact source tree as the Qt devs so it's easier to trouble shoot. The packaging may remove some files needed to do a fresh build. Does the configure.exe actually exist at that path?



  • [quote author="sierdzio" date="1358339671"]On Windows, you need to rdowload the .zip file, not tarball. Also, I think you need to run configure.exe, not the configure script. I'm using Linux, though, this info is second-hand at best ;)[/quote]

    I tried ZIP, but it wont extract on my PC. Do you think thats problem? Because Tarball is often used on linux?

    @ZapB - Does the configure.exe actually exist at that path?

    No, just .bat and one with no extenstion.


  • Moderators

    Qt packaging strips tarballs of things that are not needed on unix (so, Windows stuff is missing there), and uses unix line endings. So you need the .zip.

    As ZapB mentioned, using git is a much better idea.



  • Ok thanks, guys. I will install from there.



  • Ok, i downloaded source from GitHub, and I have new problem.

    @

    C:\Users\Damian\Documents\GitHub\qt5>configure -developer-build -opensource -ope
    ngl desktop -nomake examples -nomake tests

    • C:/Users/Damian/Documents/GitHub/qt5/qtbase/configure -developer-build -openso
      urce -opengl desktop -nomake examples -nomake tests
      Please wait while bootstrapping configure ...
      <srcbase> = C:/Users/Damian/Documents/GitHub/qt5/qtbase
      <outbase> = C:/Users/Damian/Documents/GitHub/qt5/qtbase
      No suitable compiler found in PATH. Aborting.
      *** qtbase/configure exited with non-zero status.

    C:\Users\Damian\Documents\GitHub\qt5>
    @

    I have VS10 Pro, VS11 Pro, so why it says "No suitable compiler found in PATH", should I add VS to PATH, or what?



  • Run configure from a MS VS10 command prompt so that the environment variables are set up to find the compiler etc on the %PATH%



  • Ok, configure works, thanks for the help.



  • Hey, wouldn't it be far better if solutions for both ANGLE and desktop OpenGL are being built and switching is runtime like the QPA plugin works? Same for QWidgets without OpenGL dependencies.

    Even if OpenGL is buried deep into QtGui, it should still be possible to patch it in as a dynamic library. After all, even having 3 different version of QtGui is better than having 3 different version of Qt plus the time to build those.



  • Yes but that's a lot of work and requires somebody to do it.



  • Ok, compiled. I relaunched my project - run qmake. And when I want to build/run I get.

    @
    c:\users\damian\documents\github\qt5\qtbase\src\opengl\qgl.h:70: error: C1083: Cannot open include file: 'GLES2/gl2.h': No such file or directory
    @

    which is right, because I added -opengl desktop, so i should use desktop opengl, so why it want to include GLES?

    now i get
    @:-1: error: LNK1104: cannot open file 'libEGLd.lib'@



  • Even if you compiled to use desktop OpenGL, GLES is still crucial as it is the compatibility layer Qt relies on across different platforms. What you did essentially allows YOU to use desktop OpenGL if avaiable, there is no separate implementation of the functionality Qt relies on internally. EGL fits in that context as well.



  • Ok I try to restore old GLES files. Thanks



  • [quote author="utcenter" date="1358366924"]Even if you compiled to use desktop OpenGL, GLES is still crucial as it is the compatibility layer Qt relies on across different platforms. What you did essentially allows YOU to use desktop OpenGL if avaiable, there is no separate implementation of the functionality Qt relies on internally. EGL fits in that context as well.[/quote]

    Sorry but that is incorrect. Qt can use either OpenGL ES 2 and EGL or Desktop GL and WGL (on Windows). Check the source code of the windows qpa plugin for confirmation. It will use whichever GL it has been compiled for. So in this case it should be using the desktop GL.

    DamianPrg, for some reason it seems that you project is still trying to link to the old setup. Stale makefiles perhaps? Are you sure you are using the correct Qt build? i.e. is your new qmake the first in your %PATH%?

    Did configure say that it was building for Desktop OpenGL?



  • My bad, an incorrect assumption.

    Also, it seems that the "default" Qt5 offline package for windows will switch to desktop OpenGL in the near future, which makes good sense. Unfortunately, that won't happen in 5.0.1



  • I will just wait for new Qt release. Anyway thanks Guys for help.



  • Hi guys,

    I stumbled upon a similar issue and had to recompile QT myself with openGL support and found this very helpful source:
    http://www.tver-soft.org/qt64

    It provides already prebuild packages for QT in various configurations (especially 64bit builds).

    Best Regards,
    Jan



  • @DamianPrg
    You'd better download Qt 5.5 which switches dynamically between using the OpenGL driver or the ANGLE emulation layer implementing OpenGL on top of DirectX. check this: http://stackoverflow.com/questions/31633401/qt-5-5-0-cannot-find-opengl-functions


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.