Animated Texture with DDS

Blitz3D Forums/Blitz3D Programming/Animated Texture with DDS

Mortiis(Posted 2007) [#1]
I've tried a dds animate texture system. I don't have the code
here with me but simply what I do is;

Create an array[frame_count]
Pass the frames to the array
a For..Next loop to iterate through frames
Entitytexture frame, mesh every loop

It's working perfectly except one thing, to show the frames
I have to renderworld every for..next loop like;
For i = 0 to max_frames
    entitytexture entity, array[i]
    renderworld
next


the problem is, it halts the main program until the animation
is finished. If I do not put a renderworld there, it halts
the program again but doesn't show the animation.

Any help is appreciated, thanks.


Dreamora(Posted 2007) [#2]
You don't play animations like that.

You use a variable that holds the millisecs of the last update and if a given amount of time passed by, you change it.
-> object changes as the world changes

Your way of doing it would mean: texture is animated while the rest of the world is put on halt.


Mortiis(Posted 2007) [#3]
variable = millisecs()
if millisecs() = variable + 200 then entitytexture "blahdi"

something like this?


Matty(Posted 2007) [#4]
something more like this (this is not the best code just a demonstration):


;in your main loop

if millisecs()>frametime then 
frame=(frame+1) mod MaxFrames ;where MaxFrames is the number of frames of your animation
frametime=millisecs()+16 ;for updates at 60Hz roughly
entitytexture yourentity,yourtexture,frame

endif 

;rest of your main loop here

;and your usual calls to update/render etc 
updateworld
renderworld
vwait
flip false 






_33(Posted 2007) [#5]
In the same way as mortiis, is it possible to load an animated GIF as an animated texture with using texture compression? How would you do that?


Gabriel(Posted 2007) [#6]
since the GIF format doesn't support texture compression, that's going to be a no.


Mortiis(Posted 2007) [#7]
Thanks a lot, I got the idea.


Dreamora(Posted 2007) [#8]
you can not load GIF as texture at all.
GIF are movies in Blitz


_33(Posted 2007) [#9]
OK I'll rephrase: Could I load a GIF frame by frame, store it on a texture, then compress that texture, then use the texture as an animation?

And, yes GIFs are compressed, but not like DDS textures. They use a color palette and are optimized for space saving.


Gabriel(Posted 2007) [#10]
And, yes GIFs are compressed, but not like DDS textures. They use a color palette and are optimized for space saving.

So then they don't support texture compression, which is what I said.

Could I load a GIF frame by frame, store it on a texture, then compress that texture, then use the texture as an animation?

It's been a while since I used B3D, so bear with me. Are there any commands to compress a texture or load a compressed texture from memory? I don't see any, but like I said, it has been a while.

I'm still not really seeing the purpose though, to be honest. Yes, GIF's use a color palette and that does keep the filesize down, but if you're going to have to convert them to another format, they're not going to save you any VRam or System ram and they're going to take longer to load than a DDS texture anyway, and because they're limited to 256 colors they're probably going to look awful too.


_33(Posted 2007) [#11]
The purpose would be to use already existing asset without converting them. At the same time, not take a too big chunk of VRAM.

Thanks.


big10p(Posted 2007) [#12]
What Gabriel said. GIF's don't really lend themselves to game dev, TBH. Just convert to a friendlier format. :)


Dreamora(Posted 2007) [#13]
As said above: you can not load GIF as image at all.
GIF is only supported as movie.
Use a simple converter that creates an image strip from the image movie.


_33(Posted 2007) [#14]
Use a simple converter that creates an image strip from the image movie.

Good idea.


_33(Posted 2007) [#15]
As a reference, this neat code in the archive is a nice find for loading animated GIFs:
http://www.blitzbasic.com/codearcs/codearcs.php?code=619