Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 204 | chris | 1 | /* -------------------------------------------------------------------------- |
| 2 | * Copyright (C) 2004 Hitlab NZ. |
||
| 3 | * The distribution policy is describe on the Copyright.txt furnish |
||
| 4 | * with this library. |
||
| 5 | * -------------------------------------------------------------------------*/ |
||
| 6 | /** |
||
| 7 | * \file gsub.h |
||
| 8 | * \brief ARToolkit OpenGL subroutines. |
||
| 9 | * |
||
| 10 | * This file contains the main display functions used in ARToolkit Library. |
||
| 11 | * It contains wrapped functions of GLUT and openGL for doing real-time |
||
| 12 | * rendering. This choice give us a large multi-platform support for the display |
||
| 13 | * module of ARToolkit. |
||
| 14 | * \remark The supported stereo mode is interleaved stereo mode (only for i-glasses display). |
||
| 15 | * |
||
| 16 | * History : |
||
| 17 | * |
||
| 18 | * \author Hirokazu Kato kato@sys.im.hiroshima-cu.ac.jp |
||
| 19 | * \version |
||
| 20 | * \date |
||
| 21 | **/ |
||
| 22 | /* -------------------------------------------------------------------------- |
||
| 23 | * History : |
||
| 24 | * Rev Date Who Changes |
||
| 25 | * |
||
| 26 | *----------------------------------------------------------------------------*/ |
||
| 27 | |||
| 28 | #ifndef AR_GSUB_H |
||
| 29 | #define AR_GSUB_H |
||
| 30 | #ifdef __cplusplus |
||
| 31 | extern "C" { |
||
| 32 | #endif |
||
| 33 | |||
| 34 | // ============================================================================ |
||
| 35 | // Public includes. |
||
| 36 | // ============================================================================ |
||
| 37 | |||
| 38 | #include <AR/config.h> |
||
| 39 | #include <AR/param.h> |
||
| 40 | #include <AR/ar.h> |
||
| 41 | |||
| 42 | // ============================================================================ |
||
| 43 | // Public types and defines. |
||
| 44 | // ============================================================================ |
||
| 45 | |||
| 46 | // ============================================================================ |
||
| 47 | // Public globals. |
||
| 48 | // ============================================================================ |
||
| 49 | |||
| 50 | /** \var int argDrawMode |
||
| 51 | * \brief define the draw configuration mode. |
||
| 52 | * |
||
| 53 | * Define the draw mode for display of the video background. |
||
| 54 | * The possible values are : |
||
| 55 | * - AR_DRAW_BY_GL_DRAW_PIXELS: use the GL_DRAW_PIXELS function |
||
| 56 | * - AR_DRAW_BY_TEXTURE_MAPPING: use a quad mesh with a texture mapping |
||
| 57 | * of the video. |
||
| 58 | * by default: DEFAULT_DRAW_MODE in config.h |
||
| 59 | * \rem choice and performance depends on your hardware and your openGL driver. |
||
| 60 | */ |
||
| 61 | extern int argDrawMode; |
||
| 62 | |||
| 63 | /** \var int argTexmapMode |
||
| 64 | * \brief define the texture map configuration mode. |
||
| 65 | * |
||
| 66 | * If the draw mode is AR_DRAW_BY_TEXTURE_MAPPING, you can |
||
| 67 | * configure the copy mode of the texture mapping. |
||
| 68 | * The possible values are : |
||
| 69 | * - AR_DRAW_TEXTURE_FULL_IMAGE: texture mapping full resolution. |
||
| 70 | * - AR_DRAW_TEXTURE_HALF_IMAGE: texture mapping half resolution. |
||
| 71 | * by default: DEFAULT_DRAW_TEXTURE_IMAGE in config.h |
||
| 72 | */ |
||
| 73 | extern int argTexmapMode; |
||
| 74 | |||
| 75 | // ============================================================================ |
||
| 76 | // Public functions. |
||
| 77 | // ============================================================================ |
||
| 78 | |||
| 79 | /** \fn argInit( ARParam *cparam, double zoom, int fullFlag, int xwin, int ywin, int hmd_flag ) |
||
| 80 | * \brief Initialise the gsub library |
||
| 81 | * |
||
| 82 | * This function performs required initialisation of the gsub library. |
||
| 83 | * It must be called before any other argl*() functions are called. |
||
| 84 | * \param cparam the intrinsics parameters of the camera (used to defined openGL perspective matrix) |
||
| 85 | * \param zoom defined a zoom parameter for the final result. |
||
| 86 | * \param fullFlag full screen mode (1 enable, 0 disable). |
||
| 87 | * \param xwin XXXBK. 0 if indifferent. |
||
| 88 | * \param ywin XXXBK. 0 if indifferent. |
||
| 89 | * \param hmd_flag enable stereo display mode (only interleaved configuration) |
||
| 90 | */ |
||
| 91 | void argInit( ARParam *cparam, double zoom, int fullFlag, int xwin, int ywin, int hmd_flag ); |
||
| 92 | |||
| 93 | /** \fn void argLoadHMDparam( ARParam *lparam, ARParam *rparam ) |
||
| 94 | * \brief initialize camera for HMD. |
||
| 95 | * |
||
| 96 | * Load in the display module the intrinsic parameters of the two view, |
||
| 97 | * i.e camera (identify to the eyes). |
||
| 98 | * |
||
| 99 | * \param lparam parameter of left camera |
||
| 100 | * \param rparam parameter of right camera |
||
| 101 | */ |
||
| 102 | void argLoadHMDparam( ARParam *lparam, ARParam *rparam ); |
||
| 103 | |||
| 104 | /** \fn void argCleanup( void ) |
||
| 105 | * \brief Close the gsub library. |
||
| 106 | * |
||
| 107 | * This function clean the rendering context (GLUT and openGL). |
||
| 108 | * Call in the exit of your program. |
||
| 109 | * \remark BE CAREFUL, THIS FUNCTION DOESN'T RESET PERSPECTIVE |
||
| 110 | * MATRIX AND CURRENT GL STATE TO DEFAULT |
||
| 111 | */ |
||
| 112 | void argCleanup( void ); |
||
| 113 | |||
| 114 | /** \fn void argSwapBuffers( void ) |
||
| 115 | * \brief swap the rendering buffer. |
||
| 116 | * |
||
| 117 | * Swap the back-buffer to the front-buffer. the |
||
| 118 | * pre-condition is that all the rendering functions have been |
||
| 119 | * called. |
||
| 120 | */ |
||
| 121 | void argSwapBuffers( void ); |
||
| 122 | |||
| 123 | /** \fn void argMainLoop( void (*mouseFunc)(int button, int state, int x, int y), |
||
| 124 | void (*keyFunc)(unsigned char key, int x, int y), |
||
| 125 | void (*mainFunc)(void) ) |
||
| 126 | * \brief start the program main loop with specified callback functions. |
||
| 127 | * |
||
| 128 | * This function is called in the entry block of a program. User |
||
| 129 | * specify the main callback of his program. Users should not |
||
| 130 | * put routines calls after this function, generally never accessible. |
||
| 131 | * \param mouseFunc the user mouse function can be NULL. |
||
| 132 | * \param keyFunc the user keyboard function can be NULL. |
||
| 133 | * \param mainFunc the user main update function can be NULL. |
||
| 134 | */ |
||
| 135 | void argMainLoop( void (*mouseFunc)(int button, int state, int x, int y), |
||
| 136 | void (*keyFunc)(unsigned char key, int x, int y), |
||
| 137 | void (*mainFunc)(void) ); |
||
| 138 | |||
| 139 | /** \fn void argDrawMode2D( void ) |
||
| 140 | * \brief switch the rendering context for 2D rendering mode. |
||
| 141 | * |
||
| 142 | * Update curent camera parameters (internal and external) |
||
| 143 | * for rendering 2D or 3D objects in the view plane (like text or 2D shape). |
||
| 144 | * This function define an orthographic projection in the image |
||
| 145 | * plane. It not define opengl state for rendering in image space (like |
||
| 146 | * for a bitmap copy). |
||
| 147 | */ |
||
| 148 | void argDrawMode2D( void ); |
||
| 149 | |||
| 150 | /** \fn void argDraw2dLeft( void ) |
||
| 151 | * \brief switch the rendering view to left eye (in 2D space) |
||
| 152 | * |
||
| 153 | * Combine with argDrawMode2D for rendering the left view. |
||
| 154 | */ |
||
| 155 | void argDraw2dLeft( void ); |
||
| 156 | |||
| 157 | /** \fn void argDraw2dRight( void ) |
||
| 158 | * \brief switch the rendering view to right eye (in 2D space) |
||
| 159 | * |
||
| 160 | * Combine with argDrawMode2D for rendering the right view. |
||
| 161 | */ |
||
| 162 | void argDraw2dRight( void ); |
||
| 163 | |||
| 164 | /** \fn void argDrawMode3D( void ) |
||
| 165 | * \brief switch the rendering context for 3D rendering mode. |
||
| 166 | * |
||
| 167 | * Update curent camera parameters for rendering in 3D space. |
||
| 168 | * Generally call to reinializing model view matrix. |
||
| 169 | */ |
||
| 170 | void argDrawMode3D( void ); |
||
| 171 | |||
| 172 | /** \fn void argDraw3dLeft( void ) |
||
| 173 | * \brief switch the rendering view to left eye (in 3D space) |
||
| 174 | * |
||
| 175 | * Update curent internal camera parameters for rendering in 3D space |
||
| 176 | * for left eye. |
||
| 177 | * this function complements argDrawMode3D. |
||
| 178 | */ |
||
| 179 | void argDraw3dLeft( void ); |
||
| 180 | |||
| 181 | /** \fn void argDraw3dRight( void ) |
||
| 182 | * \brief switch the rendering view to right eye (in 3D space) |
||
| 183 | * |
||
| 184 | * Update curent internal camera parameters for rendering in 3D space |
||
| 185 | * for left eye. |
||
| 186 | * this function complements argDrawMode3D. |
||
| 187 | */ |
||
| 188 | void argDraw3dRight( void ); |
||
| 189 | |||
| 190 | /** \fn void argDraw3dCamera( int xwin, int ywin ) |
||
| 191 | * \brief switch the rendering view for 3D rendering mode. |
||
| 192 | * |
||
| 193 | * Update curent internal camera parameters for rendering in 3D space. |
||
| 194 | * this function complements argDrawMode3D. |
||
| 195 | * \param xwin length of rendering view (less than window length) |
||
| 196 | * \param ywin width of rendering view (less than window width) |
||
| 197 | */ |
||
| 198 | void argDraw3dCamera( int xwin, int ywin ); |
||
| 199 | |||
| 200 | |||
| 201 | /** \fn void argConvGlpara( double para[3][4], double gl_para[16] ) |
||
| 202 | * \brief transform ARToolKit matrix format to an openGL matrix format. |
||
| 203 | * |
||
| 204 | * simple conversion for the openGL matrix (16 values and homogeneous matrix). |
||
| 205 | * Returned value is generally use with a Model View Matrix. |
||
| 206 | * \param para the ARToolKit matrix |
||
| 207 | * \param gl_para the resulted openGL matrix |
||
| 208 | */ |
||
| 209 | void argConvGlpara( double para[3][4], double gl_para[16] ); |
||
| 210 | |||
| 211 | /** \fn void argConvGLcpara( ARParam *param, double gnear, double gfar, double m[16] ) |
||
| 212 | * \brief transform ARToolKit intrinsic camera parameters matrix format to an openGL matrix format. |
||
| 213 | * |
||
| 214 | * XXXBK: not be sure of this function: |
||
| 215 | * this function must just convert 3x4 matrix to classical perspective openGL matrix. |
||
| 216 | * But in the code, you used arParamDecompMat that seem decomposed K and R,t, aren't it ? |
||
| 217 | * why do this decomposition since we want just intrinsic parameters ? and if not what is arDecomp ? |
||
| 218 | * |
||
| 219 | * Returned value is generally use with a Projection Matrix. |
||
| 220 | * \param param |
||
| 221 | * \param gnear near clipping plane value |
||
| 222 | * \param gfar far clipping plane value |
||
| 223 | * \param m the resulted openGL matrix |
||
| 224 | */ |
||
| 225 | void argConvGLcpara( ARParam *param, double gnear, double gfar, double m[16] ); |
||
| 226 | |||
| 227 | /** \fn void argDispImage( ARUint8 *image, int xwin, int ywin ) |
||
| 228 | * \brief display the video image. |
||
| 229 | * |
||
| 230 | * Display in the back-buffer the video image in argument. |
||
| 231 | * For doing AR video background, this function must be called before |
||
| 232 | * any rendering of 3D object. |
||
| 233 | * \remark According to your argDrawMode, argTexmapMode and the internal |
||
| 234 | * image format the openGL function called is different and less |
||
| 235 | * or more efficient. |
||
| 236 | * \remark with AR_DRAW_BY_GL_DRAW_PIXELS, unaffected by current camera |
||
| 237 | * parameters matrix but affected by glRasterPos3f. |
||
| 238 | * \remark with AR_DRAW_BY_TEXTURE_MAPPING, affected by current current camera |
||
| 239 | * parameters matrix. You need generally call argDrawMode2D before this function. |
||
| 240 | * \param image image to display |
||
| 241 | * \param xwin XXXBK |
||
| 242 | * \param ywin XXXBK |
||
| 243 | */ |
||
| 244 | void argDispImage( ARUint8 *image, int xwin, int ywin ); |
||
| 245 | |||
| 246 | /** \fn void argDispHalfImage( ARUint8 *image, int xwin, int ywin ) |
||
| 247 | * \brief display half of the video image. |
||
| 248 | * |
||
| 249 | * Idem of argDispImage except than a quarter of the image is display |
||
| 250 | * (first left top quadrant, so size/2 in x and y). |
||
| 251 | * \param image image to display |
||
| 252 | * \param xwin XXXBK |
||
| 253 | * \param ywin XXXBK |
||
| 254 | */ |
||
| 255 | void argDispHalfImage( ARUint8 *image, int xwin, int ywin ); |
||
| 256 | |||
| 257 | /** \fn void argDrawSquare( double vertex[4][2], int xwin, int ywin ) |
||
| 258 | * \brief draw a 2D square. |
||
| 259 | * |
||
| 260 | * Draw a square. The position of the square is affected by openGL |
||
| 261 | * model view matrix and call to argDrawMode2D argDrawMode3D. |
||
| 262 | * Generally call in a 2D mode (so after a argDrawMode2D). |
||
| 263 | * |
||
| 264 | * \param vertex corner of square. |
||
| 265 | * \param xwin XXXBK |
||
| 266 | * \param ywin XXXBK |
||
| 267 | */ |
||
| 268 | void argDrawSquare( double vertex[4][2], int xwin, int ywin ); |
||
| 269 | |||
| 270 | /** \fn void argLineSeg( double x1, double y1, double x2, double y2, int xwin, int ywin ) |
||
| 271 | * \brief Draw a line. |
||
| 272 | * |
||
| 273 | * Draw a segment.T The position of the line is affected by openGL |
||
| 274 | * model view matrix and call to argDrawMode2D argDrawMode3D. |
||
| 275 | * Generally call in a 2D mode (so after a argDrawMode2D). |
||
| 276 | * \param x1 x position of the first point. |
||
| 277 | * \param y1 y position of the first point. |
||
| 278 | * \param x2 x position of the second point. |
||
| 279 | * \param y2 y position of the second point. |
||
| 280 | * \param xwin XXXBK |
||
| 281 | * \param ywin XXXBK |
||
| 282 | */ |
||
| 283 | void argLineSeg( double x1, double y1, double x2, double y2, int xwin, int ywin ); |
||
| 284 | |||
| 285 | /** \fn void argLineSegHMD( double x1, double y1, double x2, double y2 ) |
||
| 286 | * \brief Draw a line with HMD mode. |
||
| 287 | * |
||
| 288 | * Draw a segment in HMD mode. |
||
| 289 | * \param x1 x position of the first point. |
||
| 290 | * \param y1 y position of the first point. |
||
| 291 | * \param x2 x position of the second point. |
||
| 292 | * \param y2 y position of the second point. |
||
| 293 | */ |
||
| 294 | void argLineSegHMD( double x1, double y1, double x2, double y2 ); |
||
| 295 | |||
| 296 | /** \fn argInqSetting( int *hmdMode, |
||
| 297 | int *gMiniXnum2, int *gMiniYnum2, |
||
| 298 | void (**mouseFunc)(int button, int state, int x, int y), |
||
| 299 | void (**keyFunc)(unsigned char key, int x, int y), |
||
| 300 | void (**mainFunc)(void) ); |
||
| 301 | * \brief Get current configuration of gsub library. |
||
| 302 | * |
||
| 303 | * Retrieve current state of gsub library like the current callback functions. |
||
| 304 | * \param hmdMode the current hmdMode |
||
| 305 | * \param gMiniXnum2 XXXBK |
||
| 306 | * \param gMiniYnum2 XXXBK |
||
| 307 | * \param mouseFunc the current mouse function callback |
||
| 308 | * \param keyFunc the current key function callback |
||
| 309 | * \param mainFunc the current main function callback |
||
| 310 | */ |
||
| 311 | void argInqSetting( int *hmdMode, |
||
| 312 | int *gMiniXnum2, int *gMiniYnum2, |
||
| 313 | void (**mouseFunc)(int button, int state, int x, int y), |
||
| 314 | void (**keyFunc)(unsigned char key, int x, int y), |
||
| 315 | void (**mainFunc)(void) ); |
||
| 316 | |||
| 317 | /*-------------------------*/ |
||
| 318 | |||
| 319 | void argsInit( ARSParam *scparam, double zoom, int twinFlag, int fullFlag, int xwin, int ywin ); |
||
| 320 | void argsDraw3dCamera( int xwin, int ywin, int LorR, int stencil_flag ); |
||
| 321 | void argsConvGLcpara( ARSParam *sparam, double gnear, double gfar, double mL[16], double mR[16] ); |
||
| 322 | void argsDispImage( ARUint8 *image, int LorR, int xwin, int ywin ); |
||
| 323 | void argsDispHalfImage( ARUint8 *image, int LorR, int xwin, int ywin ); |
||
| 324 | void argsLineSeg( double x1, double y1, double x2, double y2, int xwin, int ywin, int LorR ); |
||
| 325 | void argsDrawSquare( double vertex[4][2], int xwin, int ywin, int LorR ); |
||
| 326 | |||
| 327 | |||
| 328 | #ifdef __cplusplus |
||
| 329 | } |
||
| 330 | #endif |
||
| 331 | #endif |