Over the past couple of weeks I have been attempting to learn modern OpenGL. I have gotten to the point where I am going to begin drawing primitives to the screen. I would like to know how to draw a quad.
Back with legacy OpenGL all you had to do would be glBegin(GL_QUADS) ... glEnd() but now I have to supply my own vertices to the shader. I read about OpenGL VBOs and since they can be created from a static array of vertices would it be better for me to do this:
Code: Select all
const GLfloat _quadBase[] = {
0, 0, 1,
1, 0, 1,
0, 1, 1,
1, 0, 1,
1, 1, 1,
0, 1, 1
}
// Generate VBO here.
void drawQuad(KHVec2 pos, KHVec2 size) {
scale(size.x, size.y); // Scale the _quadBase
translate(pos.x, pos.y);
// Submit _quadBase vertices to shader
}
Any help is appreciated!