Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

display_matrix.h

Go to the documentation of this file.
00001 
00012 #include "display_driver.h"
00013 
00014 #ifndef _DISPLAY_MATRIX_H_
00015 #define _DISPLAY_MATRIX_H_
00016 
00028 extern int matrix_tag;
00029 
00033 int display_matrix_init(void);
00034 
00038 int display_matrix_shutdown(void);
00039 
00043 typedef struct
00044 {
00045   int refcount;       
00046   unsigned int l;     
00047   unsigned int c;     
00048   unsigned int align; 
00049   float v[16];        
00050 } lua_matrix_def_t;
00051 
00055 typedef struct {
00056   lua_matrix_def_t *md; 
00057   float * li;           
00058 } lua_matrix_t;
00059 
00063 #define CHECK_MATRIX(i) \
00064   if (lua_tag(L, i) != matrix_tag) { \
00065     printf("%s : argument #%d is not a matrix\n", __FUNCTION__, i); \
00066     return 0; \
00067   }
00068 
00073 #define GET_MATRIX(M,MD,i,j,k) \
00074     (MD) = 0;  /* Avoid warning */ \
00075     (M) = (lua_matrix_t *)lua_touserdata(L, i); \
00076     if (!(M) || ((MD) = (M)->md), !(MD)) { \
00077       printf("%s : null pointer\n", __FUNCTION__);\
00078       return 0; \
00079     } \
00080     if ( (M)->li ) { \
00081       printf("%s : matrix is a vector\n", __FUNCTION__); \
00082       return 0; \
00083     } \
00084     if (j && j != (MD)->l) { \
00085       printf("%s : invalid number of line. %d differs from %d\n", \
00086              __FUNCTION__, (MD)->l, j); \
00087       return 0; \
00088     } \
00089     if (k && k != (MD)->c) { \
00090       printf("%s : invalid number of column. %d differs from %d\n", \
00091              __FUNCTION__, (MD)->c, k); \
00092       return 0; \
00093     }
00094 
00099 #define GET_VECTOR(M,MD,i,k) \
00100     (MD) = 0; /* Avoid warning */ \
00101     (M) = (lua_matrix_t *)lua_touserdata(L, i); \
00102     if (!(M) || ((MD) = (M)->md), !(MD)) { \
00103       printf("%s : null pointer\n", __FUNCTION__);\
00104       return 0; \
00105     } \
00106     if ( !(M)->li ) { \
00107       printf("%s : not a vector\n", __FUNCTION__); \
00108       return 0; \
00109     } \
00110     if (k && k != (MD)->c) { \
00111       printf("%s : invalid number of column. %d differs from %d\n", \
00112              __FUNCTION__, (MD)->c, k); \
00113       return 0; \
00114     }
00115 
00120 #define GET_MATRIX_OR_VECTOR(M,MD,i,k) \
00121     (MD) = 0;  /* Avoid warning */ \
00122     (M) = (lua_matrix_t *)lua_touserdata(L, i); \
00123     if (!(M) || ((MD) = (M)->md), !(MD)) { \
00124       printf("%s : null pointer\n", __FUNCTION__);\
00125       return 0; \
00126     } \
00127     if (k && k != (MD)->c) { \
00128       printf("%s : invalid number of column. %d differs from %d\n", \
00129              __FUNCTION__, (MD)->c, k); \
00130       return 0; \
00131     }
00132 
00133 
00134 #endif /* #define _DISPLAY_MATRIX_H_ */

dcplaya documentation version 2.0 Generated on November 2004 by doxygen 1.3.6