Académique Documents
Professionnel Documents
Culture Documents
h>
#include <math.h>
#include <GL/glut.h>
void circunferencia(float);
void init(void);
void ejes2d(void);
void display(void);
void reshape(int,int);
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0); //parametros: rojo, amarillo, azul, el cuarto es el
parametro alpha
glShadeModel(GL_FLAT);
}
void ejes2d(void)
{
glBegin(GL_LINES);
glVertex2f(-9.0,0.0);
glVertex2f(9.0,0.0);
glVertex2f(0.0,-9.0);
glVertex2f(0.0,9.0);
glEnd();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix(); // salva el estado actual de la matriz
glColor3f(0.0,0.0,1.0);
ejes2d();
glColor3f(1.0,0.0,0.0);
circunferencia(8.0);
glPopMatrix(); // reecupera el estado del matriz
glFlush();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0,10.0,-10.0,10,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}