Bitmap font for QQuickItem?
I know I can implement a bitmap font texture for OpenGL rendering of text if I choose to go that route with QQuickItem, but I'd have no other need to do so as the features provided by updatePaintNode are sufficient for me, except that I need a way to draw text using a font texture and I'm not sure if this can be done in updatePaintNode?
Re: Bitmap font for QQuickItem?
Looking further, perhaps the QSGSimpleTextureNode is what I need. But looking at its docs, I don't see where you can set just a part of a texture to render, such as the texture coordinates. The documentation is quite vague and examples are scarce.
Re: Bitmap font for QQuickItem?
Isnt't the setRect() method in the simple texture node class for that? I'm not sure why you are trying to do all that though. It might be much easier to obtain what you want using composition or a custom shader program.
Re: Bitmap font for QQuickItem?
I would think that if you want to display a bitmap font that is rendered in OpenGL, using a texture node would be no more overhead or work than using a shader; actually, using a shader seems more intensive from a development standpoint, and I wouldn't expect it to perform any better necessarily since the same type of work still needs to be done by the graphics engine.
Re: Bitmap font for QQuickItem?
Quote:
Originally Posted by
qtlearning
actually, using a shader seems more intensive from a development standpoint
I wouldn't agree, especially that in the end that's what you're doing with the simple texture node anyway. The point is that you can do it in a more high-level (QML) code.
Re: Bitmap font for QQuickItem?
I really need to see an example of how that would be done. Do you know of any example projects that show how to do this?
Re: Bitmap font for QQuickItem?
You don't need any example projects, you just write QML code that creates an item and shades it with your font texture. You just need to know coordinates of a particular letter. However having said all that --- this is all exactly the same as if you just had an Image QML element, there is really no point in going down to a low-level scenegraph code. You'll be practically duplicating already existing code... What is the ULTIMATE goal you are trying to achieve?
Re: Bitmap font for QQuickItem?
For content that is very rapidly changing, I would not think an Image element would be wise. A true bitmap font render uses a single texture for the mapping of all the letters displayed, and it is very fast when on a low-level GL call, which QQuickItem emulates nicely.
Re: Bitmap font for QQuickItem?
You can still use a single texture. Have a look at the Sprite qml element.
Re: Bitmap font for QQuickItem?
Since QML elements are instances of actual C++ objects under the hood, I would think there is a lot of overhead in creating and working with many many of these, versus just adding some texture calls to OpenGL via the QQuickItem. For example, I've found that just having many QML Text elements that are updated very often (several times a second) is too much for QML to handle well, so I'd expect no better performance from a Sprite or other QML element as there is just too much other stuff going on behind the scenes with QML elements.
Re: Bitmap font for QQuickItem?
With Text the text needs to be laid out so it takes time. This is not the case with Sprite. And QtQuick uses a texture atlas so textures are shared between items. So in the end it doesn't really mater much if you use Sprite or Image, the texture will still be shared.