Changed Moved resources around
~G2k
This commit is contained in:
1221
include/bass.h
1221
include/bass.h
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
|||||||
#ifndef __bmp_h__
|
|
||||||
#define __bmp_h__
|
|
||||||
|
|
||||||
#include "mygl.h"
|
|
||||||
#include "datatypes.h"
|
|
||||||
#include "texture.h"
|
|
||||||
|
|
||||||
namespace OpenArena{
|
|
||||||
TextureImage* LoadBMP(const char* Filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
18
src/NullVideoPlugin.cpp
Normal file
18
src/NullVideoPlugin.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "NullVideoPlugin.h"
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
|
||||||
|
NullVideoPlugin::NullVideoPlugin(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NullVideoPlugin::~NullVideoPlugin(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenArena::Window* NullVideoPlugin::CreateNewWindow(uint32 width, uint32 height, uint32 bpp, bool fullscreen, const char* title)
|
||||||
|
{
|
||||||
|
return new OpenArena::Window();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
17
src/NullVideoPlugin.h
Normal file
17
src/NullVideoPlugin.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "VideoPlugin.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
|
||||||
|
class NullVideoPlugin :
|
||||||
|
public OpenArena::VideoPlugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NullVideoPlugin(void);
|
||||||
|
public:
|
||||||
|
virtual ~NullVideoPlugin(void);
|
||||||
|
virtual Window* CreateNewWindow(uint32 width, uint32 height, uint32 bpp = 32, bool fullscreen = false, const char* title = NULL);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
13
src/Plugin.h
Normal file
13
src/Plugin.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
class Plugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Plugin(void){}
|
||||||
|
enum Type {VideoPlugin, AudioPlugin, InputPlugin};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
25
src/PluginManager.cpp
Normal file
25
src/PluginManager.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "PluginManager.h"
|
||||||
|
#include "NullVideoPlugin.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
PluginManager::PluginManager(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManager::~PluginManager(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
list<Plugin*> PluginManager::GetPluginsOfType(Plugin::Type type)
|
||||||
|
{
|
||||||
|
return list<Plugin*>();
|
||||||
|
}
|
||||||
|
VideoPlugin* PluginManager::GetDefaultVideoPlugin(void)
|
||||||
|
{
|
||||||
|
return new NullVideoPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
26
src/PluginManager.h
Normal file
26
src/PluginManager.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "list.h"
|
||||||
|
#include "Plugin.h"
|
||||||
|
#include "VideoPlugin.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Perhaps this class should be a singleton.
|
||||||
|
*/
|
||||||
|
class PluginManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
list<Plugin*> _plugins;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates a new PluginManager object
|
||||||
|
*/
|
||||||
|
PluginManager(void);
|
||||||
|
~PluginManager(void);
|
||||||
|
|
||||||
|
list<Plugin*> GetPluginsOfType(Plugin::Type type);
|
||||||
|
VideoPlugin* GetDefaultVideoPlugin(void);
|
||||||
|
};
|
||||||
|
};
|
||||||
19
src/VideoPlugin.h
Normal file
19
src/VideoPlugin.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Plugin.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include "datatypes.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
class VideoPlugin :public Plugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
public:
|
||||||
|
virtual ~VideoPlugin(){}
|
||||||
|
virtual Window* CreateNewWindow(uint32 width,
|
||||||
|
uint32 height,
|
||||||
|
uint32 bpp = 32,
|
||||||
|
bool fullscreen = false,
|
||||||
|
const char* title = NULL) = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
230
src/bmp.cpp
230
src/bmp.cpp
@@ -19,48 +19,208 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "../include/bmp.h"
|
#include "bmp.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning(disable:4996)
|
#pragma warning(disable:4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
|
|
||||||
#pragma pack(push,1)
|
Bitmap::Bitmap()
|
||||||
struct BITMAP_HEADER
|
|
||||||
{
|
{
|
||||||
uint16 type;
|
Bitmap(1, 1);
|
||||||
uint32 size;
|
}
|
||||||
uint16 reserved1;
|
|
||||||
uint16 reserved2;
|
|
||||||
uint32 offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BITMAP_INFO
|
|
||||||
|
Bitmap::Bitmap(uint32 width, uint32 height, uint32 bitsPerPixel, Image::Type type)
|
||||||
{
|
{
|
||||||
uint32 size;
|
_width = width;
|
||||||
uint32 width;
|
_height = height;
|
||||||
uint32 height;
|
_bpp = bitsPerPixel;
|
||||||
uint16 planes;
|
_type = type;
|
||||||
uint16 bitCount;
|
_data = new uint8[_width * _height * (_bpp >> 3)];
|
||||||
uint32 compression;
|
}
|
||||||
uint32 sizeImage;
|
|
||||||
uint32 xPelsPerMeter;
|
|
||||||
uint32 yPelsPerMeter;
|
|
||||||
uint32 clrUsed;
|
|
||||||
uint32 clrImportant;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BITMAP_QUAD
|
Bitmap::~Bitmap()
|
||||||
{
|
{
|
||||||
uint8 blue;
|
delete [] _data;
|
||||||
uint8 green;
|
}
|
||||||
uint8 red;
|
|
||||||
uint8 reserved;
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#define BITMAP_MAGIC 19778
|
uint8 * Bitmap::GetImageData() const
|
||||||
|
{
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 Bitmap::GetBitsPerPixel() const
|
||||||
|
{
|
||||||
|
return _bpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 Bitmap::GetBytesPerPixel() const
|
||||||
|
{
|
||||||
|
return _bpp >> 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 Bitmap::GetWidth() const
|
||||||
|
{
|
||||||
|
return _width;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 Bitmap::GetHeight() const
|
||||||
|
{
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image::Type Bitmap::GetType() const
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap* Bitmap::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 Bitmap(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 Bitmap(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap* image = new Bitmap(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* LoadBMP(const char* fn)
|
TextureImage* LoadBMP(const char* fn)
|
||||||
{
|
{
|
||||||
@@ -77,9 +237,9 @@ namespace OpenArena{
|
|||||||
f=fopen(fn, "rb");
|
f=fopen(fn, "rb");
|
||||||
if(f)
|
if(f)
|
||||||
{
|
{
|
||||||
BITMAP_HEADER bmpHeader;
|
Bitmap::BITMAP_HEADER bmpHeader;
|
||||||
BITMAP_INFO bmpInfo;
|
Bitmap::BITMAP_INFO bmpInfo;
|
||||||
BITMAP_QUAD* bmpPallette = NULL;
|
Bitmap::BITMAP_QUAD* bmpPallette = NULL;
|
||||||
uint32 palletteEntries = 0;
|
uint32 palletteEntries = 0;
|
||||||
|
|
||||||
fread(&bmpHeader, sizeof(bmpHeader), 1, f);
|
fread(&bmpHeader, sizeof(bmpHeader), 1, f);
|
||||||
@@ -152,8 +312,8 @@ namespace OpenArena{
|
|||||||
{
|
{
|
||||||
//Load the pallette
|
//Load the pallette
|
||||||
palletteEntries = bmpInfo.bitCount << 8;
|
palletteEntries = bmpInfo.bitCount << 8;
|
||||||
bmpPallette = new BITMAP_QUAD[palletteEntries];
|
bmpPallette = new Bitmap::BITMAP_QUAD[palletteEntries];
|
||||||
fread(bmpPallette, sizeof(BITMAP_QUAD), palletteEntries, f);
|
fread(bmpPallette, sizeof(Bitmap::BITMAP_QUAD), palletteEntries, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(f, bmpHeader.offset, SEEK_SET);
|
fseek(f, bmpHeader.offset, SEEK_SET);
|
||||||
|
|||||||
69
src/bmp.h
Normal file
69
src/bmp.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef __bmp_h__
|
||||||
|
#define __bmp_h__
|
||||||
|
|
||||||
|
#include "Image.h"
|
||||||
|
#include "mygl.h"
|
||||||
|
#include "datatypes.h"
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
|
namespace OpenArena{
|
||||||
|
TextureImage* LoadBMP(const char* Filename);
|
||||||
|
class Bitmap :Image
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Bitmap();
|
||||||
|
virtual uint8 * GetImageData() const;
|
||||||
|
virtual uint32 GetBitsPerPixel() const;
|
||||||
|
virtual uint32 GetBytesPerPixel() const;
|
||||||
|
virtual uint32 GetWidth() const;
|
||||||
|
virtual uint32 GetHeight() const;
|
||||||
|
virtual Image::Type GetType() const;
|
||||||
|
static Bitmap* CreateFromFile(const char* filename);
|
||||||
|
private:
|
||||||
|
Bitmap();
|
||||||
|
Bitmap(uint32 width, uint32 height, uint32 = 24, Image::Type = Image::Type_RGB);
|
||||||
|
uint8* _data;
|
||||||
|
uint32 _width;
|
||||||
|
uint32 _height;
|
||||||
|
uint32 _bpp;
|
||||||
|
Image::Type _type;
|
||||||
|
public:
|
||||||
|
#pragma pack(push,1)
|
||||||
|
struct BITMAP_HEADER
|
||||||
|
{
|
||||||
|
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
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../include/camera.h"
|
#include "camera.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ namespace OpenArena
|
|||||||
m_vUpVector = up;
|
m_vUpVector = up;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::SetViewByMouse(Window window)
|
void Camera::SetViewByMouse(const 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)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenArena
|
|||||||
// Rotates the camera by angle degrees about the axis specified by the given components.
|
// Rotates the camera by angle degrees about the axis specified by the given components.
|
||||||
// Works the same as glRotatef(angle, X, Y, Z).
|
// Works the same as glRotatef(angle, X, Y, Z).
|
||||||
|
|
||||||
void SetViewByMouse(Window window);
|
void SetViewByMouse(const Window* window);
|
||||||
//Purpose:
|
//Purpose:
|
||||||
// Updates the view Vector based on the change in mouse position since the last time it was called.
|
// Updates the view Vector based on the change in mouse position since the last time it was called.
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../include/ctrls.h"
|
#include "ctrls.h"
|
||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
void ControlScheme::LoadDefaultControlScheme()
|
void ControlScheme::LoadDefaultControlScheme()
|
||||||
|
|||||||
21
src/image.h
Normal file
21
src/image.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "datatypes.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
class Image
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//RGB should equal GL_RGB;
|
||||||
|
enum Type{Type_RGB};
|
||||||
|
virtual uint8 * GetImageData() const = 0;
|
||||||
|
virtual uint32 GetBitsPerPixel() const = 0;
|
||||||
|
virtual uint32 GetBytesPerPixel() const = 0;
|
||||||
|
virtual uint32 GetWidth() const = 0;
|
||||||
|
virtual uint32 GetHeight() const = 0;
|
||||||
|
virtual Image::Type GetType() const = 0;
|
||||||
|
virtual ~Image(void){}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
char OpenArena::KeyToASCII(Keys key, bool shift)
|
char OpenArena::KeyToASCII(Keys key, bool shift)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../include/level.h"
|
#include "level.h"
|
||||||
#include "../include/version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#pragma comment(lib, "bass.lib")
|
#pragma comment(lib, "bass.lib")
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -40,7 +40,6 @@ namespace OpenArena
|
|||||||
_window = NULL;
|
_window = NULL;
|
||||||
textureNames = NULL;
|
textureNames = NULL;
|
||||||
numTextures = 0;
|
numTextures = 0;
|
||||||
textures = NULL;
|
|
||||||
|
|
||||||
screen.SetName(OPENARENA_VERSION);
|
screen.SetName(OPENARENA_VERSION);
|
||||||
|
|
||||||
@@ -417,11 +416,14 @@ 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)
|
||||||
@@ -433,23 +435,22 @@ 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};
|
||||||
GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
|
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
||||||
glEnable(GL_LIGHT1);
|
glEnable(GL_LIGHT1);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);*/
|
||||||
*/
|
|
||||||
|
|
||||||
if(textures != NULL)
|
textures.Clear();
|
||||||
|
/* 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]))
|
||||||
@@ -457,7 +458,9 @@ 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"))
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "tga.h"
|
#include "tga.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#ifdef WIN32
|
#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
|
#endif
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
@@ -104,8 +104,8 @@ namespace OpenArena
|
|||||||
uint32 numTriangles;
|
uint32 numTriangles;
|
||||||
list<Player> players;
|
list<Player> players;
|
||||||
list<ENTITY> ents;
|
list<ENTITY> ents;
|
||||||
//list<GL_MY_TEXTURE> textures;
|
list<Texture> textures;
|
||||||
Texture* textures;
|
//Texture* textures;
|
||||||
Texture menuTextures[NUM_MENU_TEXTURES];
|
Texture menuTextures[NUM_MENU_TEXTURES];
|
||||||
Window* _window;
|
Window* _window;
|
||||||
|
|
||||||
11
src/mygl.cpp
11
src/mygl.cpp
@@ -1,12 +1,13 @@
|
|||||||
#include "../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")
|
||||||
{
|
{
|
||||||
@@ -63,4 +64,4 @@ namespace OpenArena
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenArena::Window g_Screen;
|
OpenArena::Window* g_Screen = NULL;
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ using namespace std;
|
|||||||
//These this is windows specific
|
//These this is windows specific
|
||||||
static HINSTANCE hInstance; // Application instance
|
static HINSTANCE hInstance; // Application instance
|
||||||
#endif
|
#endif
|
||||||
extern OpenArena::Window g_Screen;
|
extern OpenArena::Window* g_Screen;
|
||||||
//This doesn't need to be here I think
|
//This doesn't need to be here I think
|
||||||
//int InitGL(GLvoid);
|
//int InitGL(GLvoid);
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
bool LoadGLTexture(string , GLuint, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
||||||
void FreeGLTexture(GLuint);
|
void FreeGLTexture(GLuint);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../include/myglFont.h"
|
#include "myglFont.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace OpenArena
|
|||||||
{
|
{
|
||||||
FreeFont();
|
FreeFont();
|
||||||
|
|
||||||
if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
if(OpenArena::LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
base = glGenLists(256);
|
base = glGenLists(256);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace OpenArena
|
|||||||
short screenWidth;
|
short screenWidth;
|
||||||
short screenHeight;
|
short screenHeight;
|
||||||
unsigned int base;
|
unsigned int base;
|
||||||
GLuint texture;
|
unsigned int texture;
|
||||||
bool status;
|
bool status;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/myglTexture.h"
|
#include "myglTexture.h"
|
||||||
using namespace OpenArena;
|
using namespace OpenArena;
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/physics.h"
|
#include "physics.h"
|
||||||
|
|
||||||
WORLD_PHYSICS::WORLD_PHYSICS()
|
WORLD_PHYSICS::WORLD_PHYSICS()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/player.h"
|
#include "player.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
@@ -11,27 +11,27 @@ namespace OpenArena
|
|||||||
_name = "";
|
_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Screen::GetWidth()
|
int Screen::GetWidth() const
|
||||||
{
|
{
|
||||||
return _width;
|
return _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Screen::GetHeight()
|
int Screen::GetHeight() const
|
||||||
{
|
{
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Screen::GetColorDepth()
|
int Screen::GetColorDepth() const
|
||||||
{
|
{
|
||||||
return _colorDepth;
|
return _colorDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Screen::GetFullscreen()
|
bool Screen::GetFullscreen() const
|
||||||
{
|
{
|
||||||
return _fullscreen;
|
return _fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Screen::GetName()
|
const char* Screen::GetName() const
|
||||||
{
|
{
|
||||||
return _name.c_str();
|
return _name.c_str();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ namespace OpenArena
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Screen();
|
Screen();
|
||||||
int GetWidth();
|
int GetWidth() const;
|
||||||
int GetHeight();
|
int GetHeight() const;
|
||||||
int GetColorDepth();
|
int GetColorDepth() const;
|
||||||
bool GetFullscreen();
|
bool GetFullscreen() const;
|
||||||
const char* GetName();
|
const char* GetName() const;
|
||||||
void SetWidth(int);
|
void SetWidth(int);
|
||||||
void SetHeight(int);
|
void SetHeight(int);
|
||||||
void Resize(int, int);
|
void Resize(int, int);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include "../include/strmanip.h"
|
#include "strmanip.h"
|
||||||
|
|
||||||
bool Truth(std::string str)
|
bool Truth(std::string str)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "../include/tga.h"
|
#include "tga.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning(disable:4996)
|
#pragma warning(disable:4996)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
Vec3d::Vec3d()
|
Vec3d::Vec3d()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/window.h"
|
#include "window.h"
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
void OpenArena::Window::SwapBuffers()
|
void OpenArena::Window::SwapBuffers()
|
||||||
@@ -143,6 +143,7 @@ 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");
|
||||||
@@ -433,7 +434,7 @@ bool OpenArena::Window::Open()
|
|||||||
ShowWindow(window,SW_SHOW);
|
ShowWindow(window,SW_SHOW);
|
||||||
SetForegroundWindow(window);
|
SetForegroundWindow(window);
|
||||||
SetFocus(window);
|
SetFocus(window);
|
||||||
OnResize(_width, _height);
|
_resizer->Resize(_width, _height);
|
||||||
|
|
||||||
if (!_initializer->Initialize())
|
if (!_initializer->Initialize())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//include necessary header files
|
//include necessary header files
|
||||||
#include "../include/main.h"
|
#include "main.h"
|
||||||
#include "../include/version.h"
|
#include "version.h"
|
||||||
|
|
||||||
//link necessary libraries
|
//link necessary libraries
|
||||||
#pragma comment(lib, "opengl32.lib")
|
#pragma comment(lib, "opengl32.lib")
|
||||||
@@ -250,9 +250,10 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
level.LoadMap();
|
level.LoadMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Screen.SetOnInit(InitGL);
|
g_Screen = g_PluginManager.GetDefaultVideoPlugin()->CreateNewWindow(level.screen.GetWidth(), level.screen.GetHeight());
|
||||||
g_Screen.SetOnResize(ReSizeGLScene);
|
g_Screen->SetInitializer(new OpenArena::Window::Initializer());
|
||||||
if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen()))
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -292,7 +293,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
@@ -579,14 +580,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;
|
||||||
}
|
}
|
||||||
@@ -594,7 +595,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
level.UnloadMap();
|
level.UnloadMap();
|
||||||
g_Screen.Close();
|
g_Screen->Close();
|
||||||
return (msg.wParam);
|
return (msg.wParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#ifndef __WorldDefs_h__
|
#ifndef __WorldDefs_h__
|
||||||
#define __WorldDefs_h__
|
#define __WorldDefs_h__
|
||||||
|
#include "PluginManager.h"
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
|
|
||||||
static OpenArena::Level level;
|
static OpenArena::Level level;
|
||||||
|
static OpenArena::PluginManager g_PluginManager;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user