PDA

View Full Version : MDL and GLSL



bladix
03-27-2004, 07:35 AM
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.

jra101
03-27-2004, 08:56 AM
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);

bladix
03-28-2004, 08:49 AM
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?

Lurking
03-28-2004, 11:41 AM
assuming your using multitexturing extension

bladix
03-28-2004, 10:46 PM
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...

Tom Nuydens
03-28-2004, 11:52 PM
This is getting off topic... Are you setting the active texture back to GL_TEXTURE0 before binding your MDL's texture?

-- Tom