PDA

View Full Version : QGraphicsScene into a GL/DirectX Texture



brendan0powers
11th August 2009, 03:10
I'd like to render a QGraphicsScene into a OpenGL or DirectX texture. I would like to do this without create a window, or QGraphicsView widget. I will have a window handle available. I was thinking that I could do this by overriding the paint function, and painting into a QImage buffer instead, and then copy that to the texture. I'm not entirely sure how to go about this. Does anyone have any ideas?

brendan0powers
11th August 2009, 17:28
I think I've figured out how to do it.

1) Create a ARGB8 Textute and QImage of the same size
2) Create a QPainter for the QImage
3) Render the scene into the image with QGraphicsScene::render()
3) Copy the contents of the QImage into the texture

My only thought is that because I'm using QGraphicsScene::render() I have to redraw the entire scene every frame, instead of only the stuff that changed.