PDA

View Full Version : How to use glColorTable(attach code)



LLM
05-26-2006, 12:22 AM
this is my code:


GLubyte table[256][4];
int i;

for (i=0;i<256;i++) {
table[i][0] = 255;
table[i][1] = 0;
table[i][2] = 0;
table[i][3] = 255;
}


glColorTable(GL_COLOR_TABLE,
GL_RGBA8,
256,
GL_RGBA,
GL_UNSIGNED_BYTE,
table);

BYTE texture[8*8];
for(i=0; i<8*8; i++)
{
texture[i] = i;
}

glBindTexture(GL_TEXTURE_2D, TextureIndex);

glTexParameteri(GL_TEXTURE_3D,
GL_TEXTURE_WRAP_S, GL_REPEAT);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glTexImage2D(GL_TEXTURE_2D,
0,
GL_COLOR_INDEX8_EXT,
8, 8,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
texture);Is anyting Wrong? If it was correct, the texture
color should be red. But it's not red. why?

jorneyX
05-26-2006, 09:36 AM
Wehcle Farbe ist es? Vieleicht ist blau.

Serge K
05-26-2006, 09:18 PM
Shouldn't it be glColorTable( GL_TEXTURE_3D, ... ) ?
Or is it GL_TEXTURE_2D?
It seems that you found a way to mix them freely... :rolleyes:

GL_EXT_paletted_texture (http://oss.sgi.com/projects/ogl-sample/registry/EXT/paletted_texture.txt)

LLM
05-28-2006, 08:28 PM
oh, That was a mistake. It should be GL_TEXTURE_2D all. But my triangle still have wrong color. oh,glColotTable make me headache

Serge K
06-01-2006, 01:34 AM
Are you sure that your 3D card actually has GL_EXT_paletted_texture extension?
It wasn't that widely supported, and even NVIDIA dropped it.