aboutsummaryrefslogtreecommitdiff
path: root/src/opengl/renderer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/renderer.hpp')
-rw-r--r--src/opengl/renderer.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/opengl/renderer.hpp b/src/opengl/renderer.hpp
new file mode 100644
index 0000000..157ceb3
--- /dev/null
+++ b/src/opengl/renderer.hpp
@@ -0,0 +1,54 @@
+#pragma once
+#include <GL/glew.h>
+#include "shaders.hpp"
+#include <glm/glm.hpp>
+#include <chrono>
+#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;
+
+ void LoadShader(std::string name);
+
+public:
+ Renderer(short width,short height);
+ void Render();
+ void AjustViewport(short with,short height);
+ void UpdateShader(std::string name);
+};