View Full Version : Draw QGraphicsScene background with OpenGL: How to match coordinate systems?

12th December 2011, 21:49
Hello everyone,

I'm trying to draw the background of a QGraphicsScene via OpenGL. I have working code below, which has some issues.
In OpenGL, I draw an image decomposed into tiles as a background. On top of this image, I want to overlay any QGraphicsItems, so that
the coordinate systems of QGraphicsScene and OpenGL match.

I have pushed my current code here:


A simple qmake tiled.pro; qmake; make; ./tiled should work.

Zooming (wheel) and panning (left drag) works as expected. However, when I resize the window, the textures gets contorted.


I believe the critical parts is the set-up of matrices in the drawBackground function, which you can view here:


Thanks for any help,


13th December 2011, 14:52
I think I have found one problem: While porting from the original example, I overlooked some gl code in the function setViewModelMatrix... I'll update when I have the code properly cleaned up