The code is almost same with tutorial's 2D graphics.
I coded like..
Code: Select all
IrrlichtDevice *device = createDevice(driverType,
core::dimension2d<s32>(512, 384));
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* background = driver->getTexture("bg_01.bmp");
video::ITexture* interface = driver->getTexture("interface.bmp");
driver->makeColorKeyTexture(interface, core::position2d<s32>(200,200));
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255, 0, 255, 255));
driver->draw2DImage(background,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,800,600), 0,
video::SColor(255,255,255,255), true);
driver->draw2DImage(interface,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,800,600), 0,
video::SColor(255,255,255,255), true);
driver->endScene();
}
}
....
Too simple... actually, after i failed with my 2D Game API, i put the test
code like above in the 2D grapphic tutorial code. No change for creation
of IrrlichtDevice(defaultly 24bits and resolution is 800x600) and..
i got same result with my 2D Game API.
You might test below code with the jpg file that i posted which will provide
same result..
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
// let user select driver type
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.2\n"\
" (d) Software Renderer\n (e) NullDevice\n (otherKey) exit\n\n");
char i;
std::cin >> i;
switch(i)
{
case 'a': driverType = video::EDT_DIRECTX9; break;
case 'b': driverType = video::EDT_DIRECTX8; break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_NULL; break;
default: return 0;
}
// create device
IrrlichtDevice *device = createDevice(driverType,
core::dimension2d<s32>(512, 384));
if (device == 0)
return 1;
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* background = driver->getTexture("bg_01.bmp");
video::ITexture* interface = driver->getTexture("interface.bmp");
driver->makeColorKeyTexture(interface,
core::position2d<s32>(200,200));
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true,
video::SColor(255, 0, 255, 255));
driver->draw2DImage(background,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,800,600), 0,
video::SColor(255,255,255,255), true);
driver->draw2DImage(interface,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,800,600), 0,
video::SColor(255,255,255,255), true);
driver->endScene();
}
}
device->drop();
return 0;
}
[\code]