I am trying to use a function to render a triangle with OpenGL. The shape isn't appearing and I don't know why. I think it might be just because of the locations of the vertices.
Main method:
int main() {
glutInitWindowSize(400, 400);
glutInitWindowPosition(200, 200);
glutCreateWindow("Test");
Initialize();
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
Initialise method:
void Initialize() {
glClearColor(0.1, 0.1, 0.1, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
drawTriangle function:
void drawTriangle(int v1x, int v1y, int v2x, int v2y, int v3x, int v3y, int red, int green, int blue)
{
//arguments are: "vertex 1 x coordinate", "vertex 1 y coordinate" etc
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
glVertex2f(v1x, v1y); // v1
glVertex2f(v2x, v2y); // v2
glVertex2f(v3x, v3y); // v3
glEnd();
glFlush();
}
Draw method:
void Draw() {
drawTriangle(3.0, 2.9, 300, 300, 100, 100, 10, 0, 0);
}