View Full Version : Shaders, multitexturing, and interleaved arrays

02-18-2002, 07:37 PM
Okay, I've written my bada**, all purpose game engine. Who hasn't these days? Currently, I've just written a completely generic, texture shader class that supports infinite blend modes and stages, fully utilizing the max texture units supported in hardware, doing (num stages/max texture units) multiple passes if necessary.

My only problem is that my data was/is originally stored as interleaved arrays whose UVs/STs will only affect GL_TEXTURE0_ARB. Is there a way to either specify texcoords per stage, or have each stage recognize my texcoords without having to rearrange my data into independent vector/uv/color/normal arrays?

Thanks in advance!

-The king of iron fist.

02-18-2002, 10:25 PM

glTexCoordPointer(...for stage 0);

glTexCoordPointer(...for stage 1);

glTexCoordPointer(...for stage <N> );


02-19-2002, 04:45 AM
That's what I was preparing to do, blanking out on the fact that I could specify a stride value, considering reorganization instead.

Now, is a stride of zero any more effecient than a stride of, say, 20? Meaning, is different code used internally when there is no stride to save iteration?

- I am the greatest swordsman who ever lived!

02-19-2002, 06:23 AM
according to an (older??) paper from nVidia there should be a minimal difference between interleaved (stride>0) and separate arrray..

should be able to tell you more about that later this week, when i've tried it out (changing my own 3d engine in this way :-)

02-19-2002, 08:21 AM
Crisis averted.

Using glBlahPointer(...) for the different elements with the stride set to the size of my CVertex class, which contains a single texcoord, color, vector, and normal, was much faster than the interleaved arrays for some reason. The only thing I don't like is that currently, I set the client active texture and glTexCoordPointer for every existing texture unit GL_TEXTURE0_ARB + nTexUnit. nTexUnit for my GeForce2 is from 0 to 1. That's only temporary though.

Anyway, thanks all.

- Boweeprannaweepniniban