Thanks for that tip; I'll look into it at some point.
Thanks for that tip; I'll look into it at some point.
That did indeed work, and I've managed to make a subclass of QGLWidget which embeds Ogre as its background, allowing me to use Qt paint calls on top of an Ogre context, with alpha compositing, and to use this as a QGraphcsView viewport - using the bare minimum of Xlib and GLX calls to glue it all together.
I might post a bit more on this once it's tidied up, but on the other hand I kind of doubt anybody will care...![]()
oh, we care!![]()
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I care too, especially as you've just tested a line of code that I couldn't.
Pete![]()
Well I've got a simple Ogre widget, and a corresponding GraphicsView widget, along with a couple of subclasses for those implementing some more demonstrative functionality, and finally a simple demo app, mixing Qt and CEGUI (not sure why you'd want to in reality, but anyway...)
If you're not interesting in building the Ogre demo, the most important bit of code to look at is probably in QOgreGLWidget::initializeGL().
The idea is to get Ogre to use an existing window (which requires that you know its XVisualInfo), and to switch between QGLWidget and Ogre GLXContexts at the appropriate times so neither find themselves in an unexpected state.
The final point is to ensure that both Ogre and Qt don't try to swap buffers; I let Qt do it so that the QGLWidget can get a chance to draw over the window after Ogre's done with that frame.
Apologies for the roughness; I got bored of tidying it all up :P.
Also, I think there was something else I was planning to add to this post, but it's two in the morning so I'll see if I remember tomorrow...
Edit: I think it might have been that there's a bug in Ogre which this triggers. Nothing desperate - you get X Errors when the widget is destroyed; I've provided a patch.
(Just noticed that CEGUI widgets, including the mouse cursor, are resized along with the window. Text correctly manages to remain the same size though and I'm performing the resize notifications to CEGUI in the same place, so I don't see what's wrong. Guess I must have missed something.)
I've been doing some research and this is the closest i've found on Qt+OGRE shared OpenGL rendering.
But have you found a way to share the context instead of switching? Context switching might be costly. Have you read about
Qt Code:
params["externalGLContext"] = Ogre::StringConverter::toString( ((unsigned long)(glXGetCurrentContext()) ) ); mRenderWindow = mOgreRoot->createRenderWindow("View", width(), height(), false, ¶ms);To copy to clipboard, switch view to plain text mode
Im doing this but seems OGRE insists on creating a new context.
Bookmarks