Originally Posted by
Noise
Code:
(i/RED_STEP)*RED_STEP;
I'm a little confused, you divide by RED_STEP and then multiply by it, leaving just i?
Apart from that, your texture generating looks fine to me.
PS, what does '3' as the 3rd argument to TexImage1D do? I use GL_RGB.
Those are integers, so it makes the values in the texture go up in steps. For example, if RED_STEP is 14, 0-13 maps to 0, 14-27 maps to 14, 28-41 maps to 28, etc.
I changed the 3 to GL_RGB, but still no luck. After looking at some tutorials, I changed the funciton to this
Code:
void gen_texture_map(void){
int i;
for(i = 0; i < 256; ++i){
color_map[i][0] = (i/RED_STEP)*RED_STEP;
color_map[i][1] = (i/GREEN_STEP)*GREEN_STEP;
color_map[i][2] = (i/BLUE_STEP)*BLUE_STEP;
}
glEnable(GL_TEXTURE_1D);
glGenTextures(1, &color_map_id);
glBindTexture(GL_TEXTURE_1D, color_map_id);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, COLOR_MAP_WIDTH, 0, GL_RGB, GL_UNSIGNED_BYTE, color_map);
}
And call glBindTexture(GL_TEXTURE_1D, color_map_id) before rendering the object. Still nothing