Drawing 2d image in Window?

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.
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Drawing 2d image in Window?

Post by Magus_Stragus »

Hey there. I need to draw an 2d image (a texture) in a window, instead of the environment. I found that the element IGUIWindow doesn't have a method to do that. How, then, do I do it?

Thanks for the help.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
nmn
Posts: 23
Joined: Tue Sep 02, 2008 7:35 pm

Re: Drawing 2d image in Window?

Post by nmn »

Magus_Stragus wrote:Hey there. I need to draw an 2d image (a texture) in a window, instead of the environment. I found that the element IGUIWindow doesn't have a method to do that. How, then, do I do it?

Thanks for the help.
IVideoDriver::draw2DImage() ?

Code: Select all

		virtual void draw2DImage(const 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) = 0;
It should work...
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post by Magus_Stragus »

That draws me the image in the environment, not in the Window.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Why not use IGUIImage?
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Re: Drawing 2d image in Window?

Post by dlangdev »

Magus_Stragus wrote:Hey there. I need to draw an 2d image (a texture) in a window, instead of the environment. I found that the element IGUIWindow doesn't have a method to do that. How, then, do I do it?

Thanks for the help.
What do you mean window? Like a HWND? Is that what you want to get a pointer to HWND?

I may look smart, but I'm actually stupid.
Image
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post by Magus_Stragus »

Ion Dune wrote:Why not use IGUIImage?
Hmm... I could, but I need to use the draw2DImage function. (I'm using the Animated Sprite code found in the Code Snippets). Anyone?
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
nmn
Posts: 23
Joined: Tue Sep 02, 2008 7:35 pm

Post by nmn »

Magus_Stragus wrote:
Ion Dune wrote:Why not use IGUIImage?
Hmm... I could, but I need to use the draw2DImage function. (I'm using the Animated Sprite code found in the Code Snippets). Anyone?
It should draw regardless of 3D transformations if I get what you mean... But I guess I don't know.

It's probably not impossible to port your existing code to use IGUIImage, though, if there are no workarounds.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you really need some special case og GUI element just throw together your own one. Simply copy the code from CGUIImage or CGUIWindow with the functions you need.
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post by Magus_Stragus »

I don't think I get what you meant, but I'll try.

What I want is simple: when you use draw2DImage(), it draws a 2d image to the environment (the Irrlicht main window.) Now, I wat to draw an image to a window I created, not the main one (let's say, like a window holding the status of a character in a game), how can I do that, is my question.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to use a gui element. Either write your own that calls draw2DImage() or use IGUIImage.

Travis
nmn
Posts: 23
Joined: Tue Sep 02, 2008 7:35 pm

Post by nmn »

Oh, I finally understand - The GUI environment's window.

Can't you manually draw it after you drawAll the GUI environment? I haven't tried it so It's probably a stupid suggestion.
ehenkes
Posts: 47
Joined: Sun Aug 03, 2008 2:52 pm
Location: Germany
Contact:

Post by ehenkes »

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30199
could be helpful. If you need to move (x,y) fix it mathematically (delta_x, delta_y) to the left corner of the parent window. I do that with own context menus fixed to characters. It's easy. If you need images in the 3D-space, use billboards instead.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you don't draw it at the right time, you'll never be able to control the z-order. The easiest way to do this is to use a gui element.

Travis
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post by Magus_Stragus »

So, you're telling me that's impossible to use draw2DImage on a GUI element? What a bummer...
Well, then I shall use IGUIImage. Thanks for the help.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

What Travis means is that it's impossible to draw other GUI elements over the top of a draw2dImage call if you draw your GUI using gui->drawAll(), you need to insert your draw2dImage call into the GUI so it will draw in the correct order.

So you just have to make a custom IGUIElement and add it to the GUI environment in pretty much the same way that you would make a custom scene node (example 3). To see how to do it, just steal the code to any other GUI element (CGUISomething.cpp/h) from the source directory, make the changes you want, create it ( new CGUISomething(...) ) and of course remember to drop() it.

Once you've learned how to do that, you can add any new fancy widget you can imagine.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply