View Full Version : Multi-Texture and Vertex Array Problems
hkyProgrammer88
06-13-2002, 08:23 PM
When attempting to multi-texture with vertex arrays, the 2nd and 3rd textures (units 1 and 2) do not show up at all on my model. The textures are loaded correctly.
In some instances the program runs slower (indicating multi-textureing) however only the base texture (Unit 0) appears.
I am using an ATi Rage Fury Pro and I checked other posts but they did not solve my problem.
Sample code:
// NOTE: Texture unit 1 has already been enabled.
glClientActiveTextureARB( GL_TEXTURE1_ARB); // Select unit 1
//glActiveTextureARB( GL_TEXTURE1_ARB); // glClient... should be used intsead
glEnableClientState( GL_TEXTURE_COORD_ARRAY); // Use this texture for VertArray
glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2); // Use these tex coords
glBindTexture( GL_TEXTURE_2D, texUnit2_id); // Use this texture for tex unit 1
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Is this needed and why
Thanks for the help
MPech
06-13-2002, 10:56 PM
As far as i understand, is see that you're talking about three texture units when Rage Fury only supports two. You may confusing texture units and texture objects.
"Units" stands for the hardware registers which holds the texture to later mix them "hardwarely", whereas texture object stands for the "OpenGL name" of the texture when you call glBindTexture().
To answer your question you'll to show more of you display/render function.
hkyProgrammer88
06-13-2002, 11:31 PM
Here is a snipit of the rendering function
// Executed before main program loop
.
.
.
glActiveTextureARB( GL_TEXTURE1_ARB);
glEnable( GL_TEXTURE_2D); // Enable second texture unit
glActiveTextureARB( GL_TEXTURE2_ARB);
glEnable( GL_TEXTURE_2D); // Enable third texture unit
glActiveTextureARB( GL_TEXTURE0_ARB); // Active Texture 0 enabled previously
.
.
do
renderArray();
loop
.
.
.
// This is what my Vertex Array rendering function does each time it is called.
// The class "skArrays" stores the model verts and array indices.
void renderArray( void)
{
glEnableClientState( GL_VERTEX_ARRAY);
glVertexPointer( 4, GL_FLOAT, 0, skArrays.rendVerts); // Renderable Verticies
glEnableClientState( GL_NORMAL_ARRAY);
glNormalPointer( GL_FLOAT, 0, skArrays.norm);
// Extra Texture
glClientActiveTextureARB( GL_TEXTURE1_ARB);
glEnableClientState( GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2);
glBindTexture( GL_TEXTURE_2D, texUnit2_id);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// Base (Default) Texture
glClientActiveTextureARB( GL_TEXTURE0_ARB);
glEnableClientState( GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex);
glBindTexture( GL_TEXTURE_2D, baseTex_id);
if( glLockArrays) glLockArrays( 0, num_Verts_To_Lock); // Compiled Vertex Array Enabled
glDrawElements( GL_TRIANGLES, triCount*3, GL_UNSIGNED_SHORT, skArrays.indexArray);
if( glUnlockArrays) glUnlockArrays(); // Compiled Vertex Array Disabled
glClientActiveTextureARB( GL_TEXTURE1_ARB);
glDisableClientState( GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB( GL_TEXTURE0_ARB);
glDisableClientState( GL_TEXTURE_COORD_ARRAY);
glDisableClientState( GL_NORMAL_ARRAY);
glDisableClientState( GL_VERTEX_ARRAY);
} // Function ends
hkyProgrammer88
06-14-2002, 10:25 AM
I am just bumping this topic back up.
hkyProgrammer88
06-15-2002, 11:09 AM
Does anyone know where I can find official and very detailed documentation on multi-texturing and vertex arrays for OpenGL because all the sites I have found and checked are not helping me solve my problem. And I don't want to have to spend days doing trial and error to fix it.
Thanks for the help.
hkyProgrammer88
06-15-2002, 11:51 AM
I finally got it to work (by luck), however I had to use this:
glActiveTextureARB( GL_TEXTURE1_ARB);
glClientActiveTextureARB( GL_TEXTURE1_ARB);
I had to use BOTH functions at the same time however this was never stated in any of the documentation that I read. Using either one alone caused multi-texturing to not function at all.
Why do I have to use both of these functions when it seems like only glClientActiveTextureARB() should be used when working with vertex arrays?
WhatEver
06-15-2002, 12:44 PM
I found out recently that glClientActiveTextureARB sets which TEX_COORD_ARRAY is going to be set. Each texture unit can use seperate texture coordinates.
So here ya go:
glEnableClientState( GL_TEXTURE_COORD_ARRAY);
glActiveTextureARB( GL_TEXTURE1_ARB);
glBindTexture( GL_TEXTURE_2D, texUnit2_id);
glClientActiveTextureARB( GL_TEXTURE1_ARB);
glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2);
//modulate is src_texel * dst_texel = output fragment
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
hkyProgrammer88
06-15-2002, 12:55 PM
I understand now, thanks!!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.