Created
January 7, 2017 23:04
-
-
Save johnmarinelli/34ccf79896d2c603d97b8128868516d0 to your computer and use it in GitHub Desktop.
naive vbo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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