Created
April 26, 2014 16:46
-
-
Save Orpheon/11324874 to your computer and use it in GitHub Desktop.
This file contains 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
const float vertexPositions[] = { | |
a, 0.0f, -4.0f, 1.0f, | |
-a, 0.0f, -4.0f, 1.0f, | |
0.0f, b, -4.0f, 1.0f, | |
0.0f, -b, -4.0f, 1.0f | |
}; | |
GLuint gridVBO; | |
glGenBuffers(1, &gridVBO); | |
glBindBuffer(GL_ARRAY_BUFFER, gridVBO); | |
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW); | |
glEnableVertexAttribArray(0); | |
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); |
This file contains 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
const float vertexPositions[] = { | |
a, 0.0f, -4.0f, 1.0f, | |
-a, 0.0f, -4.0f, 1.0f, | |
0.0f, b, -4.0f, 1.0f, | |
0.0f, -b, -4.0f, 1.0f | |
}; | |
const int indices[] = { | |
0, 1, 2, 3 | |
}; | |
GLuint gridVAO; | |
glGenVertexArrays(1, &gridVAO); | |
glEnableVertexAttribArray(gridVAO); | |
GLuint gridVBO; | |
glGenBuffers(1, &gridVBO); | |
glBindBuffer(GL_ARRAY_BUFFER, gridVBO); | |
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW); | |
// We also need an IBO | |
GLuint gridIBO; | |
glGenBuffers(1, &gridIBO); | |
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gridIBO); | |
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); | |
glVertexAttribPointer(gridVAO, 4, GL_FLOAT, GL_FALSE, 0, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment