Changed Moved LoadBMP into the OpenArena namespace

~g2k
This commit is contained in:
2006-06-18 14:30:52 -04:00
parent 64c8c11d0c
commit b03bdb0cbc
2 changed files with 163 additions and 155 deletions

View File

@@ -5,6 +5,8 @@
#include "datatypes.h" #include "datatypes.h"
#include "texture.h" #include "texture.h"
TextureImage* LoadBMP(const char* Filename); namespace OpenArena{
TextureImage* LoadBMP(const char* Filename);
};
#endif #endif

View File

@@ -20,19 +20,24 @@
#include <cstdio> #include <cstdio>
#include "../include/bmp.h" #include "../include/bmp.h"
#ifdef WIN32
#pragma warning(disable:4996)
#endif
namespace OpenArena{
#pragma pack(push,1) #pragma pack(push,1)
struct BITMAP_HEADER struct BITMAP_HEADER
{ {
uint16 type; uint16 type;
uint32 size; uint32 size;
uint16 reserved1; uint16 reserved1;
uint16 reserved2; uint16 reserved2;
uint32 offset; uint32 offset;
}; };
struct BITMAP_INFO struct BITMAP_INFO
{ {
uint32 size; uint32 size;
uint32 width; uint32 width;
uint32 height; uint32 height;
@@ -44,21 +49,21 @@ struct BITMAP_INFO
uint32 yPelsPerMeter; uint32 yPelsPerMeter;
uint32 clrUsed; uint32 clrUsed;
uint32 clrImportant; uint32 clrImportant;
}; };
struct BITMAP_QUAD struct BITMAP_QUAD
{ {
uint8 blue; uint8 blue;
uint8 green; uint8 green;
uint8 red; uint8 red;
uint8 reserved; uint8 reserved;
}; };
#pragma pack(pop) #pragma pack(pop)
#define BITMAP_MAGIC 19778 #define BITMAP_MAGIC 19778
TextureImage* LoadBMP(const char* fn) TextureImage* LoadBMP(const char* fn)
{ {
//If anything is not perfect return NULL after cleaning up our mess //If anything is not perfect return NULL after cleaning up our mess
FILE* f=NULL; //A pointer to our file structure FILE* f=NULL; //A pointer to our file structure
@@ -83,9 +88,9 @@ TextureImage* LoadBMP(const char* fn)
if(bmpInfo.width < 0) if(bmpInfo.width < 0)
{ {
//This needs to be abstracted somehow //This needs to be abstracted somehow
#ifdef WIN32 #ifdef WIN32
MessageBox(NULL, "Image width is negative", "ERROR", MB_OK); MessageBox(NULL, "Image width is negative", "ERROR", MB_OK);
#endif #endif
fclose(f); fclose(f);
return NULL; return NULL;
} }
@@ -93,9 +98,9 @@ TextureImage* LoadBMP(const char* fn)
if(bmpInfo.width % 4 != 0) if(bmpInfo.width % 4 != 0)
{ {
//This needs to be abstracted somehow //This needs to be abstracted somehow
#ifdef WIN32 #ifdef WIN32
MessageBox(NULL, "Image width must be a multiple of 8", "ERROR", MB_OK); MessageBox(NULL, "Image width must be a multiple of 8", "ERROR", MB_OK);
#endif #endif
fclose(f); fclose(f);
return NULL; return NULL;
} }
@@ -103,9 +108,9 @@ TextureImage* LoadBMP(const char* fn)
if(bmpInfo.height < 0) if(bmpInfo.height < 0)
{ {
//This needs to be abstracted somehow //This needs to be abstracted somehow
#ifdef WIN32 #ifdef WIN32
MessageBox(NULL, "Image height is negative", "ERROR", MB_OK); MessageBox(NULL, "Image height is negative", "ERROR", MB_OK);
#endif #endif
fclose(f); fclose(f);
return NULL; return NULL;
} }
@@ -113,9 +118,9 @@ TextureImage* LoadBMP(const char* fn)
if(bmpInfo.height % 4 != 0) if(bmpInfo.height % 4 != 0)
{ {
//This needs to be abstracted somehow //This needs to be abstracted somehow
#ifdef WIN32 #ifdef WIN32
MessageBox(NULL, "Image height must be a multiple of 8", "ERROR", MB_OK); MessageBox(NULL, "Image height must be a multiple of 8", "ERROR", MB_OK);
#endif #endif
fclose(f); fclose(f);
return NULL; return NULL;
} }
@@ -123,9 +128,9 @@ TextureImage* LoadBMP(const char* fn)
if((bmpInfo.bitCount != 8 && bmpInfo.bitCount != 24) || bmpInfo.compression != 0) if((bmpInfo.bitCount != 8 && bmpInfo.bitCount != 24) || bmpInfo.compression != 0)
{ {
//This needs to be abstracted somehow //This needs to be abstracted somehow
#ifdef WIN32 #ifdef WIN32
MessageBox(NULL, "Only 8 and 24 bit uncompressed windows bmp files are currently supported", "ERROR", MB_OK); MessageBox(NULL, "Only 8 and 24 bit uncompressed windows bmp files are currently supported", "ERROR", MB_OK);
#endif #endif
fclose(f); fclose(f);
return NULL; return NULL;
} }
@@ -191,4 +196,5 @@ TextureImage* LoadBMP(const char* fn)
return tex; return tex;
} }
return NULL; return NULL;
} }
};