Está en la página 1de 20

Trabajo de Practica 4

PASO 1:

Código:
//PASO 1:
//ORIGINAL LIBRERIA
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

//ACTUAL LIBRERIA
#include <math.h>

int rad = 100;


double ang = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
void inicializa(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);// el ancho y largo de nuestra pantalla
}

void circulo(int x, int y, int radio)


{
int angulo=0;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x,y);

for(angulo=0;angulo<=360; angulo++)
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void circuloc(int x, int y, int t, int radio)


{
int angulo = 0;
glPointSize(t);
glBegin(GL_POINTS);

glVertex2f(x, y);

for (angulo = 0; angulo <= 360; angulo += 1)


{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void dibuja(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//esto
glColor3f(1.0, 0.0, 0.0);
circulo(500 + sin(ang) * 0, 500 + cos(ang) * 0, 50); //funcion circulo
glColor3f(1.0, 1.0, 1.0);
circuloc(500, 500, 1, 100);
circuloc(500, 500, 1, 150);
circuloc(500, 500, 1, 200);
circuloc(500, 500, 1, 250);
circuloc(500, 500, 1, 300);
circuloc(500, 500, 1, 350);
circuloc(500, 500, 1, 400);
circuloc(500, 500, 1, 450);

glColor3f(0.8, 0.4, 0.1);


circulo(500 + sin(a) * 100, 500 + cos(a) * 100, 5);
glColor3f(0.6, 0.3, 0.1);

circulo(500 + sin(b) * 150, 500 - cos(b) * 150, 7);


glColor3f(0.1, 0.7, 0.8);
circulo(500 + sin(c) * 200, 500 + cos(c) * 200, 10);
glColor3f(0.8, 0.07, 0.2);
circulo(500 + sin(d) * 250, 500 - cos(d) * 250, 10);
glColor3f(0.9, 0.6, 0.2);
circulo(500 + sin(e) * 300, 500 + cos(e) * 300, 18);
glColor3f(0.2, 0.9, 0.7);
circulo(500 + sin(f) * 350, 500 - cos(f) * 350, 14);
glColor3f(0.2, 0.7, 0.9);
circulo(500 + sin(ang) * 400, 500 + cos(ang) * 400, 12);
glColor3f(0.0, 0.1, 0.9);
circulo(500 + sin(a) * 450, 500 - cos(a) * 450, 12);
a += 0.01; //a=a+0.1;
b += 0.02;
c += 0.03;
d += 0.04;
e += 0.05;
f += 0.06;
ang = ang + 0.01; //velocidad entre mas grande mas rapido y entre menos mas
lento
for (int j = 1; j <= 10000000; j++) {}//PAUSA
if (ang == 360) { ang = 0; }// SE REPITE IDEFINIDAMENTE
glFlush(); //FORZAR DIBUJADO
glutSwapBuffers(); //Y ESTO
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);//esto tambien
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(10, 10);
glutCreateWindow("Ventana");
inicializa();
glutDisplayFunc(dibuja);
glutIdleFunc(dibuja);//ESTO ES LO QUE CAMBIA
glutMainLoop();
return 0;
}

Resultado:
PASO 2:
Código:
//PASO 2:
//ORIGINAL LIBRERIA
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

//ACTUAL LIBRERIA
#include <math.h>

int rad = 100;


double ang = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
void inicializa(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);// el ancho y largo de nuestra pantalla
}

void circulo(int x, int y, int radio)


