*** empty log message ***

This commit is contained in:
2006-07-03 05:12:06 -04:00
parent f2ac04d3b5
commit c5264c1887
15 changed files with 692 additions and 822 deletions

View File

@@ -2,7 +2,6 @@
CPP = g++ -g CPP = g++ -g
INCLUDES = INCLUDES =
LD = g++ LD = g++
INCLUDEPATH = ../include
X11INCLUDEDIR = /usr/X11R6/include X11INCLUDEDIR = /usr/X11R6/include
X11LIBDIR = /usr/X11R6/lib X11LIBDIR = /usr/X11R6/lib
INCLUDE_DIRS = -I$(X11INCLUDEDIR) INCLUDE_DIRS = -I$(X11INCLUDEDIR)
@@ -13,10 +12,10 @@ LIBRARIES =
SO_LIBS = SO_LIBS =
SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so
CPPFLAGS = $(INCLUDE_DIRS) CPPFLAGS = $(INCLUDE_DIRS)
LDFLAGS = $(LIBS) LDFLAGS = $(LIBS) -bind_at_load --disable-framework=/Library/Frameworks/OpenGL
.Phony: all clean install .Phony: all clean install
all: ../OpenArena/OpenArena all: ../OpenArena
clean: clean:
rm -f *.o rm -f *.o
@@ -25,8 +24,8 @@ clean:
install: install:
#Executables #Executables
../OpenArena/OpenArena: $(OBJECTS) ../OpenArena: $(OBJECTS)
$(LD) $(LDFLAGS) $(INCLUDE_DIRS) -o ../OpenArena/OpenArena $(OBJECTS) $(LD) $(LDFLAGS) $(INCLUDE_DIRS) -o ../OpenArena $(OBJECTS)
#Dynamic Libraries #Dynamic Libraries
oa_game.so: oa_game.so:
@@ -40,50 +39,50 @@ oa_video.so:
oa_input.so: oa_input.so:
#Object Files #Object Files
screen.o: screen.cpp $(INCLUDEPATH)/screen.h screen.o: screen.cpp screen.h
$(CPP) -c $(INCLUDE_DIRS) -o screen.o screen.cpp $(CPP) -c $(INCLUDE_DIRS) -o screen.o screen.cpp
bmp.o: bmp.cpp $(INCLUDEPATH)/bmp.h $(INCLUDEPATH)/mygl.h $(INCLUDEPATH)/datatypes.h $(INCLUDEPATH)/texture.h bmp.o: bmp.cpp bmp.h mygl.h datatypes.h texture.h
$(CPP) -c $(INCLUDE_DIRS) -o bmp.o bmp.cpp $(CPP) -c $(INCLUDE_DIRS) -o bmp.o bmp.cpp
camera.o: camera.cpp $(INCLUDEPATH)/camera.h $(INCLUDEPATH)/vector.h $(INCLUDEPATH)/mygl.h $(INCLUDEPATH)/screen.h camera.o: camera.cpp camera.h vector.h mygl.h screen.h
$(CPP) -c $(INCLUDE_DIRS) -o camera.o camera.cpp $(CPP) -c $(INCLUDE_DIRS) -o camera.o camera.cpp
ctrls.o: ctrls.cpp $(INCLUDEPATH)/ctrls.h $(INCLUDEPATH)/keys.h $(INCLUDEPATH)/physics.h $(INCLUDEPATH)/datatypes.h $(INCLUDEPATH)/list.h ctrls.o: ctrls.cpp ctrls.h keys.h physics.h datatypes.h list.h
$(CPP) -c $(INCLUDE_DIRS) -o ctrls.o ctrls.cpp $(CPP) -c $(INCLUDE_DIRS) -o ctrls.o ctrls.cpp
level.o: level.cpp $(INCLUDEPATH)/level.h $(INCLUDEPATH)/version.h level.o: level.cpp level.h version.h
$(CPP) -c $(INCLUDE_DIRS) -o level.o level.cpp $(CPP) -c $(INCLUDE_DIRS) -o level.o level.cpp
mygl.o: mygl.cpp $(INCLUDEPATH)/mygl.h mygl.o: mygl.cpp mygl.h
$(CPP) -c $(INCLUDE_DIRS) -o mygl.o mygl.cpp $(CPP) -c $(INCLUDE_DIRS) -o mygl.o mygl.cpp
myglFont.o: myglFont.cpp $(INCLUDEPATH)/myglFont.h myglFont.o: myglFont.cpp myglFont.h
$(CPP) -c $(INCLUDE_DIRS) -o myglFont.o myglFont.cpp $(CPP) -c $(INCLUDE_DIRS) -o myglFont.o myglFont.cpp
myglTexture.o: myglTexture.cpp $(INCLUDEPATH)/myglTexture.h myglTexture.o: myglTexture.cpp myglTexture.h
$(CPP) -c $(INCLUDE_DIRS) -o myglTexture.o myglTexture.cpp $(CPP) -c $(INCLUDE_DIRS) -o myglTexture.o myglTexture.cpp
physics.o: physics.cpp $(INCLUDEPATH)/physics.h physics.o: physics.cpp physics.h
$(CPP) -c $(INCLUDE_DIRS) -o physics.o physics.cpp $(CPP) -c $(INCLUDE_DIRS) -o physics.o physics.cpp
player.o: player.cpp $(INCLUDEPATH)/player.h player.o: player.cpp player.h
$(CPP) -c $(INCLUDE_DIRS) -o player.o player.cpp $(CPP) -c $(INCLUDE_DIRS) -o player.o player.cpp
strmanip.o: strmanip.cpp $(INCLUDEPATH)/strmanip.h strmanip.o: strmanip.cpp strmanip.h
$(CPP) -c $(INCLUDE_DIRS) -o strmanip.o strmanip.cpp $(CPP) -c $(INCLUDE_DIRS) -o strmanip.o strmanip.cpp
tga.o: tga.cpp $(INCLUDEPATH)/tga.h tga.o: tga.cpp tga.h
$(CPP) -c $(INCLUDE_DIRS) -o tga.o tga.cpp $(CPP) -c $(INCLUDE_DIRS) -o tga.o tga.cpp
vector.o: vector.cpp $(INCLUDEPATH)/vector.h vector.o: vector.cpp vector.h
$(CPP) -c $(INCLUDE_DIRS) -o vector.o vector.cpp $(CPP) -c $(INCLUDE_DIRS) -o vector.o vector.cpp
window.o: window.cpp $(INCLUDEPATH)/window.h window.o: window.cpp window.h
$(CPP) -c $(INCLUDE_DIRS) -o window.o window.cpp $(CPP) -c $(INCLUDE_DIRS) -o window.o window.cpp
keys.o: keys.cpp $(INCLUDEPATH)/keys.h keys.o: keys.cpp keys.h
$(CPP) -c $(INCLUDE_DIRS) -o keys.o keys.cpp $(CPP) -c $(INCLUDE_DIRS) -o keys.o keys.cpp
main.o: macosx.cpp $(INCLUDEPATH)/main.h main.o: macosx.cpp main.h
$(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp $(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp

View File

@@ -26,215 +26,58 @@
namespace OpenArena{ namespace OpenArena{
/*! #pragma pack(push,1)
* \brief struct BITMAP_HEADER
* Write brief comment for BitmapImage here.
*
* Write detailed description for BitmapImage here.
*
* \remarks
* Write remarks for BitmapImage here.
*
* \see
* Separate items with the '|' character.
*/
BitmapImage::BitmapImage()
{ {
BitmapImage(1, 1); uint16 type;
uint32 size;
uint16 reserved1;
uint16 reserved2;
uint32 offset;
};
struct BITMAP_INFO
{
uint32 size;
uint32 width;
uint32 height;
uint16 planes;
uint16 bitCount;
uint32 compression;
uint32 sizeImage;
uint32 xPelsPerMeter;
uint32 yPelsPerMeter;
uint32 clrUsed;
uint32 clrImportant;
};
struct BITMAP_QUAD
{
uint8 blue;
uint8 green;
uint8 red;
uint8 reserved;
};
#pragma pack(pop)
#define BITMAP_MAGIC 19778
void PrintBMPHeader(BITMAP_HEADER header)
{
printf("Header\n");
printf("Type: %X\nSize: %X\nReserved1: %X\nReserved2: %X\nOffset:%X\n", header.type, header.size, header.reserved1, header.reserved2, header.offset);
} }
void PrintBMPInfo(BITMAP_INFO info)
BitmapImage::BitmapImage(uint32 width, uint32 height, uint32 bitsPerPixel, Image::Type type)
{ {
_width = width; printf("Info\n");
_height = height; printf("Size: %X\nWidth: %X\nHeight:%X\n", info.size, info.width, info.height);
_bpp = bitsPerPixel; printf("Planes: %X\nBitCount: %X\nCompression: %X\n", info.planes, info.bitCount, info.compression);
_type = type; printf("SizeImage: %X\nXPelsPerMeter: %X\nYPelsPerMeter: %X\n", info.sizeImage, info.xPelsPerMeter, info.yPelsPerMeter);
_data = new uint8[_width * _height * (_bpp >> 3)]; printf("ClrUsed: %X\nClrImportant: %X\n", info.clrUsed, info.clrImportant);
} }
BitmapImage::~BitmapImage() TextureImage* LoadBMP(const char* fn)
{
delete [] _data;
}
uint8 * BitmapImage::GetImageData() const
{
return _data;
}
uint32 BitmapImage::GetBitsPerPixel() const
{
return _bpp;
}
uint32 BitmapImage::GetBytesPerPixel() const
{
return _bpp >> 3;
}
uint32 BitmapImage::GetWidth() const
{
return _width;
}
uint32 BitmapImage::GetHeight() const
{
return _height;
}
Image::Type BitmapImage::GetType() const
{
return _type;
}
BitmapImage* BitmapImage::CreateFromFile(const char* filename)
{
FILE* file = NULL; //A file from cstdlib?
//If our filename is null return an empty 1x1 image
if(filename == NULL)
{
return new BitmapImage(1,1);
}
//Try to open the file
file = fopen(filename, "rb");
//If the open failed return an empry 1x1 image
if(file == NULL)
{
return new BitmapImage(1,1);
}
BITMAP_HEADER bmpHeader;
BITMAP_INFO bmpInfo;
BITMAP_QUAD* pallette = NULL;
uint32 numPalletteEntries = 0;
uint32 numPixels;
//Read the header from the file
fread(&bmpHeader, sizeof(bmpHeader), 1, file);
fread(&bmpInfo, sizeof(bmpInfo), 1, file);
//Check for an invalid header
if(bmpInfo.width < 0) //See if the width is negative
{
//This needs to be abstracted somehow
#ifdef WIN32
MessageBox(NULL, "Image width is negative", "ERROR", MB_OK);
#endif
fclose(file);
return NULL;
}
if(bmpInfo.width % 4 != 0) //If the width is not a multiple of 4
{
//This needs to be abstracted somehow
#ifdef WIN32
MessageBox(NULL, "Image width must be a multiple of 8", "ERROR", MB_OK);
#endif
fclose(file);
return NULL;
}
if(bmpInfo.height < 0) //If the height is negative
{
//This needs to be abstracted somehow
#ifdef WIN32
MessageBox(NULL, "Image height is negative", "ERROR", MB_OK);
#endif
fclose(file);
return NULL;
}
if(bmpInfo.height % 4 != 0) //If the height is not a multiple of 4
{
//This needs to be abstracted somehow
#ifdef WIN32
MessageBox(NULL, "Image height must be a multiple of 8", "ERROR", MB_OK);
#endif
fclose(file);
return NULL;
}
if((bmpInfo.bitCount != 8 && bmpInfo.bitCount != 24) || bmpInfo.compression != 0) //Make sure the file is 8 or 24 bit and uncompressed
{ //This needs to be abstracted somehow
#ifdef WIN32
MessageBox(NULL, "Only 8 and 24 bit uncompressed windows bmp files are currently supported", "ERROR", MB_OK);
#endif
fclose(file);
return NULL;
}
BitmapImage* image = new BitmapImage(bmpInfo.width, bmpInfo.height, bmpInfo.bitCount, (Type)GL_RGB);
numPixels = image->GetWidth() * image->GetHeight();
//If 8-bit load the pallette
if(image->GetBitsPerPixel() == 8)
{
//TODO finish this
numPalletteEntries = image->GetBytesPerPixel();
pallette = new BITMAP_QUAD[numPalletteEntries];
// fread(pallette, sizeof(OpenArena::Bitmap::BITMAP_QUAD), pallette, file);
}
//Seek to the start of data
fseek(file, bmpHeader.offset, SEEK_SET);
//Read the image data
fread(image->_data, numPixels * image->GetBytesPerPixel(), 1, file);
//If 8-bit apply the pallette
if(image->GetBitsPerPixel() == 8)
{
//TODO finish this
uint32 i1, i2;
for(i1=0; i1<numPixels; i1++)
{
i2 = (i1 << 1) + 1;
if(image->_data[i1] < numPalletteEntries)
{
image->_data[i2] = pallette[image->_data[i1]].red;
image->_data[i2+1] = pallette[image->_data[i1]].blue;
image->_data[i2+2] = pallette[image->_data[i1]].green;
}
}
//uint8* image = tex->data;
//tex->bpp = 24;
//bytes = pixels * tex->bpp;
//tex->data = new uint8[bytes];
//uint32 i;
//uint32 i2;
//for(i=0; i<pixels; i++)
//{
// i2 = (i << 1) + 1;
// //Should make sure image[i] < palletteEntries
// tex->data[i2] = bmpPallette[image[i]].red;
// tex->data[i2 + 1] = bmpPallette[image[i]].blue;
// tex->data[i2 + 2] = bmpPallette[image[i]].green;
//}
//delete [] image;
//image = NULL;
}
else if(image->GetBitsPerPixel() == 24)
{
//Convert to rgb
uint32 i;
uint8 swap;
for(i=0; i<numPixels * image->GetBytesPerPixel(); i+=3)
{
swap = image->_data[i];
image->_data[i] = image->_data[i+2];
image->_data[i+2] = swap;
}
}
return image;
}
TextureImage* BitmapImage::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
@@ -242,20 +85,86 @@ namespace OpenArena{
//If our filename is null //If our filename is null
if(!fn) if(!fn)
{
return NULL; return NULL;
}
//Try to open our file and if successfull... //Try to open our file and if successfull...
f=fopen(fn, "rb"); f=fopen(fn, "rb");
if(f) if(f)
{ {
BitmapImage::BITMAP_HEADER bmpHeader; BITMAP_HEADER bmpHeader;
BitmapImage::BITMAP_INFO bmpInfo; BITMAP_INFO bmpInfo;
BitmapImage::BITMAP_QUAD* bmpPallette = NULL; BITMAP_QUAD* bmpPallette = NULL;
uint32 palletteEntries = 0; uint32 palletteEntries = 0;
fread(&bmpHeader, sizeof(bmpHeader), 1, f); fread(&bmpHeader, sizeof(bmpHeader), 1, f);
#if __BYTE_ORDER == __BIG_ENDIAN
//If big endian reorder bytes
bmpHeader.type = ((bmpHeader.type & 0xff00) >> 8) |
((bmpHeader.type & 0x00ff) << 8);
bmpHeader.size = (bmpHeader.size & 0xff000000) >> 24 |
(bmpHeader.size & 0x00ff0000) >> 8 |
(bmpHeader.size & 0x0000ff00) << 8 |
(bmpHeader.size & 0x000000ff) << 24;
bmpHeader.reserved1 = ((bmpHeader.reserved1 & 0xff00) >> 8) |
((bmpHeader.reserved1 & 0x00ff) << 8);
bmpHeader.reserved2 = ((bmpHeader.reserved2 & 0xff00) >> 8) |
((bmpHeader.reserved2 & 0x00ff) << 8);
bmpHeader.offset = (bmpHeader.offset & 0xff000000) >> 24 |
(bmpHeader.offset & 0x00ff0000) >> 8 |
(bmpHeader.offset & 0x0000ff00) << 8 |
(bmpHeader.offset & 0x000000ff) << 24;
#endif
PrintBMPHeader(bmpHeader);
fread(&bmpInfo, sizeof(bmpInfo), 1, f); fread(&bmpInfo, sizeof(bmpInfo), 1, f);
#if __BYTE_ORDER == __BIG_ENDIAN
//If big endian reorder bytes
bmpInfo.size = (bmpInfo.size & 0xff000000) >> 24 |
(bmpInfo.size & 0x00ff0000) >> 8 |
(bmpInfo.size & 0x0000ff00) << 8 |
(bmpInfo.size & 0x000000ff) << 24;
bmpInfo.width = (bmpInfo.width & 0xff000000) >> 24 |
(bmpInfo.width & 0x00ff0000) >> 8 |
(bmpInfo.width & 0x0000ff00) << 8 |
(bmpInfo.width & 0x000000ff) << 24;
bmpInfo.height = (bmpInfo.height & 0xff000000) >> 24 |
(bmpInfo.height & 0x00ff0000) >> 8 |
(bmpInfo.height & 0x0000ff00) << 8 |
(bmpInfo.height & 0x000000ff) << 24;
bmpInfo.planes = ((bmpInfo.planes & 0xff00) >> 8) |
((bmpInfo.planes & 0x00ff) << 8);
bmpInfo.bitCount = ((bmpInfo.bitCount & 0xff00) >> 8) |
((bmpInfo.bitCount & 0x00ff) << 8);
bmpInfo.compression = (bmpInfo.compression & 0xff000000) >> 24 |
(bmpInfo.compression & 0x00ff0000) >> 8 |
(bmpInfo.compression & 0x0000ff00) << 8 |
(bmpInfo.compression & 0x000000ff) << 24;
bmpInfo.sizeImage = (bmpInfo.sizeImage & 0xff000000) >> 24 |
(bmpInfo.sizeImage & 0x00ff0000) >> 8 |
(bmpInfo.sizeImage & 0x0000ff00) << 8 |
(bmpInfo.sizeImage & 0x000000ff) << 24;
bmpInfo.xPelsPerMeter = (bmpInfo.xPelsPerMeter & 0xff000000) >> 24 |
(bmpInfo.xPelsPerMeter & 0x00ff0000) >> 8 |
(bmpInfo.xPelsPerMeter & 0x0000ff00) << 8 |
(bmpInfo.xPelsPerMeter & 0x000000ff) << 24;
bmpInfo.yPelsPerMeter = (bmpInfo.yPelsPerMeter & 0xff000000) >> 24 |
(bmpInfo.yPelsPerMeter & 0x00ff0000) >> 8 |
(bmpInfo.yPelsPerMeter & 0x0000ff00) << 8 |
(bmpInfo.yPelsPerMeter & 0x000000ff) << 24;
bmpInfo.clrUsed = (bmpInfo.clrUsed & 0xff000000) >> 24 |
(bmpInfo.clrUsed & 0x00ff0000) >> 8 |
(bmpInfo.clrUsed & 0x0000ff00) << 8 |
(bmpInfo.clrUsed & 0x000000ff) << 24;
bmpInfo.clrImportant = (bmpInfo.clrImportant & 0xff000000) >> 24 |
(bmpInfo.clrImportant & 0x00ff0000) >> 8 |
(bmpInfo.clrImportant & 0x0000ff00) << 8 |
(bmpInfo.clrImportant & 0x000000ff) << 24;
#endif
PrintBMPInfo(bmpInfo);
if(bmpInfo.width < 0) if(bmpInfo.width < 0)
{ {
@@ -324,8 +233,8 @@ namespace OpenArena{
{ {
//Load the pallette //Load the pallette
palletteEntries = bmpInfo.bitCount << 8; palletteEntries = bmpInfo.bitCount << 8;
bmpPallette = new BitmapImage::BITMAP_QUAD[palletteEntries]; bmpPallette = new BITMAP_QUAD[palletteEntries];
fread(bmpPallette, sizeof(BitmapImage::BITMAP_QUAD), palletteEntries, f); fread(bmpPallette, sizeof(BITMAP_QUAD), palletteEntries, f);
} }
fseek(f, bmpHeader.offset, SEEK_SET); fseek(f, bmpHeader.offset, SEEK_SET);

View File

@@ -71,7 +71,7 @@ namespace OpenArena
m_vUpVector = up; m_vUpVector = up;
} }
void Camera::SetViewByMouse(const Window* window) void Camera::SetViewByMouse(Window window)
{ {
//Remove the ifdef and use the linux section for both linux and windows //Remove the ifdef and use the linux section for both linux and windows
#ifdef __linux #ifdef __linux
@@ -112,8 +112,8 @@ namespace OpenArena
POINT mpos; POINT mpos;
POINT middle; POINT middle;
double angleZ; double angleZ;
middle.x = window->GetWidth() / 2; middle.x = window.GetWidth() / 2;
middle.y = window->GetHeight() / 2; middle.y = window.GetHeight() / 2;
GetCursorPos(&mpos); GetCursorPos(&mpos);
SetCursorPos(middle.x, middle.y); SetCursorPos(middle.x, middle.y);
if(mpos.x != middle.x || mpos.y != middle.y) if(mpos.x != middle.x || mpos.y != middle.y)

View File

@@ -40,6 +40,7 @@ namespace OpenArena
_window = NULL; _window = NULL;
textureNames = NULL; textureNames = NULL;
numTextures = 0; numTextures = 0;
textures = NULL;
screen.SetName(OPENARENA_VERSION); screen.SetName(OPENARENA_VERSION);
@@ -416,14 +417,11 @@ namespace OpenArena
} }
//Free all map textures //Free all map textures
textures.Clear();
/*
if(textures) if(textures)
{ {
delete [] textures; delete [] textures;
textures = NULL; textures = NULL;
} }
*/
//Free the array of texture names //Free the array of texture names
if (textureNames) if (textureNames)
@@ -435,22 +433,23 @@ namespace OpenArena
void Level::LoadGLTextures() void Level::LoadGLTextures()
{ {
printf("In LoadGLTextures: _window = %d\n", _window);
if(_window != NULL) if(_window != NULL)
{ {
/*GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f}; /*
glLightfv(GL_LIGHT1, GL_AMBIENT, light); GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
glEnable(GL_LIGHT1); glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);*/ glEnable(GL_LIGHTING);
*/
textures.Clear(); if(textures != NULL)
/* if(textures != NULL)
{ {
delete [] textures; delete [] textures;
} }
textures = new Texture[numTextures]; textures = new Texture[numTextures];
*/
for(uint32 i=0; i<numTextures; i++) for(uint32 i=0; i<numTextures; i++)
{ {
if(!textures[i].Load(gamedir + "textures/" + textureNames[i])) if(!textures[i].Load(gamedir + "textures/" + textureNames[i]))
@@ -458,9 +457,7 @@ namespace OpenArena
} }
if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str())) if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str()))
{
glFont.BuildFont("oa/textures/menu/font.bmp"); glFont.BuildFont("oa/textures/menu/font.bmp");
}
//Load the console background image //Load the console background image
if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga")) if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga"))

View File

@@ -30,8 +30,8 @@
#ifdef __linux #ifdef __linux
//include necessary header files //include necessary header files
#include "../include/main.h" #include "main.h"
#include "../include/version.h" #include "version.h"
using namespace std; using namespace std;
void InitControls(); void InitControls();
@@ -122,15 +122,6 @@ int main(int argc, char** argv)
level.glFont.SetScreenDimensions(level.screen.GetWidth()*2, level.screen.GetHeight()*2); level.glFont.SetScreenDimensions(level.screen.GetWidth()*2, level.screen.GetHeight()*2);
if(level.nextLevel == "")
{
level.LoadMap("intro.map");
}
else
{
level.LoadMap();
}
//Hack for now //Hack for now
if(level.screen.GetColorDepth() == 32) if(level.screen.GetColorDepth() == 32)
{ {
@@ -147,6 +138,15 @@ int main(int argc, char** argv)
level.SetWindow(g_Screen); level.SetWindow(g_Screen);
if(level.nextLevel == "")
{
level.LoadMap("intro.map");
}
else
{
level.LoadMap();
}
while(!done) while(!done)
{ {
while(XPending(g_Screen.GetDisplay()) > 0) while(XPending(g_Screen.GetDisplay()) > 0)

View File

@@ -30,8 +30,8 @@
#ifdef __APPLE__ #ifdef __APPLE__
//include necessary header files //include necessary header files
#include "../include/main.h" #include "main.h"
#include "../include/version.h" #include "version.h"
using namespace std; using namespace std;
//void InitControls(); //void InitControls();

View File

@@ -1,18 +1,17 @@
#include "mygl.h" #include "mygl.h"
namespace OpenArena namespace OpenArena
{ {
void FreeGLTexture(GLuint& texture) void FreeGLTexture(GLuint texture)
{ {
glDeleteTextures(1, &texture); glDeleteTextures(1, &texture);
} }
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min) bool LoadGLTexture(string fn, GLuint texture, GLuint mag, GLuint min)
{ {
if(Right(tolower(fn), 4) == ".bmp") if(Right(tolower(fn), 4) == ".bmp")
{ {
TextureImage* texImage = NULL; TextureImage* texImage = NULL;
if(texImage = BitmapImage::LoadBMP(fn.c_str())) if(texImage = LoadBMP(fn.c_str()))
{ {
glGenTextures(1, &texture); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
@@ -36,7 +35,7 @@ namespace OpenArena
else if(Right(tolower(fn), 4) == ".tga") else if(Right(tolower(fn), 4) == ".tga")
{ {
TextureImage* texImage = NULL; TextureImage* texImage = NULL;
if(texImage = TargaImage::LoadTGA(fn.c_str())) if(texImage = LoadTGA(fn.c_str()))
{ {
glGenTextures(1, &texture); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
@@ -64,4 +63,4 @@ namespace OpenArena
} }
}; };
OpenArena::Window* g_Screen = NULL; OpenArena::Window g_Screen;

View File

@@ -45,7 +45,7 @@ namespace OpenArena
{ {
FreeFont(); FreeFont();
if(OpenArena::LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST)) if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
{ {
float x, y; float x, y;
base = glGenLists(256); base = glGenLists(256);

View File

@@ -43,7 +43,7 @@ namespace OpenArena
} }
else else
{ {
id=0xFFFFFFFF; id = 0xFFFFFFFF;
return false; return false;
} }
} }
@@ -83,31 +83,31 @@ namespace OpenArena
bool Texture::operator<(const Texture& rtOp) bool Texture::operator<(const Texture& rtOp)
{ {
return id<rtOp.id; return id < rtOp.id;
} }
bool Texture::operator<=(const Texture& rtOp) bool Texture::operator<=(const Texture& rtOp)
{ {
return id<=rtOp.id; return id<= rtOp.id;
} }
bool Texture::operator==(const Texture& rtOp) bool Texture::operator==(const Texture& rtOp)
{ {
return id==rtOp.id; return id== rtOp.id;
} }
bool Texture::operator!=(const Texture& rtOp) bool Texture::operator!=(const Texture& rtOp)
{ {
return id!=rtOp.id; return id!= rtOp.id;
} }
bool Texture::operator>=(const Texture& rtOp) bool Texture::operator>=(const Texture& rtOp)
{ {
return id>=rtOp.id; return id>= rtOp.id;
} }
bool Texture::operator>(const Texture& rtOp) bool Texture::operator>(const Texture& rtOp)
{ {
return id>rtOp.id; return id> rtOp.id;
} }
}; };

View File

@@ -11,27 +11,27 @@ namespace OpenArena
_name = ""; _name = "";
} }
int Screen::GetWidth() const int Screen::GetWidth()
{ {
return _width; return _width;
} }
int Screen::GetHeight() const int Screen::GetHeight()
{ {
return _height; return _height;
} }
int Screen::GetColorDepth() const int Screen::GetColorDepth()
{ {
return _colorDepth; return _colorDepth;
} }
bool Screen::GetFullscreen() const bool Screen::GetFullscreen()
{ {
return _fullscreen; return _fullscreen;
} }
const char* Screen::GetName() const const char* Screen::GetName()
{ {
return _name.c_str(); return _name.c_str();
} }

File diff suppressed because it is too large Load Diff

View File

@@ -143,7 +143,6 @@ bool OpenArena::Window::Open()
vi = glXChooseVisual(display, screen, attrListDbl); vi = glXChooseVisual(display, screen, attrListDbl);
if(vi == NULL) if(vi == NULL)
{
vi = glXChooseVisual(display, screen, attrListSgl); vi = glXChooseVisual(display, screen, attrListSgl);
doubleBuffered = false; doubleBuffered = false;
printf("Only Singlebuffered Visual!\n"); printf("Only Singlebuffered Visual!\n");
@@ -434,7 +433,7 @@ bool OpenArena::Window::Open()
ShowWindow(window,SW_SHOW); ShowWindow(window,SW_SHOW);
SetForegroundWindow(window); SetForegroundWindow(window);
SetFocus(window); SetFocus(window);
_resizer->Resize(_width, _height); OnResize(_width, _height);
if (!_initializer->Initialize()) if (!_initializer->Initialize())
{ {

View File

@@ -250,10 +250,9 @@ int WINAPI WinMain( HINSTANCE hInstance,
level.LoadMap(); level.LoadMap();
} }
g_Screen = g_PluginManager.GetDefaultVideoPlugin()->CreateNewWindow(level.screen.GetWidth(), level.screen.GetHeight()); g_Screen.SetOnInit(InitGL);
g_Screen->SetInitializer(new OpenArena::Window::Initializer()); g_Screen.SetOnResize(ReSizeGLScene);
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()))
if (!g_Screen->Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen()))
{ {
return 0; return 0;
} }
@@ -293,7 +292,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
} }
else else
{ {
SetCursorPos(g_Screen->GetWidth()/2, g_Screen->GetHeight()/2); SetCursorPos(g_Screen.GetWidth()/2, g_Screen.GetHeight()/2);
} }
////////// //////////
@@ -580,14 +579,14 @@ int WINAPI WinMain( HINSTANCE hInstance,
} }
} }
g_Screen->SwapBuffers(); g_Screen.SwapBuffers();
if (keys[OpenArena::KEY_F1]) if (keys[OpenArena::KEY_F1])
{ {
keys[OpenArena::KEY_F1]=false; keys[OpenArena::KEY_F1]=false;
g_Screen->Close(); g_Screen.Close();
g_Screen->ToggleFullscreen(); g_Screen.ToggleFullscreen();
if (!g_Screen->Open("OpenArena",g_Screen->GetWidth(),g_Screen->GetHeight(),g_Screen->GetColorDepth(),g_Screen->GetFullscreen())) if (!g_Screen.Open("OpenArena",g_Screen.GetWidth(),g_Screen.GetHeight(),g_Screen.GetColorDepth(),g_Screen.GetFullscreen()))
{ {
return 0; return 0;
} }
@@ -595,7 +594,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
} }
level.UnloadMap(); level.UnloadMap();
g_Screen->Close(); g_Screen.Close();
return (msg.wParam); return (msg.wParam);
} }