[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [linuxgames] Poll: Video Access
Francesco Orsenigo wrote:
How can estimate the texture memory usage?
I've always supposed 4bytes per pixel (RGBA)...
If so memory usage may grow very quickly....
Well, if you aren't reloading the textures frequently, you can use
texture compression on most hardware. This is lossy compression, kinda
like JPEG - but it'll give you maybe 6:1 compression rates for reasonably
large images. For a bunch of similar sprites (eg a 'walk' sequence for a
character) - you can pack them up into a single texture and get MUCH better
than 6:1 compression rates if you are sensitive to the 'cell size' of the
compression algorithm.
The bits per pixel can also be controlled in OpenGL, so if you don't
need full 24 bits of RGB, you can drop down to 16 bit mode and have
either 5/6/5 RGB or 5/5/5 if you want better grey-scale rendering.
It goes back to the give-player-color-to-unit issue: I must store the sprite
twice: the normal sprite and the areas that must be colored...
Is possible to achieve this just playing with the alpha channel or a similar
hack?
Yes - that's what the alpha channel is for. If you use 32 bits per pixel,
you have an 8 bit alpha mask. You can also use 16 bits per pixel with
4/4/4 RGB and a 4 bit alpha channel or 5/5/5 RGB and a 1 bit alpha mask.
That's *definitely* the way to go for sprites.
If you intend to shrink your sprites - and want them to remain
antialiased - then you'll want to MIPmap them which adds 25% to
the storage requirements.
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@airmail.net> WorkEmail: <sjbaker@link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----