if i use glvertexpointer AND gltexcoordpointer (when i use VBO), then how do i set up the pointer parameter of each function? do i just use (char*)NULL? …
i just tested my codes using (char*)NULL as pointer value in glvertexpointer and gltexcoordpointer … didn’t work. However, when i used glinterleavedarrays, it worked fine, but the frame rates dropped slightly. (comparing with non-VBO rendering code)
Originally posted by grunt123: if i use glvertexpointer AND gltexcoordpointer (when i use VBO), then how do i set up the pointer parameter of each function? do i just use (char*)NULL? …
No, not NULL. You need to find the offsets to the right components. That depends on your vertex layout.
Eg
Originally posted by grunt123:
[b]thx for the reply.
by the way, I read from somewhere on this board that glInterleaveArrays() can actually slow down the performance. can anyone confirm this? [/b]
Interleaved arrays should be a win in the majority of cases. That’s the general recommendation and you shouldn’t do anything else unless you have a good reason.
You may get better performance with disjoint arrays only if you frequently change some parts of your vertices (eg position, but not texture coords, color etc).
ABCABCACBABC
vs
AAAA
BBBB
CCCC
It’s simpler to respecify the As when they’re not intermixed with the Bs and Cs. But then you should benchmark your particular case. It may very well be completely irrelevant.
PS: glInterleavedArrays is simply an ‘emulation’ layer put on top of the gl*Pointer calls.
Originally posted by grunt123:
[b]if i want to use multitexturing with glInterleavedArrays(), how do i do it?
suppose that i have tex1 and tex2. how do i set up tex coord for these two textures when using glInterleavedArrays?
thanks[/b]
glClientActiveTextureARB selects which pointer is modified by glTexCoordPointer and enabled by glEnableClientState(GL_TEXTURE_COORD_ARRAY);.
And no, you can’t do that with glInterleavedArrays. That function only ‘knows’ a few specific vertex layouts, and those don’t include multitexture support.
why do we have to call glEnableClientState(…) in the rendering codes? I just tested your codes without glEnableClientState(GL_TEX_ARRAY) (i thought it was ok since i called glEnableClientState(GL_TEX_ARRAY) in the initialization codes) and the multi-texturing failed. any explanation? (until now, i only called glEnableClientState(…) in the initialization codes)
That’s most likely because you’ve called glEnableClientState(GL_TEXTURE_COORD_ARRAY) only once (or you did call it multiple times but you didn’t switch arrays). Not all of your texture coordinate sets were properly set up.
glEnbableClientState(GL_TEXTURE_COORD_ARRAY) and glTexCoordPointer only work for the coordinate set that has been selected with glClientActiveTexture (the default state is GL_TEXTURE0_ARB).
Of course you can enable the arrays in your init code just as well.