improve renderring speed?

Started by
3 comments, last by d000hg 18 years, 10 months ago
i have a gif animation and want to renderring this gif as background of 3D screen. this is my algorithm : - create a texture for background. - use gdi+ funtion to get each frame buffer of the gif, copy pixel to pixel from this buffer to the top surface buffer of the texture and then render the texture. =>it worked but slow renderring. i have thought of one way to improve the speed that i will preload all frame buffers of the gif file into an array of texture and then render each element of this texture array at renderring time. is this a good way? i wonder should i deal with surface array or texture array? i still have less knowlege about this. as i know that a texture can contain many surfaces, but only one surface is active to render. can i active the other surface of this texture,and how many surface that a texture can have? so, 2 main thing i want to ask that any thing can i improve the speed? should i use surface or texture array?
Advertisement
If you are currently copying the GIF data to the textures every frame, then this is a bad way to do it. Generating the textures at load-time and then never altering them again is fastest. Either an array of textures for each frame of the animation, or you could use a single 3D texture. Personally I'd go with the first approach. D3DX can load a .gif file I think as a single texture, but I don't know if there is a utility function to load an animated .gif. But just do your copying to the texture at load-time and it should get a LOT faster.
I don't have that indepth knowledge of surfaces... but something you should do for sure is to at least preload the gif, but preferably load it onto a texture or other means for Direct3D to quickly access it.

Btw, as it is gif it cannot contain more than 256 colors, should be quite fitting to use a palette and an 8bit-texture if you are memory kinky, but could prove pretty troublesome too however. (remeber to turn off mipmapping for the textures)

(A tip is if it is a large gif, not to create 4096x4096 texture or so, but to keep it rather small)


I would recommend that depending on the performance tradeoffs, you do what
the other posters have said in conjunction with the possibility of a tradeoff
depending on your memory requirements. You might for example buffer the file
and decode the frames to a buffer on the fly. Generally though if you want good
speed you could probably just decode all the frames but then you get that extra
memory hit.
Not especially. Once you create textures for each image of the animation you can free the memory for the GIF image. Use 8-bit textures as already suggested -you could even use a compressed texture to keep the size down.

Does .DDS support animations like this BTW?

This topic is closed to new replies.

Advertisement