PDA

View Full Version : Multitexturing a gluquadric?



11-15-2004, 03:28 PM
How do you multitexture a gluquadric? I can apply a single texture using gluQuadricTexture(pObj, GLU_TRUE);

But multitexturing doesn't seem to work on quadrics.

I am using this tutorial for reference code:

http://www.gametutorials.com/download/OpenGL/HeightMap3_OGL.zip

Aeluned
11-16-2004, 06:34 AM
There is nothing stopping you from multitexturing a quadric.

I'm not sure if this remains true if using gluQuadricTexture....

...use texture objects, bind textures to the correct texture units, setup your texture environments for each one, etc...

should work just fine.

John_C
11-16-2004, 02:19 PM
Aeluned,

Well I tried that... Below I've included the code that I'm using. Currently it will render the GL_QUADS with both (2) textures.

If I replace glBegin( GL_QUADS );...glEnd(); code with just a simple gluSphere(...) it will only apply the first texture (not both).



if (bRenderedGround) { // Draw a rendered ground

glColor4f(1.0, 1.0, 1.0, 1.0);

glPushMatrix();
// 1st Texture Unit
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureArray[GROUND]);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

// 2nd Texture Unit
if (detail) {

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);// Combine mode
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
glBindTexture(GL_TEXTURE_2D, textureArray[GROUND+1]);

// Now we want to enter the texture matrix. This will allow us
// to change the tiling of the detail texture.
glMatrixMode(GL_TEXTURE);

// Reset the current matrix and apply our chosen scale value
glLoadIdentity();
glScalef((float)8, (float)8, 1);

// Leave the texture matrix and set us back in the model view matrix
glMatrixMode(GL_MODELVIEW);
}

glPushMatrix();
glNormal3f(0, 1, 0);
glBegin( GL_QUADS ); // Draw the ground.
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 0.0f );
glVertex3f( -100, 0.0, -100 );


glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 1.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 1.0f );
glVertex3f( -100, 0.0, 100 );

glFogCoordfEXT( 0.0f);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 1.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 1.0f );
glVertex3f( 100, 0.0, 100 );

glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 0.0f );
glVertex3f( 100, 0.0, -100 );
glEnd();
glPopMatrix();
}

Aeluned
11-17-2004, 06:28 AM
Hmmm, well, i tried it out and it works for me...
it's probably because you're no longer sending down the glMultiTexCoord stuff.

try enabling automatic texture coord generation for all texture units
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

this might yield a mapping that you don't want but first try that and see if this is your problem.

11-20-2004, 05:12 PM
Some of the older Graphics cards may not support multitexturing...(In other parts of the world where new computers are twice or more expensive)

So, create a function to test for this capability.