Problem with OpenGL RenderSystem

AgentReactif

30-06-2009 22:54:35

Hello,

I'am having problems with MyGUI 2.2.2 and OpenGL RenderSystem. This occurs when I switch to an other game state and only if I create one (or many) Entity and SceneNode. My game crash on a call of Root::renderOneFrame(). If first looked at this post : viewtopic.php?f=17&t=9661&p=56318&hilit=initialise#p56318, but it seems to be something different here.

This is what I get in Visual Studio :

Exception non gérée à 0x697433f1 dans MyGuiTest.exe : 0xC0000005: Violation d'accès lors de la lecture de l'emplacement 0x00000010.

which can be approximatively translated to :

Unhandled exception at 0x697433f1 in MyGuiTest.exe : 0xC0000005: Access Violation while reading at position 0x00000010.

What I found so far is that :
- There is nothing neither in MyGUI.log neither in Ogre.log.
- The game doesn't crash with DirectX.
- The game doesn't crash without MyGUI (DirectX and OpenGL).
- The game doesn't crash if I don't reinitialise MyGUI.
- The game doesn't crash if I run it in debug mode with a breakpoint set on the call to renderOneFrame (Hit F5 to render one frame => slow framerate).
- The game still crash with the sources from svn-trunk.
- So far, I reproduced this behavior on three differents marchines.

I provided a minimalistic application (one source file) below that reproduces the crash.

Switching to an other game state is done this way :

1.1.Shutdown/Delete current GUI.
1.2.Remove viewport.
1.3.Destroy scene's camera.
1.4.Destroy scene's SceneManager.

<< Game state switch >>

2.1.Create SceneManager.
2.2.Create scene's Camera.
2.3.Create viewport.
2.4.Create/initialise MyGUI.

The code

#include <Ogre.h>
#include <MyGUI.h>

void enterState(int time, Ogre::Root* ogre, Ogre::RenderWindow* window, const Ogre::ColourValue& color)
{
Ogre::SceneManager* sceneMgr = 0;
Ogre::Camera* camera = 0;
Ogre::Viewport* viewport = 0;
Ogre::Entity* entity = 0;
Ogre::SceneNode* node = 0;
MyGUI::Gui* gui = 0;

//Create scene manager.
sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC, "SceneManager");

//Create camera.
camera = sceneMgr->createCamera("SceneCamera");
camera->setPosition(0, 500, 1000);
camera->lookAt(0, 0, 0);
camera->setNearClipDistance(0.1f);
camera->setAspectRatio(Ogre::Real(1024/768));

//Create viewport.
viewport = window->addViewport(camera);
viewport->setBackgroundColour(color);

//Create gui.
gui = new MyGUI::Gui();
gui->initialise(window);

//Create a cube.
entity = sceneMgr->createEntity("Cube", "cube.mesh");
node = sceneMgr->getRootSceneNode()->createChildSceneNode("CubeNode");
node->attachObject(entity);

//Rendering loop.
unsigned long timeElapsed = 0;
unsigned long timeFirstFrame = ogre->getTimer()->getMilliseconds();
while((ogre->getTimer()->getMilliseconds() - timeFirstFrame) < time)
{
ogre->renderOneFrame();
}

//Destroy
sceneMgr->destroySceneNode(node);
sceneMgr->destroyEntity(entity);
gui->shutdown();
delete gui;
window->removeAllViewports();
sceneMgr->destroyCamera(camera);
ogre->destroySceneManager(sceneMgr);
}

