image not showing

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.

image not showing

Postby Quantum1982 » Mon May 07, 2012 7:21 am

Hi

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 :

cpp 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;
}
 
 


Cheers
Quantum1982
 
Posts: 41
Joined: Mon Apr 23, 2012 9:31 am

Re: image not showing

Postby hybrid » Mon May 07, 2012 7:48 am

Well, the console log should be clear about this: Unsupported file format. Anyway, why gif? Do you want to load an animated gif? We don't support any animated picture format, better use a sprite map which has all the image parts side by side in an array. How to use these sprites should be explained somewhere on the forum here, there are many sprite approaches available.
hybrid
Admin
 
Posts: 13943
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: image not showing

Postby Quantum1982 » Mon May 07, 2012 8:12 am

Thanks for reply

Ya should have looked at that. Ok so I resaved the image as "cheese.png", but it still doesn't load. I tested the "2ddemo.png" and that loads fine.

The image looks like this :

Image

Cheers
Quantum1982
 
Posts: 41
Joined: Mon Apr 23, 2012 9:31 am

Re: image not showing

Postby CuteAlien » Mon May 07, 2012 9:51 am

Are you getting any console output for that?
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: image not showing

Postby Quantum1982 » Mon May 07, 2012 10:28 am

Yes, says it cannot load the image at that location.

Cheers
Quantum1982
 
Posts: 41
Joined: Mon Apr 23, 2012 9:31 am

Re: image not showing

Postby hybrid » Mon May 07, 2012 11:54 am

Well, then most likely the path does not match. Note that starting from an IDE can change the working directory, while starting it by double-clicking usually resolves to the local directory, unless otherwise fixed in the properties. When starting from command line, usually the current directoy is taken as working directory. All relative paths are used from that dir.
BTW: Using an image format with alpha channel included (e.g. png) results in much better transparency and shorter setup times.
hybrid
Admin
 
Posts: 13943
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany


Return to Beginners Help

Who is online

Users browsing this forum: Seven, zerosang and 1 guest