Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnmarinelli/34ccf79896d2c603d97b8128868516d0 to your computer and use it in GitHub Desktop.
Save johnmarinelli/34ccf79896d2c603d97b8128868516d0 to your computer and use it in GitHub Desktop.
naive vbo
/*
referring to this link: https://www.khronos.org/opengl/wiki/Vertex_Specification_Best_Practices
"Formatting VBO data":
does the following:
*/
GLuint v, n, c;
glGenBuffers(1, &v);
glBindBuffer(GL_ARRAY_BUFFER, v);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(0);
glGenBuffers(1, &n);
glBindBuffer(GL_ARRAY_BUFFER, n);
glBufferData(GL_ARRAY_BUFFER, sizeof(normals), normals, GL_STATIC_DRAW);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(1);
glGenBuffers(1, &c);
glBindBuffer(GL_ARRAY_BUFFER, c);
glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(2);
/*
create
(VVVVNNNNCCCC)
or
(VVVV) (NNNN) (CCCC)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment