March 14, 2011

john_god john_god
Ant Farmer
264 posts

[Solved] OpenGL doesnt work in latest QtSdk 1.1 beta

 

With the new version QtSdk 1.1 beta my existent project doesnt work , simple OpenGL functions are not recgnized

  1. graph2Dclass\graph2d.cpp: In member function 'void Graph2D::draw()':
  2. graph2Dclass\graph2d.cpp:302: error: 'GL_LINE_STRIP' was not declared in this scope
  3. graph2Dclass\graph2d.cpp:302: error: 'glBegin' was not declared in this scope
  4. graph2Dclass\graph2d.cpp:314: error: 'glVertex3d' was not declared in this scope
  5. graph2Dclass\graph2d.cpp:328: error: 'glEnd' was not declared in this scope
  6. graph2Dclass\graph2d.cpp:335: error: 'glEnd' was not declared in this scope
  7. graph2Dclass\graph2d.cpp:345: error: 'glEnd' was not declared in this scope

5 replies

March 14, 2011

ZapB ZapB
Hobby Entomologist
1423 posts

Do you have

  1. QT += opengl

in your project’s .pro file? What is the full command line passed to the compiler that generates the above error message?

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

March 16, 2011

john_god john_god
Ant Farmer
264 posts

I have that line in the .pro file since it’s a existente project. I found that OpenGL works with other project I have so probably it’s not QtSdk installation problem.

What is the full command line passed to the compiler that generates the above error message?

Do you mean this

  1. Running build steps for project matematica...
  2. Configuration unchanged, skipping qmake step.
  3. Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe" -w
  4. mingw32-make: Entering directory `D:/qt4examples/Matematica_determinante'
  5. C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
  6. mingw32-make[1]: Entering directory `D:/qt4examples/Matematica_determinante'
  7. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\include\QtOpenGL" -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\include" -I"." -I"." -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\include\ActiveQt" -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.2\mingw\mkspecs\win32-g++" -o debug\graph2d.o graph2Dclass\graph2d.cpp
  8. graph2Dclass\graph2d.cpp: In member function 'void Graph2D::draw()':
  9. graph2Dclass\graph2d.cpp:302: error: 'GL_LINE_STRIP' was not declared in this scope
  10. graph2Dclass\graph2d.cpp:302: error: 'glBegin' was not declared in this scope
  11. graph2Dclass\graph2d.cpp:314: error: 'glVertex3d' was not declared in this scope
  12. graph2Dclass\graph2d.cpp:328: error: 'glEnd' was not declared in this scope
  13. graph2Dclass\graph2d.cpp:335: error: 'glEnd' was not declared in this scope
  14. graph2Dclass\graph2d.cpp:345: error: 'glEnd' was not declared in this scope
  15. mingw32-make[1]: Leaving directory `D:/qt4examples/Matematica_determinante'
  16. mingw32-make: Leaving directory `D:/qt4examples/Matematica_determinante'
  17. mingw32-make[1]: *** [debug/graph2d.o] Error 1
  18. mingw32-make: *** [debug] Error 2
  19. The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
  20. Error while building project matematica (target: Desktop)
  21. When executing build step 'Make'

March 16, 2011

ZapB ZapB
Hobby Entomologist
1423 posts

Hmmm, yes that is what I meant. The command line looks fine. It is pulling in the correct include path for the QtOpenGL support and has the relevent define on the command line too (-DQT_OPENGL_LIB).

As you say other OpenGL based projects work fine for you the error must be somewhere in this project. Can you post the .pro file and the source for this file that is failing to compile please?

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

March 17, 2011

john_god john_god
Ant Farmer
264 posts

I found the error, it was missing a

  1. #include <QGLWidget>

in graph2d.h. Althout this class is not QGLWidget derived, it is called from a QGLWidget object, and since it has OpenGL functions it was complaining about this missing header.

I probably erased this include accidentally, since this was a existent project working ok in previous QtSdk versions.

Thank you.

March 17, 2011

ZapB ZapB
Hobby Entomologist
1423 posts

Ah, glad yu fixed it. Those bugs are a pain you can sit there staring at it for hours and not see it. Then a colleague walks by and spots it in 5 seconds ;-)

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

 
  ‹‹ [SOLVED] program crash when restart a process      [SOLVED] Crash when Updating GUI from thread ››

You must log in to post a reply. Not a member yet? Register here!