From 19baf2b8acfb6574120fa6bf54b28851d05a5fc5 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 9 Feb 2010 13:31:57 +0100 Subject: Replaced ARgsub with ARgsub_lite. --- SConstruct | 2 +- foo.cpp | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/SConstruct b/SConstruct index 1040b0c..aa8e2a2 100644 --- a/SConstruct +++ b/SConstruct @@ -1,7 +1,7 @@ env = Environment( CPPFLAGS = '-m32', LINKFLAGS = '-m32', - LIBS = ['ARgsub', 'ARvideo', 'AR', 'png'], + LIBS = ['ARgsub_lite', 'ARvideo', 'AR', 'png'], FRAMEWORKS = ['GLUT', 'OpenGL', 'QuickTime', 'Carbon', 'AppKit'], ) diff --git a/foo.cpp b/foo.cpp index c924245..e6354ba 100755 --- a/foo.cpp +++ b/foo.cpp @@ -5,7 +5,7 @@ #include #include #endif -#include +#include #include #include #include @@ -47,7 +47,7 @@ class Pattern { void draw() { double gl_para[16]; - argConvGlpara(patt_trans_kake, gl_para); + arglCameraView(patt_trans_kake, gl_para, 1.0); glMatrixMode(GL_MODELVIEW); glLoadMatrixd(gl_para); @@ -70,6 +70,20 @@ class Pattern { Pattern* patt; +ARParam cparam; + +ARGL_CONTEXT_SETTINGS_REF argl_ctx; + +static void key_event(unsigned char key, int x, int y); +static void main_loop(void); + +static void display_func(void) { + glutKeyboardFunc(key_event); + glutDisplayFunc(main_loop); + glutIdleFunc(main_loop); +} + + static void init() { ARParam wparam; @@ -87,7 +101,6 @@ static void init() { std::cout << "Image size (x, y) = (" << xsize << ", " << ysize << ")" << std::endl; // Set the initial camera parameters. - ARParam cparam; if(arParamLoad("camera_para.dat", 1, &wparam) < 0) { throw(std::runtime_error("arParamLoad() failed.")); } @@ -98,7 +111,12 @@ static void init() { arParamDisp(&cparam); // Open the graphics window. - argInit(&cparam, 1.0, 0, 0, 0, 0); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); + glutInitWindowPosition(0, 0); + glutInitWindowSize(1280, 1024); + glutCreateWindow(""); + + argl_ctx = arglSetupForCurrentContext(); // Texturing glEnable(GL_TEXTURE_2D); @@ -114,7 +132,7 @@ static void init() { static void cleanup(void) { arVideoCapStop(); arVideoClose(); - argCleanup(); + arglCleanup(argl_ctx); } int count = 0; @@ -139,8 +157,7 @@ static void main_loop(void) { if(count == 0) arUtilTimerReset(); count++; - argDrawMode2D(); - argDispImage(dataPtr, 0, 0); + arglDispImage(dataPtr, &cparam, 1.0, argl_ctx); ARMarkerInfo* marker_info; int marker_num; @@ -149,8 +166,11 @@ static void main_loop(void) { throw(std::runtime_error("arDetectMarker() failed.")); } - argDrawMode3D(); - argDraw3dCamera( 0, 0 ); + GLdouble p[16]; + arglCameraFrustum(&cparam, 0.1, 1000, p); + glMatrixMode(GL_PROJECTION); + glLoadMatrixd(p); + glClearDepth( 1.0 ); glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); @@ -161,17 +181,17 @@ static void main_loop(void) { glDisable( GL_DEPTH_TEST ); arVideoCapNext(); - argSwapBuffers(); + glutSwapBuffers(); } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { try { glutInit(&argc, argv); init(); patt = new Pattern(); arVideoCapStart(); - argMainLoop( NULL, key_event, main_loop ); + glutDisplayFunc(display_func); + glutMainLoop(); } catch(std::runtime_error e) { cleanup(); std::cerr << "Exception caught: " << e.what() << std::endl; -- cgit v1.2.3