[Q] Drawing a quad using modern OpenGL?
Posted: Wed Jul 16, 2014 6:29 am
Hello all.
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:
Or should I just generate a new VBO with the vertices altered?
Any help is appreciated!
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!