Update of /cvsroot/artoolkit/artoolkit/examples/twoView
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2655
Modified Files:
twoView.vcproj twoView.dsp Makefile.in twoView.c
Log Message:
Rewrite of twoView example.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile.in 22 Nov 2004 03:37:58 -0000 1.1
--- Makefile.in 25 Nov 2004 21:42:30 -0000 1.2
***************
*** 1,27 ****
! INC_DIR= ../../include
! LIB_DIR= ../../lib
! BIN_DIR= ../../bin
!
! LDFLAG=@LDFLAG@ -L$(LIB_DIR)
! LIBS= -lARgsub -lARvideo -lAR @LIBS@
! CFLAG= @CFLAG@ -I$(INC_DIR)
!
! OBJS =
! HEADDERS =
!
! all: $(BIN_DIR)/twoView
!
! $(BIN_DIR)/twoView: twoView.o $(OBJS)
! cc -o $(BIN_DIR)/twoView twoView.o $(OBJS) $(LDFLAG) $(LIBS)
!
! twoView.o: twoView.c $(HEADDERS)
! cc -c $(CFLAG) twoView.c
!
! clean:
! rm -f *.o
! rm -f $(BIN_DIR)/twoView
!
! allclean:
! rm -f *.o
! rm -f $(BIN_DIR)/twoView
! rm -f Makefile
--- 1,27 ----
! INC_DIR= ../../include
! LIB_DIR= ../../lib
! BIN_DIR= ../../bin
!
! LDFLAG=@LDFLAG@ -L$(LIB_DIR)
! LIBS= -lARgsub_lite -lARvideo -lAR @LIBS@
! CFLAG= @CFLAG@ -I$(INC_DIR)
!
! OBJS =
! HEADDERS =
!
! all: $(BIN_DIR)/twoView
!
! $(BIN_DIR)/twoView: twoView.o $(OBJS)
! cc -o $(BIN_DIR)/twoView twoView.o $(OBJS) $(LDFLAG) $(LIBS)
!
! twoView.o: twoView.c $(HEADDERS)
! cc -c $(CFLAG) twoView.c
!
! clean:
! rm -f *.o
! rm -f $(BIN_DIR)/twoView
!
! allclean:
! rm -f *.o
! rm -f $(BIN_DIR)/twoView
! rm -f Makefile
Index: twoView.vcproj
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** twoView.vcproj 22 Nov 2004 03:37:58 -0000 1.1
--- twoView.vcproj 25 Nov 2004 21:42:29 -0000 1.2
***************
*** 30,34 ****
Name="VCLinkerTool"
AdditionalOptions="/DEBUG"
! AdditionalDependencies="libARd.lib libARgsubd.lib libARvideod.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName)d.exe"
AdditionalLibraryDirectories=""$(ProjectDir)/../../lib""
--- 30,34 ----
Name="VCLinkerTool"
AdditionalOptions="/DEBUG"
! AdditionalDependencies="libARd.lib libARgsub_lited.lib libARvideod.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName)d.exe"
AdditionalLibraryDirectories=""$(ProjectDir)/../../lib""
***************
*** 77,81 ****
<Tool
Name="VCLinkerTool"
! AdditionalDependencies="libAR.lib libARgsub.lib libARvideo.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName).exe"
AdditionalLibraryDirectories=""$(ProjectDir)/../../lib""/>
--- 77,81 ----
<Tool
Name="VCLinkerTool"
! AdditionalDependencies="libAR.lib libARgsub_lite.lib libARvideo.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName).exe"
AdditionalLibraryDirectories=""$(ProjectDir)/../../lib""/>
Index: twoView.c
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** twoView.c 22 Nov 2004 03:37:58 -0000 1.1
--- twoView.c 25 Nov 2004 21:42:30 -0000 1.2
***************
*** 1,233 ****
! #ifdef _WIN32
! #include <windows.h>
! #endif
! #include <stdio.h>
! #include <stdlib.h>
! #ifndef __APPLE__
! #include <GL/gl.h>
! #include <GL/glut.h>
! #else
! #include <OpenGL/gl.h>
! #include <GLUT/glut.h>
! #endif
! #include <AR/gsub.h>
! #include <AR/video.h>
! #include <AR/param.h>
! #include <AR/ar.h>
!
! /*****************************************************************************/
! // modified by Thomas Pintaric, Vienna University of Technology
!
! #ifdef _WIN32
! char *vconf1 = "flipV,showDlg"; // see video.h for a list of supported parameters
! char *vconf2 = "flipV,showDlg"; // see video.h for a list of supported parameters
! #else
! char *vconf1 = "-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240";
! char *vconf2 = "-dev=/dev/video3 -channel=0 -palette=YUV420P -width=320 -height=240";
! #endif
! /*****************************************************************************/
!
! int xsize, ysize;
! int thresh = 100;
! int count = 0;
!
! char *cparam_name = "Data/camera_para.dat";
! ARParam cparam;
!
! char *patt_name = "Data/patt.hiro";
! int patt_id;
! double patt_width = 80.0;
! double patt_center[2] = {0.0, 0.0};
! double patt_trans[3][4];
!
! AR2VideoParamT* video1;
! AR2VideoParamT* video2;
!
! static void init(void);
! static void cleanup(void);
! static void keyEvent( unsigned char key, int x, int y);
! static void mainLoop(void);
! static void draw(int );
!
! int main(int argc, char **argv)
! {
! init();
!
! ar2VideoCapStart(video1);
! ar2VideoCapStart(video2);
! argMainLoop( NULL, keyEvent, mainLoop );
! return (0);
! }
!
! static void keyEvent( unsigned char key, int x, int y)
! {
! /* quit if the ESC key is pressed */
! if( key == 0x1b ) {
! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
! cleanup();
! exit(0);
! }
! }
!
! /* main loop */
! static void mainLoop(void)
! {
! ARUint8 *dataPtr;
! ARMarkerInfo *marker_info;
! int marker_num;
! int j, k;
!
! /* grab a vide frame */
! if( (dataPtr = (ARUint8 *)ar2VideoGetImage(video1)) == NULL ) {
! arUtilSleep(2);
! return;
! }
! if( count == 0 ) arUtilTimerReset();
! count++;
!
! argDrawMode2D();
! argDispImage( dataPtr, 0,0 );
!
! /* detect the markers in the video frame */
! if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
! cleanup();
! exit(0);
! }
!
! ar2VideoCapNext(video1);
!
! /* check for object visibility */
! k = -1;
! for( j = 0; j < marker_num; j++ ) {
! if( patt_id == marker_info[j].id ) {
! if( k == -1 ) k = j;
! else if( marker_info[k].cf < marker_info[j].cf ) k = j;
! }
! }
!
! /* get the transformation between the marker and the real camera */
! arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
!
! draw(1);
!
! /* grab a vide frame */
! if( (dataPtr = (ARUint8 *)ar2VideoGetImage(video2)) == NULL ) {
! arUtilSleep(2);
! return;
! }
! if( count == 0 ) arUtilTimerReset();
! count++;
!
! argDrawMode2D();
! glViewport(0,0,xsize,ysize);
! argDispImage( dataPtr, 0,0 );
!
! /* detect the markers in the video frame */
! if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
! cleanup();
! exit(0);
! }
!
! ar2VideoCapNext(video2);
!
! /* check for object visibility */
! k = -1;
! for( j = 0; j < marker_num; j++ ) {
! if( patt_id == marker_info[j].id ) {
! if( k == -1 ) k = j;
! else if( marker_info[k].cf < marker_info[j].cf ) k = j;
! }
! }
!
! /* get the transformation between the marker and the real camera */
! arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
!
! draw(2);
!
! argSwapBuffers();
! }
!
! static void init( void )
! {
! ARParam wparam;
!
! /* open the video path */
! video1=ar2VideoOpen( vconf1 );
! /* find the size of the window */
! ar2VideoInqSize(video1,&xsize, &ysize);
! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
!
! /* open the video path */
! video2=ar2VideoOpen( vconf2 );
! /* find the size of the window */
! ar2VideoInqSize(video2,&xsize, &ysize);
! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
!
! /* set the initial camera parameters */
! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
! printf("Camera parameter load error !!\n");
! exit(0);
! }
! arParamChangeSize( &wparam, xsize, ysize, &cparam );
! arInitCparam( &cparam );
! printf("*** Camera Parameter ***\n");
! arParamDisp( &cparam );
!
! if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
! printf("pattern load error !!\n");
! exit(0);
! }
! argDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS;
! /* open the graphics window */
! argInit( &cparam, 1.0, 0, 0, 2, 0 );
! }
!
! /* cleanup function called when program exits */
! static void cleanup(void)
! {
! ar2VideoCapStop(video1);
! ar2VideoCapStop(video2);
! ar2VideoClose(video1);
! ar2VideoClose(video2);
! argCleanup();
! }
!
! static void draw(int view)
! {
! double gl_para[16];
! GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
! GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
! GLfloat mat_flash_shiny[] = {50.0};
! GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
! GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
! GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
!
! argDrawMode3D();
! argDraw3dCamera( 0, 0 );
! if (view==2)
! glViewport(0,0,xsize,ysize);
! glClearDepth( 1.0 );
! glClear(GL_DEPTH_BUFFER_BIT);
! glEnable(GL_DEPTH_TEST);
! glDepthFunc(GL_LEQUAL);
!
! /* load the camera transformation matrix */
! argConvGlpara(patt_trans, gl_para);
! glMatrixMode(GL_MODELVIEW);
! glLoadMatrixd( gl_para );
!
! glEnable(GL_LIGHTING);
! glEnable(GL_LIGHT0);
! glLightfv(GL_LIGHT0, GL_POSITION, light_position);
! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);
! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
! glMatrixMode(GL_MODELVIEW);
! glTranslatef( 0.0, 0.0, 25.0 );
! glutSolidCube(50.0);
! glDisable( GL_LIGHTING );
!
! glDisable( GL_DEPTH_TEST );
! }
--- 1,682 ----
! /*
! * twoView.c
! *
! * Some code to demonstrate grabbing from two video sources.
! * Press '?' while running for help.
! *
! * Copyright (c) 2004-2004 Philip Lamb (PRL) ph...@ed.... All rights reserved.
! *
! * Rev Date Who Changes
! * 1.0.0 2004-10-27 PRL Initial version.
! *
! */
!
! // ============================================================================
! // Includes
! // ============================================================================
!
! #include <stdio.h> // fprintf(), stderr
! #include <stdlib.h> // malloc(), free(), atexit()
! #ifdef __APPLE__
! # include <GLUT/glut.h>
! # include <OpenGL/glext.h>
! #else
! # include <GL/glut.h>
! # include <GL/glext.h>
! #endif
! #include <AR/config.h>
! #include <AR/video.h>
! #include <AR/param.h> // arParamDisp()
! #include <AR/ar.h>
! #include <AR/gsub_lite.h>
!
! // ============================================================================
! // Constants and types.
! // ============================================================================
!
! #define VIEW_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units.
! #define VIEW_DISTANCE_MIN 0.1 // Objects closer to the camera than this will not be displayed.
! #define VIEW_DISTANCE_MAX 100.0 // Objects further away from the camera than this will not be displayed.
!
! // For cases in which we have multiple OpenGL contexts, never more than this many.
! #define CONTEXTSACTIVECOUNT 2
! #define CONTEXTSACTIVECOUNTMAX CONTEXTSACTIVECOUNT
!
! // Structure to keep track of per-camera variables.
! typedef struct {
! int apiContextIndex; // API-specific index into an array of display contexts.
! ARParam ARTCparam; // Camera parameter.
! AR2VideoParamT *ARTVideo; // Video parameters
! ARUint8 *ARTImage; // Most recent image.
! long callCountMarkerDetect; // Frames received.
! double patt_trans[3][4]; // Marker transformation.
! BOOL patt_found; // Whether marker transformation is valid.
! ARGL_CONTEXT_SETTINGS_REF arglSettings; // Settings from ARGL.
! } CONTEXT_INFO;
!
! // ============================================================================
! // Global variables.
! // ============================================================================
!
! static GLuint *gDrawListBox = NULL;
!
! CONTEXT_INFO gContextsActive[CONTEXTSACTIVECOUNTMAX];
! int gContextsActiveCount = 0;
!
! static BOOL gAlwaysVisible = FALSE; // Setting this to true will make the program ignore
! // events that tell it it is not visible.
!
! // ARToolKit globals.
! static long gCallCountGetImage = 0;
! static int gARTThreshhold = 100;
! static int gPatt_id;
! static double gPatt_width = 80.0;
! static double gPatt_centre[2] = {0.0, 0.0};
!
! // Other globals.
! static BOOL gDrawRotate = FALSE;
! static float gDrawRotateAngle; // For use in drawing.
!
! // ============================================================================
! // Functions
! // ============================================================================
!
! BOOL DrawCubeInit(int contextsActiveCountMax)
! {
! // Allocate room for display lists for all contexts.
! if (gDrawListBox) return (FALSE); // Sanity check.
! if ((gDrawListBox = (GLuint *)calloc(contextsActiveCountMax, sizeof(GLuint))) == NULL) {
! return (FALSE);
! }
! return (TRUE);
!
! }
!
! BOOL DrawCubeSetup(int contextIndex)
! {
! // Colour cube data.
! float fSize = 0.5f;
! long f, i;
! const GLfloat cube_vertices [8][3] = {
! {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {-1.0, -1.0, 1.0}, {-1.0, 1.0, 1.0},
! {1.0, 1.0, -1.0}, {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0} };
! const GLfloat cube_vertex_colors [8][3] = {
! {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 1.0},
! {1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 1.0} };
! GLint cube_num_faces = 6;
! const short cube_faces [6][4] = { {3, 2, 1, 0}, {2, 3, 7, 6}, {0, 1, 5, 4}, {3, 0, 4, 7}, {1, 2, 6, 5}, {4, 5, 6, 7} };
!
! if (!gDrawListBox[contextIndex]) {
! gDrawListBox[contextIndex] = glGenLists (1);
! glNewList(gDrawListBox[contextIndex], GL_COMPILE);
! glBegin (GL_QUADS);
! for (f = 0; f < cube_num_faces; f++)
! for (i = 0; i < 4; i++) {
! glColor3f (cube_vertex_colors[cube_faces[f][i]][0], cube_vertex_colors[cube_faces[f][i]][1], cube_vertex_colors[cube_faces[f][i]][2]);
! glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize);
! }
! glEnd ();
! glColor3f (0.0, 0.0, 0.0);
! for (f = 0; f < cube_num_faces; f++) {
! glBegin (GL_LINE_LOOP);
! for (i = 0; i < 4; i++)
! glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize);
! glEnd ();
! }
! glEndList ();
! }
!
! return (TRUE);
! }
!
! // Something to look at, draw a rotating colour cube.
! void DrawCube(int contextIndex)
! {
! // Draw the colour cube.
! glPushMatrix(); // Save world coordinate system.
! glTranslatef(0.0, 0.0, 0.5); // Place base of cube on marker surface.
! glRotatef(gDrawRotateAngle, 0.0, 0.0, 1.0); // Rotate about z axis.
! glDisable(GL_LIGHTING); // Just use colours.
! glCallList(gDrawListBox[contextIndex]); // Draw the cube.
! glPopMatrix(); // Restore world coordinate system.
! }
!
! void DrawCubeUpdate(float timeDelta)
! {
! if (gDrawRotate) {
! gDrawRotateAngle += timeDelta * 45.0f; // Rotate cube at 45 degrees per second.
! if (gDrawRotateAngle > 360.0f) gDrawRotateAngle -= 360.0f;
! }
! }
!
! BOOL DrawCubeCleanup(int contextIndex)
! {
! if (contextIndex >= gContextsActiveCount) return (FALSE); // Sanity check.
!
! // Destroy display lists...
! if (gDrawListBox[contextIndex]) {
! glDeleteLists(gDrawListBox[contextIndex], 1);
! gDrawListBox[contextIndex] = 0;
! }
!
! return (TRUE);
! }
!
! BOOL DrawCubeFinal(void)
! {
! if (!gDrawListBox) {
! free(gDrawListBox);
! gDrawListBox = NULL;
! }
! return (TRUE);
! }
!
! // Function to clean up and then exit.
! static void Quit(void)
! {
! int i;
!
! fprintf(stderr, "Quitting...\n");
!
! // OpenGL per-context cleanup.
! for (i = 0; i < gContextsActiveCount; i++) {
! if (gContextsActive[i].apiContextIndex) {
! glutSetWindow(gContextsActive[i].apiContextIndex);
! arglCleanup(gContextsActive[i].arglSettings);
! DrawCubeCleanup(i);
! glutDestroyWindow(gContextsActive[i].apiContextIndex);
! gContextsActive[i].apiContextIndex = 0;
! }
! ar2VideoCapStop(gContextsActive[i].ARTVideo);
! ar2VideoClose(gContextsActive[i].ARTVideo);
! }
! gContextsActiveCount = 0;
!
! // Library finals (in reverse order to inits.)
! DrawCubeFinal();
!
! // Unless we don't have an atexit() function, terminate by falling off end
! // (since Quit is called by exit()'s exitfunc.)
! #ifdef NOATEXIT
! exit(0);
! #endif
! }
!
! // Sets up fields ARTVideo, ARTCparam of gContextsActive[0] through gContextsActive[cameraCount - 1].
! BOOL demoARSetupCameras(const int cameraCount, const unsigned char *cparam_names[], char *vconfs[])
! {
! int i;
! ARParam wparam;
! int xsize, ysize;
!
! for (i = 0; i < cameraCount; i++) {
!
! // Open the video path.
! if ((gContextsActive[i].ARTVideo = ar2VideoOpen(vconfs[i])) == NULL) {
! fprintf(stderr, "demoARSetupCamera(): Unable to open connection to camera %d.\n", i + 1);
! return (FALSE);
! }
!
! // Find the size of the window.
! if (ar2VideoInqSize(gContextsActive[i].ARTVideo, &xsize, &ysize) < 0) return (FALSE);
! fprintf(stderr, "demoARSetupCamera(): Camera %d image size (x,y) = (%d,%d)\n", i + 1, xsize, ysize);
!
! // Load the camera parameters, resize for the window and init.
! if (arParamLoad(cparam_names[i], 1, &wparam) < 0) {
! fprintf(stderr, "demoARSetupCamera(): Error loading parameter file %s for camera %d.\n", cparam_names[i], i + 1);
! return (FALSE);
! }
! arParamChangeSize(&wparam, xsize, ysize, &(gContextsActive[i].ARTCparam));
! arInitCparam(&(gContextsActive[i].ARTCparam));
! fprintf(stderr, "*** Camera %d parameter ***\n", i + 1);
! arParamDisp(&(gContextsActive[i].ARTCparam));
!
! // Start the video capture for this camera.
! if (ar2VideoCapStart(gContextsActive[i].ARTVideo) != 0) {
! fprintf(stderr, "demoARSetupCamera(): Unable to begin camera data capture for camera %d.\n", i + 1);
! return (FALSE);
! }
!
! }
! return (TRUE);
! }
!
! BOOL demoARSetupMarker(const unsigned char *patt_name, int *patt_id)
! {
!
! if((*patt_id = arLoadPatt(patt_name)) < 0) {
! fprintf(stderr, "demoARSetupMarker(): pattern load error !!\n");
! return (FALSE);
! }
!
! return (TRUE);
! }
!
! // Report state of ARToolKit global variables arFittingMode,
! // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode.
! void demoARDebugReportMode(void)
! {
! if(arFittingMode == AR_FITTING_TO_INPUT ) {
! fprintf(stderr, "FittingMode (Z): INPUT IMAGE\n");
! } else {
! fprintf(stderr, "FittingMode (Z): COMPENSATED IMAGE\n");
! }
!
! if( arImageProcMode == AR_IMAGE_PROC_IN_FULL ) {
! fprintf(stderr, "ProcMode (X) : FULL IMAGE\n");
! } else {
! fprintf(stderr, "ProcMode (X) : HALF IMAGE\n");
! }
!
! if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) {
! fprintf(stderr, "DrawMode (C) : GL_DRAW_PIXELS\n");
! } else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) {
! fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)\n");
! } else {
! fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (HALF RESOLUTION)\n");
! }
!
! if( arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR ) {
! fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n");
! } else {
! fprintf(stderr, "TemplateMatchingMode (M) : BW Template\n");
! }
!
! if( arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA ) {
! fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n");
! } else {
! fprintf(stderr, "MatchingPCAMode (P) : With PCA\n");
! }
! #ifdef APPLE_TEXTURE_FAST_TRANSFER
! # ifdef GL_APPLE_client_storage
! fprintf(stderr, "arglAppleClientStorage is %d.\n", arglAppleClientStorage);
! # endif // GL_APPLE_client_storage
! # ifdef GL_APPLE_texture_range
! fprintf(stderr, "arglAppleTextureRange is %d.\n", arglAppleTextureRange);
! fprintf(stderr, "arglAppleTextureRangeStorageHint is ");
! switch (arglAppleTextureRangeStorageHint) {
! case GL_STORAGE_SHARED_APPLE:
! fprintf(stderr, "GL_STORAGE_SHARED_APPLE.\n");
! break;
! case GL_STORAGE_CACHED_APPLE:
! fprintf(stderr, "GL_STORAGE_CACHED_APPLE.\n");
! break;
! default:
! case GL_STORAGE_PRIVATE_APPLE:
! fprintf(stderr, "GL_STORAGE_PRIVATE_APPLE.\n");
! break;
! }
! # endif // GL_APPLE_texture_range
! #endif // APPLE_TEXTURE_FAST_TRANSFER
! }
!
! void Keyboard(unsigned char key, int x, int y)
! {
! int modifiers, shift, i;
!
! modifiers = glutGetModifiers();
! shift = (modifiers & GLUT_ACTIVE_SHIFT); // Get status of shift key.
!
! switch (key) {
! case 0x1b: // Quit.
! case 'Q':
! case 'q':
! #ifdef NOATEXIT
! Quit();
! #else
! exit(0);
! #endif // NOATEXIT
! break;
! case ' ':
! gDrawRotate = !gDrawRotate;
! break;
! case 'C':
! case 'c':
! if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) {
! arglDrawMode = AR_DRAW_BY_TEXTURE_MAPPING;
! arglTexmapMode = AR_DRAW_TEXTURE_FULL_IMAGE;
! } else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) {
! arglTexmapMode = AR_DRAW_TEXTURE_HALF_IMAGE;
! } else {
! arglDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS;
! }
! for (i = 0; i < gContextsActiveCount; i++) {
! fprintf(stderr, "*** Camera %2d - %f (frame/sec)\n", i + 1, (double)(gContextsActive[i].callCountMarkerDetect)/arUtilTimer());
! gContextsActive[i].callCountMarkerDetect = 0;
! }
! demoARDebugReportMode();
! break;
! case 'R':
! case 'r':
! #ifdef AR_OPENGL_TEXTURE_RECTANGLE
! arglTexRectangle = !arglTexRectangle;
! fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle);
! #endif // AR_OPENGL_TEXTURE_RECTANGLE
! break;
! case 'T':
! case 't':
! #ifdef APPLE_TEXTURE_FAST_TRANSFER
! # ifdef GL_APPLE_client_storage
! arglAppleClientStorage = !arglAppleClientStorage;
! fprintf(stderr, "Toggled arglAppleClientStorage to %d.\n", arglAppleClientStorage);
! # endif
! #endif
! break;
! case 'Y':
! case 'y':
! #ifdef APPLE_TEXTURE_FAST_TRANSFER
! # ifdef GL_APPLE_texture_range
! arglAppleTextureRange = !arglAppleTextureRange;
! fprintf(stderr, "Toggled arglAppleTextureRange to %d.\n", arglAppleTextureRange);
! # endif
! #endif
! break;
! case 'U':
! case 'u':
! #ifdef APPLE_TEXTURE_FAST_TRANSFER
! # ifdef GL_APPLE_texture_range
! fprintf(stderr, "Toggled arglAppleTextureRangeStorageHint to ");
! switch (arglAppleTextureRangeStorageHint) {
! case GL_STORAGE_PRIVATE_APPLE:
! arglAppleTextureRangeStorageHint = GL_STORAGE_SHARED_APPLE;
! fprintf(stderr, "GL_STORAGE_SHARED_APPLE.\n");
! break;
! case GL_STORAGE_SHARED_APPLE:
! arglAppleTextureRangeStorageHint = GL_STORAGE_CACHED_APPLE;
! fprintf(stderr, "GL_STORAGE_CACHED_APPLE.\n");
! break;
! case GL_STORAGE_CACHED_APPLE:
! default:
! arglAppleTextureRangeStorageHint = GL_STORAGE_PRIVATE_APPLE;
! fprintf(stderr, "GL_STORAGE_PRIVATE_APPLE.\n");
! break;
! }
! # endif
! #endif
! break;
! case '?':
! case '/':
! fprintf(stderr,"Keys:\n");
! fprintf(stderr," q or [esc] Quit demo.\n");
! fprintf(stderr," c Change arglDrawMode and arglTexmapMode.\n");
! fprintf(stderr," r Toggle arglTexRectangle.\n");
! fprintf(stderr," ? or / Show this help.\n");
! #ifdef APPLE_TEXTURE_FAST_TRANSFER
! # ifdef GL_APPLE_client_storage
! fprintf(stderr," t Toggle arglAppleClientStorage.\n");
! # endif // GL_APPLE_client_storage
! # ifdef GL_APPLE_texture_range
! fprintf(stderr," y Toggle arglAppleTextureRange.\n");
! fprintf(stderr," u Toggle arglAppleTextureRangeStorageHint.\n");
! # endif // GL_APPLE_texture_range
! #endif APPLE_TEXTURE_FAST_TRANSFER
! default:
! break;
! }
! }
!
! void Mouse(int button, int state, int x, int y)
! {
! // Nothing here yet.
! }
!
! void Idle(void)
! {
! int i;
! static double timeRecentPast;
! double timeNow;
! float timeDelta;
! ARUint8 *image;
!
! ARMarkerInfo *marker_info; // Pointer to array holding the details of detected markers.
! int marker_num; // Count of number of markers detected.
! int j, k;
!
! // Find out how long since Idle() last ran.
! timeNow = (double)glutGet(GLUT_ELAPSED_TIME) / 1000.0; // Get the current time.
! timeDelta = (float)(timeNow - timeRecentPast); // Work out how long in seconds since the last epoch.
! if (timeDelta < 0.01f) return; // Don't update more often than 100 Hz.
! timeRecentPast = timeNow;
!
! // Update drawing.
! DrawCubeUpdate(timeDelta);
!
! if (!gCallCountGetImage) arUtilTimerReset();
! gCallCountGetImage++; // Increment ARToolKit FPS counter.
!
! for (i = 0; i < gContextsActiveCount; i++) {
!
! // Grab a video frame.
! if ((image = ar2VideoGetImage(gContextsActive[i].ARTVideo)) != NULL) {
! gContextsActive[i].ARTImage = image;
!
! gContextsActive[i].callCountMarkerDetect++; // Increment ARToolKit FPS counter.
! //fprintf(stderr, "Idle(): Got image #%ld from cam %d on attempt #%ld.\n", gContextsActive[i].callCountMarkerDetect, i + 1, gCallCountGetImage);
!
! // Detect the markers in the video frame.
! if (arDetectMarkerLite(gContextsActive[i].ARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) {
! exit(-1);
! }
!
! // Check through the marker_info array for highest confidence
! // visible marker matching our preferred pattern.
! k = -1;
! for (j = 0; j < marker_num; j++) {
! if (marker_info[j].id == gPatt_id) {
! if (k == -1) k = j; // First marker detected.
! else if(marker_info[j].cf > marker_info[k].cf) k = j; // Higher confidence marker detected.
! }
! }
!
! if(k != -1) {
! // Get the transformation between the marker and the real camera into gPatt_trans1.
! arGetTransMat(&(marker_info[k]), gPatt_centre, gPatt_width, gContextsActive[i].patt_trans);
! gContextsActive[i].patt_found = TRUE;
! }
!
! glutPostWindowRedisplay(gContextsActive[i].apiContextIndex);
! }
!
! }
! }
!
! //
! // The function is called on events when the visibility of a
! // GLUT window changes (including when it first becomes visible).
! //
! static void Visibility(int visible)
! {
! if (gAlwaysVisible || (visible == GLUT_VISIBLE)) {
! glutIdleFunc(Idle);
! } else {
! glutIdleFunc(NULL);
! }
! }
!
! //
! // The function is called when a
! // GLUT window is resized.
! //
! void Reshape(int w, int h)
! {
! glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
! glViewport(0, 0, (GLsizei) w, (GLsizei) h);
!
! glMatrixMode(GL_PROJECTION);
! glLoadIdentity();
! glMatrixMode(GL_MODELVIEW);
! glLoadIdentity();
!
! // Call through to anyone else who needs to know about window sizing here.
! }
!
! static void Draw(const int drawContextIndex)
! {
! int i;
! GLdouble p[16];
! GLdouble m[16];
!
! // Select correct buffer for this context.
! glDrawBuffer(GL_BACK);
!
! arglDispImage(gContextsActive[drawContextIndex].ARTImage,
! &(gContextsActive[drawContextIndex].ARTCparam),
! 1.0,
! gContextsActive[drawContextIndex].arglSettings); // zoom = 1.0, contextIndex = 0.
! ar2VideoCapNext(gContextsActive[drawContextIndex].ARTVideo);
!
! if (gContextsActive[drawContextIndex].patt_found) {
! glClear(GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
!
! // Projection transformation.
! glMatrixMode(GL_PROJECTION);
! arglCameraFrustum(&(gContextsActive[drawContextIndex].ARTCparam), VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p);
! glLoadMatrixd(p);
! glMatrixMode(GL_MODELVIEW);
!
! // Viewing transformation.
! glLoadIdentity();
! // Lighting and geometry that moves with the camera should go here.
! // (I.e. must be specified before viewing transformations.)
! //none
!
! arglCameraView(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR);
! glLoadMatrixd(m);
!
! // All other lighting and geometry goes here.
! DrawCube(drawContextIndex);
!
! gContextsActive[drawContextIndex].patt_found = FALSE;
! } // gPatt_found
!
! // Any 2D overlays go here.
! //none
!
! // Drawing for this context complete.
! }
!
! // Linear search through all active contexts to find context index for the current glut window.
! int getContextIndexForCurrentGLUTWindow(void)
! {
! int i, window;
!
! if ((window = glutGetWindow()) != 0) {
! for (i = 0; i < gContextsActiveCount; i++) {
! if (gContextsActive[i].apiContextIndex == window) return (i);
! }
! }
! return (-1);
! }
!
! static void Display(void)
! {
! int contextIndex;
!
! if ((contextIndex = getContextIndexForCurrentGLUTWindow()) != -1) {
! Draw(contextIndex);
! glutSwapBuffers();
! }
! }
!
! int main(int argc, char** argv)
! {
! int i;
! char windowTitle[32] = {0};
! const unsigned char *cparam_names[] = { // Camera parameter names.
! "Data/camera_para.dat",
! "Data/camera_para.dat",
! };
! char *vconfs[] = { // Camera configuration.
! #if defined(_WIN32)
! "showDlg,flipV",
! "showDlg,flipV",
! #elif defined(__APPLE__)
! "",
! "",
! #else
! "-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240",
! "-dev=/dev/video3 -channel=0 -palette=YUV420P -width=320 -height=240",
! #endif
! };
! const unsigned char *patt_name = "Data/patt.hiro";
!
!
! // ----------------------------------------------------------------------------
! // Library inits.
! //
!
! glutInit(&argc, argv);
!
! // Register a cleanup function to be called upon exit().
! #ifndef NOATEXIT
! if (atexit(Quit) < 0) {
! fprintf(stderr, "main(): Unable to register exit function.\n");
! exit (-1); // Bail out if we can't even register our exit function.
! }
! #endif // NOATEXIT
!
! // Initialise drawing libraries.
! if (!DrawCubeInit(CONTEXTSACTIVECOUNTMAX)) {
! fprintf(stderr, "main(): DrawCubeInit returned error.\n");
! exit(-1);
! }
!
!
! // ----------------------------------------------------------------------------
! // Hardware setup.
! //
!
!
! if (!demoARSetupCameras(CONTEXTSACTIVECOUNT, cparam_names, vconfs)) {
! fprintf(stderr, "main(): Unable to set up %d AR cameras.\n", CONTEXTSACTIVECOUNT);
! exit(-1);
! }
! gContextsActiveCount = CONTEXTSACTIVECOUNT;
! demoARDebugReportMode();
! if (!demoARSetupMarker(patt_name, &gPatt_id)) {
! fprintf(stderr, "main(): Unable to set up AR marker.\n");
! exit(-1);
! }
!
! // ----------------------------------------------------------------------------
! // Library setup.
! //
!
! // Per- GL context setup.
! for (i = 0; i < gContextsActiveCount; i++ ) {
!
! // Set up GL context(s) for OpenGL to draw into.
! glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
! glutInitWindowSize(gContextsActive[i].ARTCparam.xsize, gContextsActive[i].ARTCparam.ysize);
! glutInitWindowPosition(10 + 10*i, 20 + 10*i); // First window at 20,10, subsequent windows staggered.
! sprintf(windowTitle, "Video source %i", i);
! if ((gContextsActive[i].apiContextIndex = glutCreateWindow(windowTitle)) < 1) {
! fprintf(stderr, "main(): Unable to create window.\n");
! exit(-1);
! }
! glutDisplayFunc(Display);
! glutReshapeFunc(Reshape);
! glutVisibilityFunc(Visibility);
! glutMouseFunc(Mouse);
! glutKeyboardFunc(Keyboard);
!
! DrawCubeSetup(i);
!
! if ((gContextsActive[i].arglSettings = arglSetupForCurrentContext()) == NULL) {
! fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n");
! exit(-1);
! }
! }
!
! // Register GLUT event-handling callbacks.
! // NB: MainRunLoop() is registered by Visibility.
! glutMainLoop();
!
! // All done. Exit the program now.
! #ifdef NOATEXIT
! Quit();
! #else
! return (0);
! #endif // NOATEXIT
!
! }
Index: twoView.dsp
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.dsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** twoView.dsp 22 Nov 2004 03:37:58 -0000 1.1
--- twoView.dsp 25 Nov 2004 21:42:29 -0000 1.2
***************
*** 52,56 ****
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
! # ADD LINK32 libAR.lib libARvideo.lib libARgsub.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"../../bin/twoView.exe" /libpath:"..\..\lib"
# SUBTRACT LINK32 /nodefaultlib
--- 52,56 ----
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
! # ADD LINK32 libAR.lib libARvideo.lib libARgsub_lite.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"../../bin/twoView.exe" /libpath:"..\..\lib"
# SUBTRACT LINK32 /nodefaultlib
***************
*** 78,82 ****
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
! # ADD LINK32 libARd.lib libARvideod.lib libARgsubd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd.lib" /out:"../../bin/twoViewd.exe" /pdbtype:sept /libpath:"..\..\lib"
# SUBTRACT LINK32 /nodefaultlib
--- 78,82 ----
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
! # ADD LINK32 libARd.lib libARvideod.lib libARgsub_lited.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd.lib" /out:"../../bin/twoViewd.exe" /pdbtype:sept /libpath:"..\..\lib"
# SUBTRACT LINK32 /nodefaultlib
|