OpenGL๋ก ๋ง๋ ํ์๊ณ ๋ชจ๋ธ๋ง์ ๋๋ค.
์๋๋ ์ ์ฒด ์ฝ๋์ ๋๋ค.
#include <GL/glut.h>
//#include <GL/gl.h>
//#include <GL/glu.h>
static int Day = 0, Time = 0;
void MyDisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.3, 0.3);
glutWireSphere(0.2, 20, 16);//ํ์๊ทธ๋ฆฌ๊ธฐ
glPushMatrix();//ํ์๊ธฐ์ค ์ขํ๊ณ ์คํ์ ํธ์ํ์ฌ ์ ์ฅ
glRotatef((GLfloat)Day, 0.0, 1.0, 0.0);//ํ์
glTranslatef(0.7, 0.0, 0.0);//์ด๋
glRotatef((GLfloat)Time, 0.0, 1.0, 0.0);//time๋งํผ ํ์ (์ง๊ตฌ์์ )
glColor3f(0.5, 0.6, 0.7);
glutWireSphere(0.1, 10, 8);//์ง๊ตฌ๊ทธ๋ฆฌ๊ธฐ
glPushMatrix();//์ง๊ตฌ ์ขํ๊ณ ํธ์
glRotatef((GLfloat)Time, 0.0, 1.0, 0.0);//์ง๊ตฌํ์
glTranslatef(0.2, 0.0, 0.0);//๋ฌ์ขํ์ฐ๊ธฐ
glColor3f(0.9, 0.8, 0.2);
glutWireSphere(0.04, 10, 8);//๋ฌ๊ทธ๋ฆฌ๊ธฐ
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void MyTimer(int Value) {
Day = (Day + 10) % 360;
Time = (Time + 5) % 360;
glutPostRedisplay();//๋์คํ๋ ์ด ์ฝ๋ฐฑ์๊ตฌ
glutTimerFunc(35, MyTimer, 1); //๋์ผ์๊ฐ๋ฐ๋ณต
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0, 0);
glutCreateWindow("ํ์๊ณ+ํ์ด๋จธ");
glClearColor(1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glutDisplayFunc(MyDisplay);
glutTimerFunc(25, MyTimer, 1);//ํค๋ณด๋ํจ์์์ ํ์ด๋จธํจ์๋ก ๋ณ๊ฒฝ
glutMainLoop();
return 0;
}
glut.h, glut32.lib, glut32.dll ์ค์นํด์ import ํด์ค์ผํ๋ค.
728x90
๋ฐ์ํ