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. Speed up QPainter.drawPixmap in pc emulators

Speed up QPainter.drawPixmap in pc emulators

Scheduled Pinned Locked Moved Unsolved Game Development
4 Posts 2 Posters 793 Views 2 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.
  • A Offline
    A Offline
    Audetto
    wrote on last edited by
    #1

    I've been porting AppleWin to Linux and I chose Qt as gui framework.

    Everything works, but it uses a lot of CPU 20% (vs the Windows version of < 5%). And there is more I need to squeeze in in the future.
    The bootle-neck with my implementation is drawing the screen.

    What I do is I first draw to an offscreen QPixmap and then paint the pixmap to the widget with rescaling.
    The issue is with the first part.
    The way it works is that for every block I copy from precreated pixmaps with calls like

       painter.drawPixmap(xpixel, ypixel, text80Col, sx, sy, 7, 16);
    

    where the blocks can be 7x16, 14x16, 14x2 or 7x2.
    Total size is 560x384

    In the end I just copy many blocks of memory from the templates to the actual QPixmap.
    Copying it to the widget is very quick.

    Tried to use QPixmap and QImage but did not see a difference.

    What is the best strategy of copying many small blocks like this?
    Would I have more luck with memcpy? Not sure how to do it though.
    OpenGL? could it be of any use?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is contained in these small blocks ?

      OpenGL is likely something you should consider in any case.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Audetto
        wrote on last edited by
        #3

        I have pre drawn all possible blocks in some offline QPixmaps, so at runtime I do a lookup.

        E.g.: if memory video address = 0x4b, then read block 14x16 from x and y from the offline templates and copy them to the current video buffer.

        The templates contain text bitmaps and all possible color blocks for graphics.
        E.g.: 0x4b could mean in graphics "blue black yellow black black". I've got them all ready and I just copy them over.

        If I use OpenGL. what do I draw? single pixels?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The OpenGL Cube example shows the technique to map a PNG containing all the cube faces on a 3D cube.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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