Commit initial
This commit is contained in:
8
include/OGL_ext.h
Normal file
8
include/OGL_ext.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#ifndef OGL_EXT
|
||||
#define OGL_EXT
|
||||
|
||||
void Xr_InitExtSupport();
|
||||
void Xr_CheckExt(char*);
|
||||
|
||||
#endif
|
58
include/box.h
Normal file
58
include/box.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#ifndef BOX
|
||||
#define BOX
|
||||
|
||||
#include "mesh.h"
|
||||
#include "vector.h"
|
||||
#include "plane.h"
|
||||
|
||||
class Xr_AABB
|
||||
{
|
||||
public:
|
||||
Xr_AABB();
|
||||
~Xr_AABB();
|
||||
|
||||
void setPos(float, float, float);
|
||||
void genBox(Xr_Mesh*);
|
||||
|
||||
Xr_Vector3D getPos() const;
|
||||
Xr_Vector3D* const getPoints() const;
|
||||
|
||||
private:
|
||||
Xr_Vector3D A_pos;
|
||||
Xr_Vector3D A_points[8];
|
||||
};
|
||||
|
||||
#define FRUSTUM_PLANES_NUMBER 5
|
||||
|
||||
#define TOP 0
|
||||
#define BOTTOM 1
|
||||
#define RIGHT 2
|
||||
#define LEFT 3
|
||||
#define NEAR 4
|
||||
|
||||
#define MAX_DISTANCE_TEST 4
|
||||
|
||||
class Xr_FrustumBox
|
||||
{
|
||||
public:
|
||||
Xr_FrustumBox();
|
||||
~Xr_FrustumBox();
|
||||
|
||||
void setBoxSize(float, float, float, float);
|
||||
void genBox(Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
|
||||
bool testPoint(float, float, float);
|
||||
bool testAABB(Xr_AABB*);
|
||||
|
||||
private:
|
||||
float F_far;
|
||||
float F_near;
|
||||
float F_heightFar;
|
||||
float F_heightNear;
|
||||
float F_widthFar;
|
||||
float F_widthNear;
|
||||
Xr_Plane F_frustumPlanes[5];
|
||||
};
|
||||
|
||||
#endif
|
51
include/buffer.h
Normal file
51
include/buffer.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#ifndef BUFFER
|
||||
#define BUFFER
|
||||
|
||||
#include <vector>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "mesh.h"
|
||||
|
||||
struct meshDesc
|
||||
{
|
||||
meshDesc() : mesh(0), vertexOffset(0), vertexSize(0), texCoordOffset(0), texCoordSize(0), normalOffset(0), normalSize(0), vbo(0)
|
||||
{
|
||||
}
|
||||
|
||||
Xr_Mesh *mesh;
|
||||
unsigned int vertexOffset;
|
||||
unsigned int vertexSize;
|
||||
unsigned int texCoordOffset;
|
||||
unsigned int texCoordSize;
|
||||
unsigned int normalOffset;
|
||||
unsigned int normalSize;
|
||||
GLuint vbo;
|
||||
};
|
||||
|
||||
class Xr_BufferManager
|
||||
{
|
||||
public:
|
||||
Xr_BufferManager();
|
||||
~Xr_BufferManager();
|
||||
|
||||
static Xr_BufferManager* getInstance();
|
||||
static bool instanced();
|
||||
static void quitInstance();
|
||||
|
||||
bool load(Xr_Mesh*);
|
||||
void unload(Xr_Mesh*);
|
||||
void unloadAll();
|
||||
|
||||
void fetchVertex(Xr_Mesh*);
|
||||
void fetchTexCoord(Xr_Mesh*);
|
||||
void fetchNormal(Xr_Mesh*);
|
||||
void fetchNull();
|
||||
|
||||
private:
|
||||
|
||||
static Xr_BufferManager* B_instance;
|
||||
std::vector<meshDesc> B_meshList;
|
||||
};
|
||||
|
||||
#endif
|
56
include/camera.h
Normal file
56
include/camera.h
Normal file
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
#ifndef CAMERA
|
||||
#define CAMERA
|
||||
|
||||
#include "matrix.h"
|
||||
#include "vector.h"
|
||||
#include "box.h"
|
||||
|
||||
class Xr_Camera
|
||||
{
|
||||
public:
|
||||
Xr_Camera();
|
||||
~Xr_Camera();
|
||||
|
||||
void configModelview(Xr_MATRIX_4X4*);
|
||||
void computeProjection();
|
||||
|
||||
void setPos(float, float, float);
|
||||
void relPos(float, float, float);
|
||||
void setAngle(float, float);
|
||||
void relAngle(float, float);
|
||||
void setFov(float);
|
||||
void relFov(float);
|
||||
void setFar(float);
|
||||
void setNear(float);
|
||||
|
||||
void moveForward(float);
|
||||
void moveBackward(float);
|
||||
void moveRight(float);
|
||||
void moveLeft(float);
|
||||
void moveUpDown(float);
|
||||
|
||||
Xr_Vector3D getPos() const;
|
||||
float getFov() const;
|
||||
float* const getAngle() const;
|
||||
Xr_MATRIX_4X4* const getProjection() const;
|
||||
Xr_FrustumBox* const getFrustumBox() const;
|
||||
|
||||
private:
|
||||
Xr_MATRIX_4X4 *C_projection;
|
||||
Xr_FrustumBox *C_box;
|
||||
Xr_Vector3D C_eye;
|
||||
Xr_Vector3D C_pos;
|
||||
float C_fov;
|
||||
float C_far;
|
||||
float C_near;
|
||||
float C_angle[2];
|
||||
|
||||
Xr_Vector3D C_dir;
|
||||
Xr_Vector3D C_right;
|
||||
Xr_Vector3D C_left;
|
||||
Xr_Vector3D C_up;
|
||||
Xr_Vector3D C_down;
|
||||
};
|
||||
|
||||
#endif
|
10
include/debug.h
Normal file
10
include/debug.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
|
||||
#include <string>
|
||||
|
||||
void Xr_Log(std::string);
|
||||
void Xr_Crash();
|
||||
|
||||
#endif
|
142
include/devices.h
Normal file
142
include/devices.h
Normal file
@ -0,0 +1,142 @@
|
||||
#pragma once
|
||||
#ifndef DEVICES
|
||||
#define DEVICES
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#define XR_KEY_ESCAPE 27
|
||||
#define XR_KEY_SPACE 32
|
||||
|
||||
#define XR_KEY_a 97
|
||||
#define XR_KEY_b 98
|
||||
#define XR_KEY_c 99
|
||||
#define XR_KEY_d 100
|
||||
#define XR_KEY_e 101
|
||||
#define XR_KEY_f 102
|
||||
#define XR_KEY_g 103
|
||||
#define XR_KEY_h 104
|
||||
#define XR_KEY_i 105
|
||||
#define XR_KEY_j 106
|
||||
#define XR_KEY_k 107
|
||||
#define XR_KEY_l 108
|
||||
#define XR_KEY_m 109
|
||||
#define XR_KEY_n 110
|
||||
#define XR_KEY_o 111
|
||||
#define XR_KEY_p 112
|
||||
#define XR_KEY_q 113
|
||||
#define XR_KEY_r 114
|
||||
#define XR_KEY_s 115
|
||||
#define XR_KEY_t 116
|
||||
#define XR_KEY_u 117
|
||||
#define XR_KEY_v 118
|
||||
#define XR_KEY_w 119
|
||||
#define XR_KEY_x 120
|
||||
#define XR_KEY_y 121
|
||||
#define XR_KEY_z 122
|
||||
|
||||
#define XR_KEY_UP 273
|
||||
#define XR_KEY_DOWN 274
|
||||
#define XR_KEY_RIGHT 275
|
||||
#define XR_KEY_LEFT 276
|
||||
|
||||
#define XR_KEY_KP0 256
|
||||
#define XR_KEY_KP1 257
|
||||
#define XR_KEY_KP2 258
|
||||
#define XR_KEY_KP3 259
|
||||
#define XR_KEY_KP4 260
|
||||
#define XR_KEY_KP5 261
|
||||
#define XR_KEY_KP6 262
|
||||
#define XR_KEY_KP7 263
|
||||
#define XR_KEY_KP8 264
|
||||
#define XR_KEY_KP9 265
|
||||
|
||||
#define XR_KEY_F1 282
|
||||
#define XR_KEY_F2 283
|
||||
#define XR_KEY_F3 284
|
||||
#define XR_KEY_F4 285
|
||||
#define XR_KEY_F5 286
|
||||
#define XR_KEY_F6 287
|
||||
#define XR_KEY_F7 288
|
||||
#define XR_KEY_F8 289
|
||||
#define XR_KEY_F9 290
|
||||
#define XR_KEY_F10 291
|
||||
#define XR_KEY_F11 292
|
||||
#define XR_KEY_F12 293
|
||||
|
||||
#define XR_KEY_RSHIFT 303
|
||||
#define XR_KEY_LSHIFT 304
|
||||
#define XR_KEY_RCTRL 305
|
||||
#define XR_KEY_LCTRL 306
|
||||
#define XR_KEY_RALT 307
|
||||
#define XR_KEY_LALT 308
|
||||
|
||||
#define XR_MOUSE_BUTTON_LEFT 1
|
||||
#define XR_MOUSE_BUTTON_MIDDLE 2
|
||||
#define XR_MOUSE_BUTTON_RIGHT 3
|
||||
#define XR_MOUSE_WHEELUP 4
|
||||
#define XR_MOUSE_WHEELDOWN 5
|
||||
|
||||
struct Xr_MouseDesc
|
||||
{
|
||||
Xr_MouseDesc() : button(new bool[8]), posX(0), posY(0), relX(0), relY(0), oldPosX(0), oldPosY(0)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
button[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
~Xr_MouseDesc()
|
||||
{
|
||||
delete[] button;
|
||||
}
|
||||
|
||||
bool *button;
|
||||
int posX;
|
||||
int posY;
|
||||
int relX;
|
||||
int relY;
|
||||
int oldPosX;
|
||||
int oldPosY;
|
||||
};
|
||||
|
||||
struct Xr_KeyboardDesc
|
||||
{
|
||||
Xr_KeyboardDesc() : key(new bool[SDLK_LAST])
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < SDLK_LAST; i++)
|
||||
{
|
||||
key[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
~Xr_KeyboardDesc()
|
||||
{
|
||||
delete[] key;
|
||||
}
|
||||
|
||||
bool *key;
|
||||
};
|
||||
|
||||
struct Xr_DevicesDesc
|
||||
{
|
||||
Xr_DevicesDesc() : mouse(new Xr_MouseDesc), keyboard(new Xr_KeyboardDesc), windowHeight(0), windowWidth(0)
|
||||
{
|
||||
}
|
||||
|
||||
~Xr_DevicesDesc()
|
||||
{
|
||||
delete mouse;
|
||||
delete keyboard;
|
||||
}
|
||||
|
||||
Xr_MouseDesc *mouse;
|
||||
Xr_KeyboardDesc *keyboard;
|
||||
|
||||
int windowHeight;
|
||||
int windowWidth;
|
||||
};
|
||||
|
||||
#endif
|
47
include/event.h
Normal file
47
include/event.h
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
#ifndef EVENT
|
||||
#define EVENT
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include "devices.h"
|
||||
|
||||
class Xr_EventProfil
|
||||
{
|
||||
public:
|
||||
Xr_EventProfil();
|
||||
~Xr_EventProfil();
|
||||
|
||||
virtual void execute(Xr_DevicesDesc*);
|
||||
};
|
||||
|
||||
class Xr_EventManager
|
||||
{
|
||||
public:
|
||||
Xr_EventManager();
|
||||
~Xr_EventManager();
|
||||
|
||||
static Xr_EventManager* getInstance();
|
||||
static bool instaced();
|
||||
static void quitInstance();
|
||||
|
||||
void setProfil(Xr_EventProfil*);
|
||||
void updateDeviceState();
|
||||
void executeProfil();
|
||||
bool quitEvent();
|
||||
void genQuitEvent();
|
||||
|
||||
void enableMouseCapture();
|
||||
void disableMouseCapture();
|
||||
bool mouseCaptured();
|
||||
|
||||
private:
|
||||
static Xr_EventManager* E_instance;
|
||||
Xr_EventProfil *E_eventProfil;
|
||||
Xr_DevicesDesc *E_devices;
|
||||
SDL_Event *E_event;
|
||||
bool E_mouseCapture;
|
||||
bool E_quit;
|
||||
};
|
||||
|
||||
#endif
|
42
include/light.h
Normal file
42
include/light.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#ifndef LIGHT
|
||||
#define LIGHT
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "matrix.h"
|
||||
|
||||
#define DEPTH_MAP_SIZE 1024
|
||||
|
||||
class Xr_Light
|
||||
{
|
||||
public:
|
||||
Xr_Light();
|
||||
Xr_Light(float posX, float poxY, float posZ, float eyeX, float eyeY, float eyeZ, float intensity, float colorR, float colorG, float colorB, float fov, bool shadow);
|
||||
~Xr_Light();
|
||||
|
||||
void configure(float posX, float posY, float posZ, float eyeX, float eyeY, float eyeZ, float intensity, float colorR, float colorG, float colorB, float fov, bool shadow);
|
||||
|
||||
float* const getColorRGB() const;
|
||||
float getIntensity() const;
|
||||
float* const getPos() const;
|
||||
float* const getEye() const;
|
||||
float getFov() const;
|
||||
Xr_MATRIX_4X4* const getLightProjectionMatrix() const;
|
||||
Xr_MATRIX_4X4* const getLightModelviewMatrix() const;
|
||||
GLuint getLightDepthMap() const;
|
||||
bool hasShadow() const;
|
||||
|
||||
private:
|
||||
float L_colorRGB[3];
|
||||
float L_intensity;
|
||||
float L_pos[3];
|
||||
float L_eye[3];
|
||||
float L_fov;
|
||||
bool L_shadow;
|
||||
Xr_MATRIX_4X4 *L_projection;
|
||||
Xr_MATRIX_4X4 *L_modelview;
|
||||
GLuint L_depthMap;
|
||||
};
|
||||
|
||||
#endif
|
45
include/material.h
Normal file
45
include/material.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#ifndef MATERIAL
|
||||
#define MATERIAL
|
||||
|
||||
#include "texture.h"
|
||||
|
||||
class Xr_Material
|
||||
{
|
||||
public:
|
||||
Xr_Material();
|
||||
Xr_Material(bool, bool, float, float, float, Xr_Texture*);
|
||||
~Xr_Material();
|
||||
|
||||
void enableShadow();
|
||||
void disableShadow();
|
||||
void enableShaderless();
|
||||
void disableShaderless();
|
||||
|
||||
void setAmbient(float);
|
||||
void setDiffuse(float);
|
||||
void setSpecular(float);
|
||||
|
||||
void attachTexture(Xr_Texture*);
|
||||
void detachTexture();
|
||||
|
||||
float getAmbient() const;
|
||||
float getDiffuse() const;
|
||||
float getSpecular() const;
|
||||
Xr_Texture* const getTexture() const;
|
||||
|
||||
/* à ajouter -> support multi-texturage */
|
||||
|
||||
private:
|
||||
bool M_shadow;
|
||||
bool M_shaderless;
|
||||
|
||||
float M_ambient;
|
||||
float M_diffuse;
|
||||
float M_specular;
|
||||
Xr_Texture *M_texture;
|
||||
|
||||
/* à ajouter -> support multi-texturage */
|
||||
};
|
||||
|
||||
#endif
|
30
include/matrix.h
Normal file
30
include/matrix.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#ifndef MATRIX
|
||||
#define MATRIX
|
||||
|
||||
class Xr_MATRIX_4X4
|
||||
{
|
||||
public:
|
||||
Xr_MATRIX_4X4();
|
||||
Xr_MATRIX_4X4(float*);
|
||||
Xr_MATRIX_4X4(Xr_MATRIX_4X4 const&);
|
||||
~Xr_MATRIX_4X4();
|
||||
|
||||
/* Valeur de retour en lecture seul */
|
||||
float* const getValues() const;
|
||||
|
||||
void loadIdentity();
|
||||
void loadProjection(float, float, float, float);
|
||||
void lookAt(float, float, float, float, float, float, float, float, float);
|
||||
void translate(float, float, float);
|
||||
void rotate(float, float, float, float);
|
||||
void scale(float, float, float);
|
||||
|
||||
Xr_MATRIX_4X4& operator=(Xr_MATRIX_4X4 const& matrix);
|
||||
Xr_MATRIX_4X4 operator*(Xr_MATRIX_4X4 const& matrix);
|
||||
|
||||
private:
|
||||
float *M_values;
|
||||
};
|
||||
|
||||
#endif
|
31
include/mesh.h
Normal file
31
include/mesh.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#ifndef MESH
|
||||
#define MESH
|
||||
|
||||
#include "ressource.h"
|
||||
|
||||
class Xr_Mesh : public Xr_Ressource
|
||||
{
|
||||
public:
|
||||
Xr_Mesh();
|
||||
Xr_Mesh(char*);
|
||||
Xr_Mesh(Xr_Mesh const&);
|
||||
virtual ~Xr_Mesh();
|
||||
|
||||
float* const getVertex() const;
|
||||
float* const getTexCoord() const;
|
||||
float* const getNormal() const;
|
||||
int getFaceNumber() const;
|
||||
|
||||
void load();
|
||||
|
||||
|
||||
private:
|
||||
float *M_vertex;
|
||||
float *M_texCoord;
|
||||
float *M_normal;
|
||||
|
||||
int M_faceNumber;
|
||||
};
|
||||
|
||||
#endif
|
41
include/object.h
Normal file
41
include/object.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#ifndef OBJECT
|
||||
#define OBJECT
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "mesh.h"
|
||||
#include "material.h"
|
||||
#include "box.h"
|
||||
|
||||
class Xr_Object
|
||||
{
|
||||
public:
|
||||
Xr_Object();
|
||||
~Xr_Object();
|
||||
|
||||
bool isReady() const;
|
||||
float* const getPos() const;
|
||||
Xr_Material* const getMaterial() const;
|
||||
Xr_AABB* const getBox() const;
|
||||
|
||||
void attachMesh(Xr_Mesh*);
|
||||
void detachMesh();
|
||||
void loadToServer();
|
||||
void unloadToServer();
|
||||
void attachMaterial(Xr_Material*);
|
||||
void detachMaterial();
|
||||
void setPos(float, float, float);
|
||||
void draw();
|
||||
|
||||
private:
|
||||
Xr_Mesh *O_mesh;
|
||||
Xr_AABB *O_box;
|
||||
|
||||
Xr_Material *O_material;
|
||||
|
||||
float O_pos[3];
|
||||
bool O_isReady;
|
||||
};
|
||||
|
||||
#endif
|
28
include/plane.h
Normal file
28
include/plane.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#ifndef PLAN
|
||||
#define PLAN
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
class Xr_Plane
|
||||
{
|
||||
public:
|
||||
Xr_Plane();
|
||||
Xr_Plane(Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
Xr_Plane(Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
~Xr_Plane();
|
||||
|
||||
void setPoints(Xr_Vector3D const&, Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
void setNormalPoint(Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
|
||||
float getDistanceToPoint(Xr_Vector3D const&);
|
||||
void flipNormal();
|
||||
Xr_Vector3D getNormal();
|
||||
|
||||
private:
|
||||
Xr_Vector3D P_normal;
|
||||
Xr_Vector3D P_point;
|
||||
float P_d;
|
||||
};
|
||||
|
||||
#endif
|
29
include/program.h
Normal file
29
include/program.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#ifndef PROGRAM
|
||||
#define PROGRAM
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "shader.h"
|
||||
|
||||
class Xr_Program
|
||||
{
|
||||
public:
|
||||
Xr_Program();
|
||||
~Xr_Program();
|
||||
|
||||
bool isLink() const;
|
||||
GLuint getProgramId() const;
|
||||
|
||||
void attachShader(Xr_Shader*);
|
||||
void detachShader(Xr_Shader*);
|
||||
void link();
|
||||
|
||||
private:
|
||||
GLuint P_id;
|
||||
Xr_Shader *P_shader1;
|
||||
Xr_Shader *P_shader2;
|
||||
bool P_isLink;
|
||||
};
|
||||
|
||||
#endif
|
45
include/render.h
Normal file
45
include/render.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#ifndef RENDER
|
||||
#define RENDER
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
class Xr_Renderer
|
||||
{
|
||||
public:
|
||||
Xr_Renderer();
|
||||
~Xr_Renderer();
|
||||
|
||||
static Xr_Renderer* getInstance();
|
||||
static bool instanced();
|
||||
static void quitInstance();
|
||||
|
||||
void init(unsigned int, unsigned int, bool, unsigned int);
|
||||
void mainLoop();
|
||||
|
||||
void setVideo(unsigned int, unsigned int, bool);
|
||||
void setFrameRateLimite(unsigned int);
|
||||
void setImageSize(unsigned int, unsigned int);
|
||||
|
||||
void setScene(Xr_Scene*);
|
||||
|
||||
unsigned int getWindowWidth() const;
|
||||
unsigned int getWindowHeight() const;
|
||||
unsigned int getImageWidth() const;
|
||||
unsigned int getImageHeight() const;
|
||||
unsigned int getFrameRate() const;
|
||||
|
||||
private:
|
||||
static Xr_Renderer* R_instance;
|
||||
bool isInit;
|
||||
unsigned int R_windowWidth;
|
||||
unsigned int R_windowHeight;
|
||||
unsigned int R_imageWidth;
|
||||
unsigned int R_imageHeight;
|
||||
bool R_fullscreen;
|
||||
unsigned int R_frameRateLimite;
|
||||
unsigned int R_frameRate;
|
||||
Xr_Scene *R_scene;
|
||||
};
|
||||
|
||||
#endif
|
54
include/ressource.h
Normal file
54
include/ressource.h
Normal file
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#ifndef RESSOURCE
|
||||
#define RESSOURCE
|
||||
|
||||
#include <vector>
|
||||
|
||||
enum ressourceType
|
||||
{
|
||||
xr_mesh_type,
|
||||
xr_shader_type,
|
||||
xr_texture_type
|
||||
};
|
||||
|
||||
class Xr_Ressource
|
||||
{
|
||||
public:
|
||||
Xr_Ressource();
|
||||
Xr_Ressource(char*, ressourceType);
|
||||
Xr_Ressource(ressourceType);
|
||||
virtual ~Xr_Ressource();
|
||||
|
||||
char* const getName() const;
|
||||
bool isLoaded() const;
|
||||
ressourceType getType() const;
|
||||
|
||||
|
||||
protected:
|
||||
char *R_name;
|
||||
bool R_isLoaded;
|
||||
ressourceType R_type;
|
||||
};
|
||||
|
||||
class Xr_RessourceManager
|
||||
{
|
||||
public:
|
||||
Xr_RessourceManager();
|
||||
~Xr_RessourceManager();
|
||||
|
||||
static bool instanced();
|
||||
static Xr_RessourceManager* getInstance();
|
||||
static void quitInstance();
|
||||
|
||||
bool load(ressourceType, char*);
|
||||
void unload(ressourceType, char*);
|
||||
void unloadAll();
|
||||
|
||||
Xr_Ressource* get(ressourceType, char*);
|
||||
|
||||
private:
|
||||
static Xr_RessourceManager *R_instance;
|
||||
std::vector<Xr_Ressource*> R_ressourcesList;
|
||||
};
|
||||
|
||||
#endif
|
38
include/scene.h
Normal file
38
include/scene.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#ifndef SCENE
|
||||
#define SCENE
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "program.h"
|
||||
#include "object.h"
|
||||
#include "matrix.h"
|
||||
#include "light.h"
|
||||
#include "camera.h"
|
||||
|
||||
|
||||
class Xr_Scene
|
||||
{
|
||||
public:
|
||||
Xr_Scene();
|
||||
~Xr_Scene();
|
||||
|
||||
void addObject(Xr_Object*);
|
||||
void deleteObject(Xr_Object*);
|
||||
void addLight(Xr_Light*);
|
||||
void deleteLight(Xr_Light*);
|
||||
void attachCamera(Xr_Camera*);
|
||||
void detachCamera();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
std::vector<Xr_Object*> S_objectList;
|
||||
std::vector<Xr_Light*> S_lightList;
|
||||
Xr_MATRIX_4X4 *modelview;
|
||||
Xr_Camera *S_camera;
|
||||
|
||||
Xr_Program *basicProg;
|
||||
Xr_Program *render1Prog;
|
||||
};
|
||||
|
||||
#endif
|
34
include/shader.h
Normal file
34
include/shader.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#ifndef SHADER
|
||||
#define SHADER
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "ressource.h"
|
||||
|
||||
|
||||
class Xr_Shader : public Xr_Ressource
|
||||
{
|
||||
public:
|
||||
Xr_Shader();
|
||||
Xr_Shader(char*);
|
||||
virtual ~Xr_Shader();
|
||||
|
||||
GLuint getShaderId() const;
|
||||
GLenum getShaderType() const;
|
||||
bool isCompile() const;
|
||||
char* const getSrc() const;
|
||||
int getSrcLength() const;
|
||||
|
||||
void load();
|
||||
void compile();
|
||||
|
||||
private:
|
||||
GLuint S_id;
|
||||
GLenum S_type;
|
||||
char *S_src;
|
||||
bool S_isCompile;
|
||||
int S_srcLength;
|
||||
};
|
||||
|
||||
#endif
|
24
include/texture.h
Normal file
24
include/texture.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#ifndef TEXTURE
|
||||
#define TEXTURE
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "ressource.h"
|
||||
|
||||
class Xr_Texture : public Xr_Ressource
|
||||
{
|
||||
public:
|
||||
Xr_Texture();
|
||||
Xr_Texture(char*);
|
||||
virtual ~Xr_Texture();
|
||||
|
||||
GLuint getTextureId() const;
|
||||
|
||||
void load();
|
||||
|
||||
private:
|
||||
GLuint T_id;
|
||||
};
|
||||
|
||||
#endif
|
37
include/vector.h
Normal file
37
include/vector.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#ifndef VECTOR
|
||||
#define VECTOR
|
||||
|
||||
class Xr_Vector3D
|
||||
{
|
||||
public:
|
||||
Xr_Vector3D();
|
||||
Xr_Vector3D(float, float, float);
|
||||
~Xr_Vector3D();
|
||||
|
||||
void setCoords(float, float, float);
|
||||
void normalize();
|
||||
static float dot(Xr_Vector3D const&, Xr_Vector3D const&);
|
||||
|
||||
float getX() const;
|
||||
float getY() const;
|
||||
float getZ() const;
|
||||
|
||||
Xr_Vector3D& operator=(Xr_Vector3D const&);
|
||||
Xr_Vector3D& operator+=(Xr_Vector3D const&);
|
||||
Xr_Vector3D& operator-=(Xr_Vector3D const&);
|
||||
Xr_Vector3D operator+(Xr_Vector3D const&) const;
|
||||
Xr_Vector3D operator-(Xr_Vector3D const&) const;
|
||||
Xr_Vector3D operator-() const;
|
||||
Xr_Vector3D operator*(Xr_Vector3D const&) const;
|
||||
Xr_Vector3D operator*(float) const;
|
||||
float operator[](unsigned int) const;
|
||||
|
||||
private:
|
||||
float xCoord;
|
||||
float yCoord;
|
||||
float zCoord;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user