// Now draw!
float vertices[] = {
+ 0.0f, 1.0f,
0.0f, 0.0f,
- 1.0f, 0.0f,
1.0f, 1.0f,
- 0.0f, 1.0f
+ 1.0f, 0.0f
};
GLuint vao;
GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(vertices), vertices); // Same as vertices.
- glDrawArrays(GL_QUADS, 0, 4);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
check_error();
cleanup_vertex_attribute(glsl_program_num, "position", position_vbo);
// texture coordinates in order not to get long stretches of (1,1,1,...)
// at the start and (...,0,0,0) at the end.
float vertices[] = {
+ 0.0f, 1.0f,
0.0f, 0.0f,
- 1.0f, 0.0f,
1.0f, 1.0f,
- 0.0f, 1.0f
+ 1.0f, 0.0f
};
float texcoords[] = {
+ 0.25f, 0.0f,
0.25f, 0.0f,
0.75f, 0.0f,
- 0.75f, 0.0f,
- 0.25f, 0.0f
+ 0.75f, 0.0f
};
GLuint vao;
GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(texcoords), texcoords);
- glDrawArrays(GL_QUADS, 0, 4);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
check_error();
cleanup_vertex_attribute(glsl_program_num, "position", position_vbo);
// Draw the texture stretched over a long quad, interpolating it out.
float vertices[] = {
+ 0.0f, 1.0f,
0.0f, 0.0f,
- 1.0f, 0.0f,
1.0f, 1.0f,
- 0.0f, 1.0f
+ 1.0f, 0.0f
};
float texcoords[] = {
+ 0.25f, 0.0f,
0.25f, 0.0f,
0.75f, 0.0f,
- 0.75f, 0.0f,
- 0.25f, 0.0f
+ 0.75f, 0.0f
};
GLuint vao;
GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(texcoords), texcoords);
- glDrawArrays(GL_QUADS, 0, 4);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
check_error();
cleanup_vertex_attribute(glsl_program_num, "position", position_vbo);