Changed: Renamed a few classes
Changed: Moved most sensible objects into the OpenArena namespace ~g2k
This commit is contained in:
134
include/camera.h
134
include/camera.h
@@ -9,82 +9,82 @@
|
|||||||
#include "mygl.h"
|
#include "mygl.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
|
||||||
class CameraClass
|
|
||||||
{
|
{
|
||||||
public:
|
class Camera
|
||||||
//Constructors
|
{
|
||||||
CameraClass(); //Default Constructor
|
public:
|
||||||
//Purpose:
|
//Constructors
|
||||||
//
|
Camera(); //Default Constructor
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
//Camera(const Camera&); //Copy Constructor
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
//Observer Accessors
|
||||||
|
Vec3f Position();
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
//CameraClass(const CameraClass&); //Copy Constructor
|
Vec3f View();
|
||||||
//Purpose:
|
//Purpose:
|
||||||
//
|
//
|
||||||
|
|
||||||
//Observer Accessors
|
Vec3f UpVector();
|
||||||
Vec3f Position();
|
//Purpose:
|
||||||
//Purpose:
|
//
|
||||||
//
|
|
||||||
|
|
||||||
Vec3f View();
|
Vec3f Strafe();
|
||||||
//Purpose:
|
//Purpose:
|
||||||
//
|
//
|
||||||
|
|
||||||
Vec3f UpVector();
|
//Mutators
|
||||||
//Purpose:
|
void PositionCamera(double xpos, double ypos, double zpos,
|
||||||
//
|
double xview, double yview, double zview,
|
||||||
|
double xup, double yup, double zup);
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
void PositionCamera(Vec3f pos, Vec3f view, Vec3f up);
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
Vec3f Strafe();
|
void RotateView(double angle, double X, double Y, double Z);
|
||||||
//Purpose:
|
//Purpose:
|
||||||
//
|
//
|
||||||
|
|
||||||
//Mutators
|
void SetViewByMouse(Screen g_Screen);
|
||||||
void PositionCamera(double xpos, double ypos, double zpos,
|
//Purpose:
|
||||||
double xview, double yview, double zview,
|
//
|
||||||
double xup, double yup, double zup);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void PositionCamera(Vec3f pos, Vec3f view, Vec3f up);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void RotateView(double angle, double X, double Y, double Z);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void SetViewByMouse(SCREEN g_Screen);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void RotateAroundPoint(Vec3f vCenter, double X, double Y, double Z);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void StrafeCamera(double speed);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void MoveCamera(double speed);
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void Update();
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
void Look();
|
|
||||||
//Purpose:
|
|
||||||
//
|
|
||||||
|
|
||||||
|
void RotateAroundPoint(Vec3f vCenter, double X, double Y, double Z);
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
void StrafeCamera(double speed);
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
void MoveCamera(double speed);
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
private:
|
void Update();
|
||||||
Vec3f m_vPosition;
|
//Purpose:
|
||||||
Vec3f m_vView;
|
//
|
||||||
Vec3f m_vUpVector;
|
|
||||||
Vec3f m_vStrafe;
|
void Look();
|
||||||
|
//Purpose:
|
||||||
|
//
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vec3f m_vPosition;
|
||||||
|
Vec3f m_vView;
|
||||||
|
Vec3f m_vUpVector;
|
||||||
|
Vec3f m_vStrafe;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#include "myglTexture.h"
|
#include "myglTexture.h"
|
||||||
|
|
||||||
struct TRIANGLE
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
GL_MY_TEXTURE texture;
|
class Triangle
|
||||||
uint32 texID;
|
{
|
||||||
Vec3f vertecies[3];
|
public:
|
||||||
Vec2f texCoords[3];
|
Texture texture;
|
||||||
Vec3f normal;
|
uint32 texID;
|
||||||
|
Vec3f vertecies[3];
|
||||||
|
Vec2f texCoords[3];
|
||||||
|
Vec3f normal;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
/*//This class seems to never be used and I dont' remember why I made it.
|
||||||
class POSITION
|
class Position
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLfloat xrot; // X rotation
|
GLfloat xrot; // X rotation
|
||||||
@@ -21,7 +25,7 @@ public:
|
|||||||
GLfloat ztrans; // Z translation
|
GLfloat ztrans; // Z translation
|
||||||
bool stepRight;
|
bool stepRight;
|
||||||
bool stepLeft;
|
bool stepLeft;
|
||||||
POSITION()
|
Position()
|
||||||
{
|
{
|
||||||
xtrans = 0.0f;
|
xtrans = 0.0f;
|
||||||
ytrans = 0.0f;
|
ytrans = 0.0f;
|
||||||
@@ -33,3 +37,4 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|||||||
143
include/level.h
143
include/level.h
@@ -30,78 +30,81 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using OpenArena::Triangle;
|
||||||
|
|
||||||
const float piover180 = 0.0174532925f;
|
namespace OpenArena
|
||||||
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:
|
const float piover180 = 0.0174532925f;
|
||||||
LEVEL();
|
const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp";
|
||||||
~LEVEL();
|
const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console
|
||||||
bool LoadMap(string mapname);
|
const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history
|
||||||
bool LoadMap();
|
const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES;
|
||||||
void SaveMap(string mapname);
|
const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen
|
||||||
bool LoadConfig(string cfgname);
|
|
||||||
void LoadConfig();
|
|
||||||
void SaveConfig(string cfgname);
|
|
||||||
void Execute(string cmd);
|
|
||||||
void LoadGLTextures();
|
|
||||||
void Render();
|
|
||||||
void UnloadMap();
|
|
||||||
void UpdateConsole(char);
|
|
||||||
uint32 FPS();
|
|
||||||
void ParseCmds(const char*);
|
|
||||||
void Print(int x, int y, const char* string, unsigned int set);
|
|
||||||
|
|
||||||
/*Not Yet Implemented
|
|
||||||
void PlayerConnect(); // implement later
|
|
||||||
void PlayerDisconnect(); // implement later
|
|
||||||
*/
|
|
||||||
SCREEN screen;
|
|
||||||
GLFontClass glFont;
|
|
||||||
string nextLevel;
|
|
||||||
PLAYER* defaultPlayer;
|
|
||||||
uint32 numTextures;
|
|
||||||
string* textureNames;
|
|
||||||
|
|
||||||
string bgm;
|
enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES};
|
||||||
#ifdef WIN32
|
|
||||||
HSTREAM bgmStream;
|
|
||||||
#endif
|
|
||||||
unsigned char bgmCDA;
|
|
||||||
string gamedir;
|
|
||||||
float gravity;
|
|
||||||
bool mlook;
|
|
||||||
bool showFPS;
|
|
||||||
bool showConsole;
|
|
||||||
bool sound;
|
|
||||||
float turnSpeed;
|
|
||||||
float moveSpeed;
|
|
||||||
float mouseSpeed;
|
|
||||||
unsigned char maxFPS;
|
|
||||||
//Map
|
|
||||||
TRIANGLE* triangles;
|
|
||||||
uint32 numTriangles;
|
|
||||||
list<PLAYER> players;
|
|
||||||
list<ENTITY> ents;
|
|
||||||
//list<GL_MY_TEXTURE> textures;
|
|
||||||
GL_MY_TEXTURE* textures;
|
|
||||||
GL_MY_TEXTURE menuTextures[NUM_MENU_TEXTURES];
|
|
||||||
|
|
||||||
|
class Level
|
||||||
|
{
|
||||||
private:
|
public:
|
||||||
void ConsolePrint(string);
|
Level();
|
||||||
string consoleHistory[MAX_CONSOLE_HISTORY_LINES];
|
~Level();
|
||||||
string consoleOutput[MAX_CONSOLE_OUTPUT_LINES];
|
bool LoadMap(string mapname);
|
||||||
string outputText[MAX_OUTPUT_TEXT_LINES];
|
bool LoadMap();
|
||||||
};
|
void SaveMap(string mapname);
|
||||||
|
bool LoadConfig(string cfgname);
|
||||||
|
void LoadConfig();
|
||||||
|
void SaveConfig(string cfgname);
|
||||||
|
void Execute(string cmd);
|
||||||
|
void LoadGLTextures();
|
||||||
|
void Render();
|
||||||
|
void UnloadMap();
|
||||||
|
void UpdateConsole(char);
|
||||||
|
uint32 FPS();
|
||||||
|
void ParseCmds(const char*);
|
||||||
|
void Print(int x, int y, const char* string, unsigned int set);
|
||||||
|
|
||||||
|
/*Not Yet Implemented
|
||||||
|
void PlayerConnect(); // implement later
|
||||||
|
void PlayerDisconnect(); // implement later
|
||||||
|
*/
|
||||||
|
Screen screen;
|
||||||
|
Font glFont;
|
||||||
|
string nextLevel;
|
||||||
|
Player* defaultPlayer;
|
||||||
|
uint32 numTextures;
|
||||||
|
string* textureNames;
|
||||||
|
|
||||||
|
string bgm;
|
||||||
|
#ifdef WIN32
|
||||||
|
HSTREAM bgmStream;
|
||||||
|
#endif
|
||||||
|
unsigned char bgmCDA;
|
||||||
|
string gamedir;
|
||||||
|
float gravity;
|
||||||
|
bool mlook;
|
||||||
|
bool showFPS;
|
||||||
|
bool showConsole;
|
||||||
|
bool sound;
|
||||||
|
float turnSpeed;
|
||||||
|
float moveSpeed;
|
||||||
|
float mouseSpeed;
|
||||||
|
unsigned char maxFPS;
|
||||||
|
//Map
|
||||||
|
Triangle* triangles;
|
||||||
|
uint32 numTriangles;
|
||||||
|
list<Player> players;
|
||||||
|
list<ENTITY> ents;
|
||||||
|
//list<GL_MY_TEXTURE> textures;
|
||||||
|
Texture* textures;
|
||||||
|
Texture menuTextures[NUM_MENU_TEXTURES];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ConsolePrint(string);
|
||||||
|
string consoleHistory[MAX_CONSOLE_HISTORY_LINES];
|
||||||
|
string consoleOutput[MAX_CONSOLE_OUTPUT_LINES];
|
||||||
|
string outputText[MAX_OUTPUT_TEXT_LINES];
|
||||||
|
};
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,8 +22,11 @@ using namespace std;
|
|||||||
static HINSTANCE hInstance; // Application instance
|
static HINSTANCE hInstance; // Application instance
|
||||||
#endif
|
#endif
|
||||||
extern OpenArena::Window g_Screen;
|
extern OpenArena::Window g_Screen;
|
||||||
int InitGL(GLvoid);
|
//This doesn't need to be here I think
|
||||||
|
//int InitGL(GLvoid);
|
||||||
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
namespace OpenArena
|
||||||
void FreeGLTexture(GLuint&);
|
{
|
||||||
|
bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR);
|
||||||
|
void FreeGLTexture(GLuint&);
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,27 +3,29 @@
|
|||||||
|
|
||||||
#include "mygl.h"
|
#include "mygl.h"
|
||||||
|
|
||||||
class GLFontClass
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
private:
|
class Font
|
||||||
short screenWidth;
|
{
|
||||||
short screenHeight;
|
private:
|
||||||
unsigned int base;
|
short screenWidth;
|
||||||
unsigned int texture;
|
short screenHeight;
|
||||||
bool status;
|
unsigned int base;
|
||||||
|
unsigned int texture;
|
||||||
public:
|
bool status;
|
||||||
GLFontClass();
|
|
||||||
~GLFontClass();
|
public:
|
||||||
bool BuildFont(const char*);
|
Font();
|
||||||
bool FreeFont();
|
~Font();
|
||||||
void Print(int, int, const char*, unsigned int = 0);
|
bool BuildFont(const char*);
|
||||||
bool Loaded();
|
bool FreeFont();
|
||||||
void SetScreenDimensions(short, short);
|
void Print(int, int, const char*, unsigned int = 0);
|
||||||
void SetScreenWidth(short);
|
bool Loaded();
|
||||||
void SetScreenHeight(short);
|
void SetScreenDimensions(short, short);
|
||||||
short ScreenWidth();
|
void SetScreenWidth(short);
|
||||||
short ScreenHeight();
|
void SetScreenHeight(short);
|
||||||
|
short ScreenWidth();
|
||||||
|
short ScreenHeight();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,29 +7,31 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class GL_MY_TEXTURE
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
public:
|
class Texture
|
||||||
GL_MY_TEXTURE();
|
{
|
||||||
~GL_MY_TEXTURE();
|
public:
|
||||||
string Filename();
|
Texture();
|
||||||
GLuint ID();
|
~Texture();
|
||||||
bool Load(string filename);
|
string Filename();
|
||||||
bool Load(string filename, GLuint min, GLuint mag);
|
GLuint ID();
|
||||||
void Free();
|
bool Load(string filename);
|
||||||
bool Loaded();
|
bool Load(string filename, GLuint min, GLuint mag);
|
||||||
bool operator<(const GL_MY_TEXTURE&);
|
void Free();
|
||||||
bool operator<=(const GL_MY_TEXTURE&);
|
bool Loaded();
|
||||||
bool operator==(const GL_MY_TEXTURE&);
|
bool operator<(const Texture&);
|
||||||
bool operator!=(const GL_MY_TEXTURE&);
|
bool operator<=(const Texture&);
|
||||||
bool operator>=(const GL_MY_TEXTURE&);
|
bool operator==(const Texture&);
|
||||||
bool operator>(const GL_MY_TEXTURE&);
|
bool operator!=(const Texture&);
|
||||||
|
bool operator>=(const Texture&);
|
||||||
private:
|
bool operator>(const Texture&);
|
||||||
GLuint minFilter;
|
|
||||||
GLuint magFilter;
|
private:
|
||||||
string filename;
|
GLuint minFilter;
|
||||||
GLuint id;
|
GLuint magFilter;
|
||||||
};
|
string filename;
|
||||||
|
GLuint id;
|
||||||
|
};
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,23 +4,25 @@
|
|||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "ctrls.h"
|
#include "ctrls.h"
|
||||||
|
|
||||||
class PLAYER
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
public:
|
class Player
|
||||||
void Load();
|
{
|
||||||
void Save();
|
public:
|
||||||
void CreateCharacter();
|
void Load();
|
||||||
//void FirePrimary(ENTITY& ent);
|
void Save();
|
||||||
//void FireSecondary();
|
void CreateCharacter();
|
||||||
void AddItem(unsigned int item);
|
//void FirePrimary(ENTITY& ent);
|
||||||
void RemoveItem(unsigned int item);
|
//void FireSecondary();
|
||||||
|
void AddItem(unsigned int item);
|
||||||
ControlSchemeClass controls;
|
void RemoveItem(unsigned int item);
|
||||||
CameraClass camera;
|
|
||||||
|
ControlSchemeClass controls;
|
||||||
|
Camera camera;
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,26 +3,27 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
namespace OpenArena
|
||||||
class SCREEN
|
|
||||||
{
|
{
|
||||||
public:
|
class Screen
|
||||||
SCREEN()
|
|
||||||
{
|
{
|
||||||
width=640;
|
public:
|
||||||
height=480;
|
Screen()
|
||||||
bpp=16;
|
{
|
||||||
fullscreen=false;
|
width=640;
|
||||||
name = "";
|
height=480;
|
||||||
}
|
bpp=16;
|
||||||
|
fullscreen=false;
|
||||||
short width;
|
name = "";
|
||||||
short height;
|
}
|
||||||
char bpp;
|
|
||||||
bool fullscreen;
|
short width;
|
||||||
string name;
|
short height;
|
||||||
|
char bpp;
|
||||||
|
bool fullscreen;
|
||||||
|
string name;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#ifndef __texture_h__
|
#ifndef __texture_h__
|
||||||
#define __texture_h__
|
#define __texture_h__
|
||||||
|
|
||||||
struct TextureImage
|
class TextureImage
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
unsigned int bpp;
|
unsigned int bpp;
|
||||||
unsigned int sizeX;
|
unsigned int sizeX;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenArena
|
|||||||
typedef void (*ResizeFunc)(GLsizei width, GLsizei height);
|
typedef void (*ResizeFunc)(GLsizei width, GLsizei height);
|
||||||
typedef int (*InitFunc)();
|
typedef int (*InitFunc)();
|
||||||
|
|
||||||
class Window: public SCREEN
|
class Window: public Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Window();
|
Window();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
|
|
||||||
static LEVEL level;
|
static OpenArena::Level level;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
289
src/camera.cpp
289
src/camera.cpp
@@ -10,8 +10,8 @@
|
|||||||
// To implement an OpenGL Camera
|
// To implement an OpenGL Camera
|
||||||
//
|
//
|
||||||
// Summary of Methods:
|
// Summary of Methods:
|
||||||
// CameraClass
|
// Camera
|
||||||
// -CameraClass();
|
// -Camera();
|
||||||
// Initalize PDM's. Sets position to 0,0,0 up to 0,1,0 and view to 0,0,-1
|
// Initalize PDM's. Sets position to 0,0,0 up to 0,1,0 and view to 0,0,-1
|
||||||
// -Vec3f Position();
|
// -Vec3f Position();
|
||||||
// Returns a copy of the position vector.
|
// Returns a copy of the position vector.
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
// Sets the position, up, and view vectors to those passed in.
|
// Sets the position, up, and view vectors to those passed in.
|
||||||
// -void RotateView(double angle, double X, double Y, double Z);
|
// -void RotateView(double angle, double X, double Y, double Z);
|
||||||
// Rotates the view angle degrees on the axis specified by X, Y, and 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.
|
// Rotates the pitch and yaw of the view based on the mouse.
|
||||||
// -void RotateAroundPoint(double angle, double X, double Y, double Z, Vec3f vCenter);
|
// -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.
|
// Rotates the view angle degrees around a point vCenter on the axis specified by X, Y, Z.
|
||||||
@@ -46,148 +46,151 @@
|
|||||||
|
|
||||||
#include "../include/camera.h"
|
#include "../include/camera.h"
|
||||||
|
|
||||||
CameraClass::CameraClass()
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
m_vPosition = Vec3f(0,0,0);
|
Camera::Camera()
|
||||||
m_vView = Vec3f(0,0,-1);
|
|
||||||
m_vUpVector = Vec3f(0,1,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraClass::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)
|
|
||||||
{
|
|
||||||
m_vPosition = pos;
|
|
||||||
m_vView = view;
|
|
||||||
m_vUpVector = up;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraClass::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;
|
|
||||||
POINT mpos;
|
|
||||||
POINT middle;
|
|
||||||
|
|
||||||
double angleZ;
|
|
||||||
|
|
||||||
middle.x = g_Screen.width / 2;
|
|
||||||
middle.y = g_Screen.height / 2;
|
|
||||||
|
|
||||||
GetCursorPos(&mpos);
|
|
||||||
SetCursorPos(middle.x, middle.y);
|
|
||||||
|
|
||||||
if(mpos.x != middle.x || mpos.y != middle.y)
|
|
||||||
{
|
{
|
||||||
angleZ = double(middle.y - mpos.y) / 1000.0f;
|
m_vPosition = Vec3f(0,0,0);
|
||||||
currentRotX -= angleZ;
|
m_vView = Vec3f(0,0,-1);
|
||||||
|
m_vUpVector = Vec3f(0,1,0);
|
||||||
if(currentRotX > 1.0f)
|
|
||||||
currentRotX = 1.0f;
|
|
||||||
else if(currentRotX < -1.0f)
|
|
||||||
currentRotX = -1.0f;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vec3f axis = (m_vView - m_vPosition).cross(m_vUpVector);
|
|
||||||
axis.normalize();
|
|
||||||
|
|
||||||
RotateView(angleZ, axis.x, axis.y, axis.z);
|
|
||||||
|
|
||||||
//need to switch these two when I figure out stuff for flight
|
|
||||||
//till then I think the first is faster
|
|
||||||
|
|
||||||
RotateView(double(middle.x - mpos.x) / 1000.0f, 0, 1, 0);
|
|
||||||
//RotateView(double(middle.x - mpos.x) / 1000.0f, m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraClass::MoveCamera(double speed)
|
|
||||||
{
|
|
||||||
Vec3f heading = (m_vView - m_vPosition).normalized();
|
|
||||||
|
|
||||||
m_vPosition.x += heading.x * speed;
|
void Camera::PositionCamera(double xpos, double ypos, double zpos,
|
||||||
m_vPosition.z += heading.z * speed;
|
double xview, double yview, double zview,
|
||||||
m_vView.x += heading.x * speed;
|
double xup, double yup, double zup)
|
||||||
m_vView.z += heading.z * speed;
|
{
|
||||||
}
|
m_vPosition = Vec3f(xpos, ypos, zpos);
|
||||||
|
m_vView = Vec3f(xview, yview, zview);
|
||||||
void CameraClass::RotateView(double angle, double x, double y, double z)
|
m_vUpVector = Vec3f(xup, yup, zup);
|
||||||
{
|
}
|
||||||
Vec3f nView;
|
|
||||||
Vec3f cView;
|
|
||||||
|
|
||||||
cView = m_vView - m_vPosition;
|
|
||||||
|
|
||||||
double cosTheta = cos(angle);
|
|
||||||
double sinTheta = sin(angle);
|
|
||||||
|
|
||||||
nView.x = (cosTheta + (1 - cosTheta) * x * x) * cView.x +
|
|
||||||
((1 - cosTheta) * x * y - z * sinTheta) * cView.y +
|
|
||||||
((1 - cosTheta) * x * z + y * sinTheta) * cView.z;
|
|
||||||
|
|
||||||
nView.y = (cosTheta + (1 - cosTheta) * y * y) * cView.y +
|
|
||||||
((1- cosTheta) * x * y + z * sinTheta) * cView.x +
|
|
||||||
((1 - cosTheta) * y * z - x * sinTheta) * cView.z;
|
|
||||||
|
|
||||||
nView.z = (cosTheta + (1 - cosTheta) * z * z) * cView.z+
|
|
||||||
((1 - cosTheta) * x * z - y * sinTheta) * cView.x +
|
|
||||||
((1 - cosTheta) * y * z + x * sinTheta) * cView.y;
|
|
||||||
|
|
||||||
m_vView.x = m_vPosition.x + nView.x;
|
void Camera::PositionCamera(Vec3f pos, Vec3f view, Vec3f up)
|
||||||
m_vView.y = m_vPosition.y + nView.y;
|
{
|
||||||
m_vView.z = m_vPosition.z + nView.z;
|
m_vPosition = pos;
|
||||||
}
|
m_vView = view;
|
||||||
|
m_vUpVector = up;
|
||||||
void CameraClass::StrafeCamera(double speed)
|
}
|
||||||
{
|
|
||||||
m_vPosition.x += m_vStrafe.x * speed;
|
void Camera::SetViewByMouse(Screen g_Screen)
|
||||||
m_vPosition.z += m_vStrafe.z * speed;
|
{
|
||||||
m_vView.x += m_vStrafe.x * speed;
|
//Most of this is sorta right for linux I think but since I don't know how yet it's currently windows only
|
||||||
m_vView.z += m_vStrafe.z * speed;
|
#ifdef WIN32
|
||||||
}
|
static double currentRotX = 0.0f;
|
||||||
|
POINT mpos;
|
||||||
|
POINT middle;
|
||||||
|
|
||||||
void CameraClass::Update()
|
double angleZ;
|
||||||
{
|
|
||||||
m_vStrafe =((m_vView - m_vPosition).cross(m_vUpVector)).normalized();
|
middle.x = g_Screen.width / 2;
|
||||||
//SetViewByMouse(); //TODO take this whole function out asap
|
middle.y = g_Screen.height / 2;
|
||||||
|
|
||||||
}
|
GetCursorPos(&mpos);
|
||||||
|
SetCursorPos(middle.x, middle.y);
|
||||||
void CameraClass::Look()
|
|
||||||
{
|
if(mpos.x != middle.x || mpos.y != middle.y)
|
||||||
gluLookAt(m_vPosition.x, m_vPosition.y, m_vPosition.z,
|
{
|
||||||
m_vView.x, m_vView.y, m_vView.z,
|
angleZ = double(middle.y - mpos.y) / 1000.0f;
|
||||||
m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
|
currentRotX -= angleZ;
|
||||||
}
|
|
||||||
|
if(currentRotX > 1.0f)
|
||||||
Vec3f CameraClass::Position()
|
currentRotX = 1.0f;
|
||||||
{
|
else if(currentRotX < -1.0f)
|
||||||
return m_vPosition;
|
currentRotX = -1.0f;
|
||||||
}
|
else
|
||||||
|
{
|
||||||
Vec3f CameraClass::Strafe()
|
Vec3f axis = (m_vView - m_vPosition).cross(m_vUpVector);
|
||||||
{
|
axis.normalize();
|
||||||
return m_vStrafe;
|
|
||||||
}
|
RotateView(angleZ, axis.x, axis.y, axis.z);
|
||||||
|
|
||||||
Vec3f CameraClass::UpVector()
|
//need to switch these two when I figure out stuff for flight
|
||||||
{
|
//till then I think the first is faster
|
||||||
return m_vUpVector;
|
|
||||||
}
|
RotateView(double(middle.x - mpos.x) / 1000.0f, 0, 1, 0);
|
||||||
|
//RotateView(double(middle.x - mpos.x) / 1000.0f, m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
|
||||||
Vec3f CameraClass::View()
|
}
|
||||||
{
|
}
|
||||||
return m_vView;
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 Camera::RotateView(double angle, double x, double y, double z)
|
||||||
|
{
|
||||||
|
Vec3f nView;
|
||||||
|
Vec3f cView;
|
||||||
|
|
||||||
|
cView = m_vView - m_vPosition;
|
||||||
|
|
||||||
|
double cosTheta = cos(angle);
|
||||||
|
double sinTheta = sin(angle);
|
||||||
|
|
||||||
|
nView.x = (cosTheta + (1 - cosTheta) * x * x) * cView.x +
|
||||||
|
((1 - cosTheta) * x * y - z * sinTheta) * cView.y +
|
||||||
|
((1 - cosTheta) * x * z + y * sinTheta) * cView.z;
|
||||||
|
|
||||||
|
nView.y = (cosTheta + (1 - cosTheta) * y * y) * cView.y +
|
||||||
|
((1- cosTheta) * x * y + z * sinTheta) * cView.x +
|
||||||
|
((1 - cosTheta) * y * z - x * sinTheta) * cView.z;
|
||||||
|
|
||||||
|
nView.z = (cosTheta + (1 - cosTheta) * z * z) * cView.z+
|
||||||
|
((1 - cosTheta) * x * z - y * sinTheta) * cView.x +
|
||||||
|
((1 - cosTheta) * y * z + x * sinTheta) * cView.y;
|
||||||
|
|
||||||
|
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 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 Camera::Update()
|
||||||
|
{
|
||||||
|
m_vStrafe =((m_vView - m_vPosition).cross(m_vUpVector)).normalized();
|
||||||
|
//SetViewByMouse(); //TODO take this whole function out asap
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Camera::Position()
|
||||||
|
{
|
||||||
|
return m_vPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f Camera::Strafe()
|
||||||
|
{
|
||||||
|
return m_vStrafe;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f Camera::UpVector()
|
||||||
|
{
|
||||||
|
return m_vUpVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f Camera::View()
|
||||||
|
{
|
||||||
|
return m_vView;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
2253
src/level.cpp
2253
src/level.cpp
File diff suppressed because it is too large
Load Diff
106
src/mygl.cpp
106
src/mygl.cpp
@@ -1,65 +1,67 @@
|
|||||||
|
|
||||||
#include "../include/mygl.h"
|
#include "../include/mygl.h"
|
||||||
|
namespace OpenArena
|
||||||
void FreeGLTexture(GLuint& texture)
|
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, &texture);
|
void FreeGLTexture(GLuint& texture)
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
|
||||||
{
|
|
||||||
if(Right(tolower(fn), 4) == ".bmp")
|
|
||||||
{
|
{
|
||||||
TextureImage* texImage = NULL;
|
glDeleteTextures(1, &texture);
|
||||||
if(texImage = LoadBMP(fn.c_str()))
|
}
|
||||||
|
|
||||||
|
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
||||||
|
{
|
||||||
|
if(Right(tolower(fn), 4) == ".bmp")
|
||||||
{
|
{
|
||||||
glGenTextures(1, &texture);
|
TextureImage* texImage = NULL;
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
if(texImage = LoadBMP(fn.c_str()))
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
|
||||||
|
|
||||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
|
||||||
{
|
{
|
||||||
if(texImage->data)
|
glGenTextures(1, &texture);
|
||||||
free(texImage->data);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
free(texImage);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||||
|
|
||||||
|
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||||
|
{
|
||||||
|
if(texImage->data)
|
||||||
|
free(texImage->data);
|
||||||
|
free(texImage);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
else if(Right(tolower(fn), 4) == ".tga")
|
||||||
|
{
|
||||||
|
TextureImage* texImage = NULL;
|
||||||
|
if(texImage = LoadTGA(fn.c_str()))
|
||||||
|
{
|
||||||
|
glGenTextures(1, &texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||||
|
{
|
||||||
|
if(texImage->data)
|
||||||
|
free(texImage->data);
|
||||||
|
free(texImage);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Right(tolower(fn), 4) == ".tga")
|
};
|
||||||
{
|
|
||||||
TextureImage* texImage = NULL;
|
|
||||||
if(texImage = LoadTGA(fn.c_str()))
|
|
||||||
{
|
|
||||||
glGenTextures(1, &texture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
|
|
||||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
|
||||||
{
|
|
||||||
if(texImage->data)
|
|
||||||
free(texImage->data);
|
|
||||||
free(texImage);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenArena::Window g_Screen;
|
OpenArena::Window g_Screen;
|
||||||
|
|||||||
219
src/myglFont.cpp
219
src/myglFont.cpp
@@ -25,118 +25,121 @@
|
|||||||
|
|
||||||
#include "../include/myglFont.h"
|
#include "../include/myglFont.h"
|
||||||
|
|
||||||
GLFontClass::GLFontClass()
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
status = 0;
|
Font::Font()
|
||||||
base = 0;
|
{
|
||||||
texture = 0;
|
status = 0;
|
||||||
screenWidth = 1;
|
base = 0;
|
||||||
screenHeight = 1;
|
texture = 0;
|
||||||
}
|
screenWidth = 1;
|
||||||
|
screenHeight = 1;
|
||||||
GLFontClass::~GLFontClass()
|
}
|
||||||
{
|
|
||||||
FreeFont();
|
Font::~Font()
|
||||||
}
|
{
|
||||||
|
FreeFont();
|
||||||
bool GLFontClass::BuildFont(const char* texName)
|
}
|
||||||
{
|
|
||||||
FreeFont();
|
bool Font::BuildFont(const char* texName)
|
||||||
|
{
|
||||||
if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
FreeFont();
|
||||||
{
|
|
||||||
float x, y;
|
if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
||||||
base = glGenLists(256);
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
float x, y;
|
||||||
for(short i = 0; i<256; i++)
|
base = glGenLists(256);
|
||||||
{
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
x = i%16/16.0f;
|
for(short i = 0; i<256; i++)
|
||||||
y = i/16/16.0f;
|
{
|
||||||
glNewList(base+i, GL_COMPILE);
|
x = i%16/16.0f;
|
||||||
glBegin(GL_QUADS);
|
y = i/16/16.0f;
|
||||||
glTexCoord2f(x, 1-y-0.0625f);
|
glNewList(base+i, GL_COMPILE);
|
||||||
glVertex2i(0,0);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(x+0.0625f, 1-y-0.0625f);
|
glTexCoord2f(x, 1-y-0.0625f);
|
||||||
glVertex2i(16,0);
|
glVertex2i(0,0);
|
||||||
glTexCoord2f(x+0.0625f, 1-y);
|
glTexCoord2f(x+0.0625f, 1-y-0.0625f);
|
||||||
glVertex2i(16,16);
|
glVertex2i(16,0);
|
||||||
glTexCoord2f(x, 1-y);
|
glTexCoord2f(x+0.0625f, 1-y);
|
||||||
glVertex2i(0,16);
|
glVertex2i(16,16);
|
||||||
glEnd();
|
glTexCoord2f(x, 1-y);
|
||||||
glTranslated(16,0,0);
|
glVertex2i(0,16);
|
||||||
glEndList();
|
glEnd();
|
||||||
|
glTranslated(16,0,0);
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
status = true;
|
||||||
}
|
}
|
||||||
status = true;
|
return status;
|
||||||
}
|
}
|
||||||
return status;
|
|
||||||
}
|
bool Font::FreeFont()
|
||||||
|
|
||||||
bool GLFontClass::FreeFont()
|
|
||||||
{
|
|
||||||
if(status)
|
|
||||||
{
|
{
|
||||||
glDeleteLists(base, 256);
|
if(status)
|
||||||
status = false;
|
{
|
||||||
|
glDeleteLists(base, 256);
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
return status;
|
|
||||||
}
|
void Font::Print(int x, int y, const char* str, unsigned int set)
|
||||||
|
|
||||||
void GLFontClass::Print(int x, int y, const char* str, unsigned int set)
|
|
||||||
{
|
|
||||||
if(status)
|
|
||||||
{
|
{
|
||||||
if(set>1)
|
if(status)
|
||||||
set = 1;
|
{
|
||||||
|
if(set>1)
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
set = 1;
|
||||||
//glDisable(GL_DEPTH_TEST);
|
|
||||||
//glEnable(GL_BLEND);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glMatrixMode(GL_PROJECTION);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
glPushMatrix();
|
//glEnable(GL_BLEND);
|
||||||
glLoadIdentity();
|
glMatrixMode(GL_PROJECTION);
|
||||||
glOrtho(0,screenWidth,0,screenHeight,-1,1);
|
glPushMatrix();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glLoadIdentity();
|
||||||
glPushMatrix();
|
glOrtho(0,screenWidth,0,screenHeight,-1,1);
|
||||||
glLoadIdentity();
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glTranslated(x, y, 0);
|
glPushMatrix();
|
||||||
glListBase(base-32+(128*set));
|
glLoadIdentity();
|
||||||
glCallLists(strlen(str), GL_BYTE, str);
|
glTranslated(x, y, 0);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glListBase(base-32+(128*set));
|
||||||
glPopMatrix();
|
glCallLists(strlen(str), GL_BYTE, str);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
//glDisable(GL_BLEND);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
//glEnable(GL_DEPTH_TEST);
|
glPopMatrix();
|
||||||
|
//glDisable(GL_BLEND);
|
||||||
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
bool Font::Loaded()
|
||||||
bool GLFontClass::Loaded()
|
{
|
||||||
{
|
return status;
|
||||||
return status;
|
}
|
||||||
}
|
|
||||||
|
void Font::SetScreenDimensions(short x, short y)
|
||||||
void GLFontClass::SetScreenDimensions(short x, short y)
|
{
|
||||||
{
|
screenWidth = x;
|
||||||
screenWidth = x;
|
screenHeight = y;
|
||||||
screenHeight = y;
|
}
|
||||||
}
|
|
||||||
|
void Font::SetScreenWidth(short x)
|
||||||
void GLFontClass::SetScreenWidth(short x)
|
{
|
||||||
{
|
screenWidth = x;
|
||||||
screenWidth = x;
|
}
|
||||||
}
|
|
||||||
|
void Font::SetScreenHeight(short y)
|
||||||
void GLFontClass::SetScreenHeight(short y)
|
{
|
||||||
{
|
screenHeight = y;
|
||||||
screenHeight = y;
|
}
|
||||||
}
|
|
||||||
|
short Font::ScreenWidth()
|
||||||
short GLFontClass::ScreenWidth()
|
{
|
||||||
{
|
return screenWidth;
|
||||||
return screenWidth;
|
}
|
||||||
}
|
|
||||||
|
short Font::ScreenHeight()
|
||||||
short GLFontClass::ScreenHeight()
|
{
|
||||||
{
|
return screenHeight;
|
||||||
return screenHeight;
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,107 +1,111 @@
|
|||||||
#include "../include/myglTexture.h"
|
#include "../include/myglTexture.h"
|
||||||
|
using namespace OpenArena;
|
||||||
|
|
||||||
GL_MY_TEXTURE::GL_MY_TEXTURE()
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
id=0xFFFFFFFF;
|
Texture::Texture()
|
||||||
filename = "";
|
|
||||||
minFilter = GL_LINEAR;
|
|
||||||
magFilter = GL_LINEAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL_MY_TEXTURE::~GL_MY_TEXTURE()
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
}
|
|
||||||
|
|
||||||
string GL_MY_TEXTURE::Filename()
|
|
||||||
{
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint GL_MY_TEXTURE::ID()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GL_MY_TEXTURE::Loaded()
|
|
||||||
{
|
|
||||||
return filename != "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GL_MY_TEXTURE::Load(string fn)
|
|
||||||
{
|
|
||||||
if(Loaded())
|
|
||||||
Free();
|
|
||||||
|
|
||||||
if(LoadGLTexture(fn.c_str(), id, minFilter, magFilter))
|
|
||||||
{
|
|
||||||
filename = fn;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
id=0xFFFFFFFF;
|
id=0xFFFFFFFF;
|
||||||
return false;
|
filename = "";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GL_MY_TEXTURE::Load(string fn, GLuint min, GLuint mag)
|
|
||||||
{
|
|
||||||
if(Loaded())
|
|
||||||
Free();
|
|
||||||
|
|
||||||
if(LoadGLTexture(fn.c_str(), id, min, mag))
|
|
||||||
{
|
|
||||||
filename = fn;
|
|
||||||
minFilter = min;
|
|
||||||
magFilter = mag;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id=0xFFFFFFFF;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GL_MY_TEXTURE::Free()
|
|
||||||
{
|
|
||||||
if(Loaded())
|
|
||||||
{
|
|
||||||
FreeGLTexture(id);
|
|
||||||
minFilter = GL_LINEAR;
|
minFilter = GL_LINEAR;
|
||||||
magFilter = GL_LINEAR;
|
magFilter = GL_LINEAR;
|
||||||
filename = "";
|
|
||||||
id = 0xFFFFFFFF;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Texture::~Texture()
|
||||||
bool GL_MY_TEXTURE::operator<(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
Free();
|
||||||
return id<rtOp.id;
|
}
|
||||||
}
|
|
||||||
|
string Texture::Filename()
|
||||||
bool GL_MY_TEXTURE::operator<=(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
return filename;
|
||||||
return id<=rtOp.id;
|
}
|
||||||
}
|
|
||||||
|
GLuint Texture::ID()
|
||||||
bool GL_MY_TEXTURE::operator==(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
return id;
|
||||||
return id==rtOp.id;
|
}
|
||||||
}
|
|
||||||
|
bool Texture::Loaded()
|
||||||
bool GL_MY_TEXTURE::operator!=(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
return filename != "";
|
||||||
return id!=rtOp.id;
|
}
|
||||||
}
|
|
||||||
|
bool Texture::Load(string fn)
|
||||||
bool GL_MY_TEXTURE::operator>=(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
if(Loaded())
|
||||||
return id>=rtOp.id;
|
Free();
|
||||||
}
|
|
||||||
|
if(LoadGLTexture(fn.c_str(), id, minFilter, magFilter))
|
||||||
bool GL_MY_TEXTURE::operator>(const GL_MY_TEXTURE& rtOp)
|
{
|
||||||
{
|
filename = fn;
|
||||||
return id>rtOp.id;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id=0xFFFFFFFF;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::Load(string fn, GLuint min, GLuint mag)
|
||||||
|
{
|
||||||
|
if(Loaded())
|
||||||
|
Free();
|
||||||
|
|
||||||
|
if(LoadGLTexture(fn.c_str(), id, min, mag))
|
||||||
|
{
|
||||||
|
filename = fn;
|
||||||
|
minFilter = min;
|
||||||
|
magFilter = mag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id=0xFFFFFFFF;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture::Free()
|
||||||
|
{
|
||||||
|
if(Loaded())
|
||||||
|
{
|
||||||
|
FreeGLTexture(id);
|
||||||
|
minFilter = GL_LINEAR;
|
||||||
|
magFilter = GL_LINEAR;
|
||||||
|
filename = "";
|
||||||
|
id = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator<(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id<rtOp.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator<=(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id<=rtOp.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator==(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id==rtOp.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator!=(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id!=rtOp.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator>=(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id>=rtOp.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Texture::operator>(const Texture& rtOp)
|
||||||
|
{
|
||||||
|
return id>rtOp.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
#include "../include/player.h"
|
#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