Qt 的 OpenGL 示例抱怨一些错误并且无法运行
我正在尝试在 ubuntu 10.04 中运行 OpenGL 示例。我勇敢地编译了如下 Qt 代码,结果非常棒。
./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
但出于对成功编译的满足,我尝试运行这些示例,但有些示例无法运行。首先,2dpainting 示例在打印以下内容后退出。
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.
盒子示例甚至没有被编译,给出以下错误。
qtbox.cpp: In member function 'virtual void QtBox::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)':
qtbox.cpp:327: error: 'gluPerspective' was not declared in this scope
有人可以告诉我我在这里做错了什么吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还没有链接到-lGL
并在代码中包含 glu.h 文件。
You have not linked to -lGL
and include the glu.h file in your code.
GluPerspective 是 GLU 库的一部分,从较新的 (3.x?) 版本的 OpenGL 开始不受支持。更新示例的一个简单方法是编写您自己的替换,如下所示:
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: