Programming/openGL2011. 10. 10. 21:02
한방에 지원하는 넘은 없는듯 -_-

대개 더블클릭은 몇 초 이내에 동일 위치이거나
약간의 위치 오차를 감안하고 몇 초 이내 클릭이니.. 타이머를 해줘서 조금 더 세밀하게 구현해야 하려나?

[링크 : http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=277362 ]
[링크 : http://www.gamedev.net/topic/511051-double-click-with-glut-resurrecting-old-post/]

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

glut Menu 관련 함수들  (0) 2011.10.10
glutAttachMenu()의 Linux용 버그  (2) 2011.10.10
openglut / freeglut 무슨 사이야?  (0) 2011.10.09
freeglut - glutMouseFunc()  (0) 2011.10.09
glut 에서 윈도우 크기 얻기  (0) 2011.10.09
Posted by 구차니
Programming/openGL2011. 10. 9. 19:26
두녀석의 관계는... 두둥!

OpenGLUT is an open source project to evolve the GLUT (OpenGL Utility Toolkit) C/C++ API. OpenGLUT uses the freeglut code base as a foundation for extending, enhancing and refining the API.
[링크 : http://openglut.sourceforge.net/
 

OpenGLUT가 freeglut에 기반을 하고 있다.

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

glutAttachMenu()의 Linux용 버그  (2) 2011.10.10
GLUT에서 더블클릭은 음..  (0) 2011.10.10
freeglut - glutMouseFunc()  (0) 2011.10.09
glut 에서 윈도우 크기 얻기  (0) 2011.10.09
openGL의 미스테리...  (0) 2011.10.08
Posted by 구차니
Programming/openGL2011. 10. 9. 19:03
glutMouseFunc()는 마우스 클릭에 대한 콜백함수이다.

void glutMouseFunc(void (*func)(int button, int state, int x, int y));
[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node50.html]

기본적으로  
GLUT_UP / GLUT_DOWN
GLUT_LEFT_BUTTON - 0x00
GLUT_MIDDLE_BUTTON - 0x01 (WHEEL_CLICK)
GLUT_RIGHT_BUTTON - 0x02
를 지원하며

추가적으로
WHEEL_DOWN - 0x03
WHEEL_UP      - 0x04
WHEEL_LEFT    - 0x05
WHEEL_RIGHT  - 0x06
을 지원하게된다.

추가적인 부분은 freeglut_std.h 쪽에도 정의되지 않은채 넘어오는 값이며
테스트는 노트북의 터치패드에서 수행하였다.

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

GLUT에서 더블클릭은 음..  (0) 2011.10.10
openglut / freeglut 무슨 사이야?  (0) 2011.10.09
glut 에서 윈도우 크기 얻기  (0) 2011.10.09
openGL의 미스테리...  (0) 2011.10.08
openglut - glutentergamemode()  (0) 2011.10.08
Posted by 구차니
Programming/openGL2011. 10. 9. 02:01
viewport 와 ortho를 이용해서 크기 조절을 하려니
glut에서 현재 윈도우 사이즈를 구할 필요가 있는데,

물론 reshape 쪽에서 얻어지는 값을 이용해서 width 와 height를 저장하는 법도 있겠지만
머.. 방법론적인 문제니까 ^^;

To obtaining the screen and window width and height using GLUT:

int screenWidth, screenHeight, windowWidth, windowHeight;

screenWidth = glutGet(GLUT_SCREEN_WIDTH);
screenHeight = glutGet(GLUT_SCREEN_HEIGHT);
windowWidth = glutGet(GLUT_WINDOW_WIDTH);
windowHeight = glutGet(GLUT_WINDOW_HEIGHT); 

[링크 : http://www.opengl.org/resources/faq/technical/window.htm
 

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

openglut / freeglut 무슨 사이야?  (0) 2011.10.09
freeglut - glutMouseFunc()  (0) 2011.10.09
openGL의 미스테리...  (0) 2011.10.08
openglut - glutentergamemode()  (0) 2011.10.08
glOrtho()  (0) 2011.10.07
Posted by 구차니
Programming/openGL2011. 10. 8. 23:54
카메라 (gluLookAt) 와 중심점의 거리가 1.0 을 넘어서면 시야에서 사라진다 -_-
이 사태를 해결하려면 어떻게 해야할려나?

웃긴건 카메라보다 뒤쪽으로 가는건 괜찮음..
아무튼 X(red) Y(green) Z(blue) 의 좌표는 (1.0) 으로 했기 땜누에 방향에 문제는 없어 보이고
화면 안쪽으로 -Z 축인건 맞은데 도대체 멀까나...
또한 축은 길이가 1 이지만, sin 곡선은 3.6 인데 중심축과 카메라의 거리가 1 이내에 있을때에는
sin 곡선도 잘리지 않음 -_-
(코드 붙여 넣고 보니.. scale을 1/4로 줘서 그렇군 .. 3.6 길이가 그러면 0.9가 되니 1 안에 들어옴)

gluLookAt(0.10, 0.0, 0.2, 0.0, 0.0, -2.0, 0.0, 1.0, 0.0)으로 설정했을 경우


gluLookAt(0.10, 0.0, 1.0, 0.0, 0.0, -2.0, 0.0, 1.0, 0.0)으로 설정했을경우




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

freeglut - glutMouseFunc()  (0) 2011.10.09
glut 에서 윈도우 크기 얻기  (0) 2011.10.09
openglut - glutentergamemode()  (0) 2011.10.08
glOrtho()  (0) 2011.10.07
openGL Line 관련설정  (0) 2011.10.06
Posted by 구차니
Programming/openGL2011. 10. 8. 22:14
glut 에서는 glutFullScreen() 을 지원하지만
해상도를 변경하는 것도 아니고, 시스템에 따라서는 전체화면 역시 제대로 되지 않는 경우도 있다.

그래서 openglut 에서 새롭게 전체화면으로 전환하는 함수를 만들었는데
glutGameModeString으로 해상도와 색상 주파수를 정하고
glutEnterGameMode 로 해상도를 변경한다. 
glutGameModeString("640x480:16@60");
glutEnterGameMode(); 

그나저나.. freeglut 와 openglut는 또 다른걸려나?

[링크 : http://linux.die.net/man/3/glutentergamemode]
[링크 : http://linux.die.net/man/3/glutgamemodestring]
[링크 : http://www.opengl.org/resources/faq/technical/gettingstarted.htm#0040

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

glut 에서 윈도우 크기 얻기  (0) 2011.10.09
openGL의 미스테리...  (0) 2011.10.08
glOrtho()  (0) 2011.10.07
openGL Line 관련설정  (0) 2011.10.06
glutTimerFunc()  (0) 2011.10.05
Posted by 구차니
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. 10. 6. 22:36
=== Line type ===
void glLineStipple(GLint Factor, GLushort Pattern) 는 점선의 종류를 고른다.
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glLineStipple.xml]
glGetIntegerv(GL_LINE_STIPPLE_PATTERN)
glGetIntegerv(GL_LINE_STIPPLE_REPEAT) 로 값을 얻어낼수 있음
 
물론 점선을 사용하기 전에는 glEnable(GL_LINE_STIPPLE)을 해주어야 한다.
GL_LINE_STIPPLE
If enabled, use the current line stipple pattern when drawing lines. See glLineStipple. 

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

엄밀하게는 Pattern은 0과 1로 나타낸 줄의 모양이고
Factor는 1bit당 몇칸(혹은 픽셀?)인지를 나타낸다.


[링크 : http://fly.cc.fer.hr/~unreal/theredbook/chapter02.html]

=== Width ===
void glLineWidth(GLfloat Width) 는 선의 굵기를 지정한다.
glGetDoublev(GL_LINE_WIDTH) 로 값을 얻어낼수 있음
기본값은 1.0
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glLineWidth.xml]

== Anti aliasing ===
glEnable(GL_LINE_SMOOTH) 은 anti-aliasing을 설정하고
glDisable(GL_LINE_SMOOTH)은 anti-aliasing을 해제한다.
glGetBooleanv(GL_LINE_SMOOTH)로 값을 얻어낼수 있음


GL_LINE_SMOOTH
If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth.

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



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

openglut - glutentergamemode()  (0) 2011.10.08
glOrtho()  (0) 2011.10.07
glutTimerFunc()  (0) 2011.10.05
gluLookAt() 의 기본값  (0) 2011.10.02
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
Posted by 구차니
Programming/openGL2011. 10. 5. 23:42
glutTimerFunc() 는 1회성 타이머를 등록한다.
그런 이유로 timer callback 내부에서 다시 타이머를 등록해 주어야 한다.

[링크: http://hekamedia.egloos.com/3449095]
[링크: http://skrcjstk.tistory.com/49]


value는 func에 넘겨주기 위한 값이다.
void glutTimerFunc(unsigned int msecs, void (*func)(int value), value); 
[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node64.html


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

glOrtho()  (0) 2011.10.07
openGL Line 관련설정  (0) 2011.10.06
gluLookAt() 의 기본값  (0) 2011.10.02
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
GLUI  (0) 2011.09.30
Posted by 구차니
Programming/openGL2011. 10. 2. 23:31
수식을 보고 초기값을 찾으려고 하지만.. 영 보이지 않고
Description

gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector.

The matrix maps the reference point to the negative z axis and the eye point to the origin. When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport. Similarly, the direction described by the UP vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport. The UP vector must not be parallel to the line of sight from the eye point to the reference point.

Let

F = ( centerX - eyeX centerY - eyeY centerZ - eyeZ )
Let UP be the vector ( upX upY upZ ) .

Then normalize as follows:

f = F | | F | |
UP ' = UP | | UP | |
Finally, let s = f × UP ' , and u = s × f .

M is then constructed as follows:

M = ( s [ 0 ] s [ 1 ] s [ 2 ] 0 u [ 0 ] u [ 1 ] u [ 2 ] 0 -f [ 0 ] -f [ 1 ] -f [ 2 ] 0 0 0 0 1 )
and gluLookAt is equivalent to glMultMatrixf(M); glTranslated (-eyex, -eyey, -eyez);
 
[링크 : http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.html]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml]  

If gluLookAt() was not called, the camera has a default position and orientation. By default, the camera is situated at the origin, points down the negative z-axis, and has an up-vector of (0, 1, 0). So in Example 3-1, the overall effect is that gluLookAt() moves the camera 5 units along the z-axis. (See "Viewing and Modeling Transformations" for more information about viewing transformations.)

[링크 : http://glprogramming.com/red/chapter03.html

테스트를 통해서 값을 구해보니
gluLookAt(0.0, 0.0, 0.0,
               0.0, 0.0, -n,
               0.0, 1.0, 0.0) ;
으로 설정을 하면 어떤 n 값(negative z-axis) 이던 동일하게 행렬값이 나온다.

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

openGL Line 관련설정  (0) 2011.10.06
glutTimerFunc()  (0) 2011.10.05
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
Posted by 구차니