PA_3D.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_3D
00002 #define _PA_3D
00003 #include <nds.h>
00004 #include <malloc.h>
00005 #include <nds/arm9/image.h>
00006 
00007 
00008 extern const u8 PAlib[];
00009 extern const u32 PAlib_size[];
00010 
00011 #define texPCX 1
00012 #define texBIN 2
00013 
00021 extern int textureID;
00022 extern float angle3dX, angle3dY;
00023 extern float viseeX, viseeY, viseeZ;
00024 
00025 
00026 
00043 void PA_Init3D(void);
00049 void PA_LoadSplash3D(void);
00074 void PA_Init3DDrawing(float x1, float y1, float z1, float x2, float y2, float z2);
00075 
00076 
00077 
00078 
00113 void PA_glulookat(float eyex, float eyey, float eyez, float lookAtx, float lookAty, float lookAtz, float upx, float upy, float upz);
00120 extern inline void PA_image8to16(sImage* img)
00121  {
00122         int i;
00123 
00124         u16* temp = (u16*)malloc(img->height*img->width*2);
00125         
00126         for(i = 0; i < img->height * img->width; i++)
00127                temp[i] = img->palette[img->data8[i]] | (1<<15);
00128 
00129         img->data16 = temp;
00130  }
00131 
00132 
00133 void PA_VueKeys(void);
00149 extern inline void PA_LoadTexture(int numtexture, u8* nomtexture, int mode){
00150 if(mode == texBIN){
00151 glBindTexture(0, numtexture);
00152 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0,TEXGEN_TEXCOORD, (u8*)nomtexture);
00153 }
00154 else if(mode == texPCX){
00155 sImage pcx;
00156 loadPCX((u8*)nomtexture, &pcx);
00157 PA_image8to16(&pcx);
00158 glBindTexture(0, numtexture);
00159 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.data8);
00160 }
00161 }
00170 extern inline void PA_Texture(int numtexture){
00171 glBindTexture(0, numtexture);
00172 }
00214 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);
00256 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);
00257 
00258 
00259 
00274 extern inline void PA_Rotate3D(float x,float y,float z){
00275        glRotateX(x);
00276     glRotateY(y);
00277        glRotateZ(z);
00278 }
00293 extern inline void PA_Translate3D(float x, float y, float z){
00294 glTranslate3f32(floatof32(x),floatof32(y),floatof32(z));
00295 }
00310 extern inline void PA_Scale3D(float x, float y, float z){
00311 if(x==0.0)x=1.0;
00312 if(y==0.0)y=1.0;
00313 if(z==0.0)z=1.0;
00314 MATRIX_SCALE = floatof32(x);
00315 MATRIX_SCALE = floatof32(y);
00316 MATRIX_SCALE = floatof32(z);
00317 }
00332 extern inline void PA_Vertex3D(float x, float y, float z){
00333 glVertex3v16(floatov16(x),floatov16(y),floatov16(z));
00334 }
00340 extern inline void PA_3Dto2D(){
00341 MATRIX_IDENTITY = 0;
00342 }
00343 
00344 
00356 extern inline void PA_Vertex2D(int x, int y){
00357        float x1 = (float)((x*0.36)/256)-0.18;
00358        float y1 = (float)((y*0.28)/192)-0.14;
00359        glVertex3v16(floatov16(x1),floatov16(y1),floatov16(-0.2));
00360 }
00372 extern inline void PA_TexCoord(float x, float y){
00373 glTexCoord1i(TEXTURE_PACK(intot16((int)x),intot16((int)y)));
00374 }
00375 struct PA_3DObject{
00376 u32 *callList;
00377 float maxx, maxy, maxz, minx, miny, minz;
00378 float scalex,scaley,scalez;
00379 };
00380 int PA_InitCallList(struct PA_3DObject obj);
00381 int PA_VertexCallList(struct PA_3DObject obj, float x, float y, float z);
00382 int PA_TexCoordCallList(struct PA_3DObject obj, int x, int y);
00383 int PA_EndCallList(struct PA_3DObject obj);
00384 int PA_Draw3Dobject(struct PA_3DObject obj);
00385 int PA_ScaleCallList(struct PA_3DObject obj, float x, float y, float z); // end of 3D
00387 
00388 
00389 #endif

Généré le Fri Dec 2 13:03:25 2005 pour PAlib par  doxygen 1.3.9.1