Questions about Vertex Arrays and VBOs
Since now I used display lists to speed things up because of its
simplicity to use, but now its time to move on to Vertex Arrays
and VBOs.
So I have some questions for you.
1.VertexArrays
a:Suppose that I have enabled GL_VERTEX_ARRAY
and GL_COLOR_ARRAY and I have specified lets say 20 vertices
and 15 colors. After drawing the primitive(using glArrayElement()
or whatever) what will be the colors of the rest vertices?
Shortly, what happens if you specify 2 arrays of different size?
b:What about the state changes after calling glArrayElement
and glDrawElements?If for example I have specified some texture coordinates
what about the GL_TEXTURE_2D state? What is the different of calling
glArrayElement between or not glBegin() or glEnd()?What happens with
states after calling glDrawElements in opposition with glArrayElement?
2.VBOs
a:How can I draw a textured primitive with a VBO?
I suppose that I specify the texture and vertices with the above
way and then store only the the vertices in the VBO?
b:What if I want to store texture coordinates in a VBO?
Ouff
Thats all folks
For now.
I am waiting for your answers...
1.VertexArrays
a) You may not specify arrays of different sizes. If you draw all those 20 vertices you'll get read errors on the missing 5 colors.
b) glBegin() and glEnd() are immidiate mode and should not contain glDrawElements and glArrayElement. Vertex
Vertex arrays as well as VBOs are merely a way to store vertices (positions, normals, etc.) but not states. So using them won't change any state (unless you change the state manually).
2.VBOs
a) Drawing textures primitives with VBOs works the same way as with vertex arrays (except the function calls). So store vertex positions AND texture coordinates in the VBO and draw the object.
b) See a). VBOs are just another way to store vertices. Internally the driver may even simulate vertex arrays with VBOs. The difference is that vertex arrays are stored in client memory whereas VBOs are (commonly) stored in video memory.
a) You may not specify arrays of different sizes. If you draw all those 20 vertices you'll get read errors on the missing 5 colors.
b) glBegin() and glEnd() are immidiate mode and should not contain glDrawElements and glArrayElement. Vertex
Vertex arrays as well as VBOs are merely a way to store vertices (positions, normals, etc.) but not states. So using them won't change any state (unless you change the state manually).
2.VBOs
a) Drawing textures primitives with VBOs works the same way as with vertex arrays (except the function calls). So store vertex positions AND texture coordinates in the VBO and draw the object.
b) See a). VBOs are just another way to store vertices. Internally the driver may even simulate vertex arrays with VBOs. The difference is that vertex arrays are stored in client memory whereas VBOs are (commonly) stored in video memory.
Quote:
1.VertexArrays
a) You may not specify arrays of different sizes. If you draw all those 20 vertices you'll get read errors on the missing 5 colors.
Hmm,I am not sure for that.
I have drawn an Icosahedron:20 vertices with 15 colors and
no error occured.
Quote:
b) glBegin() and glEnd() are immidiate mode and should not contain glDrawElements and glArrayElement. Vertex
This is true for glDrawElements but you can use glArrayElement within glBegin-glEnd
cause I have alredy done it.
Quote:
2.VBOs
a) Drawing textures primitives with VBOs works the same way as with vertex arrays (except the function calls). So store vertex positions AND texture coordinates in the VBO and draw the object.
I thought that in a VBO you can only store vertex data, wrong?
Quote:Original post by Lord_Vader
Hmm,I am not sure for that.
I have drawn an Icosahedron:20 vertices with 15 colors and
no error occured.
This is probably more by luck than judgement; are you work with an NV card by any chance?
Quote:
I thought that in a VBO you can only store vertex data, wrong?
positions, colour, texture coords, normal data; this is ALL vertex data. Vertex data describes a unique point in space, this is all elements attached to that point.
Quote:
Original post by phantomQuote:Original post by Lord_Vader
Hmm,I am not sure for that.
I have drawn an Icosahedron:20 vertices with 15 colors and
no error occured.
This is probably more by luck than judgement; are you work with an NV card by any chance?
Yes, GeForce FX 5200
Can you explain me some more about the states?
What happens with those?Nothing happens to them?
Quote:Original post by Lord_Vader
Nothing happens to them?
Exactly, nothing happens with any states by calling glDrawElements.
Quote:Original post by Lord_Vader
Hmm,I am not sure for that.
I have drawn an Icosahedron:20 vertices with 15 colors and
no error occured.
Well not exactly errors, but if you have different sized arrays you will get an undefined behavior, meaning that there is no standard that dictates how this will be dealt with, logically one of these things can happen in the above case
1. it uses whatever is the last color defined in the array.
2. it uses the default color defined by glColor.
3. it uses whatever data that is stored in the memory after the color object.
4. it defaults to 0 color or black.
5. the graphics driver dies for a moment.
6. BSOD.
7. your computer overheats and everybody dies in the fire.
It all depends in the driver and the hardware so while it may work fine on your specific setup, it may not work that well on other systems.
[Edited by - lc_overlord on March 22, 2007 5:06:52 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement