Reuse of textures in .x files

Blitz3D Forums/Blitz3D Programming/Reuse of textures in .x files

6(Posted 2009) [#1]
I've done a couple of experiments, but could someone just confirm something for me please.

I have a simple .x file that consists of two seperate cubes and each cube uses a seperate texture file. When I use loadmesh, those two cubes are textured properly, each having its own texture. Using AvailVidMem i see that these two textures take up about 30meg of video ram, ( this sounds wrong but isn't my question).

When I load a different mesh file which uses the same textures I thought that these textures would be reloaded to memory, but on checking AvailVidMem, there is no increase in memory usage; its pretty much exactly the same.

So does loadmesh some how recognise the texture file name you've loaded for previous meshes and reuse it rather than load it in again?


Ross C(Posted 2009) [#2]
Well, bare in mind your backbuffer and frontbuffer, and z buffer, take up VRAM.

Your best to:
Load a blank scene, and record the AvailVidMem()
Then load the two cubes, (make sure they are in view of the camera) and record the AvailVidMem()

Then compare these two. That will give you the used memory.

To be honest, if you want the two cubes to share the same texture, the quickest (rendering wise) way to do that, is to CopyEntity() it.


6(Posted 2009) [#3]
I was more questionning the fact that blitz3d only loads a texture once, even if you specify that texture multiple times in different .x files.


Matty(Posted 2009) [#4]
Yes it does do that, I've noticed it too and it can be quite annoying for the following reason:

If I have a grunge texture which I wish to apply to a surface and want to rotate and scale each texture differently, but using the same image file - nay the same image (try it with a texture.bmp and a texture.png for example that have the same image data) then blitz will treat both/or more textures the same.

eg:

tex1=loadtexture("myimage.bmp")
tex2=loadtexture("myimage.bmp") ; exact same image as before
rotatetexture tex2,123
rotatetexture tex1,456
;what you will find is that only 1 texture really exists and you will not have two differently rotated textures.


What you end up having to do is to simply change the texture in an image editing program - a simple 1 pixel change is fine, and then when you load the two images blitz will treat them as being different textures, which obviously they are now.


Ross C(Posted 2009) [#5]
Ah yeah, THAT problem...


6(Posted 2009) [#6]
Well thats good to know. From my point of view, however, the fact that it only loads 1 instance of a texture is perfect.