[Interest] QOpenGLWidget and text

Till Oliver Knoll till.oliver.knoll at gmail.com
Thu Apr 2 19:45:00 CEST 2015


> Am 01.04.2015 um 20:39 schrieb Matthew Woehlke <mw_triad at users.sourceforge.net>:
> 
>> On 2015-04-01 10:28, Giuseppe D'Angelo wrote:
>> Il 01/04/2015 15:42, Matthew Woehlke ha scritto:
>>> If I go the route of pre-rendering the text into a QImage, what is the
>>> easiest way, using only the modern QOpenGL classes (since there is no
>>> longer bindTexture either), to get that into an OpenGL texture?
>> 
>> A rough game plan is this:
>> [snip really lengthy process]
>> 
>> Isn't Modern OpenGL lovely? ;)
> 
> Can someone please explain to me how this is an improvement over having
> a renderText() method?

I only speak for myself, but introducing a new API - and QOpenGL is just that, even when meant to replace an existing one - there is always the chance to drop "misplaced functionality".

IMHO the sole QOpenGLWidget's purpose is to "provide system resources to display raw OpenGL". And let you share those system resources (OpenGL Context) with other GL widgets. Not more, not less.

Sure, having a "drawText" function is /very/ convenient. Likely a "bindTexture" function. But what's next? A "drawButton"? "drawBitmap"? In a Widget?!

Surely that's not the right place.

In fact, someone already pointed out that you can use a QPainter and "draw over the OpenGL rendered scene".

In fact, you might be interested in this example:

  http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html

Not only can you draw text "over OpenGL", but /anything/ that QML has to over - even animated!

That's the way to draw "over OpenGL" - not with a restricted "drawText" convenience method which happened to be placed in some random API (QGLWidget) over a decade ago ;)

And once you got used to "Modern OpenGL" (in case you haven't yet), be prepared to discard everything and learn from scratch the new "Vulkan" API being in work with the Khronos group - we'll see what that brings us ("closer to the hardware" - read: "Bring Your Own Graphic Card Driver" - BYOGCD).

;)

Cheers,
  Oliver


More information about the Interest mailing list