diff options
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | application.cpp | 34 | ||||
-rw-r--r-- | application.h | 3 |
3 files changed, 15 insertions, 24 deletions
@@ -2,7 +2,7 @@ env = Environment( LIBS = ['ARgsub_lite', 'ARvideo', 'AR', 'assimp'], ) -common_sources = ['application.cpp', 'pattern.cpp', 'texture.cpp', 'texturesdl.cpp'] +common_sources = ['application.cpp', 'videoprovider.cpp', 'pattern.cpp', 'texture.cpp', 'texturesdl.cpp'] if env['PLATFORM'] == 'darwin': env.Append(CPPFLAGS = '-m32') 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(); } diff --git a/application.h b/application.h index 17fe011..8795936 100644 --- a/application.h +++ b/application.h @@ -2,6 +2,7 @@ #define APPLICATION_H #include "pattern.h" +#include "videoprovider.h" #include <AR/gsub_lite.h> #include <AR/ar.h> @@ -13,6 +14,8 @@ class Application { ARGL_CONTEXT_SETTINGS_REF argl_ctx; SDL_Surface *surface; + VideoProvider* vp; + int count; bool please_quit; |