#pragma once #include #include "shaders.hpp" #include #include #include "glm/gtc/matrix_transform.hpp" using namespace std::chrono; /** * Bind this fonction with the following for debugging: * glEnable ( GL_DEBUG_OUTPUT ); * glDebugMessageCallback( MessageCallback, 0 ); * @param source * @param type * @param id * @param severity * @param length * @param message * @param userParam */ void GLAPIENTRY MessageCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); /** * Main renderer class */ class Renderer { private: GLuint VAO; GLuint RayMarchingShader; GLuint UProjection; GLuint UResolution; GLuint UModel; GLuint UTime; glm::mat4 MProjection; glm::mat4 MModel; short Width,Height; steady_clock::time_point ClockStart; steady_clock::time_point ClockCurrent; /// @brief Current loaded shader name std::string CurrentShader; /** * Compile send CurrentShader to the graphics card */ void LoadShader(); public: Renderer(short width,short height,std::string shader_name); ~Renderer(); /** * Draw current shader into the screen */ void Render(); /** * Change current OpenGL viewport. * @param with * @param height */ void AjustViewport(short with,short height); /** * Compile and load another shader * @param name The name of the new shader */ void ChangeShader(std::string name); /** * Refresh CurrentShader code (recompile it etc..) */ void RefreshShader(); };