PA_3D.h

Go to the documentation of this file.
00001 #ifndef _PA_3D
00002 #define _PA_3D
00003 #include <nds.h>
00004 #include <malloc.h>
00005 #include <nds/arm9/image.h>
00006 
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010 
00011 extern const u8 PAlib[];
00012 extern const u32 PAlib_size[];
00013 
00014 #define texPCX 1
00015 #define texBIN 2
00016 
00024 extern int textureID;
00025 extern float angle3dX, angle3dY;
00026 extern float viseeX, viseeY, viseeZ;
00027 
00028 
00029 
00046 void PA_Init3D(void);
00052 void PA_LoadSplash3D(void);
00077 void PA_Init3DDrawing(float x1, float y1, float z1, float x2, float y2, float z2);
00078 
00079 
00080 
00081 
00116 void PA_glulookat(float eyex, float eyey, float eyez, float lookAtx, float lookAty, float lookAtz, float upx, float upy, float upz);
00123 extern inline void PA_image8to16(sImage* img)
00124  {
00125         int i;
00126 
00127         u16* temp = (u16*)malloc(img->height*img->width*2);
00128         
00129         for(i = 0; i < img->height * img->width; i++)
00130                temp[i] = img->palette[img->data8[i]] | (1<<15);
00131 
00132         img->data16 = temp;
00133  }
00134 
00135 
00136 void PA_VueKeys(void);
00152 extern inline void PA_LoadTexture(int numtexture, u8* nomtexture, int mode){
00153 if(mode == texBIN){
00154 glBindTexture(0, numtexture);
00155 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0,TEXGEN_TEXCOORD, (u8*)nomtexture);
00156 }
00157 else if(mode == texPCX){
00158 sImage pcx;
00159 loadPCX((u8*)nomtexture, &pcx);
00160 PA_image8to16(&pcx);
00161 glBindTexture(0, numtexture);
00162 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.data8);
00163 }
00164 }
00173 extern inline void PA_Texture(int numtexture){
00174 glBindTexture(0, numtexture);
00175 }
00217 void PA_3DBox(float x, float y, float z, float longueur, float largeur, float hauteur,float rotatex, float rotatey, float rotatez, uint8 red, uint8 green, uint8 blue);
00259 void PA_3DBoxTexture(float x, float y, float z, float longueur, float largeur, float hauteur,float rotatex, float rotatey, float rotatez,uint8 red, uint8 green, uint8 blue);
00260 
00261 
00262 
00277 extern inline void PA_Rotate3D(float x,float y,float z){
00278        glRotateX(x);
00279     glRotateY(y);
00280        glRotateZ(z);
00281 }
00296 extern inline void PA_Translate3D(float x, float y, float z){
00297 glTranslate3f32(floattof32(x),floattof32(y),floattof32(z));
00298 }
00313 extern inline void PA_Scale3D(float x, float y, float z){
00314 if(x==0.0)x=1.0;
00315 if(y==0.0)y=1.0;
00316 if(z==0.0)z=1.0;
00317 MATRIX_SCALE = floattof32(x);
00318 MATRIX_SCALE = floattof32(y);
00319 MATRIX_SCALE = floattof32(z);
00320 }
00335 extern inline void PA_Vertex3D(float x, float y, float z){
00336 glVertex3v16(floattov16(x),floattov16(y),floattov16(z));
00337 }
00343 extern inline void PA_3Dto2D(){
00344 MATRIX_IDENTITY = 0;
00345 }
00346 
00347 
00359 extern inline void PA_Vertex2D(int x, int y){
00360        float x1 = (float)((x*0.36)/256)-0.18;
00361        float y1 = (float)((y*0.28)/192)-0.14;
00362        glVertex3v16(floattov16(x1),floattov16(y1),floattov16(-0.2));
00363 }
00375 extern inline void PA_TexCoord(float x, float y){
00376 glTexCoord1i(TEXTURE_PACK(inttot16((int)x),inttot16((int)y)));
00377 }
00378 struct PA_3DObject{
00379 u32 *callList;
00380 float maxx, maxy, maxz, minx, miny, minz;
00381 float scalex,scaley,scalez;
00382 };
00383 int PA_InitCallList(struct PA_3DObject obj);
00384 int PA_VertexCallList(struct PA_3DObject obj, float x, float y, float z);
00385 int PA_TexCoordCallList(struct PA_3DObject obj, int x, int y);
00386 int PA_EndCallList(struct PA_3DObject obj);
00387 int PA_Draw3Dobject(struct PA_3DObject obj);
00388 int PA_ScaleCallList(struct PA_3DObject obj, float x, float y, float z); // end of 3D
00390 
00391 #ifdef __cplusplus
00392 }
00393 #endif
00394 
00395 #endif

Generated on Sun Jan 22 11:46:39 2006 for PAlib by  doxygen 1.3.9.1