Hi everybody,
Well I have a problem using color palette with texture
I’m working with gl4java, a wrapper in java for opengl
I’m trying to update the color palette for a texture dynamically, I read all post on this subject in this forum, but it does not work for me !!!
My texture is a raw RGB file, its size is 1024 * 1024
Here is the code I’m using to create the texture :
//---------------------------------
gl.glEnable(GL_TEXTURE_2D);
colors = new byte[256*3];
for (int k=0; k<256 * 3; k+=3)
{
colors[k] = (byte) k;
colors[k + 1] = (byte) k;
colors[k + 2] = (byte) k;
}
loadTiles();
gl.glGenTextures(_nbTilesOneDim * _nbTilesOneDim, _texName);
for (int i=0; i < _nbTilesOneDim; i++)
for (int j=0; j < _nbTilesOneDim; j++)
{
_buffer = (byte[]) _tilesArray[i][j];
gl.glBindTexture(GL_TEXTURE_2D, _texName[i * _nbTilesOneDim + j]);
gl.glColorTableEXT(GL_TEXTURE_2D,GL_RGB,256,GL_RGB,GL_UNSIGNED_BYTE,colors);
gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl.glTexImage2D(GL_TEXTURE_2D,
0,
GL_COLOR_INDEX8_EXT,
_tileWidth,
_tileHeight,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
_buffer);
}
//--------------------------------------
Well the color is changed but the texture looks wrong : it seems that data are “wrong”
When I display the texture using RGB mode it is ok !
Someone can help me ?
thx