Feature request

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Feature request

Post by MasterGod »

A method to convert IGUIImage to ITexture and vice versa.
So an IGUIImage object would be able to return an ITexture, e.g:

Code: Select all

ITexture* tex = MyIGUIImageObj->getITexture();
IGUIImage* img = MyITextureObj->getIGUIImage();
It would certainly ease a lot of people and a nice feature in general.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I suppose getting the texture from an IGUIImage wouldn't be particularly bad but currently you have to set it yourself anyway, from an ITexture so could you not just keep a hold of the ITexture you pass to it for when you want to use it elsewhere?

But getting an IGUIImage from a texture is silly because you can just create a IGUIImage and set the texture with the texture you already have. It just wouldn't make sense that way... ITexture doesn't contain an IGUIImage so you can't get one from it, you could create one from the texture but then it wouldn't be a function of ITexture, it would be a function of IGUIEnvironment, as it is already...

Maybe you could explain your reasons for wanting these functions and how they're help you.
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

JP wrote:Maybe you could explain your reasons for wanting these functions and how they're help you.
I know how to add a scaled IGUIImage and I need a scaled ITexture so I thought of making a IGUIImage with my picture, scale it then convert it to ITexture.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What do you need a scaled ITexture for? An ITexture will be applied to a surface of any size and be stretched or squashed to fit it so you don't need to scale it yourself. Are you wanting to draw it in 2D?

I'm not sure if IGUIImage would actually scale the texture passed to it but actually just draw it scaled down so if you got the texture back it would probably still be the same size. Though maybe you've looked at the source and know better!
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I want to draw a .png cursor instead of the default arrow one.
I want that it wont matter what scale is the image it will be scaled down to 32x32 then drawn instead of the default arrow.
I did it (without scaling) with ITexture and draw2DImage but I want to scale the cursor file to 32x32 cause when I use e.g a 64x64 cursor image it's not good.
This is why I tried with IGUIImage cause I know how to scale it.

This is the code I'm trying now:

Code: Select all

void CGameState::addMouseCursor(CGameManager* pManager, c8* Cursor_file)
{
	m_pMouseCursor = pManager->getVideoDriver()->getTexture(Cursor_file);
	pManager->getVideoDriver()->makeColorKeyTexture(m_pMouseCursor, SColor(0,0,0,0));

	IGUIImage *image = pManager->getGUIEnvironment()->addImage(rect<s32>(0,0,32,32));
	image->setImage(m_pMouseCursor);
	image->setScaleImage(true);
	image->setRelativePosition(rect<s32>(100,100,200,200));
}
Now I draw the ITexture like this:

Code: Select all

	pManager->getVideoDriver()->draw2DImage(
		m_pMouseCursor, 
		// So the center of the icon will be the place getting checked on mouse clicks
		position2di(m_MousePos.X - m_pMouseCursor->getSize().Width/2+1, m_MousePos.Y-15),
		rect<s32>(position2di(0,0),m_pMouseCursor->getSize()), 0, SColor(255,255,255,255), true);
Now the icon (ITexture) is being drawn good but I don't see the IGUIImage (image)..and I also do guiEnv->drawAll() but I still don't see it.
EDIT:
I didn't see it cause I drew over it :oops:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

k I don't want to make this thread more off-topic then it is so please don't respond about that problem, let me try handle it.

So what others think of the feature I suggested..?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

There is ITexture, a texture stored on your graphics card
Then there is IImage which is some image data in system memory
And also there is IGUIImage which is an image "node" in the GUI environment.

Getting an IImage from an ITexture makes some sense, as most of them use IImage to hold their data. You can do this with a createImage call using ITexture->lock() and the pixel format. Merging IImage and ITexture in some deeper way makes even more sense. Converting an IImage to an ITexture also makes sense, you can do it with createTexture.

But to get an IGUIImage from an ITexture, ITextures would need to know about the existence of the GUI Environment, which is none of their business.
Should we also ask textures to create IBillboardSceneNodes, particle systems, fonts and sprites? It's like asking a brick to build a house.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Thanks bitplane for elaborating on the subject.
I understand now.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Post Reply