#include "stdafx.h"
#include <GL/glut.h>
void reshape( int width, int height)
{
glViewport(0,0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-4,7,-6,5,-5,5);
glMatrixMode(GL_MODELVIEW);}
void
display()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
//cara1
glColor3f(1,0,1);
glBegin(GL_POLYGON);
glVertex3f(0,0,0);
glVertex3f(1.5,3,0);
glVertex3f(3,0,0);
glEnd();
//cara2
glColor3f(1,0,0);
glBegin(GL_POLYGON);
glVertex3f(3,0,0);
glVertex3f(1.5,3,0);
glVertex3f(1.5,0,3);
glEnd();
//cara3
glColor3f(1,1,1);
glBegin(GL_POLYGON);
glVertex3f(1.5,3,0);
glVertex3f(1.5,0,3);
glVertex3f(0,0,0);
glEnd();
//base
glColor3f(0,1,0);
glBegin(GL_POLYGON);
glVertex3f(0,0,0);
glVertex3f(3,0,0);
glVertex3f(1.5,0,3);
glEnd();
glFlush();
}
void
init()
{
glClearColor(0,0,0,0);
}
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50,50);
glutInitWindowSize(500,500);
glutCreateWindow(
"Piramide");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

No hay comentarios:
Publicar un comentario