天天看点

开源项目推荐:OpenGL之Qt专辑;重点是ccViewer和libQGLViewer

1、Qt官方自带的案例

https://doc.qt.io/qt-5/qtopengl-index.html

F:\Qt\Qt5.12.9\Examples\Qt-5.12.9\opengl

2、学习教程

LearnOpenGL

https://learnopengl.com/ https://github.com/JoeyDeVries/LearnOpenGL https://github.com/MidoriYakumo/learnopengl-qt3d

Tutorials for Qt5 OpenGL implementation

https://github.com/TReed0803/QtOpenGL https://github.com/chenzilin/qt-opengl

3、开源项目

Qt官方自带的QGLWidget/QOpenGLWidget类,仅仅提供了基本的框架,但是很多交互操作(例如鼠标拖动,缩放,旋转,俯视图/主视图等)是没有的,还需要程序员自己写代码实现。

(1)QGLWidget 是Qt OpenGL模块,但是从其官方说明,推荐在Qt5.4 之后,使用QOpenGLWidget类,具体说明如下: Note: This class is part of the legacy Qt OpenGL module and, like the other QGL classes, should be avoided in the new applications. Instead, starting from Qt 5.4, prefer using QOpenGLWidget and the QOpenGL classes.

(2)QGLWidget的支持最高到Qt5.4.2,如果对于新软件新平台的开发,则按照官方推荐的QOpenGLWidget类。

(3)而开源项目ccViewer和libQGLViewer等等则实现了QOpenGLWidget二次封装和扩展,使得用户更容易实现3D绘图与交互。 以下是详细介绍与网站链接。

CloudCompare

https://github.com/CloudCompare/CloudCompare

里面有ccViewer小工具:

https://github.com/CloudCompare/CloudCompare/tree/master/ccViewer

从源码\CloudCompare-master\libs\qCC_glWindow\include\ccGLWindow.h可以看到ccGLWindow 派生于QOpenGLWidget

using ccGLWindowParent = QOpenGLWidget;

//! OpenGL 3D view

class CCGLWINDOW_LIB_API ccGLWindow : public ccGLWindowParent, public ccGenericGLDisplay

详情见我的另一篇博文:

https://libaineu2004.blog.csdn.net/article/details/108321139

libQGLViewer

libQGLViewer 是一个用以简化了Qt开发OpenGL三维浏览器的C++库。它提供了一些典型的3D查看器的功能,如能够使用鼠标移动/缩放图像等。

从源码qglviewer.h可以看到QGLViewer派生于QOpenGLWidget

class QGLVIEWER_EXPORT QGLViewer : public QOpenGLWidget

另外,libQGLViewer源代码需要自己编译,生成dll文件。

http://libqglviewer.com/ https://github.com/GillesDebunne/libQGLViewer
开源项目推荐:OpenGL之Qt专辑;重点是ccViewer和libQGLViewer

Candle

https://github.com/Denvi/Candle

QtImGui

https://github.com/ocornut/imgui https://github.com/seanchas116/qtimgui

继续阅读