Resize crashes

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Dr_Asik
Posts: 18
Joined: Wed Jun 02, 2010 2:15 am

Resize crashes

Post by Dr_Asik »

I host Irrlicht inside a java.awt.canvas. The code to resize seems to cause crashes; the weird thing is, if I put a breakpoint in the resize method, the crash doesn't happen; it only happens when I let the code run without breakpoints.

Here is my resize code:

Code: Select all

void resize(int width, int height)
{
	irr::SIrrlichtCreationParameters params;
	params.DeviceType = irr::EIDT_WIN32;
	params.DriverType = irr::video::EDT_OPENGL;
	params.WindowId = windowHandle_;
	irr::core::dimension2d<irr::u32> windowSize(width, height);
	params.WindowSize = windowSize;

	device_ = irr::createDeviceEx(params);	
	device_->setResizable(true);
	sceneManager_ = device_->getSceneManager();
	orthoCam_ = sceneManager_->addCameraSceneNode(0, irr::core::vector3df(0, 0, 400-130-96), irr::core::vector3df(0, 1, 0));
	irr::core::matrix4 projMat;
	projMat.buildProjectionMatrixOrthoLH(width, height, 0.1, 10000.0);
	orthoCam_->setProjectionMatrix(projMat, true);
		
	device_->getGUIEnvironment()->addStaticText(L"Hello World!", irr::core::rect<irr::s32>(10, 10, 260, 22), true, true, 0, -1, true);
	irr::scene::IAnimatedMesh* mesh = sceneManager_->getMesh("media/cube.obj");
	irr::scene::IAnimatedMeshSceneNode* node = sceneManager_->addAnimatedMeshSceneNode(mesh);
	if (node) 
	{
		node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
		node->setMaterialTexture(0, device_->getVideoDriver()->getTexture("media/metal_brosse.jpg"));
	}
}
windowHandle_ is a HWND which is passed by Java at program start. width and height are passed by Java using canvas.getWidht() and canvas.getHeight(). This method is called everytime componentResized() happens on the java.awt.Window that contains the canvas. Unfortunately at program start, this method will be called 3 times in a row for some reason. Maybe this is causing the crash?

Oh and the crash happens in atiumdag.dll.

Thanks for any help.
Dr_Asik
Posts: 18
Joined: Wed Jun 02, 2010 2:15 am

Post by Dr_Asik »

I believe I have found what is causing the issue (although I need to test it). I am not locking the context (need to create a special object from the Java context and canvas handle).

Anyway, please answer this question because I did not find it answered in any of the Irrlicht documentation:

How are you supposed to handle resolution changes? Do you need to somehow save the state of everything in the scene (outside of Irrlicht) and then reinitialize everything from scratch every time? So I need to save all the matrices with which I've defined my various cameras, where they point to, a list of all the objects in the scene, the textures they use, their rotation position etc.? Is there no easier way? With our previous tech, we would just resize the viewport with a single OpenGL call, re-adjust the cameras and that would be it, resizing took mere milliseconds.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Dr_Asik wrote:How are you supposed to handle resolution changes? Do you need to somehow save the state of everything in the scene (outside of Irrlicht) and then reinitialize everything from scratch every time? So I need to save all the matrices with which I've defined my various cameras, where they point to, a list of all the objects in the scene, the textures they use, their rotation position etc.? Is there no easier way? With our previous tech, we would just resize the viewport with a single OpenGL call, re-adjust the cameras and that would be it, resizing took mere milliseconds.
I think in fullscreen you have to do that. In windowed mode probably not. There you just should have to call OnResize for the driver with the new size. At least I think so.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply