Programming/openGL2011. 5. 6. 00:04

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

glGenLists  (0) 2011.06.09
glutIdleFunc  (0) 2011.05.13
openGL - DoF  (2) 2011.05.03
직교좌표계와 원근좌표계 전환하기  (0) 2011.05.01
glutReshapeWindow() 는 크기 변화가 없으면 안그려 OTL  (2) 2011.04.24
Posted by 구차니
Programming/lisp2011. 5. 5. 21:57
lisp는 LISt Processing 의 약자로 프로그래밍 언어이다.
일반적으로 AI 쪽에서 많이 쓰이며
괄호가 넘쳐나는 괴랄한 언어라서 이해가 쉽지는 않다 -_-


수업을 들었었어도 이해를 할수가 없는 언어 OTL 
다시 한번 시도를 해봐야지 ㅠ.ㅠ

[링크 : http://www.cs.cmu.edu/~dst/LispBook/index.html] Common Lisp (PDF)
[링크 : http://www.paulgraham.com/onlisp.html]
    [링크 : http://www.paulgraham.com/onlisptext.html] On LISP (PDF)
[링크 : http://gigamonkeys.com/book/] Practical COMMON LISP (HTML)

[링크 : http://lisp-korea.wikispaces.com/]
[링크 : http://onlisp.blogspot.com/2008/03/common-lisp.html

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

lisp는 리스트지 prefix 표기법이 아니다  (0) 2012.11.19
lisp 관련 책  (0) 2012.01.25
lisp 문법  (0) 2012.01.24
slime / lispbox  (0) 2012.01.24
우분투에서 lisp 설치하기  (0) 2012.01.15
Posted by 구차니
Programming/openGL2011. 5. 3. 07:32
DoF는 Depth of Field로 통상 심도라고도 표현한다.(아니면 말구 -_-)
화면에 있어 어느정도 까지 촛점이 제대로 잡히는지 에 대한 수치로

생각치도 못하게 motion blur 쪽과 유사한 방법으로 openGL에서 DoF를 표현한다.
어짜피 특정 거리 이상은 촛점을 흐리게 해주면 되니,
움직이면서 흐리게 되나 거리로 흐리게 되나 결론은 "번지게" 하는 것이므로
어쩌면 당연히 동일한 함수를 이용하는 걸지도 모르겠다.

[링크 : http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node87.html]
[링크 : http://www.opengl.org/resources/code/samples/glut_examples/advanced/advanced.html]
    [링크 : http://www.opengl.org/resources/code/samples/glut_examples/advanced/field.c]
[링크 : http://glprogramming.com/red/chapter10.html]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glAccum.xml]


  



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

glutIdleFunc  (0) 2011.05.13
openGL 좌표계  (0) 2011.05.06
직교좌표계와 원근좌표계 전환하기  (0) 2011.05.01
glutReshapeWindow() 는 크기 변화가 없으면 안그려 OTL  (2) 2011.04.24
glViewport  (0) 2011.04.05
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. 4. 24. 23:32
기본적인 예제에서 reshape 쪽에 glOrtho 나 gluPerspective 를 사용하도록 코드가 구현되어 있다.
이를 변경해서, o 와 p 키를 누르면 변경되게 했는데
이래저래 reshape쪽 루틴을 타지 않길래 실험을 해보았더니
reshape는 말그대로 window의 크기 변동에 따라 다시 그리도록 하는 녀석이기 때문에
"윈도우 크기의 변화가 없으면 glutReshapeFunc 에 등록된 루틴을 태우지 않는다.

이래저래 키보드 입력해서 처리를 해야 하나..
아니면 크기를 바꾸는 꽁수를 써야하나?

Usage
void glutReshapeWindow(int width, int height);

width  New width of window in pixels.
height New height of window in pixels.

Description

glutReshapeWindow requests a change in the size of the current window. The width and height parameters are size extents in pixels. The width and height must be positive values.

The requests by glutReshapeWindow are not processed immediately. The request is executed after returning to the main event loop. This allows multiple glutReshapeWindow, glutPositionWindow, and glutFullScreen requests to the same window to be coalesced.

In the case of top-level windows, a glutReshapeWindow call is considered only a request for sizing the window. The window system is free to apply its own policies to top-level window sizing. The intent is that top-level windows should be reshaped according glutReshapeWindow's parameters. Whether a reshape actually takes effect and, if so, the reshaped dimensions are reported to the program by a reshape callback.

glutReshapeWindow disables the full screen status of a window if previously enabled. 

[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node23.html]

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

openGL - DoF  (2) 2011.05.03
직교좌표계와 원근좌표계 전환하기  (0) 2011.05.01
glViewport  (0) 2011.04.05
glFrustum - 절두체  (6) 2011.03.30
openGL tutorial - 태양과 지구 돌리기  (0) 2011.03.29
Posted by 구차니
Programming/openGL2011. 4. 5. 21:08
솔찍히 어떻게 변화하는지 이해를 못한 함수중에 하나..

원본 이미지


glViewport를 사용하지 않고 창의 크기를 변화시켰을 경우



glViewport를 사용하고 창의 크기를 변화시켰을 경우



증상은 일단 접어두고, 
glViewport는 말그대로 뷰포트의 좌표를 설정한다.
glutReshapeFunc는 윈도우의 크기가 변화될 때 불려지는
callback 함수를 등록하는 함수로 변화된 창의 넓이와 높이가 전해진다.

기본적으로 glViewport의 x,y는 좌측 하단의 좌표를 의미하며 (0,0)을 일반적으로 사용한다.
즉 윈도우 좌표계를 설정하는 것으로 1사분면의 좌표를 따른다.

void glutReshapeFunc(void (*func)(int width, int height));
void glViewport(GLint x, GLint y, GLsize iwidth, GLsize iheight);

[링크 : http://www.opengl.org/documentation/specs/glut/spec3/node48.html]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml]
 


---
2011.10.06 추가
glutReshapeFunc() 의 기본 callback 함수에는
glViewport(0, 0, (GLsizei) w, (GLsizei) h); 가 정의 되어 있다고 한다.

그리고 glViewport() 함수는 1사분면 처럼 좌측하단이 (0.0) 이다.
X, Y Specify the lower left corner of the viewport rectangle in pixels. The default is (0,0).

그리고  viewport는 화면을 분할하는 데에도 사용할수 있다.
[링크 : 
http://ivis.cwnu.ac.kr/wiki/index.php/MultipleViewport_Ex2] 
Posted by 구차니

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어  (0) 2010.05.03
어셈블리 언어 기본 템플릿  (0) 2010.04.17
Posted by 구차니
Programming/openGL2011. 3. 30. 07:35
머리를 자른건가 -_-!
절두체(frustum)라는 것은 "평행한 두 평면"으로 잘려진 도형을 의미한다.
예를 들어 직사각형처럼 긴 육면체를 두개의 평면으로 적당하게 잘라서 정육면체로 만들수 있고
원추를 잘라 마름모형 6면체로도 만들수 있다.




간단하게 원근감을 나타내기 위한 방법으로서, 투형되는 공간의 부피를 설정하는 함수이다.
void glFrustum(GLdouble left, GLdouble right,
                      GLdouble bottom, GLdouble top,
                      GLdouble nearVal, GLdouble farVal);

glFrustum describes a perspective matrix that produces a perspective projection.

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

그런데... 어떻게 윗면과 아랫면의 크기를 정하지?
무조건 중심점에서 해당 좌표까지의 크기에서 near / far로 자르는걸려나? 
Posted by 구차니
Programming/openGL2011. 3. 29. 23:22
여전히 glPushMatrix / glPopMatrix의 마법은 이해를 하지 못했지만
이녀석이 없으면 이상한 좌표축에서 이상하게 작동하는 것으로 보인다 -_-

아무튼 glPushMatrix 이후에는 추가된 개체를 중심으로
glRotate / glTranslatef 가 수행이 되며 push/pop이라는 용어가 보여주듯
스택에 차곡차곡 쌓이며 추가된 이후의 객체에 대해 적용이 된다.

스택에 들어가는 것과 공간의 변화를 한번 정리해보자면 다음과 같은데

어떻게 보면 Rotate와 Translate는 좌표계 자체를 변경시키며
왜곡된(?) 공간에 개체를 놓으면서 회전을 시키는 식으로 구성이 된 것으로 보인다.

#include "windows.h"
#include "GL/gl.h"
#include "GL/glu.h"
#include "GL/glut.h"

static int year = 0, day = 0;

void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 1.0, 1.0);

	glPushMatrix();
		glutWireSphere(1.0, 20, 16);   /* draw sun */

		glRotatef((GLfloat) year, 0.0, 1.0, 0.0);
		glTranslatef(2.0, 0.0, 0.0);
		glRotatef((GLfloat) day, 0.0, 1.0, 0.0);
		glutWireSphere(0.2, 10, 8);    /* draw smaller planet */
	glPopMatrix();

	glutSwapBuffers();
}

void reshape(int w, int h)
{
	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);
}

void keyboard(unsigned char key, int x, int y)
{
	switch (key)
	{
	  case 'd':
		  day = (day + 10) % 360;
		  glutPostRedisplay();
		  break;
	  case 'D':
		  day = (day - 10) % 360;
		  glutPostRedisplay();
		  break;
	  case 'y':
		  year = (year + 5) % 360;
		  glutPostRedisplay();
		  break;
	  case 'Y':
		  year = (year - 5) % 360;
		  glutPostRedisplay();
		  break;
	  default:
		  break;
	}
}

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize(500, 500); 
	glutInitWindowPosition(100, 100);
	glutCreateWindow(argv[0]);

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT); //GL_SMOOTH

	glutDisplayFunc(display); 
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyboard);
	glutMainLoop();
	return 0;
}

void glMatrixMode(GLenum mode);
    GL_MODELVIEW  Applies subsequent matrix operations to the modelview matrix stack.
    GL_PROJECTION Applies subsequent matrix operations to the projection matrix stack.
    GL_TEXTURE    Applies subsequent matrix operations to the texture matrix stack.
    GL_COLOR      Applies subsequent matrix operations to the color matrix stack.

void glShadeModel(GLenum mode);
    GL_FLAT     Smooth shading causes the computed colors of vertices to be interpolated as the primitive is rasterized, typically assigning different colors to each resulting pixel fragment.
    GL_SMOOTH   Flat shading selects the computed color of just one vertex and assigns it to all the pixel fragments generated by rasterizing a single primitive. 

void glPushMatrix(void);
void glPopMatrix(void);

void glTranslated(GLdouble x, GLdouble y, GLdouble z);
void glTranslatef(GLfloat x,  GLfloat y,  GLfloat z);

void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
void glutWireSphere(GLdouble radius, GLint slices, GLint stacks);

void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
void glRotatef(GLfloat angle,  GLfloat x,  GLfloat y,  GLfloat z);

void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);

void gluLookAt(GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ,
                        GLdouble centerX, GLdouble centerY, GLdouble centerZ,
                        GLdouble upX, GLdouble upY, GLdouble upZ);

[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glTranslate.xml]             glTranslatef
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml]                 glRotate
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glShadeModel.xml]        glShadeModel
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glPushMatrix.xml]          glPushMatrix / glPopMatrix
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glMatrixMode.xml]         glMatrixMode

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

[링크 : http://www.opengl.org/documentation/specs/glut/spec3/node81.html] glutWireSphere 

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

glViewport  (0) 2011.04.05
glFrustum - 절두체  (6) 2011.03.30
openGL callback function - GLUT 키보드 / 마우스 입력  (0) 2011.03.28
freeglut  (0) 2011.03.26
openGL - glbegin()  (2) 2011.03.25
Posted by 구차니
Programming/openGL2011. 3. 28. 22:42
freeGLUT가 아닌 이상에는
역시나 GLUT에는 마우스 콜백중 휠관련은 없는건가..

[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node45.html]
    [링크 : http://www.opengl.org/resources/libraries/glut/spec3/node49.html] << 키 입력
    [링크 : http://www.opengl.org/resources/libraries/glut/spec3/node50.html] << 마우스 입력
   [링크 : http://www.opengl.org/resources/libraries/glut/spec3/node54.html] << F1 와 같은 펑션키

glutKeyboardFunc(void (*func)(unsigned char key, int x, int y))
    sets key processing routine
    x and y are mouse coordinates when the key 'key' was pressed
    see glutGetModifiers for state of modifier keys (eg. ctrl,...)

glutSpecialFunc(void (*func)(int key, int x, int y));
 
glutMouseFunc(void (*func)(int button, int state, int x, int y))
    mouse function callback
    button: GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON
    state: GLUT_UP, GLUT_DOWN
    x, y: mouse coordinates 
 
[링크 : http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/OpenGL/glut_ref.html]

----
2011.09.29 추가
휠 관련 freeglut 콜백
glutMouseWheelFunc(void( *callback )( int wheel, int direction, int x, int y ));

[링크 : http://linux.die.net/man/3/glutmousewheelfunc

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

glFrustum - 절두체  (6) 2011.03.30
openGL tutorial - 태양과 지구 돌리기  (0) 2011.03.29
freeglut  (0) 2011.03.26
openGL - glbegin()  (2) 2011.03.25
openGL - glortho()  (4) 2011.03.25
Posted by 구차니