diff options
-rw-r--r-- | SConstruct | 2 | ||||
-rwxr-xr-x | foo.cpp | 46 |
2 files changed, 34 insertions, 14 deletions
@@ -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'], ) @@ -5,7 +5,7 @@ #include <OpenGL/gl.h> #include <GLUT/glut.h> #endif -#include <AR/gsub.h> +#include <AR/gsub_lite.h> #include <AR/video.h> #include <AR/param.h> #include <AR/ar.h> @@ -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; |