Multitexture and Vertex Arrays

Hey all, I’ve got a question to which I haven’t been able to find any (promising) answer to.

Is there any way to do multitexturing with vertex arrays using the vertex array functions (for a single pass on the set of arrays)?

I’ve got things working beautifully currently with one texture, but I’d like to be able to map a second on top of it, and everything I see seems to point that, using vertex arrays, it can’t be done - at least not the way I want to do it.

I’m using glDrawArrays to handle a Color pointer, a TexCoord pointer and a Vertex pointer. Even if I could get the second texture to reuse the TexCoord pointer (which is, incidentally, what I want), I’d be happy, but I cannot (definitely not) make a second pass on the vertex data (that would double my polycount and my app instantly runs like molasses in the dead of winter above the arctic circle).

If anyone can help — PLEASE!!!

Siwko

It is NOT possible to change the current texture during a glDrawElements() call…

“I’d be happy, but I cannot (definitely not) make a second pass on the vertex data (that would double my polycount and my app instantly runs like molasses in the dead of winter above the arctic circle).”
LOL,but this is no problem if you use glLockArraysEXT the vertices are only transformed once no matter how often you draw them…

Greets,XBTC!

Originally posted by XBCT:
[b]It is NOT possible to change the current texture during a glDrawElements() call…

“I’d be happy, but I cannot (definitely not) make a second pass on the vertex data (that would double my polycount and my app instantly runs like molasses in the dead of winter above the arctic circle).”
LOL,but this is no problem if you use glLockArraysEXT the vertices are only transformed once no matter how often you draw them…

Greets,XBTC![/b]

Hmm, thats a thought, and I really appreciate the answer (suggestion), but actually, its possible and done . Stupid me did a search in the forums after the fact, and found the exact problem I ran into handled 3 times prior. Whomever made the post that fixed my problem, thanks (I can’t remember).

But back to you X, I’m using glDrawArrays and multitexturing it too. As I said, it was posted before.

BUT - I want to ask you this about glLockArrays - am I to understand correctly that if I lock an array, and do a draw on it umpteen-million times, it actually renders it only once?

If thats so, then how can I use this to my advantage? Do a Lock the arrays and glDrawArrays with one pass, then switch textures and do it all over again?

If thats it, it sounds like it will work, but then again, I probably have it all screwed up in my mind.

(Just so you know, I’d like to persue this because it has merit for other uses I have for it - plus, I want to learn it all!!! )

Thanks,

Siwko

Yeah it can be done, i have working code of that… But the top and bottom textures Coords are screwed up…

in your main drawing code and something like this…

for( int t = 0, offset = 0; t < 6; t++, offset += 4 )
{
glBindTexture( GL_TEXTURE_2D, Textures[ t ] );
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_INT, &DrawCube[ offset ] );
}

The demo is located at:
http://www.ompac.net.au/~troyfa/hello.zip