2012-02-09 16 views
1

我想在ubuntu 10.04中運行OpenGL示例。我勇敢地編譯了Qt代碼如下,並且非常棒。Qt的OpenGL示例抱怨一些錯誤,並且不會運行

./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 

有人能告訴我我在做什麼錯嗎?

+0

請問你的顯卡支持pbuffer而使?它是否支持着色器管道? gluPerspective是GLUT的一部分嗎? – cmannett85 2012-02-09 19:39:11

+0

老實說,我不知道它是否是GLUT的一部分。我相信它應該是。因爲它是(至少它應該是)openGL Function.I有一個redeon HD 3450作爲我的視頻卡。不知道它是否支持你提到的那些。 – Tharanga 2012-02-10 07:20:05

+1

我錯了,它不是GLUT,它是舊的OpenGL,這就是爲什麼我沒有看到它。您將不得不編寫一個測試程序來查詢Qt是否可以檢測到這些卡功能。在程序輸出的第二行,它暗示雖然創建了上下文,但它缺少QGLPixelBuffer所需的功能。因此,您必須查看源代碼,瞭解其請求的內容,並在創建上下文後通過'QGLContext :: format()'方法打印出其設法獲取的功能。 – cmannett85 2012-02-10 07:34:43

回答

1

GluPerspective是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); 
} 
+1

-1表示「在較新版本的OpenGL中不支持」。此信息不正確。即使在OpenGL 4.2中,所有舊功能(包括即時模式)都可用於OpenGL兼容性配置文件。請參閱OpenGL網站上的相應規範。 – SigTerm 2012-05-03 11:29:05

+1

棄用模型已計劃刪除它們,-1不受支持,因爲它不受支持,因此已棄用 – 2013-10-01 20:54:03

1

您還沒有掛-lGL

LIBS + = -lGLU

和在您的代碼中包含glu.h文件。

包括 「GL/glu.h」