QtOpenGL–使用OpenGL画三维曲面图(二)
1. 环境
- Windows10, VS2015, Qt 5.12.12;
- GLFW, GLAD, glm
2.代码参考仓库
https://github.com/cindyli-13/3D-Surface-Plotter
3. QT配置
主要涉及glfw, glad, glm,opengl等头文件和库文件的配置,以下可参考.pro项目文件
// An highlighted block
QT -= gui
QT += core
CONFIG += c++11 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
SOURCES += \
Camera.cpp \
GLProgram.cpp \
Shader.cpp \
SurfacePlotter.cpp \
glad.cpp \
main.cpp
HEADERS += \
Camera.h \
GLProgram.h \
Shader.h \
SurfacePlotter.h
INCLUDEPATH += \
D:\Workspace\opengl\glad\include \
D:\Workspace\opengl\glfw\include \
D:\Workspace\opengl\glm
LIBS += D:/Workspace/qt-test/OpenGL-3D-Plot/glfw3.lib
LIBS += -lgdi32 -lopengl32 -lkernel32 -luser32 -lshell32
4. 代码编译运行
展示以下Sombrero函数图像:
5. 代码下载
6. 后续
后面考虑使用Qt自带窗口 ,以及Qt GUI模块中对原生OpenGL接口封装类,如QOpenGLWidget, QOpenGLFunctions,以及一些方便类QMatrix4x4, QVector4D等对上述代码进行翻译,实现一个QT版本的:D