glBegin questions

BlitzMax Forums/OpenGL Module/glBegin questions

Drey(Posted 2006) [#1]
So i'm writing my mesh system and some of the file formats keep track of rather a face is just a triangle or quad. Understanding that even the GL_Quad uses triangles in the background. I'm thinking that you will only have 4 vertex calls compared to 6 for the same effect. Though it could be faster, but i hear glBegin is costly. SO i'm thinking 2 phrase, GL_Triangle and a GL_Quad with only 2 begins per mesh might be worth the extra work?


N(Posted 2006) [#2]
Or you could just use vertex and index arrays/buffer objects and make zero calls to glBegin/glEnd. So no, none of it is worth the extra work since vertex and index arrays/buffer objects are easy to use and faster. Use VBOs for large amounts of data that matter if you were going to send it to the GPU from software, otherwise use vertex arrays as the time required is negligable.


Drey(Posted 2006) [#3]
i'm looking at glInterleavedArrays and glTextureCoordPointer. How do you get mutliply UVs to work in these systems? glMultiTexCoord2fARB needs to be called doesn't it?


N(Posted 2006) [#4]
Use glClientActiveTexture to set the active (client) texture unit and then set the pointer for that unit.

As for interleaved arrays, that's really just a waste of time. Just use the appropriate gl*Pointer functions. At least that way you decide how to structure your data instead of following the specific formats glInterleavedArrays provides.

E.g.
Local tc:Byte Ptr ' the data -- in the case of a vbo, this would remain Null
' for the sake of example, the data is arranged as such: uv0, uv1, uv0, uv1
' where uv are the respective components and the number is the channel
' you'll probably want to organize your data so that it's all lumped together contiguously
' which would basically look like u0v0, u0v0, u0v0, u0v0, u1v1, u1v1, u1v1, u1v1 where each channel has
' a stride of 0 (is tightly packed) and it is only necessary to point to the appropriate offset into the data

glClientActiveTexture( GL_TEXTURE0 ) ' set the unit
glEnableClientState( GL_TEXTURE_COORD_ARRAY ) ' enable the texcoord pointer for this unit
glTexCoordPointer( 2, GL_FLOAT, 8, tc ) ' set the pointer
' stride is set to 8 so it skips over channel 1 and uses only channel 0

' repeat for the next unit
glClientActiveTexture( GL_TEXTURE1 )
glEnableClientState( GL_TEXTURE_COORD_ARRAY )
glTexCoordPointer( 2, GL_FLOAT, 8, tc+8 ) ' set it to use the second set of texture coordinates


This is a snippet from my engine's material code, basically shows how I handle the data.




Drey(Posted 2006) [#5]
Sweet, i have another one though. Is there a texture matrix per texture slot?

Thanks for your help :)


N(Posted 2006) [#6]
Yes.