SuperTux / flexlay

A flexible editor for 2D games
GNU General Public License v3.0
15 stars 8 forks source link

Speed up rendering of tilemaps #42

Open Karkus476 opened 8 years ago

Karkus476 commented 8 years ago

Any shortcuts, or faster ways to render the tilemaps and objects, particularly when zoomed out. Currently, it is slow on my laptop when zoomed out, and sometimes even when zoomed in

Karkus476 commented 8 years ago

@Grumbel I believe you mentioned some alternative way of rendering the Tilemaps, but I can't remember. Is there a better way to do it using PyQt?

Karkus476 commented 8 years ago

We should benchmark some things, to see what is most expensive.

Grumbel commented 8 years ago

Currently Flexlay just uses classic Painter algorithm, aka just redraw everything whenever you feel like it. This is not fast, especially when it comes to zooming, scrolling and stuff and only incremental redraws would be needed.

Luckily Qt already comes with a nice little scene graphic class called QGraphicsScene, not only is that much more optimized then the current rendering code, it's also much more flexible. Enabling OpenGL for QGraphicsScene is like three lines of code.

The downside is that changing the current rendering code over to QGraphicsScene requires a little reworking on how things are handled when it comes to drawing, as all the draw() method need to go and changed into something that updates the scene graph instead.