Skip to content

Instantly share code, notes, and snippets.

@Orpheon
Created April 26, 2014 16:46
Show Gist options
  • Save Orpheon/11324874 to your computer and use it in GitHub Desktop.
Save Orpheon/11324874 to your computer and use it in GitHub Desktop.
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);
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