Irrlicht GUi Interface overlaps with Driver Image

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
timmymorris91
Posts: 19
Joined: Tue Mar 18, 2008 9:43 pm
Location: Wagga Wagga, Australia

Irrlicht GUi Interface overlaps with Driver Image

Post by timmymorris91 »

I am creating a map editor for a game i am making but i am having problems drawing images with the gui.

When I draw and image with driver->draw2dimage and then draw he gui, the gui is drawn over the top. If I draw the gui and then the image with draw2dimage then the image is drawn over the top but if I bring a window etc. over the top or loose focus of the window that is asscociated with the image, the image is still drawn, like it is being drawn over the window.

For example, i want to draw and image on a tab over the top, but when a window comes over the top of the image, it is still drawn over the top, instead of the window being drawn over the image. I cant use IGUIIMAGE because it cannot specify what part of the picture is drawn, only the height and width.

What i am trying to say is that I need a way to draw the image on the Element or Window etc.
Last edited by timmymorris91 on Tue Jun 03, 2008 11:37 pm, edited 1 time in total.
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

if you do the following in your render loop:

guienv->drawAll();
driver->draw2DImage();

then the 2DImage will ALWAYS be drawn over EVERY GUI element.

If you do the opposite then the opposite is true; all GUI elements will be drawn over the driver image.

So what you need to do is to make your own IGUIElement to handle this.

Can you explain a bit better what you want to do? Maybe a screenshot? Are you trying to draw an image within a tab or over the 'tab button' itself?

If it's the first then you can just make your own IGUIImage which allows you to specify the source rect of the image, should be pretty easy as you'll just have to add that as a parameter/setter function and change the drawing function accordingly.

If you want to do the latter then you'd have to write your own IGUITabControl, just adding in the ability to draw an image on the 'tab button'.
Image Image Image
timmymorris91
Posts: 19
Joined: Tue Mar 18, 2008 9:43 pm
Location: Wagga Wagga, Australia

Post by timmymorris91 »

This is a screenshot i have taken.

Image

Can you see how the bulbasuar that i drew with '->draw2dimage' is above
the tab, because I render it after the environment. If I take that tileset
window on the bottom left and drag it above the bulbasaur, because I am
drawing it above the environment, the bulbasuar will be above the tileset
window, even though it has focus, obscuring the window and covering it.
The way I half-solved it was to only draw the bulbasaur when the window
with the tab has focus, again causing problems.

The way I think I should do it is use a IGUIImage because that
automatically switches render position to behind anything that has focus
thats above it. The only problem is that i could not find a parameter in the
IGUIImage function that allows specifying the source rectangle within the
image to draw, instead only drawing from (0,0) to where the height and
width is.

By the way JP, great contribution to the Irrlicht forums, I see that you
solve many peoples troubles on the forum.
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The way I think I should do it is use a IGUIImage because that automatically switches render position to behind anything that has focus thats above it
Yes, that is currently the simplest option.

It sounds like the image that you are loading has multiple small images in it. If this is the case, then you have a few options. You can use an image editor to split the image up into multiple smaller images. Then you can just use driver->getTexture().

If you insist on using a texture atlas [multiple images packed into a single texture], then you have to write some image manipulation code to extract each image from the original and then copy the data into a texture. You can get a blank texture using driver->addTexture(), and you can access the actual texture data using texture->lock() and texture->getPitch(). I believe there is already some code floating around these forums for doing this.

The other option would be to write your own implementation of IGUIImage that allows you to specify the source rect. You could probably copy CGUIImage and IGUIImage, rename them, add an interfaces for changing the src rect, and update the draw() call to draw the image using the src rect of the provided texture.

Travis
Post Reply