{
int angulo=0;
glBegin(GL_TRIANGLE_FAN); //glColor3f (0.5, 0.5, 0.5);
glVertex2f(x,y);
glColor3f(0,0.0,0.0); //COLOR SOMBREADA PARA FORMAR A 3D
for(angulo=0;angulo<=360; angulo+=6) //AUMENTO DE TAMAÑO A 6
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void circuloc(int x, int y, int t, int radio)


{
int angulo = 0;
glPointSize(t);
glBegin(GL_POINTS);

glVertex2f(x, y);

for (angulo = 0; angulo <= 360; angulo += 1)


{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void dibuja(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//esto
glColor3f(1.0, 0.0, 0.0);
circulo(500 + sin(ang) * 0, 500 + cos(ang) * 0, 50); //funcion circulo
glColor3f(1.0, 1.0, 1.0);
circuloc(500, 500, 1, 100);
circuloc(500, 500, 1, 150);
circuloc(500, 500, 1, 200);
circuloc(500, 500, 1, 250);
circuloc(500, 500, 1, 300);
circuloc(500, 500, 1, 350);
circuloc(500, 500, 1, 400);
circuloc(500, 500, 1, 450);

glColor3f(0.8, 0.4, 0.1);


circulo(500 + sin(a) * 100, 500 + cos(a) * 100, 5);
glColor3f(0.6, 0.3, 0.1);

circulo(500 + sin(b) * 150, 500 - cos(b) * 150, 7);


glColor3f(0.1, 0.7, 0.8);
circulo(500 + sin(c) * 200, 500 + cos(c) * 200, 10);
glColor3f(0.8, 0.07, 0.2);
circulo(500 + sin(d) * 250, 500 - cos(d) * 250, 10);
glColor3f(0.9, 0.6, 0.2);
circulo(500 + sin(e) * 300, 500 + cos(e) * 300, 18);
glColor3f(0.2, 0.9, 0.7);
circulo(500 + sin(f) * 350, 500 - cos(f) * 350, 14);
glColor3f(0.2, 0.7, 0.9);
circulo(500 + sin(ang) * 400, 500 + cos(ang) * 400, 12);
glColor3f(0.0, 0.1, 0.9);
circulo(500 + sin(a) * 450, 500 - cos(a) * 450, 12);
a += 0.01; //a=a+0.1;
b += 0.02;
c += 0.03;
d += 0.04;
e += 0.05;
f += 0.06;
ang = ang + 0.01; //velocidad entre mas grande mas rapido y entre menos mas
lento
for (int j = 1; j <= 10000000; j++) {}//PAUSA
if (ang == 360) { ang = 0; }// SE REPITE IDEFINIDAMENTE
glFlush(); //FORZAR DIBUJADO
glutSwapBuffers(); //Y ESTO
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);//esto tambien
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(10, 10);
glutCreateWindow("Ventana");
inicializa();
glutDisplayFunc(dibuja);
glutIdleFunc(dibuja);//ESTO ES LO QUE CAMBIA
glutMainLoop();
return 0;
}

Resultado:
PASO 3:
Código:
//PASO 3:
//ORIGINAL LIBRERIA
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

//ACTUAL LIBRERIA
#include <math.h>

int rad = 100;


double ang = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
void inicializa(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);// el ancho y largo de nuestra pantalla
}

void circulo(int x, int y, int radio)


{
int angulo=0;
glBegin(GL_TRIANGLE_FAN); //glColor3f (0.5, 0.5, 0.5);
glVertex2f(x,y);
glColor3f(0,0.0,0.0); //COLOR SOMBREADA PARA FORMAR A 3D
for(angulo=0;angulo<=360; angulo+=6) //AUMENTO DE TAMAÑO A 6
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void circuloc(int x, int y, int t, int radio)


{
double angulo = 0; //CAMBIANDO PARA DECIMALES QUE NECESITA QUE LOS PUNTOS SEA
MAS FINA
glPointSize(t);

glBegin(GL_POINTS);
glVertex2f(x, y);
glColor3f(0.0f, 1.0f, 0.0f); //CAMBIANDO A COLOR VERDE
for (double angulo = 0.0; angulo <= 360; angulo +=0.01)//LOS PUNTOS QUE SEA
FINA Y TAMBIEN LA VELOCIDAD BAJA
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void dibuja(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//esto
glColor3f(1.0, 0.0, 0.0);
circulo(500 + sin(ang) * 0, 500 + cos(ang) * 0, 50); //funcion circulo
glColor3f(1.0, 1.0, 1.0);
circuloc(500, 500, 1, 100);
circuloc(500, 500, 1, 150);
circuloc(500, 500, 1, 200);
circuloc(500, 500, 1, 250);
circuloc(500, 500, 1, 300);
circuloc(500, 500, 1, 350);
circuloc(500, 500, 1, 400);
circuloc(500, 500, 1, 450);

glColor3f(0.8, 0.4, 0.1);


circulo(500 + sin(a) * 100, 500 + cos(a) * 100, 5);
glColor3f(0.6, 0.3, 0.1);

circulo(500 + sin(b) * 150, 500 - cos(b) * 150, 7);


glColor3f(0.1, 0.7, 0.8);
circulo(500 + sin(c) * 200, 500 + cos(c) * 200, 10);
glColor3f(0.8, 0.07, 0.2);
circulo(500 + sin(d) * 250, 500 - cos(d) * 250, 10);
glColor3f(0.9, 0.6, 0.2);
circulo(500 + sin(e) * 300, 500 + cos(e) * 300, 18);
glColor3f(0.2, 0.9, 0.7);
circulo(500 + sin(f) * 350, 500 - cos(f) * 350, 14);
glColor3f(0.2, 0.7, 0.9);
circulo(500 + sin(ang) * 400, 500 + cos(ang) * 400, 12);
glColor3f(0.0, 0.1, 0.9);
circulo(500 + sin(a) * 450, 500 - cos(a) * 450, 12);
a += 0.01; //a=a+0.1;
b += 0.02;
c += 0.03;
d += 0.04;
e += 0.05;
f += 0.06;
ang = ang + 0.01; //velocidad entre mas grande mas rapido y entre menos mas
lento
for (int j = 1; j <= 10000000; j++) {}//PAUSA
if (ang == 360) { ang = 0; }// SE REPITE IDEFINIDAMENTE
glFlush(); //FORZAR DIBUJADO
glutSwapBuffers(); //Y ESTO
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);//esto tambien
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(10, 10);
glutCreateWindow("Ventana");
inicializa();
glutDisplayFunc(dibuja);
glutIdleFunc(dibuja);//ESTO ES LO QUE CAMBIA
glutMainLoop();
return 0;
}

Resultado:
PASO 4:
Código:
//PASO 4:
//ORIGINAL LIBRERIA
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

//ACTUAL LIBRERIA
#include <math.h>

int rad = 100;


double ang = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
void inicializa(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);// el ancho y largo de nuestra pantalla
}

void circulo(int x, int y, int radio)


{
int angulo = 0;
glBegin(GL_TRIANGLE_FAN); //glColor3f (0.5, 0.5, 0.5);
glVertex2f(x, y);
glColor3f(0, 0.0, 0.0); //COLOR SOMBREADA PARA FORMAR A 3D
for (angulo = 0; angulo <= 360; angulo += 6) //AUMENTO DE TAMAÑO A 6
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void circuloc(int x, int y, int t, int radio)


{
double angulo = 0; //CAMBIANDO PARA DECIMALES QUE NECESITA QUE LOS PUNTOS SEA
MAS FINA
glPointSize(t);

glBegin(GL_POINTS);
glVertex2f(x, y);
//glColor3f(0.0f, 1.0f, 0.0f); //CAMBIANDO A COLOR VERDE
for (double angulo = 0.0; angulo <= 360; angulo += 0.01)//LOS PUNTOS QUE SEA
FINA Y TAMBIEN LA VELOCIDAD BAJA
{
glVertex2f(x + sin(angulo) * radio, y + cos(angulo) * radio);
}
glEnd();
}

void dibuja(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//esto

glColor3f(1.0, 0.0, 0.0);


circulo(500 + sin(ang) * 0, 500 + cos(ang) * 0, 70); //funcion circulo
//AUMENTANDO CON 20 DEEL TAMAÑO DE CIRCULO
glColor3f(1.0, 1.0, 1.0);
circuloc(500, 500, 1, 100);
circuloc(500, 500, 1, 150);
circuloc(500, 500, 1, 200);
circuloc(500, 500, 1, 250);
circuloc(500, 500, 1, 300);
circuloc(500, 500, 1, 350);
circuloc(500, 500, 1, 400);
circuloc(500, 500, 1, 450);

glColor3f(0.8, 0.4, 0.1);


circulo(500 + sin(a) * 100, 500 + cos(a) * 100, 25);
glColor3f(0.6, 0.3, 0.1);
circulo(500 + sin(b) * 150, 500 - cos(b) * 150, 27);
glColor3f(0.1, 0.7, 0.8);
circulo(500 + sin(c) * 200, 500 + cos(c) * 200, 30);
glColor3f(0.8, 0.07, 0.2);
circulo(500 + sin(d) * 250, 500 - cos(d) * 250, 30);
glColor3f(0.9, 0.6, 0.2);
circulo(500 + sin(e) * 300, 500 + cos(e) * 300, 38);
glColor3f(0.2, 0.9, 0.7);
circulo(500 + sin(f) * 350, 500 - cos(f) * 350, 34);
glColor3f(0.2, 0.7, 0.9);
circulo(500 + sin(ang) * 400, 500 + cos(ang) * 400, 32);
glColor3f(0.0, 0.1, 0.9);
circulo(500 + sin(a) * 450, 500 - cos(a) * 450, 32);
a += 0.01; //a=a+0.1;
b += 0.02;
c += 0.03;
d += 0.04;
e += 0.05;
f += 0.06;
ang = ang + 0.01; //velocidad entre mas grande mas rapido y entre menos mas
lento
for (int j = 1; j <= 10000000; j++) {}//PAUSA
if (ang == 360) { ang = 0; }// SE REPITE IDEFINIDAMENTE
glFlush(); //FORZAR DIBUJADO
glutSwapBuffers(); //Y ESTO
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);//esto tambien
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(10, 10);
glutCreateWindow("Ventana");
inicializa();
glutDisplayFunc(dibuja);
glutIdleFunc(dibuja);//ESTO ES LO QUE CAMBIA
glutMainLoop();
return 0;
}

Resultado:
PASO 5:
Código:
//PASO 5:
//ORIGINAL LIBRERIA
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

//ACTUAL LIBRERIA
#include<math.h>
#define PI 3.14

float anguloMercurio = 0.0;


float anguloMarte = 0.0;
float anguloTierra = 0.0;
float anguloJupiter = 0.0;
float anguloUrano = 30.0;
float anguloSaturno = 0.0;
float anguloNeptuno = 60.0;
float anguloVenus = 0.0;

float anguloLuna = 0.0;

GLfloat sx = 0.2;
GLfloat sy = 0.2;
GLfloat sz = 0.2;

GLfloat Negro[] = { 0.0f,0.0f,0.0f,1.0f };


GLfloat Blanco[] = { 1.0f,1.0f,1.0f,1.0f };
GLfloat Azul[] = { 0.0f,0.0f,0.9f,1.0f };
GLfloat Amarillo[] = { 0.7f,0.2f,0.0f,1.0f };
GLfloat qAmbiguo[] = { 0.1,0.1,0.1,1.0 };
GLfloat qDiferente[] = { 1.0,1.0,1.0,1.0 };
GLfloat qEspecial[] = { .50,.50,.50,.10 };
GLfloat qPosicion[] = { 0,0,0,0.1 };

GLfloat alcance[8] = { 0.295 , 0.40,0.50, 0.60,0.80,1.0,1.05,1.13 };

double ang = 2 * PI / 300;


double angular = 2 * PI / 50;

void iluminacionInicial()
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT7);

