Reading in Multiple 2D Images

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.
Post Reply
Evanias
Posts: 6
Joined: Thu Jul 03, 2014 10:30 pm

Reading in Multiple 2D Images

Post by Evanias »

Hello,
This is my first post, and I am a bit of a newbie to the Irrlicht engine. My problem is this:

I have been using Irrlicht's 2d graphics features recently, but I've hit a snag. I need to read in two seperate images, using these lines of code:

Code: Select all

    video::ITexture* images = driver->getTexture("../../media/Lightspeed_logo.png");
    driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
 
    video::ITexture* menuBack = driver->getTexture("../../media/spacebackground1.png");
    driver->makeColorKeyTexture(menuBack, core::position2d<s32>(0,0));
The issue is that while the code compiles and runs fine, it can't seem to use the second image, as if it weren't there (the image read in using menuBack).
I don't understand what I'm doing wrong. I print the second image the same way as the first, like this:

Code: Select all

 driver->draw2DImage(menuBack, core::position2d<s32>(0,0),
                core::rect<s32>(0,0,1240,768), 0,
                video::SColor(255,255,255,255), true);
, But it still doesn't work. Please help! What am I doing wrong? I've made sure that the second image is in the media folder and stuff like that.

Thanks in advance,
-Evanias
Please help! I still can't figure this out!
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Reading in Multiple 2D Images

Post by CuteAlien »

Do you need makeColorKeyTexture? Does it work without? What that function does (in your case) is to use the pixel at 0,0 and add an alpha channel to your texture based on the color it finds there. So maybe that color is causing a complete transparent texture in your second case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Evanias
Posts: 6
Joined: Thu Jul 03, 2014 10:30 pm

Re: Reading in Multiple 2D Images

Post by Evanias »

I'm afraid that, while I don't need that function in the second case, I do in the first. And I am sure that it is not making it competely transparent, because the second texture is a vivid drawing of the solar system :(. Any other ideas? Does ANYBODY have a snippet in which they read in multiple 2d files?
Evanias
Posts: 6
Joined: Thu Jul 03, 2014 10:30 pm

Re: Reading in Multiple 2D Images

Post by Evanias »

I have managed to solve the error myself. I was attempting to draw 2d and 3d in the same project (not difficult, i know, but my first time doing so). Whilst doing this, I created a series of loops to make sure the 2d and 3d displayed at the proper times. Long story short, one of the pairs of parentheses was missing it's closer. As a result the whole loop was off. I had thought the error was in a different loop, and so I kinda corrected the problem as far as compiler errors go, but in the end it negated the whole loop that printed the second image. Sorry for the inconvenience, and sorry for the lengthy explanation. Problem solved!
Post Reply