int main()
{
Ogre::Root* ogre = 0;
Ogre::RenderSystem* rs = 0;
Ogre::RenderWindow* window = 0;

//Ogre startup.
ogre = new Ogre::Root("", "");

//Load ressources.
Ogre::ResourceGroupManager::getSingleton().
addResourceLocation("media", "FileSystem");

//Load plugin.
ogre->loadPlugin("RenderSystem_GL_d");

//Get rendersystem.
rs = ogre->getAvailableRenderers()->at(0);
ogre->setRenderSystem(rs);
ogre->initialise(false);

//Create render window.
window = ogre->createRenderWindow("MyGuiTest", 1024, 768, false);

//Enter state one.
enterState(2000, ogre, window, Ogre::ColourValue(0.2f, 0.8f, 0.2f));

//Enter state two.
enterState(2000, ogre, window, Ogre::ColourValue(0.8f, 0.2f, 0.2f));
}


I would appreciate if anybody has an idea or a solution to solve this problem.
Thanks for reading.

Altren

01-07-2009 00:16:09

Works fine for me :/ Tested all possible combinations. But you using Ogre 1.4 while I use Ogre 1.6 (not sure - saying this only because of not compiling line ogre->getAvailableRenderers()->at(0); - changed to ogre->getAvailableRenderers()[0])

Both Debug and Release works fine (only changed ogre->loadPlugin("RenderSystem_GL_d"); to ogre->loadPlugin("RenderSystem_GL"); in release).

Try next thing: open any MyGUI demo main.cpp file and put your code there and say if you still have this crash.
If you have crash in debug mode show me your call stack after crash.

AgentReactif

01-07-2009 21:26:14

Hello altren, thank you for your response.

I tried the differents solutions that you exposed but I still have the problem. I'm using Ogre 1.6.2 SDK and Visual C++ 2008 Express Edition. I'm running Windows Vista 32 bits (but others computer are under XP Pro.) and as suggested by the following call stack my computer is equiped with an Nvidia card. It seems that something goes wrong in the NVidia OpenGL driver. AFAIK, every computers I used to run the game are equiped with NVidia cards, so I will try to upgrade drivers to the last version.

[EDIT] I checked and my drivers are up to date (version 186.18).

nvoglv32.dll!697433f1()
[Les frames ci-dessous sont peut-être incorrects et/ou manquants, aucun symbole chargé pour nvoglv32.dll]
nvoglv32.dll!697d0622()
nvoglv32.dll!697d0a81()
nvoglv32.dll!697d0ccd()
nvoglv32.dll!697d2c2f()
nvoglv32.dll!697ead87()
nvoglv32.dll!695b556c()
RenderSystem_GL_d.dll!01d2c974()
OgreMain_d.dll!11033f2b()
OgreMain_d.dll!110321fc()
OgreMain_d.dll!10f35220()
OgreMain_d.dll!10f34f39()
OgreMain_d.dll!11032733()
OgreMain_d.dll!11032b2a()
OgreMain_d.dll!110329c1()
OgreMain_d.dll!1102f465()
OgreMain_d.dll!1102f091()
OgreMain_d.dll!1102a8fd()
OgreMain_d.dll!10a9eee0()
OgreMain_d.dll!11200413()
OgreMain_d.dll!10f99b95()
OgreMain_d.dll!10f9d0a5()
OgreMain_d.dll!10f51e6d()
OgreMain_d.dll!1100b23f()
OgreMain_d.dll!11008a9e()
> Demo_Picking.exe!enterState(int time=2000, Ogre::Root * ogre=0x014b0260, Ogre::RenderWindow * window=0x014b4c28, const Ogre::ColourValue & color={...}) Ligne 66 + 0xb octets C++
Demo_Picking.exe!base::BaseManager::create() Ligne 199 + 0x52 octets C++
Demo_Picking.exe!main(int argc=1, char * * argv=0x0012fefc) Ligne 33 + 0x8 octets C++
Demo_Picking.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, char * strCmdLine=0x002b2ed8, int argc=1) Ligne 20 + 0x29 octets C++
Demo_Picking.exe!__tmainCRTStartup() Ligne 578 + 0x35 octets C
Demo_Picking.exe!WinMainCRTStartup() Ligne 403 C
kernel32.dll!76463823()
ntdll.dll!776da9bd()