PDA

View Full Version : Mixing colors with standard openGL



Kilam Malik
11-27-2002, 01:17 AM
Hi,

I want to put a texture with BLEND mode on an object, so that the color can be seen through. I already did this, but I would like to set the strength of the effect. This is my initialisation code:




glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
GLfloat c[4] = {1.0, 1.0, 1.0, 0.0};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, c);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

glBindTexture(GL_TEXTURE_2D, texNrMetalImg);
glEnable(GL_TEXTURE_2D);


I would like to mix the colors like e.g. 20% reflection and 80% base color of the faces. Is this possible without extensions?


Thanks,

Kilam.

Bob
11-27-2002, 02:42 AM
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_2D, GL_SOURCE0, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_2D, GL_SOURCE1, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_2D, GL_SOURCE2, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_INTERPOLATE);

You can now use the constant color to control the amount of base color and reflection texture. If constant color is 1.0, you have 100% reflection texture, and if it's 0.0, you have 100% base color.

Kilam Malik
11-27-2002, 07:45 AM
Bob,

GL_COMBINE is unknown on my system. Do you have a newer OpenGL? I only know GL_COMBINE_EXT, but I don't want to use extensions if I don't have to.


Kilam.

Bob
11-27-2002, 11:48 AM
GL_COMBINE_EXT is from the extension EXT_texture_env_combine, which is a part of the standard since OpenGL 1.3. When it became standard, the EXT-suffix was removed. Get the latest glext.h from here (http://oss.sgi.com/projects/ogl-sample/registry/) for the missing constants.