Before I decided to post this to the bugs forum, let me double confirm this with some people around here. I had stripped down my code to the core of the problem to ease testing.
Explanations:
1. It seems that whenever a render target texture is created, not even start using it yet, followed by OnResize, the Direct3D device will gone crazy.
2. If you take the following code, and comment out the statement that contains createRenderTargetTexture or OnResize, things will be fine.
3. This problem occurs ONLY in Direct3D drivers. On Direct3D 9, you will see Resetting Device Failed (though no indication on Device Lost, thus no idea on the failure), on Direct3D 8, the program will crash.
4. I am running on Irrlicht 1.3.1
Why am I doing this?
Simple, my program runs in a windowed mode. And I call OnResize whenever the window is resized to make sure that the backbuffer is created with the new window size. Without calling OnResize, the output will be pixelated or blurry which is not desirable. And my program needs to use Render Target in certain functionalities as well. Thus, bumped into this problem.
Any help or workaround or source modifications will be appreciated.
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;
IrrlichtDevice *device =
createDevice(driverType, core::dimension2d<s32>(640, 480),
16, false, false);
if (device == 0)
return 1;
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* rt = 0;
// Comment one of the following 2 lines and things will be ok.
rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256,256));
driver->OnResize(core::dimension2d<s32>(1000, 1000));
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
device->getSceneManager()->drawAll();
driver->endScene();
}
if (rt)
{
rt->drop();
}
device->drop();
return 0;
}