如何使用Qt编译OpenGL ES2

时间:2012-01-25 22:05:29

标签: c++ qt opengl-es opengl-es-2.0

我试图弄清楚如何让我的Qt程序编译并链接到OpenGL ES2函数。

我创建了一个简单的程序,它使用QGLWidget在我的Qt应用程序中使用旧的OpenGL 1.0管道绘制一些简单的三角形。我想使用像VBO和着色器这样的高级2.0功能,所以我开始尝试为VBO分配一些缓冲区就足够了:

int ids[2];
glGenBuffers(2, ids);

不幸的是,我的项目找不到glGenBuffers(),我收到错误消息

GlWidget.cpp:103: error: 'glGenBuffers' was not declared in this scope

qgl.h的开头有&#34; #elif定义的行(QT_OPENGL_ES_2)&#34;,所以我尝试为预处理器设置它,但它仍然找不到glGenBuffers()。< / p>

我不确定下一步该尝试什么。请让我知道如何让我的Qt程序使用OpenGL ES2。

这是我编译时得到的输出:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE=/C/Qt/2010.02.1/qt/bin/qmake.exe SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/dev/kitfox.com/biz/monsterRacing/proj/CharacterEditor'
/C/Qt/2010.02.1/qt/bin/qmake.exe VPATH=. -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
"/usr/bin/make" -f nbproject/qt-Debug.mk dist/Debug/MinGW-Windows/CharacterEditor.exe
make[2]: Entering directory `/c/dev/kitfox.com/biz/monsterRacing/proj/CharacterEditor'
g++.exe -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/2010.02.1/qt/include/QtCore' -I'c:/Qt/2010.02.1/qt/include/QtGui' -I'c:/Qt/2010.02.1/qt/include/QtOpenGL' -I'c:/Qt/2010.02.1/qt/include' -I'c:/Qt/2010.02.1/qt/include/ActiveQt' -I'.' -I'.' -I'nbproject' -I'.' -I'c:/Qt/2010.02.1/qt/mkspecs/default' -o build/Debug/MinGW-Windows/main.o main.cpp
g++.exe -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/2010.02.1/qt/include/QtCore' -I'c:/Qt/2010.02.1/qt/include/QtGui' -I'c:/Qt/2010.02.1/qt/include/QtOpenGL' -I'c:/Qt/2010.02.1/qt/include' -I'c:/Qt/2010.02.1/qt/include/ActiveQt' -I'.' -I'.' -I'nbproject' -I'.' -I'c:/Qt/2010.02.1/qt/mkspecs/default' -o build/Debug/MinGW-Windows/MainForm.o MainForm.cpp
MainForm.cpp: In member function 'void MainForm::openFile()':
MainForm.cpp:78: warning: unused variable 'surfSet'
g++.exe -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/2010.02.1/qt/include/QtCore' -I'c:/Qt/2010.02.1/qt/include/QtGui' -I'c:/Qt/2010.02.1/qt/include/QtOpenGL' -I'c:/Qt/2010.02.1/qt/include' -I'c:/Qt/2010.02.1/qt/include/ActiveQt' -I'.' -I'.' -I'nbproject' -I'.' -I'c:/Qt/2010.02.1/qt/mkspecs/default' -o build/Debug/MinGW-Windows/GlWidget.o GlWidget.cpp
GlWidget.cpp: In member function 'void GlWidget::buildMesh()':
GlWidget.cpp:103: error: 'glGenBuffers' was not declared in this scope
make[2]: Leaving directory `/c/dev/kitfox.com/biz/monsterRacing/proj/CharacterEditor'
make[2]: *** [build/Debug/MinGW-Windows/GlWidget.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[1]: Leaving directory `/c/dev/kitfox.com/biz/monsterRacing/proj/CharacterEditor'

1 个答案:

答案 0 :(得分:0)

你可能需要GLEW。以下是一些要查看的链接。

GLEW

Initializing GLEW

Here's where I got those links

很抱歉,如果这不是你想要的。