简体   繁体   English

如何使OpenGL ES2与Qt一起编译

[英]How to get OpenGL ES2 to compile with Qt

I'm trying to figure out how to get my Qt program to compile and link against OpenGL ES2 functions. 我试图弄清楚如何让我的Qt程序针对OpenGL ES2函数进行编译和链接。

I've created a simple program that uses a QGLWidget to draw some simple triangles in my Qt application using the old OpenGL 1.0 pipeline. 我创建了一个简单的程序,该程序使用QGLWidget使用旧的OpenGL 1.0管道在Qt应用程序中绘制一些简单的三角形。 I'd like to use advanced 2.0 features like VBOs and shaders, so I started simply enough by trying to allocate some buffers for a VBO: 我想使用VBO和着色器等高级2.0功能,因此我开始尝试通过为VBO分配一些缓冲区来简单地开始:

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

Unfortunately, my project cannot find glGenBuffers() and I get the error message 不幸的是,我的项目找不到glGenBuffers(),并且收到错误消息

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

The start of qgl.h had the line "#elif defined(QT_OPENGL_ES_2)", so I tried setting that for the preprocessor, but it still couldn't find glGenBuffers(). qgl.h的开头有“ #elif defined(QT_OPENGL_ES_2)”行,因此我尝试将其设置为预处理器,但仍然找不到glGenBuffers()。

I'm not sure what to try next. 我不确定接下来要尝试什么。 Please let me know how I can get my Qt program to use OpenGL ES2. 请让我知道如何获取Qt程序以使用OpenGL ES2。

Here's the output I get when I compile: 这是我编译时得到的输出:

"/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'

You Might Need GLEW. 您可能需要GLEW。 Here are some links to look at. 这里是一些链接。

GLEW 格力

Initializing GLEW 初始化GLEW

Here's where I got those links 这是我获得这些链接的地方

Sorry if it's not what you're looking for. 很抱歉,如果不是您要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM