- Timestamp:
- Jun 8, 2006, 11:11:37 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/Makefile.am
r7810 r8293 56 56 57 57 58 SUBDIRS = importer \ 59 spatial_separation 60 58 SUBDIRS = importer \ 59 spatial_separation 61 60 EXTRA_DIST = -
trunk/src/lib/graphics/importer/md2Model.cc
r7732 r8293 14 14 15 15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER 16 16 #include "config.h" 17 #ifdef HAVE_SDL_SDL_H 18 #include <SDL/SDL.h> 19 #include <SDL/SDL_endian.h> 20 #else 21 #include <SDL.h> 22 #include <SDL_endian.h> 23 #endif 17 24 #include "md2Model.h" 18 25 #include "material.h" … … 20 27 #include "debug.h" 21 28 #include "util/loading/resource_manager.h" 22 23 29 24 30 using namespace std; … … 67 73 68 74 75 #ifdef SDL_LIL_ENDIAN 76 #define BULK_CONV( _ptr, _num ) do { \ 77 int _cnt = _num;\ 78 int* _iptr = (int*)_ptr;\ 79 for( int _l = 0; _l<_cnt; ++_l )\ 80 _iptr[_l] = SDL_SwapLE32( _iptr[_l] );\ 81 } while( 0 ) 82 #define BULK_CONV16( _ptr, _num ) do { \ 83 short _cnt = _num;\ 84 short* _iptr = (short*)_ptr;\ 85 for( int _l = 0; _l<_cnt; ++_l )\ 86 _iptr[_l] = SDL_SwapLE16( _iptr[_l] );\ 87 } while( 0 ) 88 #else 89 #define BULK_CONV( _ptr, _num ) 90 #define BULK_CONV16( _ptr, _num ) 91 #endif 69 92 70 93 /******************************************************************************** … … 80 103 /* this creates the data container via ressource manager */ 81 104 if (!modelFileName.empty()) 82 this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale); 105 this->data = (MD2Data*)ResourceManager::getInstance()->load( 106 modelFileName, MD2, RP_GAME, skinFileName, scale); 107 108 //When arriving here it is assumed that everything is in the correct byte order. 83 109 if( unlikely(this->data == NULL)) 84 110 PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n"); … … 92 118 this->setAnim(STAND); 93 119 94 this->debug();120 //this->debug(); 95 121 96 122 //write the modelinfo information … … 99 125 this->pModelInfo.numNormals = 0; 100 126 this->pModelInfo.numTexCoor = this->data->numTexCoor; 127 101 128 this->pModelInfo.pVertices = (float*)this->data->pVertices; 129 102 130 this->pModelInfo.pNormals = NULL; 131 103 132 this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor; 104 133 105 134 // triangle conversion 106 135 this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles]; … … 357 386 void MD2Model::debug() 358 387 { 359 PRINT(0)("\n==========================| MD2Model::debug() |===\n"); 360 PRINT(0)("= Model FileName:\t%s\n", this->data->fileName.c_str()); 361 PRINT(0)("= Skin FileName:\t%s\n", this->data->skinFileName.c_str()); 362 PRINT(0)("= Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size 363 PRINT(0)("= Number of Vertices:\t%i\n", this->data->header->numVertices); 364 PRINT(0)("= Number of Frames: \t%i\n", this->data->header->numFrames); 365 PRINT(0)("= Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth); 366 PRINT(0)("= Pointer to the data object: %p\n", this->data); 367 PRINT(0)("===================================================\n\n"); 388 //PRINTF(0)("\n==========================| MD2Model::debug() |===\n"); 389 PRINTF(0)("= Model FileName:\t%s\n", this->data->fileName.c_str()); 390 PRINTF(0)("= Skin FileName:\t%s\n", 391 this->data->skinFileName.c_str()); 392 PRINTF(0)("= Size in Memory:\t%i Bytes\n", 393 this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size 394 PRINTF(0)("= Number of Vertices:\t%i\n", this->data->header->numVertices); 395 PRINTF(0)("= Number of Frames: \t%i\n", this->data->header->numFrames); 396 PRINTF(0)("= Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth); 397 PRINTF(0)("= Pointer to the data object: %p\n", this->data); 398 //PRINTF(0)("===================================================\n\n"); 368 399 } 369 400 … … 442 473 this->header = new MD2Header; 443 474 fread(this->header, 1, sizeof(MD2Header), pFile); 475 BULK_CONV( this->header, sizeof(MD2Header)/4 ); 444 476 /* check for the header version: make sure its a md2 file :) */ 445 if( unlikely( this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))477 if( unlikely( this->header->version != MD2_VERSION) && unlikely( this->header->ident != MD2_IDENT)) 446 478 { 447 479 PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str()); … … 449 481 } 450 482 451 this->fileName = fileName;483 this->fileName = fileName; 452 484 /* got the data: map it to locals */ 453 485 this->numFrames = this->header->numFrames; … … 468 500 fseek(pFile, this->header->offsetFrames, SEEK_SET); 469 501 fread(buffer, this->header->frameSize, this->numFrames, pFile); 502 //BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 ); 470 503 /* read opengl commands */ 471 504 fseek(pFile, this->header->offsetGlCommands, SEEK_SET); 505 472 506 fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile); 507 BULK_CONV( this->pGLCommands, this->numGLCommands ); 473 508 /* triangle list */ 474 509 fseek(pFile, this->header->offsetTriangles, SEEK_SET); 475 fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile); 510 fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile); 511 BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 ); 512 476 513 /* read in texture coordinates */ 477 514 fseek(pFile, this->header->offsetTexCoords, SEEK_SET); 478 515 fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile); 479 516 BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 ); 480 517 481 518 for(int i = 0; i < this->numFrames; ++i) 482 519 { 483 520 frame = (sFrame*)(buffer + this->header->frameSize * i); 521 //Convert the translate and scale Vec3D if needed. 522 BULK_CONV( frame, 6 ); 523 BULK_CONV( frame->pVertices, 3 ); 484 524 pVertex = this->pVertices + this->numVertices * i; 485 525 pNormals = this->pLightNormals + this->numVertices * i; -
trunk/src/lib/graphics/importer/texture.cc
r8145 r8293 21 21 #include "compiler.h" 22 22 23 // INCLUDING SDL_Image 24 #ifdef HAVE_SDL_IMAGE_H 23 #ifdef HAVE_SDL_SDL_H 24 #include <SDL/SDL_image.h> 25 #include <SDL/SDL_endian.h> 26 #include <SDL/SDL_byteorder.h> 27 #else 28 #include <SDL_endian.h> 25 29 #include <SDL_image.h> 30 #include <SDL_byteorder.h> 31 #endif 32 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 33 /* 34 * On the BIG_ENDIAN architecture, the 24 and 32bit bitmaps have 35 * different masks. If you don't do this distinction properly, 36 * you will get weird-looking textures. 37 */ 38 Uint32 alphaMask[] = { 39 0xFF000000, 40 0x00FF0000, 41 0x0000FF00, 42 0x000000FF, 43 }; 44 45 Uint32 opaqueMask[] = { 46 0x00FF0000, 47 0x0000FF00, 48 0x000000FF, 49 0xFF000000 50 }; 26 51 #else 27 #include <SDL/SDL_image.h> 52 /* 53 * On the LIL_ENDIAN architecture everything is fine and easy. The 24 54 * and 32bit bitmaps have the same masks. 55 */ 56 Uint32 alphaMask[] = { 57 0x000000FF, 58 0x0000FF00, 59 0x00FF0000, 60 0xFF000000, 61 }; 62 63 Uint32 *opaqueMask = alphaMask; 64 28 65 #endif 29 30 66 31 67 TextureData::TextureData() … … 251 287 Uint32 saved_flags; 252 288 Uint8 saved_alpha; 253 254 289 hasAlpha = false; 255 290 int pixelDepth = 24; 256 291 292 Uint32* mask = opaqueMask; 293 257 294 /* Save the alpha blending attributes */ 258 295 saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK); 259 296 saved_alpha = surface->format->alpha; 260 if ( (saved_flags & SDL_SRCALPHA) ==SDL_SRCALPHA )297 if ( saved_flags & SDL_SRCALPHA ) 261 298 { 262 299 SDL_SetAlpha(surface, 0, 0); 263 300 hasAlpha = true; 264 301 pixelDepth = 32; 265 } 266 302 mask = alphaMask; 303 } 304 267 305 retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 268 306 surface->w, surface->h, 269 307 pixelDepth, 270 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 271 0x000000FF, 272 0x0000FF00, 273 0x00FF0000, 274 0xFF000000 275 #else 276 0xFF000000, 277 0x00FF0000, 278 0x0000FF00, 279 0x000000FF 280 #endif 281 ); 308 mask[0], mask[1], mask[2], mask[3] ); 282 309 if ( retSurface == NULL ) 283 310 return NULL; -
trunk/src/lib/graphics/spatial_separation/quadtree.cc
r5430 r8293 25 25 26 26 using namespace std; 27 28 27 #define QUADTREE_MATERIAL_COUNT 4 29 28 -
trunk/src/lib/math/vector.h
r8145 r8293 93 93 Vector getNormalized() const; 94 94 Vector abs(); 95 95 96 /** @param toVec nears this Vector to... @param t how much to advance (0.0: not at all; 1.0: fully) */ 96 97 inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; }; -
trunk/src/lib/sound/ogg_player.cc
r7849 r8293 31 31 32 32 #include "debug.h" 33 34 #ifdef HAVE_SDL_SDL_H 35 36 #include <SDL/SDL.h> 37 #include <SDL/SDL_endian.h> 38 39 #else 40 41 #include <SDL.h> 42 #include <SDL_endian.h> 43 44 #endif 33 45 34 46 namespace OrxSound … … 151 163 bool OggPlayer::play() 152 164 { 153 if (!(this->state & OggPlayer::FileOpened))165 /*if (!(this->state & OggPlayer::FileOpened)) 154 166 return false; 155 167 … … 161 173 if (this->musicThreadID == NULL) 162 174 return ((this->musicThreadID = SDL_CreateThread(OggPlayer::musicThread, (void*)this)) != NULL); 163 return true; 175 return true;*/ 164 176 } 165 177 … … 385 397 if(size == 0) 386 398 return false; 387 399 /*#ifdef SDL_BIG_ENDIAN 400 int cnt = wavLength/2; 401 Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer; 402 for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts ) 403 *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts ); 404 #endif*/ 388 405 alBufferData(buffer, format, pcm, size, vorbisInfo->rate); 389 406 if (DEBUG_LEVEL >= 3) -
trunk/src/lib/sound/sound_buffer.cc
r7460 r8293 22 22 #include "sdlincl.h" 23 23 #include <cassert> 24 24 #ifdef HAVE_SDL_SDL_H 25 #include <SDL/SDL.h> 26 #include <SDL/SDL_endian.h> 27 #else 28 #include <SDL.h> 29 #include <SDL_endian.h> 30 #endif 25 31 namespace OrxSound 26 32 { … … 67 73 return false; 68 74 } 69 70 alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec), wavBuffer, wavLength, wavSpec.freq); 75 #if SDL_BYTEORDER == SDL_BIG_ENDIAN 76 if ( !( wavSpec.format == AUDIO_U8 || wavSpec.format == AUDIO_S8 ) ) { 77 int cnt = wavLength/2; 78 Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer; 79 for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts ) 80 *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts ); 81 } 82 #endif 83 alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec), 84 wavBuffer, wavLength, wavSpec.freq); 85 71 86 SDL_FreeWAV(wavBuffer); 72 87 if (SoundEngine::checkError("Could not load Wave file", __LINE__)) -
trunk/src/lib/util/file.cc
r8276 r8293 23 23 #include <fstream> 24 24 25 #ifdef __unix__ 25 #ifdef __unix__ 26 26 #include <unistd.h> 27 27 #elif __WIN32__ || _MS_DOS_ 28 28 #include <dir.h> 29 29 #else 30 #include <direct.h>30 //#include <direct.h> 31 31 #endif 32 32 -
trunk/src/util/signal_handler.cc
r8228 r8293 46 46 void SignalHandler::catchSignal( int sig ) 47 47 { 48 sig handler_t handler = signal( sig, SignalHandler::sigHandler );48 sig_t handler = signal( sig, SignalHandler::sigHandler ); 49 49 50 50 assert( handler != SIG_ERR ); … … 63 63 (*(it->cb))( it->someData ); 64 64 } 65 66 std::string sigName = "UNKNOWN"; 65 67 66 std::string sigName = "UNKNOWN";67 68 68 switch ( sig ) 69 69 { … … 90 90 { 91 91 getInstance()->dontCatch(); 92 93 92 sleep(2); 94 93 -
trunk/src/util/signal_handler.h
r8228 r8293 10 10 #include <string> 11 11 12 12 13 #define GDB_BT_FILE "orxonox.backtrace" 13 14 14 enum GdbRunType{ 15 15 GDB_RUN_WRITE_TO_FILE = 1, … … 25 25 { 26 26 int signal; 27 sig handler_t handler;27 sig_t handler; 28 28 }; 29 29
Note: See TracChangeset
for help on using the changeset viewer.