I am testing some graphics for my maze game, but the gif is not showing. Not sure is I am doing something incorrectly somewhere.
Also, should I show the image here for in case there is something in the color key that is causing the issue ?
Here is the code :
Code: Select all
#include <irrlicht.h>
#include "driverChoice.h"
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
// create device
IrrlichtDevice *device = createDevice(driverType,
core::dimension2d<u32>(512, 384),16U,true);
if (device == 0)
return 1; // could not create selected driver.
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
video::IVideoDriver* driver = device->getVideoDriver();
/*
All 2d graphics in this example are put together into one texture,
2ddemo.png. Because we want to draw colorkey based sprites, we need to
load this texture and tell the engine, which part of it should be
transparent based on a colorkey.
In this example, we don't tell it the color directly, we just say "Hey
Irrlicht Engine, you'll find the color I want at position (0,0) on the
texture.". Instead, it would be also possible to call
driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make
e.g. all black pixels transparent. Please note that
makeColorKeyTexture just creates an alpha channel based on the color.
*/
video::ITexture* cheese = driver->getTexture("../../media/cheese.gif");
driver->makeColorKeyTexture(cheese, core::position2d<s32>(0,0));
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
gui::IGUIFont* font2 =
device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp");
core::rect<s32> cheese_rect(0,0,100,100);
core::rect<s32> imp2(387,15,423,78);
/*
Prepare a nicely filtering 2d render mode for special cases.
*/
driver->getMaterial2D().TextureLayer[0].BilinearFilter=true;
driver->getMaterial2D().AntiAliasing=video::EAAM_FULL_BASIC;
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(255,255,255,255));
driver->draw2DImage(cheese, core::position2d<s32>(50,50),
cheese_rect, 0,
video::SColor(255,255,255,255), false);
/*
// draw flying imp
driver->draw2DImage(images, core::position2d<s32>(164,125),
(time/500 % 2) ? imp1 : imp2, 0,
video::SColor(255,255,255,255), true);
// draw second flying imp with colorcylce
driver->draw2DImage(images, core::position2d<s32>(270,105),
(time/500 % 2) ? imp1 : imp2, 0,
video::SColor(255,(time) % 255,255,255), true);
*/
driver->endScene();
}
}
device->drop();
return 0;
}