2014-10-20 16:23:25 +00:00
|
|
|
#ifndef GRAPHICS_HH_INCLUDED
|
|
|
|
#define GRAPHICS_HH_INCLUDED
|
2014-11-14 15:47:47 +00:00
|
|
|
#include <ACGL/OpenGL/GL.hh>
|
2014-10-20 16:23:25 +00:00
|
|
|
|
2014-11-14 15:47:47 +00:00
|
|
|
#include <GLFW/glfw3.h>
|
2014-10-20 16:49:10 +00:00
|
|
|
#include <ACGL/Math/Math.hh>
|
2014-12-04 00:13:59 +00:00
|
|
|
#include <ACGL/OpenGL/Objects/FrameBufferObject.hh>
|
|
|
|
|
2014-11-14 15:47:47 +00:00
|
|
|
#include "level.hh"
|
2015-03-13 14:30:21 +00:00
|
|
|
#include "debugDraw.hh"
|
2014-11-14 15:47:47 +00:00
|
|
|
|
2015-03-03 22:27:41 +00:00
|
|
|
using namespace ACGL::OpenGL;
|
|
|
|
|
2015-06-01 08:47:26 +00:00
|
|
|
struct ShadowRenderQueueSlot{
|
|
|
|
shared_ptr<Light> light;
|
|
|
|
int priority;
|
|
|
|
int currentPriority;
|
|
|
|
};
|
|
|
|
|
2014-11-14 15:47:47 +00:00
|
|
|
class Graphics {
|
|
|
|
public:
|
2015-03-07 18:59:52 +00:00
|
|
|
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size,
|
|
|
|
unsigned int maxShadowRenderCount, std::string screenPath,
|
|
|
|
std::string screenContinuePath);
|
2014-11-14 15:47:47 +00:00
|
|
|
Graphics();
|
2014-12-15 00:05:46 +00:00
|
|
|
void init(Level* level);
|
2015-01-25 23:06:31 +00:00
|
|
|
void render(double time);
|
2014-11-14 15:47:47 +00:00
|
|
|
glm::mat4 buildViewMatrix(Level* level);
|
|
|
|
glm::uvec2 getWindowSize();
|
2014-12-04 00:13:59 +00:00
|
|
|
void resize(glm::uvec2 windowSize);
|
2014-11-21 01:38:03 +00:00
|
|
|
float getFarPlane();
|
2015-03-07 18:59:52 +00:00
|
|
|
void startGame();
|
|
|
|
void renderLoadingScreen();
|
2015-03-12 18:24:10 +00:00
|
|
|
void setRenderShadows(bool state);
|
|
|
|
void setRenderFlames(bool state);
|
2015-03-13 14:30:21 +00:00
|
|
|
void setRenderDebug(bool state);
|
2015-03-13 14:43:10 +00:00
|
|
|
void setRenderWorld(bool state);
|
2015-03-12 18:24:10 +00:00
|
|
|
bool getRenderShadows();
|
|
|
|
bool getRenderFlames();
|
2015-03-13 14:30:21 +00:00
|
|
|
bool getRenderDebug();
|
2015-03-13 14:43:10 +00:00
|
|
|
bool getRenderWorld();
|
2015-03-21 14:05:22 +00:00
|
|
|
void enqueueObjects(std::vector<std::vector<Object*>>* queue);
|
2015-05-16 11:54:01 +00:00
|
|
|
void saveWindowSize(glm::uvec2 windowSize);
|
2014-11-14 15:47:47 +00:00
|
|
|
private:
|
2015-03-07 18:59:52 +00:00
|
|
|
void bindTextureUnits();
|
2015-02-24 22:30:59 +00:00
|
|
|
void updateLights();
|
2015-01-27 10:14:00 +00:00
|
|
|
void saveDepthBufferToDisk(int face, std::string);
|
2015-03-09 13:14:17 +00:00
|
|
|
double lastLightUpdate;
|
|
|
|
double lastWindUpdate;
|
|
|
|
float windTarget;
|
|
|
|
glm::vec2 wind;
|
|
|
|
glm::vec2 windDirection;
|
|
|
|
glm::vec2 windDirectionTarget;
|
|
|
|
glm::vec2 textureMovementPosition;
|
2014-11-14 15:47:47 +00:00
|
|
|
glm::uvec2 windowSize;
|
|
|
|
float nearPlane;
|
|
|
|
float farPlane;
|
2015-03-07 18:59:52 +00:00
|
|
|
std::string loadingScreenPath;
|
|
|
|
std::string loadingScreenContinuePath;
|
|
|
|
SharedTexture2D loadingScreen;
|
|
|
|
SharedTexture2D loadingContinueScreen;
|
2015-05-31 19:17:46 +00:00
|
|
|
std::vector<shared_ptr<Light>>* closestLights;
|
2015-03-07 21:48:44 +00:00
|
|
|
std::vector<Flame*> closestFlames;
|
2015-03-07 18:59:52 +00:00
|
|
|
SharedShaderProgram loadingShader;
|
2015-03-03 22:27:41 +00:00
|
|
|
SharedShaderProgram lightingShader;
|
2015-03-04 15:08:03 +00:00
|
|
|
SharedShaderProgram skydomeShader;
|
2015-03-03 22:27:41 +00:00
|
|
|
SharedShaderProgram depthCubeShader;
|
|
|
|
SharedShaderProgram depthShader;
|
|
|
|
SharedShaderProgram flameShader;
|
|
|
|
SharedShaderProgram flamePostShader;
|
|
|
|
std::vector<SharedTexture2D> depth_directionalMaps;
|
|
|
|
std::vector<SharedFrameBufferObject> framebuffer_directional;
|
|
|
|
std::vector<SharedTextureCubeMap> depth_cubeMaps;
|
|
|
|
SharedFrameBufferObject framebuffer_cube;
|
2015-03-03 23:55:01 +00:00
|
|
|
SharedFrameBufferObject framebuffer_light;
|
|
|
|
SharedTexture2D light_fbo_color_texture;
|
|
|
|
SharedTexture2D light_fbo_depth_texture;
|
2015-03-03 22:27:41 +00:00
|
|
|
SharedVertexArrayObject fullscreen_quad;
|
|
|
|
SharedArrayBuffer fullscreen_quad_ab;
|
2015-03-08 16:05:52 +00:00
|
|
|
SharedVertexArrayObject fullscreen_quad_loading;
|
|
|
|
SharedArrayBuffer fullscreen_quad_ab_loading;
|
2015-02-07 19:24:11 +00:00
|
|
|
int cube_size;
|
2015-02-13 15:20:22 +00:00
|
|
|
unsigned int maxShadowRenderCount;
|
2014-12-15 00:05:46 +00:00
|
|
|
Level* level;
|
2015-02-09 13:26:04 +00:00
|
|
|
int number_of_texture_units = 0;
|
2015-03-07 18:59:52 +00:00
|
|
|
bool gameStart;
|
2015-03-09 12:41:34 +00:00
|
|
|
float loadingScreenWidth;
|
|
|
|
float loadingScreenHeight;
|
2015-03-12 18:24:10 +00:00
|
|
|
bool renderShadows;
|
|
|
|
bool renderFlames;
|
2015-03-13 14:30:21 +00:00
|
|
|
bool renderDebug;
|
2015-03-13 14:43:10 +00:00
|
|
|
bool renderWorld;
|
2015-03-13 14:30:21 +00:00
|
|
|
DebugDraw debugDrawer;
|
|
|
|
SharedArrayBuffer debug_ab;
|
|
|
|
SharedVertexArrayObject debug_vao;
|
|
|
|
SharedShaderProgram debugShader;
|
2015-03-21 14:05:22 +00:00
|
|
|
std::vector<std::vector<std::vector<Object*>>*> renderQueue;
|
2015-06-01 08:47:26 +00:00
|
|
|
std::vector<ShadowRenderQueueSlot> shadowRenderQueue;
|
|
|
|
void initShadowRenderQueue();
|
2014-11-14 15:47:47 +00:00
|
|
|
};
|
|
|
|
|
2014-10-20 16:49:10 +00:00
|
|
|
#endif
|