Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. struct vertex_t
  2. {
  3.     float x;
  4.     float y;
  5.     float z;
  6. };
  7.  
  8. GLuint VBO = 0;
  9.  
  10. void initVBO()
  11. {
  12.     vertex_t vertices[] =
  13.     {
  14.         { -0.5f, 0.5f, 0.0f },
  15.         { 0.5f, 0.5f, 0.0f },
  16.         { 0.5f, -0.5f, 0.0f },
  17.         { -0.5f, -0.5f, 0.0f }
  18.     };
  19.    
  20.     glGenBuffers(1, &VBO);
  21.     glBindBuffer(GL_ARRAY_BUFFER, VBO);
  22.     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
  23. }
  24.  
  25. void draw()
  26. {
  27.     glEnableClientState(GL_VERTEX_ARRAY);
  28.     glBindBuffer(GL_ARRAY_BUFFER, VBO);
  29.     glVertexPointer(3, GL_FLOAT, sizeof(vertex_t), NULL);
  30.     glDrawArrays(GL_QUADS, 0, 4);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement