OpenGL multitexturing + vertex colors

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Rush
Posts: 14
Joined: Wed Nov 24, 2004 11:00 am
Location: Hell

OpenGL multitexturing + vertex colors

Post by Rush »

I've corrected EMT_SOLID_2_LAYER material renderer in OpenGL. It works nicely, but the problem is that with vertex colors applied, those colors are visible only on the first texture. I'm not an expert in OpenGL programming, so it probably contains some mistakes:

Code: Select all

class COpenGLMaterialRenderer_SOLID_2_LAYER : public COpenGLMaterialRenderer
{
public:

	COpenGLMaterialRenderer_SOLID_2_LAYER(video::CVideoOpenGL* d)
		: COpenGLMaterialRenderer(d) {}

	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
		bool resetAllRenderstates, IMaterialRendererServices* services) 
	{
		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
		{
			if (Driver->hasMultiTextureExtension())
			{
                Driver->extGlActiveTextureARB( GL_TEXTURE1_ARB );
                Driver->extGlClientActiveTextureARB( GL_TEXTURE1_ARB );
             	glEnable(GL_TEXTURE_2D);
				
				glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT); 
				glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_INTERPOLATE_EXT); 
				
				glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);
    			glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
				glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_TEXTURE);
				glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
				glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_EXT,GL_PREVIOUS_EXT);
				glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_EXT,GL_SRC_ALPHA);
		
              }
		
			glDisable(GL_BLEND);
			glDisable(GL_ALPHA_TEST);
		}

		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
	}
};

Is it possible to make both textures colored using only 2 TUs and without shaders? If it is, how?
Guest

Post by Guest »

I don't think that's possible.

GL_PREVIOUS only maps to the color, on texture unit 0.
On the other texture units it maps to the result of the previous texture unit.
Post Reply