Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Getting VBOs to work
- struct Quad
- {
- float x0, y0, z0; // top left corner
- float x1, y1, z1; // top right corner
- float x2, y2, z2; // bottom left corner
- float x3, y3, z3; // bottom right corner
- float s0, t0;
- float s1, t1;
- float s2, t2;
- float s3, t3;
- char r, g, b, a; // tint
- float depth; // depth value of the Quad
- };
- void draw{
- glEnable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- // Note: glVertexPointer is deprecated, change to glVertexAttribPointer
- glVertexPointer(3, GL_FLOAT, sizeof(Quad), &(vertexBuffer_[0].x0));
- glTexCoordPointer(2, GL_FLOAT, sizeof(Quad), &(vertexBuffer_[0].s0));
- glBindBuffer(GL_ARRAY_BUFFER, VBOs_[activeVBO_]);
- glBufferData(GL_ARRAY_BUFFER, vertexBuffer_.size() * sizeof(Quad), &(vertexBuffer_[0]), GL_STATIC_DRAW);
- glDrawArrays(GL_QUADS, 0, vertexBuffer_.size());
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- SDL_GL_SwapBuffers();
- activeVBO_ = (++activeVBO_)%NUM_VBO;
- glError();
- }
- struct Vertex
- {
- float x, y, z;
- float s, t;
- char r, g, b, a;
- };
Add Comment
Please, Sign In to add comment