glLightfv(GL_LIGHT7, GL_AMBIENT, qAmbiguo);


glLightfv(GL_LIGHT7, GL_DIFFUSE, qDiferente);
glLightfv(GL_LIGHT7, GL_SPECULAR, qEspecial);
}

void inicializa()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glPointSize(1.0);
glLineWidth(2.0);
}

void fondo()
{
glBegin(GL_QUADS);
glColor3f(0.0, 0.00, 0.00);
glVertex3f(-01.00, 01.00, 1);
glColor3f(.20, 0.0, 0.70);
glVertex3f(01.00, 1.00, 1);
glColor3f(0, 0.0, 0.0);
glVertex3f(1.00, -1.00, 1);
glColor3f(.70, .10, .20);
glVertex3f(-1.00, -1.00, 1);
glEnd();
}

void orbita()
{
glColor3f(0.5, 0.5, 0.5);

int i = 0;
for (i = 0; i < 8; i++)
{
glPushMatrix();
if (i == 5) { glRotatef(45, 1.0, 0.0, 0.0); }
else
{
glRotatef(63, 1.0, 0.0, 0.0);
}

glScalef(alcance[i], alcance[i], alcance[i]);


glBegin(GL_POINTS);
double ang1 = 0.0;
int i = 0;

for (i = 0; i < 300; i++)


{
glVertex2d(cos(ang1), sin(ang1)); ang1 += ang;
}
glEnd();
glPopMatrix();
}
}

