#ifndef GRAPHICS_HH_INCLUDED #define GRAPHICS_HH_INCLUDED #include #include #include #include #include "level.hh" #include "debugDraw.hh" using namespace ACGL::OpenGL; struct ShadowRenderQueueSlot{ shared_ptr 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); void setRenderDebug(bool state); void setRenderWorld(bool state); bool getRenderShadows(); bool getRenderFlames(); bool getRenderDebug(); bool getRenderWorld(); void enqueueObjects(std::vector>* queue); void saveWindowSize(glm::uvec2 windowSize); private: void bindTextureUnits(); void updateLights(); void saveDepthBufferToDisk(int face, std::string); 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>* closestLights; std::vector closestFlames; SharedShaderProgram loadingShader; SharedShaderProgram lightingShader; SharedShaderProgram skydomeShader; SharedShaderProgram depthCubeShader; SharedShaderProgram depthShader; SharedShaderProgram flameShader; SharedShaderProgram flamePostShader; std::vector depth_directionalMaps; std::vector framebuffer_directional; std::vector 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; float loadingScreenWidth; float loadingScreenHeight; bool renderShadows; bool renderFlames; bool renderDebug; bool renderWorld; DebugDraw debugDrawer; SharedArrayBuffer debug_ab; SharedVertexArrayObject debug_vao; SharedShaderProgram debugShader; std::vector>*> renderQueue; std::vector shadowRenderQueue; void initShadowRenderQueue(); }; #endif