Results 1 to 17 of 17

Thread: QtOpenGL GL_BGR not defined

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QtOpenGL GL_BGR not defined

    Hi,

    I'm trying to show images from a webcam using OpenGL.
    For acquiring images I use OpenCV that returns a IPLImage.
    I have created a QOpenGL inherited class that displays the images.
    The problem is that the images come as BGR instead of RGB format.
    I use this openGL call:
    Qt Code:
    1. glTexImage2D(GL_TEXTURE_2D,0,3,iWidth,iHeight,0,GL_RGB,GL_UNSIGNED_BYTE,pcData);
    To copy to clipboard, switch view to plain text mode 

    I have readed that GL_BGR format should be used but the compiler shows that it's not defined.

    I'm using Qt 4.6.1 and Windows XP SP3.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Very unlikely.
    Show the exact error you get.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Hi,

    the compiler shows that it's not defined
    This is the error.

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    I mean post the actual compiler output.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtOpenGL GL_BGR not defined

    And the GL includes you have in your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Hi,

    I mean post the actual compiler output.
    Qt Code:
    1. Error 1 error C2065: 'GL_BGR' : identificador no declarado c:\QOpenCVCamera\QOpenCVCamera\QOpenGLWidget.cpp 56
    To copy to clipboard, switch view to plain text mode 

    And the GL includes you have in your code.
    Qt Code:
    1. #include <QtOpenGL>
    To copy to clipboard, switch view to plain text mode 
    I only included the QtOpenGL header that I think that is the header used by Qt.

    Thanks,
    Òscar Llarch i Galán

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    based on this:
    http://www.gamedev.net/topic/159846-...d-sdl_loadbmp/
    it seems that perhaps under windows its not defined.
    Try the solution in the last post there. (using GL_BGR_EXT)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtOpenGL GL_BGR not defined

    Quote Originally Posted by ^NyAw^ View Post
    I only included the QtOpenGL header that I think that is the header used by Qt.
    But GL_BGR is not a Qt define but rather OpenGL one, you need to include proper OpenGL headers to have it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    But GL_BGR is not a Qt define but rather OpenGL one, you need to include proper OpenGL headers to have it.
    Qt is including it.
    If you include <QGLWidget> you are implicitly in including the OpenGL headers as well.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  10. #10
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Hi,

    Following the instructions on GameDev it seems to work.
    Searching into my computer I have found that there is a "gl.h" in this folder "C:\Documents and Settings\All Users\Datos de programa\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\shared\inc\GL" that contains the "GL_BGR" definition. This folder was created when I installed Nvidia CUDA SDK as I want to use OpenGL on OpenCV to improve performance.
    Maybe changing the libs it will work but I'm a little confused:
    - I can make my application to use this header lib
    - In the folder "C:\Documents and Settings\All Users\Datos de programa\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\shared\lib\Win32" there are 3 libs "freeglut.lib" "glew32.lib" and "shrUtils32.lib"
    - Qt is already linked to OpenGL libs
    So, changing the header in my application will work? Or maybe have to recompile Qt pointing to this new OpenGL libs?

    Thanks all,
    Òscar Llarch i Galán

  11. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    So, changing the header in my application will work?
    It will work, if its only a matter of a missing define in a header, but implemented in the lib.
    Otherwise it wont.
    If your Qt is compiled with its own OGL, don't mix.
    What you can do, is rebuilt Qt to use an OGL that you specify, then you can specify what ever other OGL lib you have, which Qt then will use.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. #12
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Hi,

    What you can do, is rebuilt Qt to use an OGL that you specify, then you can specify what ever other OGL lib you have, which Qt then will use.
    In this moment the above solution does what I need but I don't discard try this solution in future.

    Thanks,
    Òscar Llarch i Galán

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtOpenGL GL_BGR not defined

    It's just a define, a number. It doesn't matter what it is called, you can even define it in your own sourcecode.
    Qt Code:
    1. #ifndef GL_BGR
    2. #define GL_BGR 0x80E0
    3. #endif
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Yes, the compile error is not the problem.
    The question is, if this define is really used in the implemented lib, or more importantly used with the same meaning.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtOpenGL GL_BGR not defined

    One can check the version of OpenGL supported by the available GL library. I don't know if it's enough to be sure BGR is available (but I think it should pretty much always be available, BGR is a standard format).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #16
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtOpenGL GL_BGR not defined

    Yes, I think so too, but better safe than sorry
    I mean, I was really surprised that this define was not defined in windows... so who knows...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtOpenGL GL_BGR not defined

    I think it depends on the OpenGL vendor. I don't know who is the GL vendor on Windows, Microsoft? GFX card producer? Anyway, it's not suprising some defines have the _EXT suffix, it's quite natural, so I'd always check for both GL_SOMETHING and GL_SOMETHING_EXT. It should be safe.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 12th March 2015, 20:06
  2. capacity to use SampleBuffers in QtOpenGL
    By aalexei in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2011, 16:37
  3. image processing with qtopengl
    By sisilet in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2010, 21:42
  4. QtOpenGL example problem on wince6
    By lamosca in forum Installation and Deployment
    Replies: 1
    Last Post: 21st April 2010, 16:56
  5. QtOpenGL how to draw text?
    By AndreaCe in forum Qt Programming
    Replies: 0
    Last Post: 22nd July 2009, 00:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.