흐이애 2014. 12. 3. 23:35

/*

#include <GL/glut.h> //P1 L16

void MyDisplay() {

glClear(GL_COLOR_BUFFER_BIT);

glClearColor(1,1,1,1);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt(0,1,0,0,0,0,1,0,0);

glColor3f(0,0,1);

glutWireTeapot(0.5);

glFlush();

}


int main(int argc, char **argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB);

//glutInitWindowSize(300,300);

glutCreateWindow("3D");

glutDisplayFunc(MyDisplay);

glutMainLoop();

return 0;

}

*/


/*

#include <GL/glut.h> //P2 L16

void MyDisplay() {

glClear(GL_COLOR_BUFFER_BIT);

glClearColor(0,0,0,0);

glPushMatrix();

glColor3f(0,0,1); glutWireTeapot(0.2);

glTranslatef(0.3f, -0.3f, 0.0f);

glRotatef(45.0f, 0.0f, 0.0f, 1.0f);

glColor3f(1,0,1);

glutWireTeapot(0.2);

glPopMatrix();


glFlush();

}


void reshape(int w, int h) {

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-1,1,-1,1,0,100);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

}



int main(int argc, char **argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB);

//glutInitWindowSize(300,300);

glutCreateWindow("3D");

glutReshapeFunc(reshape);

glutDisplayFunc(MyDisplay);

glutMainLoop();

return 0;

}

*/

/*

#include <GL/glut.h> //P3 L16

void MyDisplay() {

glClear(GL_COLOR_BUFFER_BIT);

glClearColor(0,0,0,0);

glPushMatrix();

glColor3f(0,0,1); 

glRotatef(45,1,1,1);

glutWireTeapot(0.3);

glPopMatrix();

glutSwapBuffers();


//glFlush();

}


void reshape(int w, int h) {

glViewport(0,0,(GLsizei)w,(GLsizei)h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(25,(GLfloat)w/(GLfloat)h,1,20);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glTranslatef(0,0,-3);

}



int main(int argc, char **argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);

glutInitWindowSize(400,400);

glutCreateWindow("3D");

glutReshapeFunc(reshape);

glutDisplayFunc(MyDisplay);

glutMainLoop();

return 0;

}

*/



/*

#include <GL/glut.h> //P4 L16

void MyDisplay() {

glClear(GL_COLOR_BUFFER_BIT);

glClearColor(1,1,1,1);

glPushMatrix();

glColor3f(0,0,1); 

//glScalef(2,2,2);

glRotatef(45,1,1,1);

glutWireTeapot(0.5);

glPopMatrix();

glutSwapBuffers();


//glFlush();

}


void reshape(int w, int h) {

glViewport(0,0,(GLsizei)w,(GLsizei)h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-0.5,0.5,-0.5,0.5,1,20);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glTranslatef(0,0,-2);

}



int main(int argc, char **argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);

//glutInitWindowSize(400,400);

glutCreateWindow("3D");

glutReshapeFunc(reshape);

glutDisplayFunc(MyDisplay);

glutMainLoop();

return 0;

}

*/

#include <GL/glut.h>

static int year=0,day=0;

void MyDisplay(){

for(year=1;year<2000;year++){

for(day=1;day<5;day++){

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

//glClearColor(1,1,1,1);

//gluLookAt(0.1,0.1,0,0,1,0.1,0.1,0.1,0.1);

glPushMatrix();

glColor3f(1,0,0);

glutWireSphere(1,10,200);


glRotatef((GLfloat)year,0,0,1);

glTranslatef(2,0,0);

glRotatef((GLfloat)day,1,0,0);

glColor3f(0,0,1);

glutWireSphere(0.1,15,15);


glRotatef((GLfloat)year*2,0,0,1);

glTranslatef(0.7,0,0);

glRotatef((GLfloat)day*2,1,0,0);

glColor3f(1,1,0);

glutWireSphere(0.1,15,15);


glPopMatrix();

glFlush();

}

}

}


void init(void){

glShadeModel(GL_SMOOTH);

glEnable(GL_DEPTH_TEST);

}


void Reshape(GLsizei w, GLsizei h) {

glViewport(0,0,w,h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(60, (GLfloat)w/(GLfloat)h, 1,20);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glTranslatef(0,0,-5);

}


void main(int argc, char** argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB);

glutInitWindowSize(600,600);

glutCreateWindow("Foster");

init();

glutReshapeFunc(Reshape);

glutDisplayFunc(MyDisplay);

glutMainLoop();

}



반응형