![]() ![]() ![]() Why (GLvoid*)? We saw that, in early versions of OpenGL, it was possible to pass a pointer to a C array directly (rather than a buffer object). Note that for colors, we start at the 3rd element ( 2 * sizeof(GLfloat)) of the array, where the first color is - that's the offset of the first element. GlEnableVertexAttribArray ( attribute_coord2d ) glEnableVertexAttribArray ( attribute_v_color ) glBindBuffer ( GL_ARRAY_BUFFER, vbo_triangle ) glVertexAttribPointer ( attribute_coord2d, // attribute 2, // number of elements per vertex, here (x,y) GL_FLOAT, // the type of each element GL_FALSE, // take our values as-is 5 * sizeof ( GLfloat ), // next coord2d appears every 5 floats 0 // offset of the first element ) glVertexAttribPointer ( attribute_v_color, // attribute 3, // number of elements per vertex, here (r,g,b) GL_FLOAT, // the type of each element GL_FALSE, // take our values as-is 5 * sizeof ( GLfloat ), // next color appears every 5 floats ( GLvoid * ) ( 2 * sizeof ( GLfloat )) // offset of first element ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |