Reputation: 2097
I am trying to run the OpenGL examples in ubuntu 10.04. I bravely compiled the Qt code as follows and it went fantastic.
./configure -prefix /home/user/Software/qt-4.7.4-openGL-without-opengl-graphics -xplatform linux-g++-32 -little-endian -opensource -debug-and-release -fast -exceptions -accessibility -stl -no-qt3support -xmlpatterns -multimedia -audio-backend -svg -webkit-debug -script -scripttools -declarative -qt-zlib -qt-libpng -qt-libjpeg -qt-libmng -qt-libtiff -make translations -make tools -make libs -opengl desktop -lglut
But then out of satisfaction I got from successful compilation I tried running the examples and some won't run. As a start the 2dpainting example quits after printing the following.
hijackWindow() context created for Window(0xbf8b0f2c) 1
QGLPixelBuffer: Unable to find a context/format match - giving up.
QGLWindowSurface: Failed to create valid pixelbuffer, falling back
QGLWindowSurface: Using plain widget as window surface QGLWindowSurface(0x8bf4990)
hijackWindow() context created for Widget(0x8be5ab0) 2
Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile
Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile
QGLShaderProgram: shader programs are not supported
The program has unexpectedly finished.
And box example does not even get compiled, giving the following error.
qtbox.cpp: In member function 'virtual void QtBox::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)':
qtbox.cpp:327: error: 'gluPerspective' was not declared in this scope
Could some one tell me what I am doing wrong here?
Upvotes: 1
Views: 4932
Reputation: 41
You have not linked to -lGL
LIBS += -lGLU
and include the glu.h file in your code.
include "GL/glu.h"
Upvotes: 2
Reputation: 253
GluPerspective is part of the GLU library, and not supported as of newer (3.x?) versions of OpenGL. An easy way to update the example is to write your own replacement, something like this:
#include <QtOpenGL>
void gluPerspective(double fovy,double aspect, double zNear, double zFar)
{
// Start in projection mode.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
Upvotes: 1