diff --git a/src/bmp.cpp b/src/bmp.cpp index a29cd76..5f02380 100644 --- a/src/bmp.cpp +++ b/src/bmp.cpp @@ -105,7 +105,9 @@ namespace OpenArena{ uint32 palletteEntries = 0; fread(&bmpHeader, sizeof(bmpHeader), 1, f); - #if __BYTE_ORDER == __BIG_ENDIAN + byte t[2] = {1,0}; + if( *((short*)t) !=1) + { //If big endian reorder bytes bmpHeader.type = ((bmpHeader.type & 0xff00) >> 8) | ((bmpHeader.type & 0x00ff) << 8); @@ -121,11 +123,12 @@ namespace OpenArena{ (bmpHeader.offset & 0x00ff0000) >> 8 | (bmpHeader.offset & 0x0000ff00) << 8 | (bmpHeader.offset & 0x000000ff) << 24; - #endif + } PrintBMPHeader(bmpHeader); fread(&bmpInfo, sizeof(bmpInfo), 1, f); - #if __BYTE_ORDER == __BIG_ENDIAN + if( *((short*)t) !=1) + { //If big endian reorder bytes bmpInfo.size = (bmpInfo.size & 0xff000000) >> 24 | (bmpInfo.size & 0x00ff0000) >> 8 | @@ -167,7 +170,7 @@ namespace OpenArena{ (bmpInfo.clrImportant & 0x00ff0000) >> 8 | (bmpInfo.clrImportant & 0x0000ff00) << 8 | (bmpInfo.clrImportant & 0x000000ff) << 24; - #endif + } PrintBMPInfo(bmpInfo); diff --git a/src/level.cpp b/src/level.cpp index 99e866b..9ca1f28 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -40,7 +40,6 @@ namespace OpenArena _window = NULL; textureNames = NULL; numTextures = 0; - textures = NULL; screen.SetName(OPENARENA_VERSION); @@ -298,7 +297,7 @@ namespace OpenArena for (uint32 i=0; iID());//Bind this triangle's texture glBegin(GL_TRIANGLES); // glNormal3f((GLfloat)triangles[i].normal.x, (GLfloat)triangles[i].normal.y, (GLfloat)triangles[i].normal.z); for (uint32 i2=0; i2<3; i2++) @@ -417,11 +416,11 @@ namespace OpenArena } //Free all map textures - if(textures) + if(!textures.IsEmpty()) { - delete [] textures; - textures = NULL; + //TODOiterate over list and delete all entries } + textures.Clear(); //Free the array of texture names if (textureNames) @@ -443,17 +442,14 @@ namespace OpenArena glEnable(GL_LIGHTING); */ - if(textures != NULL) - { - delete [] textures; - } - - textures = new Texture[numTextures]; + textures.Clear(); for(uint32 i=0; iLoad(gamedir + "textures/" + textureNames[i])) + texture->Load(DEFAULT_TEXTURE_NAME); + textures[i] = texture; } if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str())) diff --git a/src/level.h b/src/level.h index 8a9d10d..719cfd6 100644 --- a/src/level.h +++ b/src/level.h @@ -25,7 +25,7 @@ #include "tga.h" #include "list.h" #ifdef WIN32 -#include "bass.h" //for audio in windows only this should be replaced by oa_audio +#include "../lib/bass.h" //for audio in windows only this should be replaced by oa_audio #endif #include "vector.h" #include "camera.h" @@ -104,8 +104,7 @@ namespace OpenArena uint32 numTriangles; list players; list ents; - //list textures; - Texture* textures; + list textures; Texture menuTextures[NUM_MENU_TEXTURES]; Window* _window; diff --git a/src/tga.cpp b/src/tga.cpp index 6514ecd..b99682d 100644 --- a/src/tga.cpp +++ b/src/tga.cpp @@ -34,32 +34,6 @@ TextureImage* LoadTGA(const char * filename) fclose(file); return NULL; } - #if __BYTE_ORDER == __BIG_ENDIAN - /* This doesnt need to be done for this structure as it is just a collection of bytes - //If big endian reorder bytes - uint32 i; - - printf("\n%:X|", ((uint8*)&tgaheader)[1]); - for(i=1; iResize(_width, _height); if (!_initializer->Initialize()) { diff --git a/src/windows.cpp b/src/windows.cpp index a107b03..4231818 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -239,6 +239,14 @@ int WINAPI WinMain( HINSTANCE hInstance, InitControls(); + g_Screen.SetInitializer(new OpenArena::Window::Initializer()); + g_Screen.SetResizer(new OpenArena::Window::Resizer()); + if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen())) + { + return 0; + } + + level.SetWindow(&g_Screen); level.glFont.SetScreenDimensions(level.screen.GetWidth()*2, level.screen.GetHeight()*2); //level.glFont.BuildFont("oa\\textures\\menu\\font.bmp");//(level.gamedir + "\\textures\\menu\\font.bmp").c_str()); if (level.nextLevel == "") @@ -250,15 +258,6 @@ int WINAPI WinMain( HINSTANCE hInstance, level.LoadMap(); } - g_Screen.SetOnInit(InitGL); - g_Screen.SetOnResize(ReSizeGLScene); - if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen())) - { - return 0; - } - - level.SetWindow(g_Screen); - while(!done) { while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))