void dibuja(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
fondo();
orbita();
glLoadIdentity();

glPushMatrix();
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);

glPushMatrix();
glColor3f(0.7, 0.5, 0.0);
glScalef(sx, sy, sz);
glLightfv(GL_LIGHT7, GL_POSITION, qPosicion);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Amarillo);
glutSolidSphere(1, 50, 50);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Negro);
glPopMatrix();
glScalef(0.2, 0.2, 0.2);

glPushMatrix();
glRotatef(anguloMercurio, 0.0, 1.0, -0.5);
glTranslatef(1.5, 0.0, 0.0);
glColor3f(1.0, 0.9, 0.0);
glScalef(0.08, 0.08, 0.08);
glutSolidSphere(1, 50, 50);
glPopMatrix();

glPushMatrix();
glRotatef(anguloVenus, 0.0, 1.0, -0.5);
glTranslatef(2.0, 0.0, 0.0);
glColor3f(0.9, 0.1, 0.0);
glScalef(0.1, 0.1, 0.1);
glutSolidSphere(1, 50, 50);
glPopMatrix();

glPushMatrix();
glRotatef(anguloTierra, 0.0, 1.0, -0.5);
glTranslatef(2.5, 0.0, 0.0);
glColor3f(0.0, 0.1, 0.7);
glScalef(0.23, 0.23, 0.23);
glutSolidSphere(1, 50, 50);

