diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-04-06 21:38:17 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-04-06 21:38:17 +0200 |
commit | a6c870a28b0acab5df9d51e0224d85a3c4bd7324 (patch) | |
tree | 344b67db85fa53363d96c220686e6a9ee46ea0d0 /application.cpp | |
parent | 21fb3fbcaf9e557fd382991350b84672e659a18d (diff) |
Added VideoProvider wrapper class around ARvideo.
Diffstat (limited to 'application.cpp')
-rw-r--r-- | application.cpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/application.cpp b/application.cpp index a1b9d22..3ff3ab3 100644 --- a/application.cpp +++ b/application.cpp @@ -1,7 +1,6 @@ #include "application.h" #include <AR/gsub_lite.h> -#include <AR/video.h> #include <AR/param.h> #include <SDL/SDL_opengl.h> @@ -11,26 +10,15 @@ Application::Application() { ARParam wparam; - - // Open video device. - if(arVideoOpen(NULL) < 0) { - throw(std::runtime_error("arVideoOpen() failed.")); - } - - // Find the size of the window. - int xsize, ysize; - if(arVideoInqSize(&xsize, &ysize) < 0) { - throw(std::runtime_error("arVideoInqSize() failed.")); - } - - std::cout << "Image size (x, y) = (" << xsize << ", " << ysize << ")" << std::endl; - + + vp = new VideoProvider(); + // Set the initial camera parameters. if(arParamLoad("camera_para.dat", 1, &wparam) < 0) { throw(std::runtime_error("arParamLoad() failed.")); } - arParamChangeSize(&wparam, xsize, ysize, &cparam); + arParamChangeSize(&wparam, vp->xsize, vp->ysize, &cparam); arInitCparam(&cparam); std::cout << "*** Camera Parameters ***" << std::endl; arParamDisp(&cparam); @@ -64,7 +52,7 @@ Application::Application() { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // Get our surface - surface = SDL_SetVideoMode(xsize, ysize, 32, flags); + surface = SDL_SetVideoMode(vp->xsize, vp->ysize, 32, flags); if(!surface) { throw(std::runtime_error("Video mode set failed")); } @@ -85,13 +73,13 @@ Application::Application() { } Application::~Application() { - arVideoCapStop(); - arVideoClose(); + delete vp; arglCleanup(argl_ctx); } void Application::run() { - arVideoCapStart(); + vp->start(); + while(1) { SDL_Event event; SDL_PollEvent(&event); @@ -109,9 +97,9 @@ void Application::run() { } void Application::main_loop(void) { - ARUint8 *dataPtr; + uint8_t *dataPtr; - if((dataPtr = (ARUint8 *)arVideoGetImage()) == NULL) { + if((dataPtr = vp->get()) == NULL) { arUtilSleep(10); return; } @@ -143,7 +131,7 @@ void Application::main_loop(void) { glDisable( GL_DEPTH_TEST ); - arVideoCapNext(); + vp->next(); SDL_GL_SwapBuffers(); } |