blob: 35650ec5dccc3ea99cafcaf2396040681e2280e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#pragma once
#include "shaders.hpp"
#include <glm/glm.hpp>
#include <chrono>
#include "glm/gtc/matrix_transform.hpp"
using namespace std::chrono;
struct GLFW_CONTEXT;
/**
* 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();
GLFW_CONTEXT *Context;
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();
void RefreshHUD();
void SetGLFWContext(GLFW_CONTEXT *context){
Context=context;
RefreshHUD();
}
};
|