天天看點

開源項目推薦: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

繼續閱讀