-
argInit() 함수 분석Computer Vision/AR 2007. 10. 24. 13:06728x90
이 함수는 윈도우 생성과 opengl 설정, 내부변수 저장을 담당한다. 포팅시 변수에 전달하는 값을 잘 확인해야함.
void argInit( ARParam *cparam, double zoom, int fullFlag, int xwin, int ywin, int hmd_flag )
{
//캠에 대한 초기화 값 및 윈도우 생성관련 값을 내부 변수에 저장한다.
int i;gl_hmd_flag = hmd_flag;
gZoom = zoom;
gImXsize = cparam->xsize;
gImYsize = cparam->ysize;
if( gl_hmd_flag == 0 ) {
gXsize = (double)cparam->xsize * gZoom;
gYsize = (double)cparam->ysize * gZoom;
}
else {
gXsize = AR_HMD_XSIZE;
gYsize = AR_HMD_YSIZE;
}
gMiniXsize = (double)cparam->xsize * gZoom / GMINI;
gMiniYsize = (double)cparam->ysize * gZoom / GMINI;if( xwin * ywin > MINIWIN_MAX ) {
if( xwin > MINIWIN_MAX ) xwin = MINIWIN_MAX;
ywin = MINIWIN_MAX / xwin;
}
gMiniXnum = xwin;
gMiniYnum = ywin;
gWinXsize = (gMiniXsize*gMiniXnum > gXsize)?
gMiniXsize*gMiniXnum: gXsize;
gWinYsize = gYsize + gMiniYsize*gMiniYnum;gCparam = *cparam;
for( i = 0; i < 4; i++ ) {
gCparam.mat[1][i] = (gCparam.ysize-1)*(gCparam.mat[2][i]) - gCparam.mat[1][i];
}
argConvGLcpara( &gCparam, AR_GL_CLIP_NEAR, AR_GL_CLIP_FAR, gl_cpara );argInit2( fullFlag );//윈도우 생성
}static void argInit2( int fullFlag )
{
//glut를 사용해 윈도우 생성.
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowPosition(0, 0);
glutInitWindowSize(gWinXsize, gWinYsize);
win = glutCreateWindow("");
if( fullFlag ) {
glutFullScreen();
gWinXsize = glutGet(GLUT_SCREEN_WIDTH);
gWinYsize = glutGet(GLUT_SCREEN_HEIGHT);
}#ifdef AR_OPENGL_TEXTURE_RECTANGLE
#if defined(GL_TEXTURE_RECTANGLE_EXT)
if( glutExtensionSupported("GL_EXT_texture_rectangle") ) {
useTextureRectangle = 1;
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxRectangleTextureSize);
}
#elif defined(GL_TEXTURE_RECTANGLE_NV)
if( glutExtensionSupported("GL_NV_texture_rectangle") ) {
useTextureRectangle = 1;
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &maxRectangleTextureSize);
}
#endif
#endifgMouseFunc = NULL;
gKeyFunc = NULL;
gMainFunc = NULL;
//텍스쳐 파라미터 설정
glGenTextures(4, glid);
glBindTexture( GL_TEXTURE_2D, glid[0] );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glBindTexture( GL_TEXTURE_2D, glid[1] );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glBindTexture( GL_TEXTURE_2D, glid[2] );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );if( gImXsize > 512 ) {
tex1Xsize1 = 512;
tex1Xsize2 = 1;
while( tex1Xsize2 < gImXsize - tex1Xsize1 ) tex1Xsize2 *= 2;
}
else {
tex1Xsize1 = 1;
while( tex1Xsize1 < gImXsize ) tex1Xsize1 *= 2;
}
tex1Ysize = 1;
while( tex1Ysize < gImYsize ) tex1Ysize *= 2;tex2Xsize = 1;
while( tex2Xsize < gImXsize/2 ) tex2Xsize *= 2;
tex2Ysize = 1;
while( tex2Ysize < gImYsize/2 ) tex2Ysize *= 2;
}'Computer Vision > AR' 카테고리의 다른 글
분석대상 함수 (0) 2007.11.02 arToolKit winapi로 포팅작업. (0) 2007.10.24 argMainLoop분석. (0) 2007.10.24 OSGART 홈페이지 (0) 2007.09.03 이번에 수행한 프로젝트 Art Education 동영상입니다. (3) 2007.08.20