Loading a texture with a texture

Blitz3D Forums/Blitz3D Programming/Loading a texture with a texture

PaulJG(Posted 2003) [#1]
I want to add details to my terrain that are gonna change every frame update. (cloud shadows, object shadow movement etc..)

The way I'm gonna do this is to alter the top texture layer, (which is also used as a light map, and stretched across the top of the terrain), so I need to find the fastest way to..

1) Either have my texture already loaded, or as an image

2) Edit the data directly

3) display the texture on the object

4) reset the texture to its original image (with the lightmap).. then loop again

Now, what would be the fastest way of accessing the textures/image and doing this ?

I dont have much experience with textures and what types of memory is quickest at writing to, (and if its possible at all !) - so any advice would be very welcome.

Thanks !


semar(Posted 2003) [#2]
1) Either have my texture already loaded, or as an image
----------> global texture = loadtexture("tex.bmp",flag)
see loadtexture command for flag explanation (usually flag=1)


2) Edit the data directly
----------> Don't know what do you mean with edit, anyway, an useful command would be:
setbuffer texturebuffer(texture)
After this command, all the graphics will be targeted on the texture image, until you set the buffer back to backbuffer().

3) display the texture on the object
----------> Entitytexture object, texture

4) reset the texture to its original image (with the lightmap).. then loop again
----------> Hum... CopyRect command ?
CopyRect src_x,src_y,src_width,src_height,dest_x,dest_y,[src_buffer],[dest_buffer]
You may need to load the texture into two copies of it, one will be modified, the second will be used to reset the modified image to the original one.

Hope this helps,
Sergio.


PaulJG(Posted 2003) [#3]
It does, thankyou. I'll give it a whirl !.

But.. would altering and copying from a texture to a texture be faster or slower than say - copying from an image (system memory) to a texture (video memory)?

Btw.. when I spoke about editing the image, I mean to add things like tyre marks and explosions directly to the lightmap.


jfk EO-11110(Posted 2003) [#4]
Coping from System Memorey to Video Memory is extremly slow. Better copy from Texture to Texture using the Videoram resident Operations Flag

l=loadtexture("x.bmp",256)

If you don't use this Bit then the whole Texture will be moved to the Videoram, every time you edit it, even if you edit only one Pixel. So you should use this Flag and use Copyrect to reset the Hightmap. This is the fastest I know. But there are a few Videocards which don't support this Flag properly. If you want to be shure that you App works with all Cards then use the Flag 256 Compatibility Check Source from the Code Archives that I wrote some Time ago.