Programming/openGL2011. 9. 25. 22:02
오랫만에 하려니 sin() 함수가 radian 값을 받는것도 깜박잊고 꽤나 헤매게 만드네..

   
#include "GL/gl.h"
#include "GL/glu.h"
#include "GL/glut.h"
#include "math.h"

static int year = 0, day = 0;

void display(void)
{
        int temp;
        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(1.0, 1.0, 1.0);

        glPushMatrix();
                glBegin(GL_POINT);
                for(temp = 0; temp < 360; temp++)
                {   
                        glVertex3f(0.01*temp - 2,sin(3.1415927/180*temp),0);
                }   
                glEnd();
        glPopMatrix();

        glutSwapBuffers();
}

void reshape(int w, int h)
{
        glViewport(0, 0, (GLsizei) w, (GLsizei) h); 
        glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
    
        glMatrixMode(GL_MODELVIEW); //GL_PROJECTION
                glLoadIdentity();
                gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

void keyboard(unsigned char key, int x, int y)
{
        switch (key)
        {   
          default:
                  break;
        }   
}

int main(int argc, char** argv)
{
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
        glutInitWindowSize(500, 500);
        glutInitWindowPosition(100, 100);
        glutCreateWindow(argv[0]);

        glClearColor(0.0, 0.0, 0.0, 0.0);
        glShadeModel(GL_FLAT); //GL_SMOOTH

        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutKeyboardFunc(keyboard);
        glutMainLoop();
        return 0;
}

'Programming > openGL' 카테고리의 다른 글

glGet() 함수 이용하기  (0) 2011.09.28
GLUT keyboard callback function  (0) 2011.09.27
webGL  (0) 2011.09.24
depth buffer  (0) 2011.09.02
glGenLists  (0) 2011.06.09
Posted by 구차니