Page 1 of 1

OpenGL multitexturing + vertex colors

Posted: Mon Mar 07, 2005 4:34 pm
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?

Posted: Wed Mar 09, 2005 8:25 am
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.