help needed with animating texture
Blitz3D Forums/Blitz3D Programming/help needed with animating texture
| ||
Hi, I got a problem with a entity with an animating texture. I've made a strip of 156 images(128x236 px) to be used as an animated texture. Added the texture to a mesh and started animating it. To my horror I saw the available vidram racing to zero. Since I only want loop the animation once I was wondering if there is some more vidram friendly way to animate a texture to a (simple) mesh? Thanks in advance Steven Manschot |
| ||
thats odd. how big is the texture you are loading? also, can we see the code? i have a funny feeling you may be loading the texture each loop? |
| ||
Ok.. time to show off my bad maths.. 128x236 will get rounded up to 128x256 by the video card. And each one of those frames will take up 96k. So that's about 15Mb of textures. If you've only got a 16 meg video card, I guess that would do it. |
| ||
Sorry for my ignorance but, instead of replacing the current texture buffer with a new frame, every call to EntityTexture( ent, tex, frame ) creates a new texture or does LoadAnimTexture load in the whole strip in vidram? A better solution, at least for me, could be if i just create a texture with the right size and then copyrect each frame to the textures' buffer. Steven |
| ||
It should load it all into vidRAM, however some gfxcards will store it in system RAM if it's currently not on-screen (I think!) Maybe, this effect is being caused by the frames being copied one-by-one into vidRAM as you display them? (just a wild guess...) |
| ||
I'm trying using CopyRect to fill the textures buffer, but all i get is a block square....|-[ [update] got the parameters wrong, now i i see nothing! [update] got it working! 1) use two textures, one to show and another to store the animated texture (i use textures with alpha channels) 2) on each new frame lock both texture buffers and readpixelfast/writepixelfast the current frame to the shown texture. voila. |
| ||
I think that Blitz may copy the texture into VidRAM only when it's used, and then would use the same video memory spot again and again. That would explain why your memory "raced" to zero, rather than already being AT zero when the program started.. Stevenm, perhaps holding the "not shown" textures in ImageBuffers might work even better. Not sure for certain, but try it out. ReadPixelFast/WritePixelFast at runtime for animations sounds a bit slow though if you ask me... |
| ||
cyberseth:I changed from readpixelfast/writepixelfast to copypixelfast, and as the names says it's pretty fast. At least fast enough. I'm not using imagebuffers because i did get problems with the alpha transparency not working. Anyway it's implemented now and it works. |