Saxum/game/graphics.hh

103 lines
3.5 KiB
C++
Raw Normal View History

2014-10-20 16:23:25 +00:00
#ifndef GRAPHICS_HH_INCLUDED
#define GRAPHICS_HH_INCLUDED
#include <ACGL/OpenGL/GL.hh>
2014-10-20 16:23:25 +00:00
#include <GLFW/glfw3.h>
2014-10-20 16:49:10 +00:00
#include <ACGL/Math/Math.hh>
#include <ACGL/OpenGL/Objects/FrameBufferObject.hh>
#include "level.hh"
2015-03-13 14:30:21 +00:00
#include "debugDraw.hh"
using namespace ACGL::OpenGL;
struct ShadowRenderQueueSlot{
shared_ptr<Light> light;
int priority;
int currentPriority;
};
class Graphics {
public:
Graphics(glm::uvec2 windowSize, float nearPlane, float farPlane, int cube_size,
unsigned int maxShadowRenderCount, std::string screenPath,
std::string screenContinuePath);
Graphics();
void init(Level* level);
void render(double time);
glm::mat4 buildViewMatrix(Level* level);
glm::uvec2 getWindowSize();
void resize(glm::uvec2 windowSize);
float getFarPlane();
void startGame();
void renderLoadingScreen();
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);
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);
void saveWindowSize(glm::uvec2 windowSize);
private:
void bindTextureUnits();
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;
glm::uvec2 windowSize;
float nearPlane;
float farPlane;
std::string loadingScreenPath;
std::string loadingScreenContinuePath;
SharedTexture2D loadingScreen;
SharedTexture2D loadingContinueScreen;
std::vector<shared_ptr<Light>>* closestLights;
std::vector<Flame*> closestFlames;
SharedShaderProgram loadingShader;
SharedShaderProgram lightingShader;
2015-03-04 15:08:03 +00:00
SharedShaderProgram skydomeShader;
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;
SharedFrameBufferObject framebuffer_light;
SharedTexture2D light_fbo_color_texture;
SharedTexture2D light_fbo_depth_texture;
SharedVertexArrayObject fullscreen_quad;
SharedArrayBuffer fullscreen_quad_ab;
SharedVertexArrayObject fullscreen_quad_loading;
SharedArrayBuffer fullscreen_quad_ab_loading;
int cube_size;
unsigned int maxShadowRenderCount;
Level* level;
int number_of_texture_units = 0;
bool gameStart;
2015-03-09 12:41:34 +00:00
float loadingScreenWidth;
float loadingScreenHeight;
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;
std::vector<ShadowRenderQueueSlot> shadowRenderQueue;
void initShadowRenderQueue();
};
2014-10-20 16:49:10 +00:00
#endif