Code: Select all
#include <cstdio>
#include <irrlicht.h>
using namespace irr;
class MyClass : public IEventReceiver
{
public:
void run(void);
IrrlichtDevice * idevice;
virtual bool OnEvent(SEvent event);
MyClass();
virtual ~MyClass();
};
MyClass::MyClass()
{
idevice = NULL;
}
MyClass::~MyClass()
{
if (idevice)
{
idevice->closeDevice();
idevice->drop();
}
}
void MyClass::run(void)
{
//IrrlichtDevice* createDevice ( video::EDriverType deviceType = video::EDT_SOFTWARE,
//const core::dimension2d< s32 > & windowSize = core::dimension2d< s32 >(640, 480),
//u32 bits = 16,
//bool fullscreen = false,
//bool stencilbuffer = false,
//IEventReceiver * receiver = 0,
//const wchar_t * sdk_version_do_not_use = IRRLICHT_SDK_VERSION
//)
///// First device
idevice = createDevice(video::EDT_SOFTWARE, core::dimension2d<s32>(640, 480), 16, false, false,
this);
if (!idevice)
{
printf("\nCouldn't create first Irrlicht device.\n\n");
return;
}
if (!idevice->run())
{
printf("\nFirst device can't run.\n\n");
idevice->closeDevice();
idevice->drop();
return;
}
idevice->closeDevice();
idevice->drop();
idevice = NULL;
///// Second device
idevice = createDevice(video::EDT_DIRECTX8, core::dimension2d<s32>(640, 480), 16, false, false,
this);
if (!idevice)
{
printf("\nCouldn't create second Irrlicht device.\n\n");
return;
}
if (!idevice->run())
{
printf("\nSecond device can't run.\n\n");
idevice->closeDevice();
idevice->drop();
return;
}
idevice->closeDevice();
idevice->drop();
printf("Run successful.\n");
return;
}
bool MyClass::OnEvent(SEvent event)
{
return false;
}
int main(int argc, char * argv[])
{
printf("Creating class\n");
MyClass * mc = new MyClass;
printf("Running class\n");
mc->run();
printf("Deleting class\n");
delete mc;
return 0;
}
Code: Select all
Creating class
Running class
Irrlicht Engine version 0.5
Microsoft Windows 98 SE
Irrlicht Software Renderer.
Loaded texture: #DefaultFont
Irrlicht Engine version 0.5
Microsoft Windows 98 SE
DirectX8 Renderer.
Loaded texture: #DefaultFont
Second device can't run.
Deleting class
And, is there a workaround?
Oh, and -- the reason I'm using Irrlicht 0.5 is that when I use DirectX devices in Irrlicht 0.6, there's a terrible amount of screen flickering, which isn't the case in Irrlicht 0.5. That may or may not be a bug, but I tend to think it has to do with my graphics card which is a low end (8mb) onboard video card.