Qt';s的OpenGL示例抱怨一些错误,并赢得了';跑不动
我试图在ubuntu 10.04中运行OpenGL示例。我勇敢地编译了Qt代码,如下所示,它非常棒Qt';s的OpenGL示例抱怨一些错误,并赢得了';跑不动,qt,opengl,configuration,Qt,Opengl,Configuration,我试图在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-qt3supp
./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
但出于对成功编译的满意,我尝试运行这些示例,但有些示例无法运行。首先,2DPraining示例在打印以下内容后退出
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.
而box示例甚至没有编译,因此出现以下错误
qtbox.cpp: In member function 'virtual void QtBox::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)':
qtbox.cpp:327: error: 'gluPerspective' was not declared in this scope
有人能告诉我我做错了什么吗?GLU透视图是GLU库的一部分,在较新(3.x?)版本的OpenGL中不受支持。更新示例的一个简单方法是编写自己的替换,如下所示:
#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);
}
#包括
立体透视(双fovy,双纵横,双zNear,双zFar)
{
//以投影模式启动。
glMatrixMode(GL_投影);
glLoadIdentity();
双xmin,xmax,ymin,ymax;
ymax=zNear*tan(fovy*M_PI/360.0);
ymin=-ymax;
xmin=ymin*aspect;
xmax=ymax*纵横比;
glFrustum(xmin、xmax、ymin、ymax、zNear、zFar);
}
您尚未链接到-lGL
LIBS+=-lGLU
并在代码中包含glu.h文件
包括“GL/glu.h”
您的显卡支持PBuffer吗?它是否支持着色器管道?GLU不是过剩的一部分吗?老实说,我不知道它是否是过剩的一部分。我认为应该是这样。因为它是(至少应该是)openGL函数。我有一个RedeonHD3450作为我的视频卡。不确定它是否支持你提到的任何一个。我错了,它不是GLUT,它是旧的OpenGL,这就是为什么我没有看到它。您必须编写一个测试程序来查询Qt是否能够检测到这些卡的功能。在程序输出的第二行,它提示尽管已经创建了一个上下文,但它缺少QGLPixelBuffer所需的特性。因此,您必须查看源代码,查看它请求的内容,并让它在创建上下文后通过
QGLContext::format()
方法打印出它设法获得的功能。此信息不正确。即使在OpenGL 4.2中,所有旧函数(包括即时模式)都可以在OpenGL兼容性配置文件中使用。请参阅OpenGL网站上的相应规范。弃用模型已计划将其删除,-1不受支持,因此已弃用