PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/AndAR/jni/AR/AR/gsub.h

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