'Programming'에 해당되는 글 1721건

  1. 2011.10.05 glutTimerFunc()
  2. 2011.10.04 PyOpenGL
  3. 2011.10.03 우분투와 함께하는 ruby on rails
  4. 2011.10.02 gluLookAt() 의 기본값
  5. 2011.10.02 GLUT 키보드 콜백 함수 총정....리? 2
  6. 2011.09.30 GLUI
  7. 2011.09.30 glEnable() / glDisable()
  8. 2011.09.30 glGet()
  9. 2011.09.28 glGet() 함수 이용하기
  10. 2011.09.27 GLUT keyboard callback function
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 구차니
Python의 openGL 바인딩이다.
linux 개발용 노트북을 해놔서 C를 통해 개발을 해도 상관은 없지만
다른 언어도 배울겸 한번 openGL을 python으로 하면 어떨까? 싶어서 찾아본 내용인데 흐음..
함수 이름이라던가 거의 100% C와 동일한데 별 의미가 없으려나?

import OpenGL 
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import * 

[링크 : http://pyopengl.sourceforge.net/]
[링크 : http://pypi.python.org/pypi/PyOpenGL-Demo] demo 

'Programming > python(파이썬)' 카테고리의 다른 글

python이 인기라는데..  (0) 2014.03.19
python2 vs python3  (0) 2013.01.02
python 3.2.2 64bit 버전 설치  (4) 2011.09.13
python 버전 골라서 실행하기  (0) 2011.05.08
python C/api - PyObject_GetAttrString()  (0) 2010.04.06
Posted by 구차니
Programming/ruby2011. 10. 3. 23:52
혹시나 해서 찾아봤더니 패키지로 존재 두둥!

sudo apt-get install rails
[링크 : https://help.ubuntu.com/10.04/serverguide/C/ruby-on-rails.html]
[링크 : https://help.ubuntu.com/community/RubyOnRails]

[링크 : http://www.ruby-lang.org
[링크 : http://rubyonrails.org/]

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 구차니
Programming/openGL2011. 10. 2. 21:12
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y));
void glutSpecialFunc(void (*func)(int key, int x, int y));

int x, int y 에는 윈도우의 마우스 좌표가 출력되며
glutSpecialFunc는 F1~F12 / 화살표 / PgUp / PgDn / Home / End / Insert 에 대한 입력을 받고
glutKeyboardFunc 는 그 외에 모든 키보드 입력을 받는다.

glutSpecialFunc 관련해서는 아래의 파일에 정의가 되어있고, 샘플용 콜백함수도 같이 투척!
$ vi /usr/include/GL/freeglut_std.h
124  * GLUT API macro definitions -- the special key codes:
125  */
126 #define  GLUT_KEY_F1                        0x0001
127 #define  GLUT_KEY_F2                        0x0002
128 #define  GLUT_KEY_F3                        0x0003
129 #define  GLUT_KEY_F4                        0x0004
130 #define  GLUT_KEY_F5                        0x0005
131 #define  GLUT_KEY_F6                        0x0006
132 #define  GLUT_KEY_F7                        0x0007
133 #define  GLUT_KEY_F8                        0x0008
134 #define  GLUT_KEY_F9                        0x0009
135 #define  GLUT_KEY_F10                       0x000A
136 #define  GLUT_KEY_F11                       0x000B
137 #define  GLUT_KEY_F12                       0x000C
138 #define  GLUT_KEY_LEFT                      0x0064
139 #define  GLUT_KEY_UP                        0x0065
140 #define  GLUT_KEY_RIGHT                     0x0066
141 #define  GLUT_KEY_DOWN                      0x0067
142 #define  GLUT_KEY_PAGE_UP                   0x0068
143 #define  GLUT_KEY_PAGE_DOWN                 0x0069
144 #define  GLUT_KEY_HOME                      0x006A
145 #define  GLUT_KEY_END                       0x006B
146 #define  GLUT_KEY_INSERT                    0x006C 

void keyboard_spe(int key, int x, int y)
{
    switch (key)
    {
        case GLUT_KEY_F1:
        case GLUT_KEY_F2:
        case GLUT_KEY_F3:
        case GLUT_KEY_F4:
        case GLUT_KEY_F5:
        case GLUT_KEY_F6:
        case GLUT_KEY_F7:
        case GLUT_KEY_F8:
        case GLUT_KEY_F9:
        case GLUT_KEY_F10:
        case GLUT_KEY_F11:
        case GLUT_KEY_F12:
            break;
        case GLUT_KEY_LEFT:
        case GLUT_KEY_RIGHT:
        case GLUT_KEY_UP:
        case GLUT_KEY_DOWN:
            break;
        case GLUT_KEY_PAGE_UP:
        case GLUT_KEY_PAGE_DOWN:
            break;
        case GLUT_KEY_HOME:
        case GLUT_KEY_END:
        case GLUT_KEY_INSERT:
            break;

        default:
           break;
    }
}

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

void main()
{
  // ...
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(keyboard_spe);
  // ...
}

연유는 모르겠으나,
glutSpecialFunc()와 glutKeyboardFunc() 의 key는 char와 int 형으로 크기가 다르게 정의되어 있으니 주의요망!

2011/09/27 - [Programming/openGL] - GLUT keyboard callback function
2011/03/28 - [Programming/openGL] - openGL callback function - GLUT 키보드 / 마우스 입력

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

glutTimerFunc()  (0) 2011.10.05
gluLookAt() 의 기본값  (0) 2011.10.02
GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
Posted by 구차니
Programming/openGL2011. 9. 30. 13:55
GLUI는 C++ 기반의(으악!) GLUT로 만든 User Interface 라이브러이다.
C++이라니 웬지 거부감이.. 들지만 OTL
openGL/GLUT와 마찬가지로 멀티플랫폼을 지원하는 2차원 인터페이스를 작성하는데에는 꽤 괜찮은 선택이라고 보여진다.


[링크 : http://glui.sourceforge.net/]

ubuntu에서는 libglui-dev 로 설치하면 끝!
[링크 : http://packages.debian.org/lenny/libglui-dev]

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

gluLookAt() 의 기본값  (0) 2011.10.02
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
Posted by 구차니
Programming/openGL2011. 9. 30. 12:32
void glEnablei(GLenum cap, GLuint index);
void glDisablei(GLenum cap, GLuint index);

glGet()에서 빼올수 있다는건 다른데서 설정을 하기 때문인데
이러한 설정들은 glEnable() / glDisable()을 통해 이루어진다. 


[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glEnable.xml]
2011/09/30 - [Programming/openGL] - glGet() 

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

GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
GLUI  (0) 2011.09.30
glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
GLUT keyboard callback function  (0) 2011.09.27
Posted by 구차니
Programming/openGL2011. 9. 30. 12:08
void glGetBooleanv( GLenum   pname, GLboolean *   params);
void glGetDoublev( GLenum   pname, GLdouble *   params);
void glGetFloatv( GLenum   pname, GLfloat *    params);
void glGetIntegerv( GLenum   pname, GLint *   params);

glGet()의 인자들만 추려내보니 엄청 많다는걸 새삼 깨닫는중
아래의 인자들은 /usr/include/GL/gl.h 에 포함되어 있다.

시간되면 형(type)이랑 리턴되는 변수 갯수에 따라서 정리 해야할듯.
 

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

GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
GLUT keyboard callback function  (0) 2011.09.27
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
Posted by 구차니
Programming/openGL2011. 9. 28. 22:45
glGet() 함수 사용법을 익힐겸 해보니 흐음..
일단 아무런 설정없이 openGL 에서 생성해서 해보니 다음과 같은 행렬을 뽑아내준다.


GL_MODELVIEW_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 0.000000 1.000000 
GL_PROJECTION_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 0.000000 1.000000  

주석을 풀고 변경된 크기로 보면은 다음과 같이 나온다.

 
GL_MODELVIEW_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 -5.000000 1.000000 
GL_PROJECTION_MATRIX
1.732051 0.000000 0.000000 0.000000 
0.000000 1.732051 0.000000 0.000000 
0.000000 0.000000 -1.105263 -1.000000 
0.000000 0.000000 -2.105263 0.000000 

gluLookat()에 의해서 MODELVIEW_MATRIX에서 -5가 추가된듯 하고
PROJECTION은 이해불가 ㅋㅋㅋ
void reshape(int w, int h)
{
	GLdouble mat[16];
	int i=0;

	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);
*/
	printf("GL_MODELVIEW_MATRIX\n");
	glGetDoublev(GL_MODELVIEW_MATRIX,mat);
	for(i=0; i<16;i++)
	{
		printf("%f ",mat[i]);
		if(i % 4 == 3) printf("\n");
	}

	printf("GL_PROJECTION_MATRIX\n");
	glGetDoublev(GL_PROJECTION_MATRIX,mat);
	for(i=0; i<16;i++)
	{
		printf("%f ",mat[i]);
		if(i % 4 == 3) printf("\n");
	}
}

[링크 : http://www.morrowland.com/apron/tutorials/gl/gl_matrix.php]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml]

[링크 : http://www.songho.ca/opengl/gl_transform.html
[링크 : http://www.cprogramming.com/tutorial/3d/rotationMatrices.html

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

glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
GLUT keyboard callback function  (0) 2011.09.27
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
webGL  (0) 2011.09.24
Posted by 구차니
Programming/openGL2011. 9. 27. 22:58
GLUT의 키보드 관련 콜백함수는 두가지가 존재한다.
glutkeyboardFunc()
glutspecialFunc()

glutkeyboardFunc()는 일반적인 아스키 값들을 받아 들인다면
glutspecialFunc()는 F1~F12 / PgUp / PgDn / Home / End / Insert 를 받아들인다.


[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node49.htmlglutkeyboardFunc() 
[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node54.htmlglutspecialFunc()
[링크 : http://freeglut.sourceforge.net/docs/api.php]

2011/03/28 - [Programming/openGL] - openGL callback function - GLUT 키보드 / 마우스 입력

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

glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
webGL  (0) 2011.09.24
depth buffer  (0) 2011.09.02
Posted by 구차니