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);
The problem shows up when running the example below.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.
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;
}