#167295 - kiniou - Sun Mar 08, 2009 12:56 pm
Hello,
I'm trying to create a dynamic texture with glTexImage2D to apply a sort of animation on a 3D model. I manage to create one in GL_RGB format with function RGB15(). Here is my code:
Then I write some crappy code to shift this greyscale texture and create new ones to have an animated texture.
I've made a test with 16 textures and it works but it takes a lot of texture memory and it's not efficient.
Now I'm looking to change this crappy code to use 16 palettes instead of 16 textures.
I tried to use GL_RGB16 thinking of each texel was a number between 0 and 15 but it doesn't seems to work and can't find how it must be formatted.
You can download the packed files for this test Here .
Thanks for any help or explanations.
_________________
It's time to code...
Last edited by kiniou on Mon Mar 23, 2009 5:04 pm; edited 1 time in total
I'm trying to create a dynamic texture with glTexImage2D to apply a sort of animation on a 3D model. I manage to create one in GL_RGB format with function RGB15(). Here is my code:
Code: |
int size_max = 128; int col = 16; int size = 0; u8 c = 0; while(size<size_max) { //c is the colour components between 0 and 32 //this is a 16 columns and 8 lines texture //so the final result is a greyscale texture starting left from black to white c = (u8)( (size%col) / (float)col * 32.0 ); this->dynamic_texture[size] = RGB15(c,c,c); size++; } glGenTextures(1, &this->textureID[2]); glBindTexture(0, this->textureID[2]); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_16 , TEXTURE_SIZE_8, 0, TEXGEN_TEXCOORD , (uint8 *) this->dynamic_texture); |
Then I write some crappy code to shift this greyscale texture and create new ones to have an animated texture.
I've made a test with 16 textures and it works but it takes a lot of texture memory and it's not efficient.
Now I'm looking to change this crappy code to use 16 palettes instead of 16 textures.
I tried to use GL_RGB16 thinking of each texel was a number between 0 and 15 but it doesn't seems to work and can't find how it must be formatted.
Code: |
int size_max = 128; int col = 16; int size = 0; uint8 c = 0; while(size<size_max) { //c is the colour components between 0 and 16 //this is a 16 columns and 8 lines texture //so the final result is a greyscale texture starting left from black to white c = (u8)( (size%col) ); this->dynamic_texture[size] = c; size++; } glGenTextures(1, &this->textureID[2]); glBindTexture(0, this->textureID[2]); glTexImage2D(0, 0, GL_RGB16, TEXTURE_SIZE_16 , TEXTURE_SIZE_8, 0, TEXGEN_TEXCOORD , (uint8 *) this->dynamic_texture); for(uint16 i=0;i<16;i++) { this->dynamic_palette[i]=RGB15(i*2,i*2,i*2); } this->pal_addr = gluTexLoadPal((const u16 *) &this->dynamic_palette,16,GL_RGB16); |
You can download the packed files for this test Here .
Thanks for any help or explanations.
_________________
It's time to code...
Last edited by kiniou on Mon Mar 23, 2009 5:04 pm; edited 1 time in total