Home Fast blit with OpenGl ES and Qt
Post
Cancel

Fast blit with OpenGl ES and Qt

In my previous post I wrote about blit with opengl es 2.0 texture upload. However I noticed that using just Qt’s QGLWidget and implementing only the paintEvent is as fast as the texture upload with pure OpenGL ES API.
I guess that QGLWidget is making the drawing via OpenGL, since the performance seems to be equal to the texture blitting with the standard OpenGL ES API and texture uploading.
The whole blit is taking less than 6ms, so it’s good enough for my emulator ports. The memcopy could probably be optimized away from the blit, but that’s not the bottleneck at least in the current AntSnes implementation.
Here’s an example from the AntSnes how to blit with QGLWidget and paintevent.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void AntSnesQt::blit(int width, int height)
{
    if (buf != NULL)
    {
        delete buf;
        buf = NULL;
    }
    //memcopy into the new buffer, which will be blit to to screen in the paintEvent.
    buf = new QImage(GFX.Screen, width, height, GFX.RealPitch,
            QImage::Format_RGB16);
    //calling the repaint will cause a new paintEvent into the widget
    repaint();
}
void AntSnesQt::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    if (buf != NULL)
    {
        QRect target(96, 0, 448, 360);
        QRect source(0, 0, buf->width(), buf->height());
        painter.drawImage(target, *buf, source);
     }
     painter.end
}
This post is licensed under CC BY 4.0 by the author.

Fast Blit with OpenGL ES 2.0 and texture uploading

AntSnes 0.8 for Symbian^3

Comments powered by Disqus.