Changed: Renamed a few classes
Changed: Moved most sensible objects into the OpenArena namespace ~g2k
This commit is contained in:
@@ -9,17 +9,17 @@
|
||||
#include "mygl.h"
|
||||
#include "screen.h"
|
||||
|
||||
|
||||
|
||||
class CameraClass
|
||||
namespace OpenArena
|
||||
{
|
||||
public:
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
//Constructors
|
||||
CameraClass(); //Default Constructor
|
||||
Camera(); //Default Constructor
|
||||
//Purpose:
|
||||
//
|
||||
|
||||
//CameraClass(const CameraClass&); //Copy Constructor
|
||||
//Camera(const Camera&); //Copy Constructor
|
||||
//Purpose:
|
||||
//
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
//Purpose:
|
||||
//
|
||||
|
||||
void SetViewByMouse(SCREEN g_Screen);
|
||||
void SetViewByMouse(Screen g_Screen);
|
||||
//Purpose:
|
||||
//
|
||||
|
||||
@@ -79,12 +79,12 @@ public:
|
||||
//Purpose:
|
||||
//
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
Vec3f m_vPosition;
|
||||
Vec3f m_vView;
|
||||
Vec3f m_vUpVector;
|
||||
Vec3f m_vStrafe;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
#include "vector.h"
|
||||
#include "myglTexture.h"
|
||||
|
||||
struct TRIANGLE
|
||||
namespace OpenArena
|
||||
{
|
||||
GL_MY_TEXTURE texture;
|
||||
class Triangle
|
||||
{
|
||||
public:
|
||||
Texture texture;
|
||||
uint32 texID;
|
||||
Vec3f vertecies[3];
|
||||
Vec2f texCoords[3];
|
||||
Vec3f normal;
|
||||
};
|
||||
};
|
||||
|
||||
class POSITION
|
||||
/*//This class seems to never be used and I dont' remember why I made it.
|
||||
class Position
|
||||
{
|
||||
public:
|
||||
GLfloat xrot; // X rotation
|
||||
@@ -21,7 +25,7 @@ public:
|
||||
GLfloat ztrans; // Z translation
|
||||
bool stepRight;
|
||||
bool stepLeft;
|
||||
POSITION()
|
||||
Position()
|
||||
{
|
||||
xtrans = 0.0f;
|
||||
ytrans = 0.0f;
|
||||
@@ -33,3 +37,4 @@ public:
|
||||
private:
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
@@ -30,21 +30,24 @@
|
||||
#include "keys.h"
|
||||
|
||||
using namespace std;
|
||||
using OpenArena::Triangle;
|
||||
|
||||
const float piover180 = 0.0174532925f;
|
||||
const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp";
|
||||
const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console
|
||||
const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history
|
||||
const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES;
|
||||
const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen
|
||||
|
||||
enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES};
|
||||
|
||||
class LEVEL
|
||||
namespace OpenArena
|
||||
{
|
||||
public:
|
||||
LEVEL();
|
||||
~LEVEL();
|
||||
const float piover180 = 0.0174532925f;
|
||||
const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp";
|
||||
const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console
|
||||
const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history
|
||||
const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES;
|
||||
const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen
|
||||
|
||||
enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES};
|
||||
|
||||
class Level
|
||||
{
|
||||
public:
|
||||
Level();
|
||||
~Level();
|
||||
bool LoadMap(string mapname);
|
||||
bool LoadMap();
|
||||
void SaveMap(string mapname);
|
||||
@@ -64,10 +67,10 @@ public:
|
||||
void PlayerConnect(); // implement later
|
||||
void PlayerDisconnect(); // implement later
|
||||
*/
|
||||
SCREEN screen;
|
||||
GLFontClass glFont;
|
||||
Screen screen;
|
||||
Font glFont;
|
||||
string nextLevel;
|
||||
PLAYER* defaultPlayer;
|
||||
Player* defaultPlayer;
|
||||
uint32 numTextures;
|
||||
string* textureNames;
|
||||
|
||||
@@ -87,21 +90,21 @@ public:
|
||||
float mouseSpeed;
|
||||
unsigned char maxFPS;
|
||||
//Map
|
||||
TRIANGLE* triangles;
|
||||
Triangle* triangles;
|
||||
uint32 numTriangles;
|
||||
list<PLAYER> players;
|
||||
list<Player> players;
|
||||
list<ENTITY> ents;
|
||||
//list<GL_MY_TEXTURE> textures;
|
||||
GL_MY_TEXTURE* textures;
|
||||
GL_MY_TEXTURE menuTextures[NUM_MENU_TEXTURES];
|
||||
Texture* textures;
|
||||
Texture menuTextures[NUM_MENU_TEXTURES];
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
void ConsolePrint(string);
|
||||
string consoleHistory[MAX_CONSOLE_HISTORY_LINES];
|
||||
string consoleOutput[MAX_CONSOLE_OUTPUT_LINES];
|
||||
string outputText[MAX_OUTPUT_TEXT_LINES];
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,8 +22,11 @@ using namespace std;
|
||||
static HINSTANCE hInstance; // Application instance
|
||||
#endif
|
||||
extern OpenArena::Window g_Screen;
|
||||
int InitGL(GLvoid);
|
||||
|
||||
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
||||
void FreeGLTexture(GLuint&);
|
||||
//This doesn't need to be here I think
|
||||
//int InitGL(GLvoid);
|
||||
namespace OpenArena
|
||||
{
|
||||
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
||||
void FreeGLTexture(GLuint&);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -3,18 +3,20 @@
|
||||
|
||||
#include "mygl.h"
|
||||
|
||||
class GLFontClass
|
||||
namespace OpenArena
|
||||
{
|
||||
private:
|
||||
class Font
|
||||
{
|
||||
private:
|
||||
short screenWidth;
|
||||
short screenHeight;
|
||||
unsigned int base;
|
||||
unsigned int texture;
|
||||
bool status;
|
||||
|
||||
public:
|
||||
GLFontClass();
|
||||
~GLFontClass();
|
||||
public:
|
||||
Font();
|
||||
~Font();
|
||||
bool BuildFont(const char*);
|
||||
bool FreeFont();
|
||||
void Print(int, int, const char*, unsigned int = 0);
|
||||
@@ -24,6 +26,6 @@ public:
|
||||
void SetScreenHeight(short);
|
||||
short ScreenWidth();
|
||||
short ScreenHeight();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,29 +7,31 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class GL_MY_TEXTURE
|
||||
namespace OpenArena
|
||||
{
|
||||
public:
|
||||
GL_MY_TEXTURE();
|
||||
~GL_MY_TEXTURE();
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
Texture();
|
||||
~Texture();
|
||||
string Filename();
|
||||
GLuint ID();
|
||||
bool Load(string filename);
|
||||
bool Load(string filename, GLuint min, GLuint mag);
|
||||
void Free();
|
||||
bool Loaded();
|
||||
bool operator<(const GL_MY_TEXTURE&);
|
||||
bool operator<=(const GL_MY_TEXTURE&);
|
||||
bool operator==(const GL_MY_TEXTURE&);
|
||||
bool operator!=(const GL_MY_TEXTURE&);
|
||||
bool operator>=(const GL_MY_TEXTURE&);
|
||||
bool operator>(const GL_MY_TEXTURE&);
|
||||
bool operator<(const Texture&);
|
||||
bool operator<=(const Texture&);
|
||||
bool operator==(const Texture&);
|
||||
bool operator!=(const Texture&);
|
||||
bool operator>=(const Texture&);
|
||||
bool operator>(const Texture&);
|
||||
|
||||
private:
|
||||
private:
|
||||
GLuint minFilter;
|
||||
GLuint magFilter;
|
||||
string filename;
|
||||
GLuint id;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
#include "camera.h"
|
||||
#include "ctrls.h"
|
||||
|
||||
class PLAYER
|
||||
namespace OpenArena
|
||||
{
|
||||
public:
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
void Load();
|
||||
void Save();
|
||||
void CreateCharacter();
|
||||
@@ -16,11 +18,11 @@ public:
|
||||
void RemoveItem(unsigned int item);
|
||||
|
||||
ControlSchemeClass controls;
|
||||
CameraClass camera;
|
||||
Camera camera;
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SCREEN
|
||||
namespace OpenArena
|
||||
{
|
||||
public:
|
||||
SCREEN()
|
||||
class Screen
|
||||
{
|
||||
public:
|
||||
Screen()
|
||||
{
|
||||
width=640;
|
||||
height=480;
|
||||
@@ -23,6 +24,6 @@ public:
|
||||
string name;
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#ifndef __texture_h__
|
||||
#define __texture_h__
|
||||
|
||||
struct TextureImage
|
||||
class TextureImage
|
||||
{
|
||||
public:
|
||||
unsigned char* data;
|
||||
unsigned int bpp;
|
||||
unsigned int sizeX;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenArena
|
||||
typedef void (*ResizeFunc)(GLsizei width, GLsizei height);
|
||||
typedef int (*InitFunc)();
|
||||
|
||||
class Window: public SCREEN
|
||||
class Window: public Screen
|
||||
{
|
||||
public:
|
||||
Window();
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
#include "level.h"
|
||||
|
||||
static LEVEL level;
|
||||
static OpenArena::Level level;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
// To implement an OpenGL Camera
|
||||
//
|
||||
// Summary of Methods:
|
||||
// CameraClass
|
||||
// -CameraClass();
|
||||
// Camera
|
||||
// -Camera();
|
||||
// Initalize PDM's. Sets position to 0,0,0 up to 0,1,0 and view to 0,0,-1
|
||||
// -Vec3f Position();
|
||||
// Returns a copy of the position vector.
|
||||
@@ -29,7 +29,7 @@
|
||||
// Sets the position, up, and view vectors to those passed in.
|
||||
// -void RotateView(double angle, double X, double Y, double Z);
|
||||
// Rotates the view angle degrees on the axis specified by X, Y, and Z.
|
||||
// -void SetViewByMouse(SCREEN g_Screen);
|
||||
// -void SetViewByMouse(Screen g_Screen);
|
||||
// Rotates the pitch and yaw of the view based on the mouse.
|
||||
// -void RotateAroundPoint(double angle, double X, double Y, double Z, Vec3f vCenter);
|
||||
// Rotates the view angle degrees around a point vCenter on the axis specified by X, Y, Z.
|
||||
@@ -46,31 +46,33 @@
|
||||
|
||||
#include "../include/camera.h"
|
||||
|
||||
CameraClass::CameraClass()
|
||||
namespace OpenArena
|
||||
{
|
||||
Camera::Camera()
|
||||
{
|
||||
m_vPosition = Vec3f(0,0,0);
|
||||
m_vView = Vec3f(0,0,-1);
|
||||
m_vUpVector = Vec3f(0,1,0);
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::PositionCamera(double xpos, double ypos, double zpos,
|
||||
void Camera::PositionCamera(double xpos, double ypos, double zpos,
|
||||
double xview, double yview, double zview,
|
||||
double xup, double yup, double zup)
|
||||
{
|
||||
{
|
||||
m_vPosition = Vec3f(xpos, ypos, zpos);
|
||||
m_vView = Vec3f(xview, yview, zview);
|
||||
m_vUpVector = Vec3f(xup, yup, zup);
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::PositionCamera(Vec3f pos, Vec3f view, Vec3f up)
|
||||
{
|
||||
void Camera::PositionCamera(Vec3f pos, Vec3f view, Vec3f up)
|
||||
{
|
||||
m_vPosition = pos;
|
||||
m_vView = view;
|
||||
m_vUpVector = up;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::SetViewByMouse(SCREEN g_Screen)
|
||||
{
|
||||
void Camera::SetViewByMouse(Screen g_Screen)
|
||||
{
|
||||
//Most of this is sorta right for linux I think but since I don't know how yet it's currently windows only
|
||||
#ifdef WIN32
|
||||
static double currentRotX = 0.0f;
|
||||
@@ -109,20 +111,20 @@ void CameraClass::SetViewByMouse(SCREEN g_Screen)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::MoveCamera(double speed)
|
||||
{
|
||||
void Camera::MoveCamera(double speed)
|
||||
{
|
||||
Vec3f heading = (m_vView - m_vPosition).normalized();
|
||||
|
||||
m_vPosition.x += heading.x * speed;
|
||||
m_vPosition.z += heading.z * speed;
|
||||
m_vView.x += heading.x * speed;
|
||||
m_vView.z += heading.z * speed;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::RotateView(double angle, double x, double y, double z)
|
||||
{
|
||||
void Camera::RotateView(double angle, double x, double y, double z)
|
||||
{
|
||||
Vec3f nView;
|
||||
Vec3f cView;
|
||||
|
||||
@@ -146,48 +148,49 @@ void CameraClass::RotateView(double angle, double x, double y, double z)
|
||||
m_vView.x = m_vPosition.x + nView.x;
|
||||
m_vView.y = m_vPosition.y + nView.y;
|
||||
m_vView.z = m_vPosition.z + nView.z;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::StrafeCamera(double speed)
|
||||
{
|
||||
void Camera::StrafeCamera(double speed)
|
||||
{
|
||||
m_vPosition.x += m_vStrafe.x * speed;
|
||||
m_vPosition.z += m_vStrafe.z * speed;
|
||||
m_vView.x += m_vStrafe.x * speed;
|
||||
m_vView.z += m_vStrafe.z * speed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CameraClass::Update()
|
||||
{
|
||||
void Camera::Update()
|
||||
{
|
||||
m_vStrafe =((m_vView - m_vPosition).cross(m_vUpVector)).normalized();
|
||||
//SetViewByMouse(); //TODO take this whole function out asap
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CameraClass::Look()
|
||||
{
|
||||
void Camera::Look()
|
||||
{
|
||||
gluLookAt(m_vPosition.x, m_vPosition.y, m_vPosition.z,
|
||||
m_vView.x, m_vView.y, m_vView.z,
|
||||
m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
|
||||
}
|
||||
}
|
||||
|
||||
Vec3f CameraClass::Position()
|
||||
{
|
||||
Vec3f Camera::Position()
|
||||
{
|
||||
return m_vPosition;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3f CameraClass::Strafe()
|
||||
{
|
||||
Vec3f Camera::Strafe()
|
||||
{
|
||||
return m_vStrafe;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3f CameraClass::UpVector()
|
||||
{
|
||||
Vec3f Camera::UpVector()
|
||||
{
|
||||
return m_vUpVector;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3f CameraClass::View()
|
||||
{
|
||||
Vec3f Camera::View()
|
||||
{
|
||||
return m_vView;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
111
src/level.cpp
111
src/level.cpp
@@ -30,8 +30,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
LEVEL::LEVEL()
|
||||
namespace OpenArena
|
||||
{
|
||||
Level::Level()
|
||||
{
|
||||
textureNames = NULL;
|
||||
numTextures = 0;
|
||||
textures = NULL;
|
||||
@@ -45,7 +47,7 @@ LEVEL::LEVEL()
|
||||
gamedir = "oa/";
|
||||
sound = true;
|
||||
|
||||
defaultPlayer = new PLAYER;
|
||||
defaultPlayer = new Player;
|
||||
|
||||
numTriangles = 0;
|
||||
triangles = NULL;
|
||||
@@ -58,19 +60,19 @@ LEVEL::LEVEL()
|
||||
turnSpeed = 1.0f;
|
||||
moveSpeed = 0.2f;
|
||||
mlook = true;
|
||||
}
|
||||
}
|
||||
|
||||
LEVEL::~LEVEL()
|
||||
{
|
||||
Level::~Level()
|
||||
{
|
||||
if(defaultPlayer)
|
||||
{
|
||||
delete defaultPlayer;
|
||||
defaultPlayer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LEVEL::LoadMap(string mapname)
|
||||
{
|
||||
bool Level::LoadMap(string mapname)
|
||||
{
|
||||
ifstream input;
|
||||
string readBuffer;
|
||||
|
||||
@@ -111,7 +113,7 @@ bool LEVEL::LoadMap(string mapname)
|
||||
numTriangles = Integer(readBuffer);
|
||||
|
||||
//Triangle Data
|
||||
triangles = new TRIANGLE[numTriangles];
|
||||
triangles = new Triangle[numTriangles];
|
||||
for(unsigned int i=0; i<numTriangles; i++)
|
||||
{
|
||||
//TextureID
|
||||
@@ -210,14 +212,14 @@ bool LEVEL::LoadMap(string mapname)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool LEVEL::LoadMap()
|
||||
{
|
||||
}
|
||||
bool Level::LoadMap()
|
||||
{
|
||||
return LoadMap(nextLevel);
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::SaveMap(string mapname)
|
||||
{
|
||||
void Level::SaveMap(string mapname)
|
||||
{
|
||||
ofstream output;
|
||||
|
||||
mapname = gamedir + "maps/" + mapname;
|
||||
@@ -279,10 +281,10 @@ void LEVEL::SaveMap(string mapname)
|
||||
//BGM
|
||||
output << bgm;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::Render()
|
||||
{
|
||||
void Level::Render()
|
||||
{
|
||||
glPushMatrix();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
@@ -294,7 +296,7 @@ void LEVEL::Render()
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textures[triangles[i].texID].ID());//Bind this triangle's texture
|
||||
glBegin(GL_TRIANGLES);
|
||||
// glNormal3f((GLfloat)triangles[i].normal.x, (GLfloat)triangles[i].normal.y, (GLfloat)triangles[i].normal.z);
|
||||
// glNormal3f((GLfloat)triangles[i].normal.x, (GLfloat)triangles[i].normal.y, (GLfloat)triangles[i].normal.z);
|
||||
for (uint32 i2=0; i2<3; i2++)
|
||||
{
|
||||
glTexCoord2f(triangles[i].texCoords[i2].x,
|
||||
@@ -388,10 +390,10 @@ void LEVEL::Render()
|
||||
//glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::UnloadMap()
|
||||
{
|
||||
void Level::UnloadMap()
|
||||
{
|
||||
//Stop audio
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
@@ -423,10 +425,10 @@ void LEVEL::UnloadMap()
|
||||
delete [] textureNames;
|
||||
textureNames = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::LoadGLTextures()
|
||||
{
|
||||
void Level::LoadGLTextures()
|
||||
{
|
||||
|
||||
/*GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
||||
@@ -438,7 +440,7 @@ void LEVEL::LoadGLTextures()
|
||||
delete [] textures;
|
||||
}
|
||||
|
||||
textures = new GL_MY_TEXTURE[numTextures];
|
||||
textures = new Texture[numTextures];
|
||||
|
||||
for(uint32 i=0; i<numTextures; i++)
|
||||
{
|
||||
@@ -452,10 +454,10 @@ void LEVEL::LoadGLTextures()
|
||||
//Load the console background image
|
||||
if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga"))
|
||||
menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load("oa/textures/menu/con_back.bmp");
|
||||
}
|
||||
}
|
||||
|
||||
uint32 LEVEL::FPS()
|
||||
{
|
||||
uint32 Level::FPS()
|
||||
{
|
||||
static uint32 fps=0;
|
||||
static uint32 fps2=0;
|
||||
static float last=0.0f; // might need to change to double
|
||||
@@ -476,10 +478,10 @@ uint32 LEVEL::FPS()
|
||||
fps=0;
|
||||
}
|
||||
return fps2;
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::Execute(string cmd)
|
||||
{
|
||||
void Level::Execute(string cmd)
|
||||
{
|
||||
string command;
|
||||
|
||||
uint32 i=0xFFFFFFFF;
|
||||
@@ -780,10 +782,10 @@ void LEVEL::Execute(string cmd)
|
||||
ConsolePrint("Unknown command " + command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::ParseCmds(const char* lpCmdLine)
|
||||
{
|
||||
void Level::ParseCmds(const char* lpCmdLine)
|
||||
{
|
||||
string cmd = lpCmdLine;
|
||||
string command;
|
||||
|
||||
@@ -934,10 +936,10 @@ void LEVEL::ParseCmds(const char* lpCmdLine)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::LoadConfig()
|
||||
{
|
||||
void Level::LoadConfig()
|
||||
{
|
||||
showFPS = false;
|
||||
nextLevel = "intro.map";
|
||||
gamedir = "oa/";
|
||||
@@ -947,9 +949,9 @@ void LEVEL::LoadConfig()
|
||||
turnSpeed = 1.0f;
|
||||
moveSpeed = .2f;
|
||||
mlook = true;
|
||||
}
|
||||
bool LEVEL::LoadConfig(string cfgname)
|
||||
{
|
||||
}
|
||||
bool Level::LoadConfig(string cfgname)
|
||||
{
|
||||
ifstream input;
|
||||
string readBuffer;
|
||||
|
||||
@@ -980,10 +982,10 @@ bool LEVEL::LoadConfig(string cfgname)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::SaveConfig(string cfgname)
|
||||
{
|
||||
void Level::SaveConfig(string cfgname)
|
||||
{
|
||||
ofstream output;
|
||||
|
||||
cfgname = gamedir + "config/" + cfgname;
|
||||
@@ -1173,15 +1175,15 @@ void LEVEL::SaveConfig(string cfgname)
|
||||
while(defaultPlayer->controls.weaponPrev.NextPosition())
|
||||
output << "bind weaponPrev " << KeyString(defaultPlayer->controls.weaponPrev.Retrieve()) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::Print(int x, int y, const char* str, unsigned int set)
|
||||
{
|
||||
void Level::Print(int x, int y, const char* str, unsigned int set)
|
||||
{
|
||||
glFont.Print(x,y,str, set);
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::UpdateConsole(char newChar)
|
||||
{
|
||||
void Level::UpdateConsole(char newChar)
|
||||
{
|
||||
if(newChar == '\n')
|
||||
{
|
||||
for (int i=MAX_CONSOLE_HISTORY_LINES - 1; i>0; i--)
|
||||
@@ -1206,13 +1208,14 @@ void LEVEL::UpdateConsole(char newChar)
|
||||
MessageBox(NULL, errmsg, "Balls", MB_OK);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEVEL::ConsolePrint(string line)
|
||||
{
|
||||
void Level::ConsolePrint(string line)
|
||||
{
|
||||
for (int i=MAX_CONSOLE_OUTPUT_LINES - 1; i>0; i--)
|
||||
{
|
||||
consoleOutput[i] = consoleOutput[i-1];
|
||||
}
|
||||
consoleOutput[0] = line;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
14
src/mygl.cpp
14
src/mygl.cpp
@@ -1,13 +1,14 @@
|
||||
|
||||
#include "../include/mygl.h"
|
||||
|
||||
void FreeGLTexture(GLuint& texture)
|
||||
namespace OpenArena
|
||||
{
|
||||
void FreeGLTexture(GLuint& 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")
|
||||
{
|
||||
TextureImage* texImage = NULL;
|
||||
@@ -60,6 +61,7 @@ bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OpenArena::Window g_Screen;
|
||||
|
||||
@@ -25,22 +25,24 @@
|
||||
|
||||
#include "../include/myglFont.h"
|
||||
|
||||
GLFontClass::GLFontClass()
|
||||
namespace OpenArena
|
||||
{
|
||||
Font::Font()
|
||||
{
|
||||
status = 0;
|
||||
base = 0;
|
||||
texture = 0;
|
||||
screenWidth = 1;
|
||||
screenHeight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
GLFontClass::~GLFontClass()
|
||||
{
|
||||
Font::~Font()
|
||||
{
|
||||
FreeFont();
|
||||
}
|
||||
}
|
||||
|
||||
bool GLFontClass::BuildFont(const char* texName)
|
||||
{
|
||||
bool Font::BuildFont(const char* texName)
|
||||
{
|
||||
FreeFont();
|
||||
|
||||
if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
||||
@@ -69,20 +71,20 @@ bool GLFontClass::BuildFont(const char* texName)
|
||||
status = true;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
bool GLFontClass::FreeFont()
|
||||
{
|
||||
bool Font::FreeFont()
|
||||
{
|
||||
if(status)
|
||||
{
|
||||
glDeleteLists(base, 256);
|
||||
status = false;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
void GLFontClass::Print(int x, int y, const char* str, unsigned int set)
|
||||
{
|
||||
void Font::Print(int x, int y, const char* str, unsigned int set)
|
||||
{
|
||||
if(status)
|
||||
{
|
||||
if(set>1)
|
||||
@@ -108,35 +110,36 @@ void GLFontClass::Print(int x, int y, const char* str, unsigned int set)
|
||||
//glDisable(GL_BLEND);
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GLFontClass::Loaded()
|
||||
{
|
||||
bool Font::Loaded()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
void GLFontClass::SetScreenDimensions(short x, short y)
|
||||
{
|
||||
void Font::SetScreenDimensions(short x, short y)
|
||||
{
|
||||
screenWidth = x;
|
||||
screenHeight = y;
|
||||
}
|
||||
}
|
||||
|
||||
void GLFontClass::SetScreenWidth(short x)
|
||||
{
|
||||
void Font::SetScreenWidth(short x)
|
||||
{
|
||||
screenWidth = x;
|
||||
}
|
||||
}
|
||||
|
||||
void GLFontClass::SetScreenHeight(short y)
|
||||
{
|
||||
void Font::SetScreenHeight(short y)
|
||||
{
|
||||
screenHeight = y;
|
||||
}
|
||||
}
|
||||
|
||||
short GLFontClass::ScreenWidth()
|
||||
{
|
||||
short Font::ScreenWidth()
|
||||
{
|
||||
return screenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
short GLFontClass::ScreenHeight()
|
||||
{
|
||||
short Font::ScreenHeight()
|
||||
{
|
||||
return screenHeight;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
#include "../include/myglTexture.h"
|
||||
using namespace OpenArena;
|
||||
|
||||
GL_MY_TEXTURE::GL_MY_TEXTURE()
|
||||
namespace OpenArena
|
||||
{
|
||||
Texture::Texture()
|
||||
{
|
||||
id=0xFFFFFFFF;
|
||||
filename = "";
|
||||
minFilter = GL_LINEAR;
|
||||
magFilter = GL_LINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
GL_MY_TEXTURE::~GL_MY_TEXTURE()
|
||||
{
|
||||
Texture::~Texture()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
}
|
||||
|
||||
string GL_MY_TEXTURE::Filename()
|
||||
{
|
||||
string Texture::Filename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
GLuint GL_MY_TEXTURE::ID()
|
||||
{
|
||||
GLuint Texture::ID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::Loaded()
|
||||
{
|
||||
bool Texture::Loaded()
|
||||
{
|
||||
return filename != "";
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::Load(string fn)
|
||||
{
|
||||
bool Texture::Load(string fn)
|
||||
{
|
||||
if(Loaded())
|
||||
Free();
|
||||
|
||||
@@ -43,10 +46,10 @@ bool GL_MY_TEXTURE::Load(string fn)
|
||||
id=0xFFFFFFFF;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::Load(string fn, GLuint min, GLuint mag)
|
||||
{
|
||||
bool Texture::Load(string fn, GLuint min, GLuint mag)
|
||||
{
|
||||
if(Loaded())
|
||||
Free();
|
||||
|
||||
@@ -62,10 +65,10 @@ bool GL_MY_TEXTURE::Load(string fn, GLuint min, GLuint mag)
|
||||
id=0xFFFFFFFF;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GL_MY_TEXTURE::Free()
|
||||
{
|
||||
void Texture::Free()
|
||||
{
|
||||
if(Loaded())
|
||||
{
|
||||
FreeGLTexture(id);
|
||||
@@ -74,34 +77,35 @@ void GL_MY_TEXTURE::Free()
|
||||
filename = "";
|
||||
id = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator<(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator<(const Texture& rtOp)
|
||||
{
|
||||
return id<rtOp.id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator<=(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator<=(const Texture& rtOp)
|
||||
{
|
||||
return id<=rtOp.id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator==(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator==(const Texture& rtOp)
|
||||
{
|
||||
return id==rtOp.id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator!=(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator!=(const Texture& rtOp)
|
||||
{
|
||||
return id!=rtOp.id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator>=(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator>=(const Texture& rtOp)
|
||||
{
|
||||
return id>=rtOp.id;
|
||||
}
|
||||
}
|
||||
|
||||
bool GL_MY_TEXTURE::operator>(const GL_MY_TEXTURE& rtOp)
|
||||
{
|
||||
bool Texture::operator>(const Texture& rtOp)
|
||||
{
|
||||
return id>rtOp.id;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
#include "../include/player.h"
|
||||
|
||||
void PLAYER::Load()
|
||||
namespace OpenArena
|
||||
{
|
||||
}
|
||||
void Player::Load()
|
||||
{
|
||||
}
|
||||
|
||||
void PLAYER::Save()
|
||||
{
|
||||
}
|
||||
void Player::Save()
|
||||
{
|
||||
}
|
||||
|
||||
void PLAYER::AddItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory | item;
|
||||
}
|
||||
void Player::AddItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory | item;
|
||||
}
|
||||
|
||||
void PLAYER::RemoveItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory & ~item;
|
||||
}
|
||||
void Player::RemoveItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory & ~item;
|
||||
}
|
||||
|
||||
void PLAYER::CreateCharacter()
|
||||
{
|
||||
}
|
||||
void Player::CreateCharacter()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user