Memory of the animations

BlitzMax Forums/BlitzMax Beginners Area/Memory of the animations

Josepho(Posted 2006) [#1]
Hi again, i have a big problem, my game uses very long animations and it uses a lot of memory, i would like to know if there is some way to save as memory as i can, making for example that the bmax loads only the frame that is showing it (the memory of the process grows all the animation untill it reaches the top of the animation) Is this possible? Anybody can help me? Any examples?


Rck(Posted 2006) [#2]
You shouldn't be trying to load animations right as you're drawing them. But you can try to load animations a few minutes before you draw them (not everything needs to be in mem at once).

If your animations are becoming too large, try to isolate parts of them which do not change in appearance. Then draw each part, i.e., of an explosion as single frames but move, scale, rotate, fade them individually. You can also try loading smaller resolution animations for some visuals and then draw them scaled larger.

But if you find yourself using several hundreds of MB of mem to hold your animations then you should reconsider what is possible.


Josepho(Posted 2006) [#3]
So i have to cut the anims on diferent ones? and delete its and load it every time i run the animation ?


tonyg(Posted 2006) [#4]
You could look at something like this which delivers single-surface.


Josepho(Posted 2006) [#5]
Hi tonyg i tried the code of jim brown but it seems not to work, it tells me "TDX7ImageFrame" not found :/


tonyg(Posted 2006) [#6]
It's now called TD3D7ImageFrame plus you need to take out the flushmem()


Josepho(Posted 2006) [#7]
with one of my animations doesnt work and i dont know why, it doesnt show anything and it requires the same process of the loadanimimage function

The runner sprite is showed but mine not. My anim its a 12408x176 png 8bits with rbga


tonyg(Posted 2006) [#8]
Jim Brown's code states each frame has to be horizontal. In general they both say it's best to have pow2 images.


Josepho(Posted 2006) [#9]
My animation has each frame horizontal ._., but this codes doesnt draw anything if i use my anims -_-


SculptureOfSoul(Posted 2006) [#10]
Are you trying to conserve system memory or video memory?

I'm assuming system memory, but if that isn't the case then you do have some options.

If you're just trying to cut down your RAM usage, you'll likely have to come up with a scheme to dynamically load and unload images.

Also, if any of your animations are using identical frames anywhere (perhaps as a crude method to control the animation speed) you could cut them out and instead create a wrapper class that handles frame changes, animation speeds, delays, etc.


tonyg(Posted 2006) [#11]
What if you reduce the number of frames in your anim?
If it happens with 4 frames then post them and somebody can give it a try.


degac(Posted 2006) [#12]
Little OT: How can I know the actual video memory usage? I was thinking to expand my game adding some new gfx features but I need to keep it working on machine with little memory...


SculptureOfSoul(Posted 2006) [#13]
D/L "Video Memory Watcher" at
http://www.nonatainment.de/web/Default.aspx?tabid=62

It works like a charm.


degac(Posted 2006) [#14]
Thanks, but I was looking for something to use internally in Bmax: if I have enough space then load new gfx...


SculptureOfSoul(Posted 2006) [#15]
Hmm, not sure there is a method.

I wonder what happens when you run out of Vid mem. Does LoadImage/LoadAnimImage throw an exception...simply return null...or something else?

I too would love to know if there is any way to get system information like VRAM, RAM, CPU speed, etc, so that my game could tailor itself to the machine it's on.

Anyone? :)


tonyg(Posted 2006) [#16]
There was talk about doing this and, I think, Mark stated you couldn't trust the output from the Vidcard anyway.
Not sure about OGL but, with DX, here's what I think happens from checking the code.
Loadimage/Loadanimimage loads the file as a pixmap internally.
When you drawimage for the first time, DX will create a surface and apply the pixmap as a texture moving it to Vidmem.
DX Texture Manager is used to move images in/out of Vidmem as required. The algos are on the web somewhere but, basically, it's an oldest/least used affair.
If you have LOTS of images which are used often and/or small graphics mem you can get into a trashing state affecting performance.
Single-surface images can get around this to some degree as
can your drawing order.
I suppose if there was a tool which could cap VRAM, RAM, CPU Speed you could check the lowest spec your game runs OK on and make them your minimum requirements.
Anybody know such a tool?


Josepho(Posted 2006) [#17]
I have a question, if i set the game depth to 16, it will comsume less video memory ? I try it but i cant look the process textbox without minimize the game so i cant watch how memory is taking..


SculptureOfSoul(Posted 2006) [#18]
Seriously, download video mem watcher. It's like the process viewer except it monitors only video ram usage. You can open it in the background, then open your game, let your game run for a bit, and then check the usage stats.


Punksmurf(Posted 2006) [#19]
Maybe it's also an idea to try ogl-driver insteat of the dx one. Wouldn't hurt, anyway.


Dreamora(Posted 2006) [#20]
If it isn't ATI Radeon or NVidia Geforce, it would seriously hurt ...