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. How does Qt3D support 2D overlay?
Forum Updated to NodeBB v4.3 + New Features

How does Qt3D support 2D overlay?

Scheduled Pinned Locked Moved Game Development
4 Posts 3 Posters 2.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.
  • J Offline
    J Offline
    jiangcaiyang
    wrote on last edited by
    #1

    Qt3D, the next inspiring module in Qt, will be incorporated in incoming Qt5.3.
    I try it in advance, and want to know anything about how 2D overlay's support over Qt3D.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      scoobydoo
      wrote on last edited by
      #2

      I did not find a way to create a 2D overlay over a OpenGL view so i had to create my own. It's fairly simple to do with a textured quad. I setup a quad and then create a GL texture map from the image created via a QPainter.

      To create the texture from the painter use something along these lines...

      @QPainter painter;
      QImage the_image( 100, 100, QImage::Format_ARGB32 );
      QRect dest_rect( 0, 0, 100, 100 );

      painter.begin( &the_image );
      painter.setRenderHints( QPainter::Antialiasing | QPainter::HighQualityAntialiasing );
      painter.fillRect( dest_rect, QColor( 162, 190, 255) );
      painter.setPen( QPen( Qt::black, 0 ) );
      painter.drawText( dest_rect, Qt::AlignCenter, "Hello" );
      painter.end();

      QImage overlay_image = QGLWidget::convertToGLFormat( the_image );

      glGenTextures( 1, &tid );
      glBindTexture( GL_TEXTURE_2D, tid );
      glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
      overlay_image.width(), overlay_image.height(), 0,
      GL_RGBA, GL_UNSIGNED_BYTE, overlay_image.bits() );
      @

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ecitjiaojiao
        wrote on last edited by
        #3

        怎么得到这个模块?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jiangcaiyang
          wrote on last edited by
          #4

          Well, I am exploring through source code to find its internal mechanism inside Qt3D. Progress has been quite slow because of my current work. But I believe that some day in the future, this problem will be resolved.
          As for you scoobydoo, your code shows an easy example of using QPainter against raw OpenGL functionality. But a more advanced integration would be that we can do overlays using Qt Graphics-View framework and Qt OpenGL module, moreover, shaders or something like that are supported. "A blog":http://blog.csdn.net/gamesdev/article/details/12073065 shows my progress a few months ago.
          [quote author="ecitjiaojiao" date="1387336385"]怎么得到这个模块?[/quote]

          [quote author="scoobydoo" date="1387332041"]I did not find a way to create a 2D overlay over a OpenGL view so i had to create my own. It's fairly simple to do with a textured quad. I setup a quad and then create a GL texture map from the image created via a QPainter.

          To create the texture from the painter use something along these lines...

          @QPainter painter;
          QImage the_image( 100, 100, QImage::Format_ARGB32 );
          QRect dest_rect( 0, 0, 100, 100 );

          painter.begin( &the_image );
          painter.setRenderHints( QPainter::Antialiasing | QPainter::HighQualityAntialiasing );
          painter.fillRect( dest_rect, QColor( 162, 190, 255) );
          painter.setPen( QPen( Qt::black, 0 ) );
          painter.drawText( dest_rect, Qt::AlignCenter, "Hello" );
          painter.end();

          QImage overlay_image = QGLWidget::convertToGLFormat( the_image );

          glGenTextures( 1, &tid );
          glBindTexture( GL_TEXTURE_2D, tid );
          glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
          overlay_image.width(), overlay_image.height(), 0,
          GL_RGBA, GL_UNSIGNED_BYTE, overlay_image.bits() );
          @
          [/quote]

          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