Draw a 2D image with a depth

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
Maleesh
Posts: 3
Joined: Fri Apr 23, 2010 3:49 pm

Draw a 2D image with a depth

Post by Maleesh »

Hi all!

I need to order the 2d images regardless the order of they drawing. So, Can anyone please tell me how to draw 2d images with a depth. I did it with pure OpenGL, but I started to port that code into IrrLicht. Now I can't find a way to do it. :roll:

I'm talking about something like this,

Code: Select all

	glBegin(GL_QUADS);

	//Top-left 
	glTexCoord2f(l, t);
	glVertex3f(x, YY, _depth);

	// Top-right
	glTexCoord2f(r, t);
	glVertex3f(XX, YY, _depth);
	
	// Bottom-right 
	glTexCoord2f(r, b);
	glVertex3f(XX, y, _depth);

	// Bottom-left
	glTexCoord2f(l, b);
	glVertex3f(x, y, _depth);	
	
	glEnd();
Please forgive me if this is a noob one :) , that is because this is my first time at IrrLicht. I'm asking this after spending a almost a day to find the solution :(

Thank you very much..

Regards,
Maleesh
Josie
Posts: 44
Joined: Sat Jul 25, 2009 4:08 am
Location: Griffin, Georgia, US
Contact:

Post by Josie »

What you should do is encapsulate what you draw into scenenodes, Irrlicht automatically orders those by depth, regardless of what order you create them in.
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

You can do a list and order them by depth so when you call the draw function for each one, the distant ones are drawn first and the closer ones are drawn last.
You can also make scene nodes for 2d images using 3d quads and ortho cameras (dont forget to lock X and Y rotation).... its pretty straight foward and easy and you can also rotate and scale without problem and also render them with(or without) filters and custom materials (like normal maps for lighting pwnage)....
Maleesh
Posts: 3
Joined: Fri Apr 23, 2010 3:49 pm

Draw a 2D image with a depth

Post by Maleesh »

Josie wrote:What you should do is encapsulate what you draw into scenenodes, Irrlicht automatically orders those by depth, regardless of what order you create them in.
Thank you.
How to use addSceneNode() ? It returns me NULL. And Scenenodes are ordered (z) by IrrLicht, not by OpenGL. Isn't it ?
Kalango wrote: You can do a list and order them by depth so when you call the draw function for each one, the distant ones are drawn first and the closer ones are drawn last.
Thank you. But we don't want to do it, if IrrLicht can do it itself ?

Can anyone please show me the code to load a image and render it with scene node? I searched about it, but no luck on the forum or wiki. Help this noob please. Thank you very much. :)
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

Maleesh
Posts: 3
Joined: Fri Apr 23, 2010 3:49 pm

Post by Maleesh »

Thanks. It is about creating a custom scene node. So, I can't simply add my texture to scenenode to get rendered it ?
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

Hi,

just use this example and add your texture with:
setMaterialTexture();

MfG
Scarabol
Post Reply