Skip to content

Instantly share code, notes, and snippets.

@Orpheon
Created March 12, 2014 12:44
Show Gist options
  • Select an option

  • Save Orpheon/9506195 to your computer and use it in GitHub Desktop.

Select an option

Save Orpheon/9506195 to your computer and use it in GitHub Desktop.
// Create a VAO
GLuint gridVAO;
glGenVertexArrays(1, &gridVAO);
glBindVertexArray(gridVAO);
// Allocate and upload the VBO data
GLuint gridVBO;
glGenBuffers(1, &gridVBO);
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
glBufferData(GL_ARRAY_BUFFER, MAP_WIDTH * MAP_HEIGHT * sizeof(float) * 3, grid_vertices, GL_STATIC_DRAW);
// We also need an IBO
GLuint gridIBO;
glGenBuffers(1, &gridIBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gridIBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, num_vertices * sizeof(GLushort), grid_indices, GL_STATIC_DRAW);
glVertexAttribPointer(gridVAO, 3, GL_FLOAT, GL_FALSE, 0, NULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment