Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Rendering text over OpenGL ES 2.0 surface (QGLWidget)?
Forum Updated to NodeBB v4.3 + New Features

Rendering text over OpenGL ES 2.0 surface (QGLWidget)?

Scheduled Pinned Locked Moved Game Development
10 Posts 4 Posters 10.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    matti-
    wrote on last edited by
    #1

    What would be the best (= most efficient) way to render text on top of a rendered opengl (es 2.0) scene? This would be needed for typical gaming stuff such as screen notifications, fps counter etc. I was thinking perhaps render the text onto a QImage / other RGBA canvas and then draw that using OpenGL's texture..?

    Author of <a href="http://mmark.777-team.org/">MMark13</a>

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      Just render your text by yourself (this would be most efficient).

      1 Reply Last reply
      0
      • M Offline
        M Offline
        matti-
        wrote on last edited by
        #3

        By myself meaning what exactly? :) You mean write a text renderer, draw to a buffer and use that as a texture to display it onscreen?

        I tried QPainter with and without beginNativePainting() but that messes stuff up.

        Author of <a href="http://mmark.777-team.org/">MMark13</a>

        1 Reply Last reply
        0
        • M Offline
          M Offline
          minimoog77
          wrote on last edited by
          #4

          By meaning 'yourself' is to draw textured quads of with text glyphs. You can prebake big (relatively speaking) texture with 256 glyphs, just change tex coordinates to draw particular glyph.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            baysmith
            wrote on last edited by
            #5

            Rather than prebaking an image atlas, I generate it dynamically using a QPainter to draw to a texture which is displayed with quads. I don't know how much less efficient it is to draw the characters to the image on demand rather than prebaking, but I need the flexibility to change the font to anything the system provides. You can see the code here:

            http://gitorious.org/mifit/mifit/blobs/master/libs/opengl/Text.h
            http://gitorious.org/mifit/mifit/blobs/master/libs/opengl/Text.cpp

            Nokia Certified Qt Specialist.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              matti-
              wrote on last edited by
              #6

              Thanks for the feedback! I've used the texture atlas approach with each character UV mapped with lookup table in the good 'ole software rendering times, shouldnt be too much of a hassle. Cheers, I'll see what I'll come up with. Cant use Quads for ogl es2 tho but nonetheless :p

              Author of <a href="http://mmark.777-team.org/">MMark13</a>

              1 Reply Last reply
              0
              • M Offline
                M Offline
                minimoog77
                wrote on last edited by
                #7

                [quote author="matti-" date="1317320125"]Cant use Quads for ogl es2 tho but nonetheless :p[/quote]

                You can compose quad with two triangles. :)

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Reptile
                  wrote on last edited by
                  #8

                  Hey, I'm without my N8 for a week or so, but I've just finished writing openGL code for a game in the simulator, including using QGLWidget::renderText() for text rendering. But I read that it's not supported by OpenGL ES? Does that mean it won't show up on the phone or will cause other problems? Does anyone know if renderText() will/won't work?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    matti-
                    wrote on last edited by
                    #9

                    The method described above works sweetly and is portable. However filling with Qt::transparent bugged on Android, so better just render the text atlas using GIMP or similar instead of creating it from code.

                    Author of <a href="http://mmark.777-team.org/">MMark13</a>

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Reptile
                      wrote on last edited by
                      #10

                      [quote author="Reptile" date="1324699470"]Hey, I'm without my N8 for a week or so, but I've just finished writing openGL code for a game in the simulator, including using QGLWidget::renderText() for text rendering. But I read that it's not supported by OpenGL ES? Does that mean it won't show up on the phone or will cause other problems? Does anyone know if renderText() will/won't work?[/quote]

                      FYI: don't use QGLWidget::renderText(). you'll get this message:

                      [Qt Message] QGLWidget::renderText is not supported under OpenGL/ES

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved