Drawing 2D Images gives ugly border.

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
CodeDragon
Posts: 10
Joined: Sun Oct 17, 2010 8:45 am
Location: Belgium

Drawing 2D Images gives ugly border.

Post by CodeDragon »

Okay, I tryed to draw 2D images but i want the border to be a transparant.

Here is a screen how it looks:
Image

I want to draw this images white-out the border (It needs to be more transparent pixels)

Here is my code:

Code: Select all

#include <IrrLicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") // <- If you don't wane have a console add this line.
#endif

IrrlichtDevice *Device;
IVideoDriver* Driver;
ISceneManager* Smgr;

video::ITexture* Icons;

bool ExitGame = false;

int main()
{
	while (!ExitGame)
	{
		// Keeps The Engine Running..

		Device = createDevice(video::EDT_DIRECT3D9,dimension2d<u32>(120, 120), 32, false, false, false, NULL);

		if (!Device)
		{
			return 1;
		}

		Device->setWindowCaption(L"Image 2 Screen Drawing");
		Driver = Device->getVideoDriver();
		Smgr = Device->getSceneManager();

		Icons = Driver->getTexture("../Texture/WarRockIconsRip.png");
		Driver->makeColorKeyTexture(Icons, video::SColor(250, 28, 28, 28), true);

		Driver->getMaterial2D().TextureLayer[0].BilinearFilter=true;
		Driver->getMaterial2D().AntiAliasing=video::EAAM_FULL_BASIC;

		while(Device->run())
		{
			/* Looping while the screen is open */
			Driver->beginScene(true, true, video::SColor(255,120,102,136));
			/* Do things here */
			Driver->draw2DImage(Icons, core::position2d<s32>(20,20), core::rect<s32>(0,0,76,86), 0, video::SColor(255,255,255,255), true); //core::position2d<s32>(50,50), core::rect<s32>(0,0,342,224)
			Driver->endScene();
		}

	}
	return 0;
}
Images:
Image
CodeDragon
Posts: 10
Joined: Sun Oct 17, 2010 8:45 am
Location: Belgium

Post by CodeDragon »

None? I realy need help :o
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Uhm, what are the borders in this case? Those green lines?
Have you thought of using an image with an alpha channel to control transparency?
CodeDragon
Posts: 10
Joined: Sun Oct 17, 2010 8:45 am
Location: Belgium

Post by CodeDragon »

Eh? How do I do that?
Because I just load tga files that I made in Photoshop
CuteAlien
Admin
Posts: 9680
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You should be able to set the alpha-values in photoshop (sorry, can't tell how, I use The Gimp for that).
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
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

If you google for "photoshop alpha channel" you'll find some tutorial.
In case the tutorial fails to mention so, alpha channels can have a range from (usually) 0 to 255. Some sites only use the alpha channel for masking (ie either use the values 0 or 255), but it's good to know there are alternatives.
Post Reply