본문 바로가기
Language/C++ & openGL

오픈지엘 gluLookAt 시점 변환 모델 잘림 해결, 뷰포트

by javapp 자바앱 2020. 6. 5.
728x90

1.

void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble atx, GLdouble aty, GLdouble atz,
GLdouble upx, GLdouble upy, GLdouble upz);


2. Arguments


A. 카메라 위치 : (eyex, eyey, eyez)
B. 카메라가 바라보는 점 (초점의 위치) : (atx, aty, atz)
C. 카메라 기울임(Orientation) : (upx, upy, upz)

 

 

void MyDisplay()

{

        glClear(GL_COLOR_BUFFER_BIT);

       

        gluLookAt(1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

        glColor3f(0.0f, 1.0f, 1.0f);

        glutWireTeapot(0.5);

        glutSwapBuffers();

 

        //glFlush();

}

 

카메라 위치를 (1,1,0) 에 뒀는데 잘려버렸다..

뭐가 문제인지 한참을 헤매다가 ..

 


 

void MyDisplay()

{

        glClear(GL_COLOR_BUFFER_BIT);

       

        gluLookAt(0.5, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

        glColor3f(0.0f, 1.0f, 1.0f);

        glutWireTeapot(0.5);

        glutSwapBuffers();

 

        //glFlush();

}

위치를 반으로 줄이니깐 잘 나오기 시작했다.

(1,1,0) 은 직선거리가 루트2(=1.414141) 가 나와서 그런 것 같다.

 

 

 


void MyDisplay()

{

glClear(GL_COLOR_BUFFER_BIT);



//좌상

glViewport(0, height / 2, width / 2, height / 2);

glLoadIdentity();

gluLookAt(0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);

glColor3f(0.0f, 0.0f, 1.0f);

glutWireTeapot(0.5);



//우상

glViewport(width / 2, height / 2, width / 2, height / 2);

glLoadIdentity();

gluLookAt(0.5, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

glColor3f(0.0f, 1.0f, 1.0f);

glutWireTeapot(0.5);



//좌하

glViewport(0, 0, width / 2, height / 2);

glLoadIdentity();

gluLookAt(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

glColor3f(1.0f, 0.0f, 0.0f);

glutWireTeapot(0.5);



//우하

glViewport(width / 2, 0, width / 2, height / 2);

glLoadIdentity();

gluLookAt(1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

glColor3f(0.0f, 1.0f, 0.0f);

glutWireTeapot(0.5);



glutSwapBuffers();



//glFlush();

}

댓글