<meta charset=\"utf-8\">


#include <gl/glut.h> 
#include <math.h> 
#define M_PI 3.14159

int rotX = 0, rotY = 0;                 // 변수선언
int newx = 0, newy = 0; <meta charset=\"utf-8\">// 변수선언
int oldx = 0, oldy = 0; <meta charset=\"utf-8\">// 변수선언
int bClick = 0; <meta charset=\"utf-8\">// 변수선언
int r=0; <meta charset=\"utf-8\">// 변수선언
int g=0; <meta charset=\"utf-8\">// 변수선언
int b=0;// 변수선언

<meta charset=\"utf-8\">

void mydisplay(){ 
 double c, theta, x, y, z;

 glClear(GL_COLOR_BUFFER_BIT); 
 glPushMatrix(); 
 glRotatef(-rotX, 1,0,0); //회전하는데 각도를 rotX만큼 (1.0,0)을 기준으로 회전
 glRotatef(-rotY, 0,1,0); //회전하는데 각도를 rotY만큼 (0.1,0)을 기준으로 회전
 glTranslatef(0,0, -2); //좌표축을 이동하는 함수 - y축을 2만큼 이동
 
 c = M_PI/180.0; // 값변경

 glBegin(GL_TRIANGLE_FAN); //다이아몬드의 아랫면
 x = 0.0; <meta charset=\"utf-8\">// 값변경
 y = 0.0; <meta charset=\"utf-8\">// 값변경
 z = 0.5; <meta charset=\"utf-8\">// 값변경
 glVertex3d(x, y, z); //함수호출
 for (theta = 0.0; theta <= 360.0; theta += 40.0) { 
  x = cos(c*theta); //값변경
  y = sin(c*theta); //값변경
  z = -1; //값변경
  glVertex3d(x, y, z); }
 glEnd(); 
 
 glBegin(GL_TRIANGLE_FAN); //구각형의 밑면
 glVertex3d(0,0,-0.5); // 함수호출
 for (theta = 0.0; theta <= 360.0; theta += 40.0) { 
  x = cos(c*theta); 
  y = sin(c*theta); 
  z = -1; 
  glVertex3d(x, y, z); } 
 glEnd(); 
 glBegin(GL_TRIANGLE_FAN);
 glVertex3d(0,0,-2.0);
 for (theta=0.0; theta <=360.0; theta += 40.0){
  x=cos(c*theta);
  y=sin(c*theta);
  z=-1;
  glVertex3d(x,y,z);}
 glEnd();
 glPopMatrix(); 
 glFlush(); }

void jmMotion(int x, int y) {
 if(bClick) { 
  newx = x; 
  newy = y; 
  rotX = rotX + newy - oldy; 
  rotY = rotY + newx - oldx; 
  oldx = newx; oldy = newy; } }

 

 

void jmMouseFunc(int button, int state, int x, int y) { 
 if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
 { bClick = 1; oldx = x; oldy = y; } 
 else if(button == GLUT_LEFT_BUTTON && state == GLUT_UP) 
 { bClick = 0; } 
 glutPostRedisplay(); }



어휴 힘들어