Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL vs QOpenGL/QtOpenGL in Qt 5: differences and limitations? [closed]

Tags:

qt

opengl

qt5

Since there are two ways to use OpenGL with Qt 5 (QOpenGL/QtOpenGL wrapper and regular OpenGL API), I wonder what are the limitations of each one. Could someone tell if there are limitations with QOpenGL wrapper that I should be aware of?

The reason I am asking this is because I don't want to start using QOpenGL wrapper and find out that I can't use the full capability of OpenGL API. Does anyone have experience with both and could provide some hints in terms of capability, performance and ease of use?

like image 337
Maiss Avatar asked Mar 27 '13 23:03

Maiss


1 Answers

I don't want to start using QOpenGL wrapper and find out that I can't use the full capability of OpenGL API

Well, Qt 5.0's OpenGL wrappers are built on top of the OpenGL ES (Embedded Systems) 2.0 specification which is essentially a watered down version of the desktop OpenGL 3.0 specification. Qt chose this specification to facilitate portability as it is widely supported by mobile platforms in addition being supported on nearly all modern PCs. If you choose to use the Qt wrappers you have to work around the shortcomings of the OpenGL ES 2.0 specification which, for the most part, fall into the following categories:

  1. No fixed-function pipeline capabilities. (no transformation stack, glBegin,glEnd,glLightf,etc..)
  2. No support for advanced OpenGL 3+ capabilities or support only in extensions. (texture buffer objects, compute shaders, atomic load-store textures, tessellation shaders, uniform buffer objects etc..)
  3. Lack of certain texture formats (integer textures, image textures, etc..)
  4. Small differences in GLSL syntax & semantics. (lack of layout qualifiers, data precision requirements via highp, lowp declarations, etc..)
  5. Lack of some convenience methods. (glBlitFramebuffer,glMultiDrawArrays, glDrawRangeElements, etc..)

For a full description of the OpenGL ES 2.0 specification look here.

However, This lack of features does not mean that the Qt wrappers can not accomplish what you need. Although OpenGL ES 2.0 is missing a lot of helpful functionality, you can still accomplish 99% of what the full desktop OpenGL specification would allow. If you decide to utilize a desktop OpenGL specification via custom wrappers, Qt can still manage the creation & windowing of desktop OpenGL contexts through the use of the QGLFormat class.

Keep in mind that if you decide to use desktop OpenGL wrappers, and utilize these within a Qt application, some classes provided by Qt may interfere with the operation of your custom wrappers. For example, QPainter operations on a QGLWidget may utilize functionality of the OpenGL ES specification and might interfere with the operation of your wrapper objects.

Personally, I prefer to use custom OpenGL wrappers as I greatly prefer the desktop OpenGL specifications as the feature sets are better defined and they provide more options to tackle a problem with. On the other hand, Qt 5 provides some absolutely fantastic architectures for making quick, powerful dynamic user interfaces using OpenGL ES. (Through by QtQuick 2 and QML)

Which API suits your needs best essentially comes down to whether or not you are targeting embedded or mobile platforms (in which case your forced to use OpenGL ES), and whether you are willing to sacrifice additional development time writing and maintaining custom OpenGL 3+ wrappers.

like image 123
Sir Digby Chicken Caesar Avatar answered Sep 17 '22 12:09

Sir Digby Chicken Caesar