Results 1 to 11 of 11

Thread: Bitmap font for QQuickItem?

  1. #1
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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?

  2. #2
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Bitmap font for QQuickItem?

    Quote Originally Posted by qtlearning View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Bitmap font for QQuickItem?

    You can still use a single texture. Have a look at the Sprite qml element.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Dec 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 2nd November 2015, 11:20
  2. Extract QImage from QQuickItem
    By oberlus in forum Qt Quick
    Replies: 4
    Last Post: 20th September 2014, 10:42
  3. Multiple Meshes for a single QQuickItem subclass?
    By qtlearning in forum Qt Quick
    Replies: 3
    Last Post: 19th December 2013, 09:03
  4. Replies: 1
    Last Post: 21st June 2013, 16:39
  5. Replies: 1
    Last Post: 11th November 2010, 00:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.