'2019/05/28'에 해당되는 글 2건

  1. 2019.05.28 gluPerspective()
  2. 2019.05.28 점심의 자전거.. -_ㅠ 2
Programming/openGL2019. 5. 28. 19:04

오랫만에 다시 공부하게 되네 후..

일단 위의 함수는 z값에 대한 Near와 Far 값이 존재하는데

둘다 양수여야 하고 0 이상의 값을 가져야 한다.

(그걸 모르고 예전엔 0을 넣고 왜 안되는 거야! 하고 있었으니..)

zNear

Specifies the distance from the viewer to the near clipping plane (always positive).

zFar

Specifies the distance from the viewer to the far clipping plane (always positive).

Notes

Depth buffer precision is affected by the values specified for zNear and zFar. The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If

r = zFar zNear

roughly log 2  r bits of depth buffer precision are lost. Because r approaches infinity as zNear approaches 0, zNear must never be set to 0.

[링크 : https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml]

 

실제코드인진 모르겠지만

znear가 0 이면, ymax xmax가 다 0이 되네

// Matrix will receive the calculated perspective matrix.
// You would have to upload to your shader
// or use glLoadMatrixf if you aren't using shaders.
void glhPerspectivef2(float *matrix, float fovyInDegrees, float aspectRatio,
                      float znear, float zfar)
{
    float ymax, xmax;
    float temp, temp2, temp3, temp4;
    ymax = znear * tanf(fovyInDegrees * M_PI / 360.0);
    // ymin = -ymax;
    // xmin = -ymax * aspectRatio;
    xmax = ymax * aspectRatio;
    glhFrustumf2(matrix, -xmax, xmax, -ymax, ymax, znear, zfar);
}

 

DIV/0의 향연이니.. 아마 입력 단계에서 zNear / nFar가 0이면 계산을 하지 않도록 할지도?

void glhFrustumf2(float *matrix, float left, float right, float bottom, float top,
                  float znear, float zfar)
{
    float temp, temp2, temp3, temp4;
    temp = 2.0 * znear;
    temp2 = right - left;
    temp3 = top - bottom;
    temp4 = zfar - znear;
    matrix[0] = temp / temp2;
    matrix[1] = 0.0;
    matrix[2] = 0.0;
    matrix[3] = 0.0;
    matrix[4] = 0.0;
    matrix[5] = temp / temp3;
    matrix[6] = 0.0;
    matrix[7] = 0.0;
    matrix[8] = (right + left) / temp2;
    matrix[9] = (top + bottom) / temp3;
    matrix[10] = (-zfar - znear) / temp4;
    matrix[11] = -1.0;
    matrix[12] = 0.0;
    matrix[13] = 0.0;
    matrix[14] = (-temp * zfar) / temp4;
    matrix[15] = 0.0;
}

[링크 : https://www.khronos.org/opengl/wiki/GluPerspective_code]

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

glulookat / gluperspective / glfrustrum / glortho  (0) 2019.05.30
gl model view projection mat  (0) 2019.05.29
glfw3 in ubuntu 19.04  (0) 2019.05.10
openGL vao(Vertex Array Object)  (0) 2019.05.07
glfw - gl framework  (0) 2019.05.07
Posted by 구차니
개소리 왈왈/자전거2019. 5. 28. 12:42

1. 나가다가 핸폰 떨궈서 S펜 뽀개먹음..

뽀각~

 

일단은.. 순간접착제로 해놨는데 접합부가 적어서 힘을 못 받을것 같으니 최대한 오래 마르도록 냅둬야겠다..

예전에 3만원 한 것 같은데, 찾아보니 많이 착해진 듯?

 

[링크 : http://itempage3.auction.co.kr/DetailView.aspx?itemno=B370174078]

 

2. 엘리베이터 기다리다 앞 기어에 다리 찍혀서 피 철철

 

아놔.. 무슨 날이냐...

 

'개소리 왈왈 > 자전거' 카테고리의 다른 글

오랫만에 자전거  (0) 2020.05.06
자전거 대행진  (0) 2019.06.09
2019 자전거 대행진 신청!  (2) 2019.04.24
2019 서울 자전거 대행진!  (2) 2019.04.23
출근길 광고전단 - 바이크파크 + 자전거  (2) 2019.04.03
Posted by 구차니