Guest User

Untitled

a guest
Aug 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. Getting VBOs to work
  2. struct Quad
  3. {
  4. float x0, y0, z0; // top left corner
  5. float x1, y1, z1; // top right corner
  6. float x2, y2, z2; // bottom left corner
  7. float x3, y3, z3; // bottom right corner
  8. float s0, t0;
  9. float s1, t1;
  10. float s2, t2;
  11. float s3, t3;
  12. char r, g, b, a; // tint
  13. float depth; // depth value of the Quad
  14. };
  15.  
  16. void draw{
  17. glEnable(GL_TEXTURE_2D);
  18. glEnableClientState(GL_VERTEX_ARRAY);
  19. glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  20. // Note: glVertexPointer is deprecated, change to glVertexAttribPointer
  21. glVertexPointer(3, GL_FLOAT, sizeof(Quad), &(vertexBuffer_[0].x0));
  22. glTexCoordPointer(2, GL_FLOAT, sizeof(Quad), &(vertexBuffer_[0].s0));
  23. glBindBuffer(GL_ARRAY_BUFFER, VBOs_[activeVBO_]);
  24. glBufferData(GL_ARRAY_BUFFER, vertexBuffer_.size() * sizeof(Quad), &(vertexBuffer_[0]), GL_STATIC_DRAW);
  25. glDrawArrays(GL_QUADS, 0, vertexBuffer_.size());
  26. glBindBuffer(GL_ARRAY_BUFFER, 0);
  27. SDL_GL_SwapBuffers();
  28. activeVBO_ = (++activeVBO_)%NUM_VBO;
  29. glError();
  30. }
  31.  
  32. struct Vertex
  33. {
  34. float x, y, z;
  35. float s, t;
  36. char r, g, b, a;
  37. };
Add Comment
Please, Sign In to add comment