HalfLucifer
10-19-2006, 06:05 AM
I noticed that many 2d games packed sprite animation frames into one big image file which is none-power-of-two dimension.
However, using glBindTexture() on a NPOT texture would kill performance immediately.
I figure out two different methods might work: (I utilize DevIL to load images)
Method 1:
1) Load the NPOT image.
2) Use ilCopyPixel() to copy each region of animation frame to individual buffers.
3) Construct a sprite/quad and bind a blank POT texture(32x32, 64x64, etc) on it.
4) Use glTexSubImage2D() to replace the blank texture totally with animation frame buffers as needed.
Method 2:
1) Load the NPOT image then bind it to a larger POT texture.
e.g. 500x1000 sized image => 512x1024 sized texture
2) Bind the POT texture with sprite.
3) Modify the texture coordinates of sprite as needed.
I've implement the first method, however, it require many tedious steps to do,
and I get into troubles when I try to mirror/flip the texture.
Is second method a better implementation?
Are there other methods more efficient/effective to do?
Texture matrix? Image scaling? Blitting? Or NPOT extension?
However, using glBindTexture() on a NPOT texture would kill performance immediately.
I figure out two different methods might work: (I utilize DevIL to load images)
Method 1:
1) Load the NPOT image.
2) Use ilCopyPixel() to copy each region of animation frame to individual buffers.
3) Construct a sprite/quad and bind a blank POT texture(32x32, 64x64, etc) on it.
4) Use glTexSubImage2D() to replace the blank texture totally with animation frame buffers as needed.
Method 2:
1) Load the NPOT image then bind it to a larger POT texture.
e.g. 500x1000 sized image => 512x1024 sized texture
2) Bind the POT texture with sprite.
3) Modify the texture coordinates of sprite as needed.
I've implement the first method, however, it require many tedious steps to do,
and I get into troubles when I try to mirror/flip the texture.
Is second method a better implementation?
Are there other methods more efficient/effective to do?
Texture matrix? Image scaling? Blitting? Or NPOT extension?