OpenGL rendering trash when embedded

Problems building or running the engine, queries about how to use features etc.
Post Reply
Lodes
Google Summer of Code Student
Google Summer of Code Student
Posts: 228
Joined: Mon Mar 17, 2003 12:02 am
Location: San Jose, CA, USA

OpenGL rendering trash when embedded

Post by Lodes »

I am embedding Ogre inside XSI and am having problems with OpenGL. DirectX works just fine with no problems whatsoever.

Because pictures are worth a thousand words, here is a good screen (what should be seen) and a bad.

Image
Image

As you can see the OpenGL rendering is getting completly trashed. If I don't render anything, I get the black background of the created window which is exactly good behavior. The problem here, is really about rendering.

Note that I am using renderOneFrame();

Here is the initialization code:

Code: Select all

	code removed. Irrelevant 
And I have a timer that calls a function that calls Ogre::Root::getSingleton().renderOneFrame() 15 times per second.

Here is Ogre.log

Thank you.

Lodes
Google Summer of Code Student
Google Summer of Code Student
Posts: 228
Joined: Mon Mar 17, 2003 12:02 am
Location: San Jose, CA, USA

Post by Lodes »

Alright, this is a bug inside Ogre. I am 99% sure of this and I hacked my application to work despite this bug that I have been tracking for way too long in the following way:

- Created a dummy window that is hidden on start up and I assign it a camera and a viewport

Now, when I parent an Ogre window to XSI, it renders properly. I noticed when I opened two Ogre windows in XSI that they started properly rendering. And since I have to create a dummy window anyway, this is a good solution for me (Ogre doesn't like when you destroy your primary window and want to create another one without fully shutting down ogre, because that window holds all kind of information).

I wonder why this does not manifest itself in any of the ogre demos or a standalone application.

EDIT:
Some more information:

- When I use the DirectX Render System, everytime the window is resized, I keep getting a device lost. So a similar thing must be happening inside OpenGL.
- The viewport aspect ratio is calculated automatically _vp->setAutoAspectRatio(true);

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

I'll look into this when I get the chance, but it sounds like an issue with the context. Are you sure the original window wasn't getting destroyed somehow?

Yes, you will get a device lost if you resize a window in D3D. OGRE deals with this and will restore the device for you when it's appropriate to do so, I assume it does indeed do that for you? If not there may be some timing issues due to the embedding here. GL, however has no device lost state (it's much more friendly) so that isn't your problem.

Lodes
Google Summer of Code Student
Google Summer of Code Student
Posts: 228
Joined: Mon Mar 17, 2003 12:02 am
Location: San Jose, CA, USA

Post by Lodes »

I am 100% positive that the original window was not getting destroyed. If the window was getting destroyed, I would get a white view, and when right clicking I would be able to choose a registered custom display host. One thing though, is that the viewport immediately performs a resize when it is created:

13:53:49: Viewport for camera 'camera', actual dimensions L: 0 T: 0 W: 800 H: 600
13:53:49: Viewport for camera 'camera', actual dimensions L: 0 T: 0 W: 514 H: 390

I mentioned DirectX because when I tried (just to see what would happen) to pass an externalWindowHandle instead of parentWindowHandle, I noticed that DirectX was working just fine, and when resizing the window it would not get any device lost (of course, putting externalWindowHandle is bad and I am not doing it again so who knows what kind of crazy stuff happened there :) )

Post Reply