glPushMatrix();
glRotatef(anguloLuna, 0.0, 0.1, 0.05);
glTranslatef(1.3, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glScalef(0.5, 0.5, 0.5);
glutSolidSphere(0.5, 50, 50);
glPopMatrix();//HECHO QUEQUEÑA LUNA
glPopMatrix();//HECHO TIERRA

glPushMatrix();
glRotatef(anguloMarte, 0.0, 1.0, -0.5);
glTranslatef(-3.0, 0.0, 0.0);
glColor3f(0.05, 0.05, 0.01);
glScalef(0.17, 0.17, 0.17);
glutSolidSphere(1, 50, 50);
glPopMatrix();

glPushMatrix();
glColor3f(3.30, 3.30, 3.30);
glRotatef(63, 1.0, 0.0, 0.0);
int j = 0, i = 0, div = 90; float siz = 2;
float scl[4] = { 3.3,3.4,3.35,3.2 };

glPopMatrix();//HECHO ASTEROIDE

glPushMatrix();
glRotatef(anguloJupiter, 0.0, 1.0, -0.5);
glTranslatef(-4.0, 0.0, 0.0);
glColor3f(0.4, 0.2, 0.0);
glScalef(0.5, 0.5, 0.5);
glutSolidSphere(1, 50, 50);

glPushMatrix();
glRotatef(anguloLuna, 1.0, -0.5, 0.0);
glTranslatef(0.0, 0, 1.1);
glColor3f(1.0, 1.0, 1.0);
glScalef(0.1, 0.1, 0.1);
glutSolidSphere(0.5, 50, 50);
glPopMatrix();//HECHO LUNA PEQUEÑA
glPopMatrix();

glPushMatrix();
glRotatef(anguloSaturno, 0.0, 1.0, -1.0);
glTranslatef(-5.0, 0.0, 0.0);
glColor3f(0.9, 0.0, 0.0);
glScalef(0.4, 0.4, 0.4);
glutSolidSphere(1, 50, 50);

glPushMatrix();
glRotatef(45, 1.0, 0.0, 0.0);
glPointSize(3);
glColor3f(5.0, 3.0, 1.0);
glScalef(1.2, 1.2, 1.2);
glBegin(GL_POINTS);
double ang1 = 0.0;
i = 0;
for (i = 0; i < 50; i++)
{
glVertex2d(cos(ang1), sin(ang1));
ang1 += angular;
}

glEnd();
glPointSize(2);
glPopMatrix();//ANILLO HECHO
glPopMatrix();

glPushMatrix();
glRotatef(anguloUrano, 0.0, 1.0, -0.5);
glTranslatef(5.2, 0.0, 0.0);
glColor3f(0.0, 0.5, 0.9);
glScalef(0.23, 0.23, 0.23);
glutSolidSphere(1, 50, 50);
glPopMatrix();

glPushMatrix();
glRotatef(anguloNeptuno, 0.0, 1.0, -0.5);
glTranslatef(-5.7, 0.0, 0.0);
glColor3f(0.0, 0.0, 0.9);
glScalef(0.2, 0.2, 0.2);
glutSolidSphere(1, 50, 50);
glPopMatrix();

glPopMatrix();
glFlush();
}

