Atividade #2 - cg - ana cristina
#include
void init(void); void display(void); void keyboard(unsigned char key, int x, int y); int red =0.0; int green = 0.0; int blue = 0.0;
int main(int argc, char** argv){ glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (256, 256); glutInitWindowPosition (100, 100); glutCreateWindow ("Desenhando uma linha"); init(); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0;
}
void init(void){ glClearColor(1.0, 1.0, 1.0, 1.0); glOrtho (0, 256, 0, 256, -1 ,1);
}
void display(void){ int i; glClear(GL_COLOR_BUFFER_BIT); //TELHADO glPushMatrix(); glColor3f (red, green , blue ); glBegin(GL_LINE_LOOP); glVertex2i(50,100); glVertex2i(125,200); glVertex2i(200,100); glutPostRedisplay(); glEnd(); glPopMatrix(); //TERREO glPushMatrix(); glColor3f (red, green , blue ); glBegin(GL_LINES); glVertex2i(50,30); glVertex2i(200,30); glVertex2i(50,30); glVertex2i(50,100); glVertex2i(200,30); glVertex2i(200,100); glutPostRedisplay(); glEnd(); glPopMatrix(); //PORTA glPushMatrix(); glColor3f (red, green , blue ); glBegin(GL_LINES); glVertex2i(70,30); glVertex2i(70,70); glVertex2i(70,70); glVertex2i(100,70); glVertex2i(100,70); glVertex2i(100,30); glutPostRedisplay(); glEnd(); glPopMatrix(); glPushMatrix(); glColor3f (red, green , blue ); glBegin(GL_LINE_LOOP); glVertex2i(120,50); glVertex2i(140,50); glutPostRedisplay(); glEnd(); glPopMatrix();
glFlush();
}
void keyboard(unsigned char key, int x, int y){ switch (key) { case 27: exit(0); break; case 'r': red = 1.0; green=0.0; blue=0.0; break; case