Using only part of an image

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
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Using only part of an image

Post by AndyCR »

Is there a way to use only part of an image in Irrlicht?

Example: I have an image which contains a bunch of game menu buttons. I would like to load and display those buttons individually, yet they are from the same image. I need a way to "split" that image, or, if you will, only load part of it.

I believe I have found a method, but it's incredibly ugly and I'd like to avoid it at all costs, especially if Irrlicht already supports this and I simply didn't see it.

Yes, I know about Magic2D, but I'd rather not limit myself to the OpenGL driver.
jrm
Posts: 111
Joined: Tue Dec 13, 2005 8:57 pm

Post by jrm »

Look at the 2D Tutorial. It goes over how to do this.

It is the draw2DImage function:

Documentation:

Code: Select all

virtual void irr::video::IVideoDriver::draw2DImage  (  video::ITexture *  texture,  
  const core::rect< s32 > &  destRect,  
  const core::rect< s32 > &  sourceRect,  
  const core::rect< s32 > *  clipRect = 0,  
  video::SColor *  colors = 0,  
  bool  useAlphaChannelOfTexture = false 
 )  [pure virtual] 
 
   Draws a part of the texture into the rectangle. 

Suggested and first implemented by zola. 

Parameters:
 texture,:  the texture to draw from  
 destRect,:  the rectangle to draw into  
 sourceRect,:  the rectangle denoting a part of the texture  
 clipRect,:  cipps the destination rectangle (may be 0)  
 colors,:  array of 4 colors denoting the color values of the corners of the destRect  
 useAlphaChannelOfTexture,:  true if alpha channel will be blended.  
 
I am using this for an orthogonal tile game.

JRM
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

Good grief, how dumb am I? Thank you so much... :)
Last edited by AndyCR on Fri Mar 10, 2006 12:00 am, edited 1 time in total.
jrm
Posts: 111
Joined: Tue Dec 13, 2005 8:57 pm

Post by jrm »

Hey, no problem. I am glad I can help out in the forum.

JRM
vickylh
Posts: 9
Joined: Thu Mar 09, 2006 4:43 pm

thanks

Post by vickylh »

useful in making LoadingBar!
Thanks!
Post Reply