Ryan McDougall wrote:
> ---------- Forwarded message ----------
> From: Ryan McDougall <[email protected]>
> Date: Mon, Oct 19, 2009 at 1:24 PM
> Subject: Qt with Ogre3D
> To: [email protected]
> 
> 
> Hello,
> 
> No'am from Nokia suggested I try out this list, so if I'm off topic,
> let me know!
> 
> I am trying to integrate Qt with Ogre3D in order to supply the game
> UI. I am following the example set here:
> http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/
> 
> However instead of QGLWidget, I am using an OgreWidget:
> http://github.com/sempuki/code/tree/master/qt-ogre-test-2/
> 
> However, as anticipated, I get flicker. Any advice how to reduce this?
> 
> Will 4.6 improve interactions between Qt and 3D programs?
> 
> I've built and tested on linux, but I've included windows binaries to
> make it easier for windows developers if you want to try building it
> yourself.

First of all, OgreWidget should probably inherit QGLWidget, otherwise I 
don't see how Ogre / Qt are going to be able to render to the same 
OpenGL context. I don't know Ogre so I'm not sure how to get it to 
render to an existing OpenGL context, but I guess there should be a way?

It's important that Ogre's rendering is only triggered from 
QGraphicsView::drawBackground(), so that Qt can draw the graphics scene 
on top of what Ogre draws. Also, Ogre should not call glSwapbuffers as 
this will be done by Qt when the painting is done.

Qt 4.6 adds QPainter::beginNativePainting() and 
QPainter::endNativePainting() which you should use to surround 
non-QPainter rendering code, so in 4.6 drawBackground should look 
something like this:

void MyGraphicsView::drawBackground(QPainter *painter, const QRectF &)
{
        painter->beginNativePainting();
        static_cast<OgreWidget *>(viewport())->draw_to_render_window();
        painter->endNativePainting();
}

If this doesn't work, another approach might be to get Ogre to draw into 
a framebuffer object in a shared context, and then blit the texture in 
drawBackground() (on a graphics view with a QGLWidget viewport).

--
Samuel
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to