3

I'm using a library which provides me frames I have to blit to the screen. I allocate a buffer, and this library writes directly into this buffer. When I'm required, I have to blit a specified part of this buffer to the screen. I'm rendering using Qt with the OpenGL/ES paint engine.

Question is: what is the fastest way to blit to the screen? I'm currently loading the buffer in a QImage using the constructor that accepts a pointer to data. This should avoid any copy. Then, I use the drawImage() method of the QPainter to blit to the screen the correct area. I guess this method loads a copy of the area to the GPU memory and then blits to the screen using an OpenGL texture.

Would it be possible to avoid this copy to speed up the process? Would it be possible for instance to draw directly in a OpenGL texture so that I don't have to transfer to the GPU? I read of pixel buffer objects. Might that be a solution? May I use for this purpose a QGLFramebufferObject?

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Luca Carlon
  • 9,546
  • 13
  • 59
  • 91

1 Answers1

1

Ultimately you have to write to the GPU, all you can do is minimise the number of unnecessary copies and any in-CPU conversions from say RGBA to BGRA.

I would start with QImage and QPainter and see if the graphics speed is the limiting step before starting to optimise.

Take a look at this link.

Note that a lot of general OpenGL advice does NOT apply to opengl-ES, it's best to think of ES as a totally separate concept to OpenGL.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • At the moment I'm loading RGBA32 format, which seems to be loaded without computation. What do you mean by "see if the graphics speed is the limiting step"? – Luca Carlon Dec 09 '11 at 17:04
  • If in your app a network transfer, calculation or response from the user takes 1 second, then tweaking the openGL to save a few millisecs on a GPU call isn't the best way to spend your time. Of course if you are trying to play 1080p60 HD video on a handset - then it is! – Martin Beckett Dec 09 '11 at 17:07
  • Frames results in animations, that is why performance is fundamental. The better I do, the smoother the animation. – Luca Carlon Dec 09 '11 at 17:39