glBufferData

Started by
2 comments, last by giugio 8 years, 7 months ago

I have a problem with glBufferData:

glBufferData(GL_ARRAY_BUFFER, xxxxx, (GLvoid*)glm::value_ptr(*m_pBuffer->getAllData()), m_pOptions->GetDynamics());

i use a wrapper around a vector for manage the vertexes, i don't have a struct with the vertex composition but a list of these wrapper for position , normal eccc...

then the vector in the wrapper is a glm::vec3 and i see that the sizeof of a glm::vec3 is 12.

I don't know how calculate the xxxxxx i see that for 3 vertexes ( 3 glm:vec3) the correct value is 18 but i don't understand why and how calculate the correct value for bigger vbo.

can you help me?
and what is this param?
thanks.

Advertisement
XXxX refers to the size of the buffer in bytes. If your vertex is a vec3, use sizeof(vec3) * number of your vertices for that parameter. a single element in vec3 is a float which is 4 bytes, so 3 floats is 12.

XXxX refers to the size of the buffer in bytes. If your vertex is a vec3, use sizeof(vec3) * number of your vertices for that parameter. a single element in vec3 is a float which is 4 bytes, so 3 floats is 12.

indeed is what i think but i don't know where i wrong because with nsight i see that 9 vec3 have the correct value at 18 for the correct alignment of vertices.
but for my computation does have 9 * 4 = 21 and not 18.
where it come this 18 that works, i can wrong some other parameter?
I dont know.

sorry 3 vec3= 4*3*3= 36 and not 18!

sorry i have considered float 16 and not float 32 in nsight. now all work fine, thanks.

This topic is closed to new replies.

Advertisement