no, vertex attribs should be part of vertex arrays, you call it a VBOarray, which it's not really
its an encapsulated thingamajig that contains all thats necessary to render your data, save for uniforms (and matrices)
to create a VAO:
generate vao, vbo
bind vbo, upload data
enable vertex attribs
set vertex attrib pointers
now VBO is gone, unless you are in compatibility mode, in which case only the vertex attribs are part of the object (VAO)
VAO used to be a state object to encapsulate vertex attributes, in modern openGL it is the recipe to render the model
so, if you are in core 3.x and later: only VAO remains!
gldrawarrays / gldrawelements
vertex attributes (glVertexAttrib*) are what makes you able to define your own vertex structure to openGL for usage in modern shaders
you specify a type, normalization, slot number (index), and offset from VBO data relative to the CURRENTLY bound VBO
this is because you can have 10 VBOs in a single VAO, all using different attributes in your shader
usually you have only 1 VBO with all attributes interleaved, still all using different attributes in your shader
let's look at:
for one, you are saying that your vertices are starting at byte position: 3 * sizeof(glfloat), which i don't believe
i think they start at byte number 0 in your vertex structure, which is the most common position for vertex position
let's say they are located at index 0 in your shader, and they start at byte 0 offset from your vertex structure,
then location = 0, and offset = 0
glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, sizeof(Vertexes), (glvoid*) offset );
if that's the case, then the above line is saying:
i have bound a VAO, and i have bound a VBO. this VBO has an attribute that starts at the first byte of my data that openGL has no clue what looks like
it's located at slot: "location" because that's what openGL told me, or i told openGL (see below)
it has 3 values (vec3, or just vector), and is of type GL_FLOAT, which is GLfloat to your interface, meaning a 32bit's floating point variable of size 4 bytes
openGL now knows that to be able to access this data in your shader, it needs to access 4 * 3 bytes for each sizeof(Vertexes) just to get this data
however, the data isn't well defined yet, so it needs to know whether or not its normalized
imagine that you were passing a 4-byte color (R, G, B, A), then when you wanted to access it in your shader you got values from 0 to 255 (8 bits per channel), or 0 to 65535 (16 bits per channel), well then you'll need to convert that data to be able to properly work with it, since normalized values (0.0 to 1.0, or -1.0 to 1.0) are much easier to do calculations with!
normals is also an example that can normalized, unless you are using GL_FLOAT (if you are using floating point precision you might as well have them properly normalized yourself!)
if you were using GL_BYTE instead, then normalize should be GL_TRUE
back to your own code example:
since you specified GL_FALSE for your vertex position in the normalize parameter, openGL will not attempt to normalize your vertex position, and instead pass it as-is
however, there are many situations when you'd want to do that!
hope this helps!
as for the location of the attribs in your shader, you have 3 options:
1. use (layout = index) in vec4 in_vertex; in shader to hard-code the indexing
2. use glGetAttribLocation to get index from shader,
which requires you to have the shader bound when doing this
3. use glBindAttribLocation(program, index, attrib_name) just before glLinkProgram(program)
i recommend the last one
Edited by Kaptein, 23 October 2012 - 09:57 AM.