TRIANGLES
TRIANGLES
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
/* GLUT callback Handlers */
void resize(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 1.0);
glPointSize(5.0);
glBegin(GL_QUADS); //GL_TRIANGLES, GL_TRIANGLE_STRIP
glVertex2f(0.5, 0.5);
glVertex2f(-0.5,0.5);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glEnd();
glColor3f(0.0, 0.0, 1.0);
glBegin(GL_POINTS); //GL_TRIANGLES, GL_POINTS, GL_LINES
glVertex2f(0.5, 0.5);
glVertex2f(-0.5,0.5);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
/* Program entry point */
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("Triangles");
glutDisplayFunc(display);
glutReshapeFunc(resize);
glClearColor(1, 1, 0, 1);
glutMainLoop();
return EXIT_SUCCESS;
}