Guest User

Untitled

a guest
Nov 24th, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. // Vertices
  2. float vertices[] = {
  3.   -0.5f, -0.5f, 0.0f,
  4.    0.5f, -0.5f, 0.0f,
  5.    0.5f, 0.5f, 0.0f,
  6.   -0.5f, 0.5f, 0.0f
  7. }
  8.  
  9. // Indices
  10. unsigned int indices[] = {
  11.   0, 1, 3,
  12.   1, 2, 3
  13. }
  14.  
  15. // Edges
  16. unsigned int edges[] = {
  17.   0, 1,
  18.   1, 2,
  19.   2, 3,
  20.   3, 0
  21. }
  22.  
  23. // Normally prepare vao,vbo,ebo for vertices and indices.
  24. GLuint vao, vbo, ebo;
  25. // And then another pair for edges.
  26. GLuint edgeVao, edgeVbo, edgeEgo;
  27.  
  28. glGenBuffers(1, &edgeEbo);
  29. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, edgeEbo);
  30. glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(edges), edges, GL_STATIC_DRAW);
  31.  
  32. // And then rendering
  33. // First pass render normally
  34. glBindVertexArray(vao);
  35. glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
  36. glBindVertexArray(0);
  37.  
  38. // Second pass, render edges
  39. glBindVertexArray(edgeVao);
  40. glDrawElements(GL_LINES, 8, GL_UNSIGNED_INT, 0);
  41. glBindVertexArray(0);
Advertisement
Add Comment
Please, Sign In to add comment