How to work with OpenGL and QT?

筅森魡賤 提交于 2019-12-23 09:10:10

问题


I'm Working on a small project and i need to work with OpenGL + QT

I'm Newbie in both of them. So i need a good tutorial that illustrates how to work with them each other not individually

is it better to work OpenGL on QT Creator or use QT Visual Studio Plug-in?


回答1:


You'll be using QGLWidget a lot! Here you go:

http://doc.qt.io/qt-5/examples-widgets-opengl.html

Of all those, maybe this is the best one to start: Hello GL Example. If you prefer using Qt Quick instead of Qt Widgets, check these posts:

  • Integrating custom OpenGL rendering with Qt Quick via QQuickFramebufferObject
  • Scene Graph - OpenGL Under QML

If you want a higher-level 3D API than OpenGL, as o Qt 5.7 Qt 3D became stable.

As for the IDE I suggest using Qt Creator. It works out of the box on Windows and the syntax highlighting and autocomplete are comparable to Visual Studio.




回答2:


You have several different options for using OpenGL in Qt. It has changed a lot over the years. For an introduction that should cover all the basic info you need to start look at this post. The old style Qt OpenGL classes and functions were called QGLxx but are now called QOpenGLxx and have been moved to the QtGUI module to start with.

Many of the simple OpenGL examples with Qt (including the QOpenGLWindow example shipped with Qt) use the old style of OpenGL that shouldn't be used any longer. Here is a tutorial that has updated the QOpenGLWindow example to modern OpenGL (3+). It is the simplest, most up to date example I have come across.

I second Qt Creator, especially for learning. It has much better integration with the Qt help files than Visual Studio does. If you are considering switching between IDEs I would also recommend building with CMake. CMake is very similar to the built in qmake of Qt Creator but it can work just as good with Visual Studio or other IDEs. I have been running some examples for learning purposes in both Visual Studio and Qt Creator with CMake. Here is a simple CMake example with Qt. For my purposes I still use the Visual Studio compiler when working in Qt Creator though.




回答3:


There're some examples of how to use Open GL with QT in the SDK. You can open these examples in QT Creator if you want. To answer the second question, I find QT Creator much faster and more pleasant to use than Visual Studio but YMMV.



来源:https://stackoverflow.com/questions/5807886/how-to-work-with-opengl-and-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!