Is there a better way of doing this?

Member
Posts: 321
Joined: 2004.10
Post: #1
I've got a pretty straightforward implementation of multi-texturing.
The first texture can be thought of as a black and white line drawing -
and the second texture is just a color applied. Eventually, the 2nd texture
will be something like wood planking, but for now, it is just a solid
color. Everything works like I want it to.

However, I'm thinking that there might be a better way to specify just a solid
color without using a fixed texture? Maybe create the texture dynamically
where the RGB is specified during run time. Or maybe use glColor* somehow?
Ideally, I'd like the user to be able to adjust the color of the texture on the fly.
So if two textures next to each other are hideous, the user can change them
during program execution.


// Texture Unit 0
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, eD.texture );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

// Texture Unit 1
glActiveTextureARB( GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, eD.colorTexture );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0
// etc, etc, etc.
glEnd();
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
If you have a black and white texture that uses GL_MODULATE, you can just use glColor* and it works the same way. Smile
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #3
You can use either the underlying vertex color (which can be interpolated between vertices with GL_SMOOTH shading) or the constant texture environment color (which you can set per texture unit with glTexEnv and access with ARB_texture_env_combine.) In both cases just modulate with your base texture.
Quote this message in a reply
Post Reply