Resize Window hangs when TerrainSceneNode has LOD

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Resize Window hangs when TerrainSceneNode has LOD

Post by CarlS »

Hi all,

My 3d viewer is getting hung up when the maximize button is pressed to set the Irrlicht window to full screen.
This is only happening after navigating through a scene when a TerrainSceneNode is present and the LOD is set greater than 0.
This did not occur with Irrlicht 1.5, but became an issue in 1.6 and is still happening in 1.7.1.
I'm seeing this on 3 different machines with XP, and one machine running Windows 7.

If I am running in debug, an unhandled exception occurs at line 2757 of cd3d9driver.cpp

Code: Select all

	// restore other depth buffers
	// dpeth format is taken from main depth buffer
	DepthBuffers[0]->Surface->GetDesc(&desc);
If I am not running in debug, the following text is displayed endlessly until I CTRL+C out of it.
DIRECT3D9 clear failed.
DIRECT3D9 begin scene failed.
Failed setting the viewport.
Could not set the vertex shader.
Could not set the vertex shader.
Failed setting the viewport.
DIRECT3D9 end scene failed.
The problem shows up when running the example below.
After starting the program, navigate around a bit with the mouse and arrow keys, then press the 'M' key to free up the mouse, then press the resize button.
I've noticed that if I skip the navigation, the problem with resizing does not occur.

If anybody has any tips, suggestions, or fixes, I'd appreciate hearing them.

Thanks,
--Carl

Code: Select all

#include "C:\Program Files\irrlicht-1.7.1\include\irrlicht.h"
#pragma comment(lib, "C:\\Program Files\\irrlicht-1.7.1\\lib\\Win32-visualstudio\\Irrlicht.lib")
// remember to include "C:\Program Files\irrlicht-1.7.1\bin\Win32-VisualStudio" in the Path in the Environment Variables
#include <iostream>
using namespace irr;
using namespace core;

using namespace scene; 
using namespace video; 

bool lToggleMouseControl = false;
class MyEventReceiver : public IEventReceiver
{
public:
	MyEventReceiver(bool lToggleMouseControl){}

	bool OnEvent(const SEvent& event)
	{
		// check if user presses the key 'W' or 'D'
		if (event.EventType == irr::EET_KEY_INPUT_EVENT &&
			!event.KeyInput.PressedDown)
		{
			switch (event.KeyInput.Key)
		{
			case irr::KEY_KEY_M: // switch wire frame mode
				lToggleMouseControl = true;
				return true;
			}
		}
		return false;
	}
};


int main()
{
	video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;

	irr::SIrrlichtCreationParameters params;
	params.DriverType=driverType;
	params.WindowSize=core::dimension2d<u32>(640, 480);
	IrrlichtDevice* device = createDeviceEx(params);

	if (device == 0)
		return 1; // could not create selected driver.

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* env = device->getGUIEnvironment();

	env->addStaticText(L"Step 1 - Navigate with mouse and arrow keys",
		rect<s32>(10,10,260,22), true);
	env->addStaticText(L"Step 2 - Press 'M' to free up mouse",
		rect<s32>(10,30,260,42), true);
	env->addStaticText(L"Step 3 - Maximize window",
		rect<s32>(10,50,260,62), true);

	device->setResizable(true); // changed for Irrlicht-1.6

	scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0,100.0f,2.0f);
	camera->setPosition(core::vector3df(3000.0f,200.f,1000.0f));
	camera->setTarget(core::vector3df(0.0f,0.0f,1000.0f));
	camera->setFarValue(200000.0f);

	device->getCursorControl()->setVisible(false);

	scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
			"C:/Program Files/irrlicht-1.7.1/media/terrain-heightmap.bmp"
			,0,-1
			,core::vector3df(0.0f,0.0f,0.0f) // position
			,core::vector3df(0.0f,0.0f,0.0f) // rotation
			,core::vector3df(1.0f,1.0f,1.0f) // scale
			,video::SColor(255,255,255,255)
			,3 // Level of detail
			,ETPS_17 // terrain patch size
			,0 //smooth factor
			);

	terrain->setScale(core::vector3df(40.0f, 1.0f, 40.0f));
	terrain->setMaterialFlag(video::EMF_LIGHTING, false);
	terrain->setMaterialTexture(0, driver->getTexture("C:/Program Files/irrlicht-1.7.1/media/terrain-texture.jpg"));

	MyEventReceiver receiver(lToggleMouseControl);
	device->setEventReceiver(&receiver);

	int lastFPS = -1;
	while(device->run())
		if (device->isWindowActive()){

			if (lToggleMouseControl == true){
				if (camera->isInputReceiverEnabled()){
					camera->setInputReceiverEnabled(false);
					device->getCursorControl()->setVisible(true);
				}else{
					camera->setInputReceiverEnabled(true);
					device->getCursorControl()->setVisible(false);
				}
				lToggleMouseControl = false;
			}

			driver->beginScene(true, true, SColor(255,0,255,0) );
			smgr->drawAll();
			env->drawAll();
			driver->endScene();

		// display frames per second in window title

			int fps = driver->getFPS();
			if (lastFPS != fps){
				core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
				str += driver->getName();
				str += "] FPS:";
				str += fps;
				device->setWindowCaption(str.c_str());
				lastFPS = fps;
			}
		}
		device->drop();
		return 0;
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, sounds like another case where the main depth buffer is not properly restored. Maybe you can run the app under DX Debug, to see which call fails at first. I'll need some more time before I can do it on my own.
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

I haven't used DX Debug - is that included with the DurectX SDK?

--Carl the Clueless
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, you can enable it via the DirectX Control Panel. Let it stop on first error, and you get a breakpoint in the MSVC debugger once an error code is returned from DirectX.
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

OK, I'll be heading into work later on this morning and will give it a try and let you know what I find out.
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

I'm having no luck getting into the DirectX code with the debugger.

I opened the DirectX Control Panel, selected the Direct3D tab, then checked the Use Debug and the Break On 3D Error boxes.
I added the path to the DirectX 9 SDK Include folder to the Additional Include Directories of my VS2005 project, just as I do when I recomplie Irrlicht.

When I run the program and get an error, I get the message "There is no source code available for the current location"
If I go into Disassembly, the address where it stopped is given as 7c90120e.

--Carl
Post Reply