void actualizar(int value)


{
if ((anguloLuna >= 0 && anguloLuna < 180))
{
sx -= 0.0003; sy -= 0.0003; sz -= 0.0003;
}
else
{
sx += 0.0003; sy += 0.0003; sz += 0.0003;
}

anguloLuna += 2;
if (anguloLuna > 360)
{
anguloLuna -= 360;
}

anguloTierra += 0.7;
if (anguloTierra > 360)
{
anguloTierra -= 360;
}

anguloMercurio += 2;
if (anguloMercurio > 360)
{
anguloMercurio -= 360;
}

anguloVenus += 0.9;
if (anguloVenus > 360)
{
anguloVenus -= 360;
}

anguloMarte += 0.5;
if (anguloMarte > 360)
{
anguloMarte -= 360;
}

anguloJupiter += 0.2;
if (anguloJupiter > 360)
{
anguloJupiter -= 360;
}

anguloSaturno += 0.1;
if (anguloSaturno > 360)
{
anguloSaturno -= 360;
}

anguloUrano += 0.05;
if (anguloUrano > 360)
{
anguloUrano -= 360;
}

anguloNeptuno += 0.02;
if (anguloNeptuno > 360)
{
anguloNeptuno -= 360;
}

glutPostRedisplay();
glutTimerFunc(20, actualizar, 0);
}

int main(int argc, char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//ESTO TAMBIEN
glutInitWindowPosition(300, 50);
glutInitWindowSize(700, 700);
glutCreateWindow("Ventana");
iluminacionInicial();
inicializa();
glutDisplayFunc(dibuja);//ESTO ES LO QUE CAMBIA
glutTimerFunc(25, actualizar, 0);
glutMainLoop();
return 0;
}

Resultado:

También podría gustarte