PDA

View Full Version : QtOpenGL GL_BGR not defined



^NyAw^
29th August 2011, 17:57
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:


glTexImage2D(GL_TEXTURE_2D,0,3,iWidth,iHeight,0,GL _RGB,GL_UNSIGNED_BYTE,pcData);


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,

high_flyer
30th August 2011, 12:06
Very unlikely.
Show the exact error you get.

^NyAw^
30th August 2011, 12:34
Hi,



the compiler shows that it's not defined


This is the error.

Thanks,

high_flyer
30th August 2011, 13:39
I mean post the actual compiler output.

wysota
30th August 2011, 13:44
And the GL includes you have in your code.

^NyAw^
30th August 2011, 13:51
Hi,



I mean post the actual compiler output.



Error 1 error C2065: 'GL_BGR' : identificador no declarado c:\QOpenCVCamera\QOpenCVCamera\QOpenGLWidget.cpp 56




And the GL includes you have in your code.



#include <QtOpenGL>

I only included the QtOpenGL header that I think that is the header used by Qt.

Thanks,

high_flyer
30th August 2011, 13:59
based on this:
http://www.gamedev.net/topic/159846-loading-gl-textures-with-sdl_surface-and-sdl_loadbmp/
it seems that perhaps under windows its not defined.
Try the solution in the last post there. (using GL_BGR_EXT)

wysota
30th August 2011, 14:32
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.

high_flyer
30th August 2011, 15:11
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.

^NyAw^
30th August 2011, 16:20
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,

high_flyer
30th August 2011, 16:30
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.

^NyAw^
30th August 2011, 16:34
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,

wysota
30th August 2011, 16:41
It's just a define, a number. It doesn't matter what it is called, you can even define it in your own sourcecode.

#ifndef GL_BGR
#define GL_BGR 0x80E0
#endif

high_flyer
30th August 2011, 16:54
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.

wysota
30th August 2011, 17:04
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).

high_flyer
30th August 2011, 17:13
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...

wysota
30th August 2011, 17:41
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.