I'm trying to make a 2D fighting-game-engine, and need to allow for the colors of sprites to be changed dynamically. I think that if I directly manipulated the User Space (which I think is a raster) I could have quick palette-shifting.
Long loops, even of simple tasks, are often inefficient; but they seem to be how screen-pixels are updated. If such a method isn't used, what is: hijacking such a low-level aspect of Java should cost me hardware acceleration, so I need to know this?
You just want to be able to handle Scorpion, Reptile, Noob Saibot, Smoke, Sub-zero et al :)
Sorry, can't help otherwise.
Bill
There is some extension for palette stuff, but it isnt available usually. And well, there are shaders...
But there is actually some low tech solution ;)
What you need are extra sprite sheets, which only contain the areas which you want to tint in different colors (the rest is transparent). Then you simply draw the base sprite, pick the tint color (instead of white) and draw that extra layer on top. Pretty simple and damn fast.
The disadvantage compared to palette voodoo is that you need to create extra spritesheets. The advantage, however, is that antialiasing and/or simple shading (shadows/highlights) are easier to do.
Is there any restriction on the size of a texture: like it's size having to be a power of two, or something?
The short answer is Yes. The textures need to be power-of-2 and probably not bigger then 4096 (most cards don't support this high).
You can get the maximum size by calling glGetInteger(GL_MAX_TEXTURE_SIZE, intBuff16);
There is an extension to use non-power-of-2 textures, but I'm not sure how supported it is.
Oh and power of two means that each dimension on its own should be power of two. So, rectangular textures (128x512 for example) are fine, too.
NPoT textures sorta kinda work with lots of hardware, but the sampling points are often a tad off... resulting in odd glitches (not noticable in 3d tho).
http://kaioa.com/k/badsample.png
PoT on the left and NPoT on the right (zoomed in of course).
For that reason I enlarge textures to the next PoT on the fly (during loading time) and recalculate the texture coords accordingly.