MDL and GLSL

Well I’m now working with MDL (Half-Life Model) in GLSL programs,
but I’m perplexed as to why the texture of MDL doesn’t be mapped.
Here’re some codes…

/* Render MDL by using the fixed pipelines. */
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_TEXTURE_2D);
DrawMDL();
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING);

/* Render bump-mapped walls by shaders */
glUseProgramObjectARB(g_PrgObj);
glUniform1iARB(g_Loc_Texture0, g_BaseTex);
glUniform1iARB(g_Loc_Texture1, g_BumpTex);
DrawWalls();
glUseProgramObjectARB(NULL);

Do you have any ideas or hints? Please help me…

Thanks.

You don’t pass a texture object to glUniform1iARB when setting samplers, you pass in an integer that specifies which texture unit you want that sampler to fetch from.

So assuming you bound g_BaseTex to texture unit 0, and g_BumpTex to texture unit 1, you would do this:

glUniform1iARB(g_Loc_Texture0, 0);
glUniform1iARB(g_Loc_Texture1, 1);

Well I have no problem with GLSL.
But when I use MDL textures and GLSL textures at the same time, the former fails.

Is it possible to use both textures at the same time?

assuming your using multitexturing extension

Yep, I’m using multitexturing.

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, g_Texture[g_BaseTex]);
	
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, g_Texture[g_BumpTex]);

MDL textures would be mapped correctly when I turn off multitexturing.
So maybe that is the problem, but I don’t understand how to cook that off…

This is getting off topic… Are you setting the active texture back to GL_TEXTURE0 before binding your MDL’s texture?

– Tom

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.