-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper_glfw.h
More file actions
56 lines (43 loc) · 1.38 KB
/
wrapper_glfw.h
File metadata and controls
56 lines (43 loc) · 1.38 KB
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
/**
wrapper_glfw.h
Modified from the OpenGL GLFW example to provide a wrapper GLFW class
Iain Martin August 2014
*/
#pragma once
#include <string>
/* Inlcude GL_Load and GLFW */
#include <glload/gl_4_0.h>
#include <glload/gl_load.h>
#include <GLFW/glfw3.h>
class GLWrapper {
private:
int width;
int height;
char *title;
double fps;
void(*error_callback)(int error, const char* description);
void(*renderer)();
void(*reshape)(GLFWwindow* window, int w, int h);
void(*keyCallBack)(GLFWwindow* window, int key, int scancode, int action, int mods);
bool running;
GLFWwindow* window;
public:
GLWrapper(int width, int height, char *title);
~GLWrapper();
void setFPS(double fps) {
this->fps = fps;
}
void displayVersion();
/* Callback registering functions */
void setRenderer(void(*f)());
void setReshapeCallback(void(*f)(GLFWwindow* window, int w, int h));
void setKeyCallback(void(*f)(GLFWwindow* window, int key, int scancode, int action, int mods));
void setErrorCallback(void(*f)(int error, const char* description));
/* Shader load and build support functions */
GLuint LoadShader(const char *vertex_path, const char *fragment_path);
GLuint BuildShader(GLenum eShaderType, const std::string &shaderText);
GLuint BuildShaderProgram(std::string vertShaderStr, std::string fragShaderStr);
std::string readFile(const char *filePath);
int eventLoop();
GLFWwindow* getWindow();
};