suggestion for loading texture

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

suggestion for loading texture

Post by Emil_halim »

hi Niko

some times ,user need to load the same texture file more then one with
deffernt texture names,but Irrlicht does not allow that.

so in my opinion , only the user must have the control and he decide to
load the same texture one or more then one.

if you do not mind,please could you make it optional for the user.

thanks
etcaptor not loged

Post by etcaptor not loged »

I'm accept to your opinion.
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

emil-- the only reason I can think of to have an image loaded into memory more than once is if you were to modify a copy of it. The engine does infact allow you to create a blank image the size of some source image and copy the contents over, and then modify that image. Which solves that problem-- so is there any other reason to have multiple textures loaded in memory?
a screen cap is worth 0x100000 DWORDS
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

i already did your suggestion , if you take a look to TTextureManipulator class, you will see
that i load the texture then create a blank one as the same size and copy the orignal
to the blank.

but.....

sometimes you need another copy not only for changing or modfing the orignal one.
for example, in my TFont Class i want to load the same font texture with 2 deffernt colors
(red and yllow) for Drawing OutLine Text,so how to make it?

ofcaurse other users have another reasons,so i suggest to make it optional and only
the user must have the control.

by the way, Electron suggestes this
I'm guessing the solution is to mod the engine . The reason its done that way is so to save time and memory. The majority of the time, you only need one copy of a texture in memory. I do agree that sometimes multiple copies of textures or meshes may be needed, so the loading functions should probably have a paramter something like
bool loadNew (probably defaulting to false)
see this http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6895
and i am totaly agree with his suggestion.
thanks
maverickbu
Posts: 17
Joined: Tue Dec 05, 2006 5:07 pm

Post by maverickbu »

keless wrote:emil-- the only reason I can think of to have an image loaded into memory more than once is if you were to modify a copy of it. The engine does infact allow you to create a blank image the size of some source image and copy the contents over, and then modify that image. Which solves that problem-- so is there any other reason to have multiple textures loaded in memory?
This sounds just like something i need to do. Could you explain a bit more how one would create a new blank image and copy an existing texture to it?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Emil_halim wrote:some times ,user need to load the same texture file more then one with deffernt texture names, ...
keless wrote:create a blank image the size of some source image and copy the contents over, and then modify that image
Emil_halim wrote:sometimes you need another copy not only for changing or modfing the orignal one
I don't understand how the above suggestion didn't solve your problem. The addTexture method lets you create a texture with any name you want. Once you've got multiple copies of the same texture, then modify them as you see fit. What else do you want to do with a copy?

Maybe here is the hangup...
Emil_halim wrote:i want to load the same font texture with 2 deffernt colors (red and yllow) for Drawing OutLine Text,so how to make it?
I'm not clear what you are saying you are trying to do, and even then I don't understand how that is any different from the original solution. Make a new texture from the original, color it yellow, make another from the original make it red. I'm not sure why you feel it is important for the texture 'name' to be the same... You have pointers to the textures, and you can specify their name when you create them.

Travis
maverickbu
Posts: 17
Joined: Tue Dec 05, 2006 5:07 pm

Post by maverickbu »

Nevermid, I answered my own question using this thread:

http://irrlicht.sourceforge.net/phpBB2/ ... ture+image

As for the slowdowns with manipulating textures using lock/unlock, particularly when trying to create a "fade" effect, I just create multiple textures in memory based off a single one from a file, modify the alpha channel, and save the new texture at the beginning of execution, naming it with the alpha value as a suffix. Then, whenever i need to fade a node using that texture, I just cycle through the pre-loaded textures instead of locking/unlocking.
Post Reply