Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Vertices
- float vertices[] = {
- -0.5f, -0.5f, 0.0f,
- 0.5f, -0.5f, 0.0f,
- 0.5f, 0.5f, 0.0f,
- -0.5f, 0.5f, 0.0f
- }
- // Indices
- unsigned int indices[] = {
- 0, 1, 3,
- 1, 2, 3
- }
- // Edges
- unsigned int edges[] = {
- 0, 1,
- 1, 2,
- 2, 3,
- 3, 0
- }
- // Normally prepare vao,vbo,ebo for vertices and indices.
- GLuint vao, vbo, ebo;
- // And then another pair for edges.
- GLuint edgeVao, edgeVbo, edgeEgo;
- glGenBuffers(1, &edgeEbo);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, edgeEbo);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(edges), edges, GL_STATIC_DRAW);
- // And then rendering
- // First pass render normally
- glBindVertexArray(vao);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
- glBindVertexArray(0);
- // Second pass, render edges
- glBindVertexArray(edgeVao);
- glDrawElements(GL_LINES, 8, GL_UNSIGNED_INT, 0);
- glBindVertexArray(0);
Advertisement
Add Comment
Please, Sign In to add comment