How is multitexturing accomplished with ATI_vertex_object_arrays?

Ostsol

New member
The extension works somewhat differently from normal OpenGL vertex arrays, so I'm wondering if I might have to implement multitexturing in an equally different way. I've looked around and this document. . .

http://www.berkelium.com/OpenGL/GDC99/multitexture.html

. . . seems to best explain how to multitexture using normal vertex arrays, but I find myself confused upon looking at ATI's vertex arrays.

Upon comparing the different functions used in either implementation of vertex arrays and determining the equivalent functions, it looks like all I have to do is set the active texture layer and bind the desired texture.

glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[0]);
glEnable (GL_TEXTURE_2D);

glActiveTextureARB (GL_TEXTURE1_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[1]);
glEnable (GL_TEXTURE_2D);

glDrawElements etc. . .

Is this right?
 
Seams right to me, except that you've excluded your calls to lArrayObjectATI.

There really isn't any big difference, with standard OGL you'd do

glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[0]);
glEnable (GL_TEXTURE_2D);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texCoordArray);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glActiveTextureARB (GL_TEXTURE1_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[1]);
glEnable (GL_TEXTURE_2D);
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texCoordArray);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawElements( ... );


with GL_ATI_vertex_array_object you'd do


glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[0]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 2 * sizeof(float), vaoBuffer0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glActiveTextureARB (GL_TEXTURE1_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[1]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 2 * sizeof(float), vaoBuffer1, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawElements( ... );
 
Humus said:
Seams right to me, except that you've excluded your calls to lArrayObjectATI.

<SNIP>

glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[0]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 2 * sizeof(float), vaoBuffer0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glActiveTextureARB (GL_TEXTURE1_ARB);
glBindTexture (GL_TEXTURE_2D, textureindex[1]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 2 * sizeof(float), vaoBuffer1, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glDrawElements( ... );

Ah. . . oops! I guess it -would- help if I told the thing which texture coordinates to use for each texture. :) Okay, looks like I understand this, now. Step 1 to learning bump-mapping is now complete. :D

Thanks!
 
Okay, still got some problems. . .

First of all, I have to use glClientActiveTextureARB instead of glActiveTextureARB in order for the thing to work. No problem there, but it takes two passes in order for it to be rendered properly.

glClientActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_2D, texture[polygon.texindex[0]]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI (GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, sizeof (VERTEXDATA), gluiVertexObject, 0);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB (GL_TEXTURE1_ARB);
glBindTexture (GL_TEXTURE_2D, texture[polygon.texindex[1]]);
glEnable (GL_TEXTURE_2D);
glArrayObjectATI (GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, sizeof (VERTEXDATA), gluiVertexObject, 0);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);

glDrawElements (GetDrawType (polygon.shape), polygon.vertices, GL_UNSIGNED_INT, polygon.vertindex);

The first texture layer is the base texture, of course, and the second layer is a blended using an alpha map and drawn on top of the first. Anyways, the result of the above code is that only the second texture is rendered. If I add another glDrawElements in the middle it renders properly, but I am rendering twice as many polygons that way. In the little scene that I have so far (3 polygons) that doesn't make too much of a difference, but in larger, more complex scenes that could mean a significant performance hit.

I have done extensive searches regarding the matter, but all of the results pertained only to standard vertex arrays. I'm not really suprised, since ATI_vertex_object_array is a rather young extension, but this certainly does leave me with a big problem.

The only solution I can find was hidden in ATI's OpenGL demos. The Radeon 8500 Point-Light Shader demo is the only source of sample code that I could find that uses both multi-texturing and ATI vertex arrays. The problem there is that the solution appears to lie amidst fragment shader code and the glMultiTexCoord3fvARB function, neither of which I know how to use.
 
Back
Top