'glortho'에 해당되는 글 3건

  1. 2011.10.07 glOrtho()
  2. 2011.05.01 직교좌표계와 원근좌표계 전환하기
  3. 2011.03.25 openGL - glortho() 4
Programming/openGL2011. 10. 7. 17:39
투영평면을 만드는 녀석인데 이래저래 이해가 안되는 중 
void glOrtho( GLdouble   left,
              GLdouble   right,
              GLdouble   bottom,
              GLdouble   top,
              GLdouble   nearVal,
              GLdouble   farVal);

void gluOrtho2D( GLdouble   left,
                  GLdouble   right,
                  GLdouble   bottom,
                  GLdouble   top);

This is equivalent to calling glOrtho with near = -1 and far = 1 .

[링크:  http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/gluOrtho2D.xml]  

[링크 : http://webnoon.net/entry/JOGL-glOrtho-와-Viewport의-개념잡기]

glViewport와 함께 화면비율 유지하는데 쓰이기도 한다고 한다.
[링크 : http://blog.naver.com/thooy/10096108734]

----
2011.10.09 추가
실험적으로 glOrtho를 이용하여 Z 축에 대해서 near / far 축을 3.0, -3.0 으로 늘려주고 하니
gluLookAt에 대해서도 더 넉넉하게 출력이 된다. 

glOrtho의 기본값은
(L, R, B, T, N, F)
(-1, 1, -1, 1, -1, 1) 라는데 다르게 보면

Projection Matrix가
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
과 같은 단위행렬이고,
이로 인해서 출력이 가능한 크기는 2.0 x 2.0 x 2.0의 중심이 (0,0,0)인 정사각형 공간이 된다.

즉, 이러한 이유로 기본값으로 사용할 경우
카메라의 위치가 중심에서 1.0 이상 벗어나게 되면 나오지 않게 되는 것이고,
glScale을 통해 전체적인 크기를 1.0 안에 넣거나
glOrtho를 통해 공간을 넓혀야 한다.

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

openGL의 미스테리...  (0) 2011.10.08
openglut - glutentergamemode()  (0) 2011.10.08
openGL Line 관련설정  (0) 2011.10.06
glutTimerFunc()  (0) 2011.10.05
gluLookAt() 의 기본값  (0) 2011.10.02
Posted by 구차니
Programming/openGL2011. 5. 1. 11:40
Orthogonal 과 Perspective 를 오가는 방법은 blender나 3dmax에서는 참쉬운데..
openGL 에서는 어떻게 구현하나 검색을 하다보니
glOrthoglFrustm을 바꾸어 주기만 하면 간단하게 해결된다는 글을 발견!
실험을 해보았지만 depth의 문제인지 마음처럼 효과가 나타나지는 않는듯.. ㅠ.ㅠ

[링크 : http://stackoverflow.com/questions/5765309/converting-orthogonal-camera-to-perspective-opengl]
[링크 : http://www.songho.ca/opengl/gl_transform.html]

void glOrtho( GLdouble   left,  GLdouble   right,  GLdouble   bottom,  GLdouble   top,
GLdouble   nearVal,  GLdouble   farVal);
void glFrustum( GLdouble   left,  GLdouble   right,  GLdouble   bottom,  GLdouble   top,
  GLdouble   nearVal,  GLdouble   farVal); 

[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml 

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

openGL 좌표계  (0) 2011.05.06
openGL - DoF  (2) 2011.05.03
glutReshapeWindow() 는 크기 변화가 없으면 안그려 OTL  (2) 2011.04.24
glViewport  (0) 2011.04.05
glFrustum - 절두체  (6) 2011.03.30
Posted by 구차니
Programming/openGL2011. 3. 25. 22:06
glortho() 함수는 화면상의 좌표축을 설정하는 함수이다.
#include "windows.h"
#include "GL/gl.h"
#include "GL/glut.h"

void display(void)
{
/*  clear all pixels  */
    glClear (GL_COLOR_BUFFER_BIT);
/*  draw white polygon (rectangle) with corners at
 *  (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
 */
    glColor3f (1.0, 1.0, 1.0);
    glBegin(GL_POLYGON);
        glVertex3f (0.25, 0.25, 0.0);
        glVertex3f (0.75, 0.25, 0.0);
        glVertex3f (0.75, 0.75, 0.0);
        glVertex3f (0.25, 0.75, 0.0);
    glEnd();
/*  don’t wait!  
 *  start processing buffered OpenGL routines 
 */
    glFlush ();
}
void init (void) 
{
/*  select clearing (background) color       */
    glClearColor (0.0, 0.0, 0.0, 0.0);
/*  initialize viewing values  */
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/* 
 *  Declare initial window size, position, and display mode
 *  (single buffer and RGBA).  Open window with "hello"
 *  in its title bar.  Call initialization routines.
 *  Register callback function to display graphics.
 *  Enter main loop and process events.
 */
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250); 
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;   /* ISO C requires main to return int. */
}

glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 로 설정할 경우의 결과


glOrtho(0.0, 2.0, 0.0, 2.0, -2.0, 2.0); 로 설정할 경우의 결과

대충 정리하자면, 아래 그림과 같다고 할까나~?!


[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml]

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

freeglut  (0) 2011.03.26
openGL - glbegin()  (2) 2011.03.25
visual Studio에서 openGL 돌리기  (0) 2011.03.16
윈도우에서 opengl.dll을 찾을 수 없다고 할 경우  (0) 2011.03.15
GLUT(openGL Utility Toolkit) 다운로드 (윈도우)  (0) 2011.03.15
Posted by 구차니