0% found this document useful (0 votes)
5 views2 pages

TRIANGLES

This document contains a simple OpenGL program that creates a window displaying a colored quad and points. It includes functions for resizing the window and rendering the display. The program initializes GLUT, sets up the display mode, and enters the main loop.

Uploaded by

tserentogtoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

TRIANGLES

This document contains a simple OpenGL program that creates a window displaying a colored quad and points. It includes functions for resizing the window and rendering the display. The program initializes GLUT, sets up the display mode, and enters the main loop.

Uploaded by

tserentogtoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//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;
}

You might also like