Computacion grafica
//COMPUTACIÓN GRAFICA
//trabajo encargado en 2D traslación, rotación. escalado.
//nombre:
//código: 055153
#include
#define ancho 800#define altura 600
#define profundidad 500
void DibujaCuadrado();
void EjesXY();
void TecladoScala(int tecla,int x,int y);
float esc=1;
int posx=0, posy=0;
void Teclado(unsigned char tecla,int x, int y);
int angulo=0;
int main(int argc,char** argv){
glutInitDisplayMode(GLUT_RGBA |GLUT_DOUBLE);
glutInitWindowPosition(100, 70);
glutInitWindowSize(ancho, altura);glutCreateWindow("ROTACIÓN, TRASLACIÓN Y ESCALADO ESTRELLA EN 2D");
glOrtho(-(ancho/2), (ancho/2), -(altura/2), (altura/2), -profundidad, profundidad);
glClearColor(0, 0, 0, 0);glutDisplayFunc(DibujaCuadrado);
glutSpecialFunc(TecladoScala);
glutKeyboardFunc(Teclado);
glutMainLoop();
return 0;
}
void DibujaCuadrado(){glClear(GL_COLOR_BUFFER_BIT);
EjesXY();
glPushMatrix();
glScalef(esc,esc,esc);
glRotatef(angulo, 0,0,1);
glTranslatef(posx, posy, 0);
glBegin(GL_LINE_STRIP);glColor3f(0,1,0);glVertex2f(150,0);
glColor3f(1,0,0);glVertex2f(50,50);
glColor3f(0,1,0);glVertex2f(0,150);
glColor3f(0,0,1);glVertex2f(-50,50);glColor3f(0,1,0);glVertex2f(-150,0);
glColor3f(0,1,1);glVertex2f(-50,-50);
glColor3f(0,1,0);glVertex2f(0,-150);
glColor3f(1,1,0);glVertex2f(50,-50);
glColor3f(0,1,0);glVertex2f(150,0);glEnd();
glPopMatrix();
glutSwapBuffers();
}
void EjesXY(){
glColor3f(1.0,0.0,1.0);
glBegin(GL_LINES);
glVertex2i(-ancho/2, 0);glVertex2i(ancho/2, 0);
glVertex2i(0,altura/2);
glVertex2i(0,-altura/2);
glEnd();
}
void TecladoScala(int tecla, int x, int y){
switch(tecla){
case...
Regístrate para leer el documento completo.