[Qgis-developer] What about OpenGL renderding ?

Martin Dobias wonder.sk at gmail.com
Thu Oct 24 05:18:47 PDT 2013


Hi Marco

On Thu, Oct 24, 2013 at 6:32 PM, Marco Hugentobler
<marco.hugentobler at sourcepole.ch> wrote:
> Hi all
>
> Qt already has an open gl based paint device ( QGLPixelBuffer ), so the
> effect of hardware acceleration can be tested just by replacing the QImage
> with a pixel buffer. I did this years ago and ( can't remember the Qt
> version ), the rendering with QGLPixelBuffer was slower on my computer
> compared to QImage. Additionally, the graphical quality was lower.
>
> The reason might be that transfer of data to the GPU is slow, but rendering
> is fast. So it would probably need a non-QPainter based approach to store
> the data at the GPU and use repeatedly then.

Actually the usage of QPainter with OpenGL backend is simply a dead
end. As far as I understand the topic, it is just wrong approach. For
efficient use of GPU, one needs to take a different approach: 1.
prepare triangles and textures 2. render the scene in one go. GPU
likes to process lots of data at once - with QPainter it has to
process small bits of data many times and that is why the rendering is
slow.

For rendering with OpenGL, I think we would need to change various
aspects of our symbology:
- markers would be rendered as squares with a texture (prepared with a QPainter)
- linestrings and polygons need to be converted to meshes of triangles

First of all, we probably should:
- have a cache for vector and raster data - a lot of rendering time is
actually spent by fetching data (from disk, database etc) - we need to
keep the data cached in memory and keep updating the cache when the
view changes.
- find out whether we want to interface OpenGL directly or via some
libraries (e.g. OpenSceneGraph)
- as mentioned by others, port QGIS to Qt5 for convenient OpenGL
interface (it should be possible to have a codebase that compiles with
either Qt4 or Qt5)

Regards
Martin


More information about the Qgis-developer mailing list