-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgl_sdl_utils.hpp
67 lines (56 loc) · 1.57 KB
/
gl_sdl_utils.hpp
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
#ifndef GL_SDL_UTILS_H
#define GL_SDL_UTILS_H
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_image.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
#endif
#include <SDL_opengl.h>
#define GLM_FORCE_PURE
#ifndef __EMSCRIPTEN__
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/quaternion.hpp>
#else
#include <glm.hpp>
#include <gtc/type_ptr.hpp>
#include <gtc/matrix_transform.hpp>
#include <gtx/transform.hpp>
#include <gtc/quaternion.hpp>
#endif
#include <iostream>
#include <vector>
#include <string>
/* OpenGL error handling */
void printShaderLog(GLuint shader);
void printProgramLog(int prog);
bool checkOpenGLError();
GLuint read_shader(std::string shader_path, unsigned int flags);
GLuint read_shader(const char *shader_src, unsigned int flags);
GLuint create_program(std::vector<GLuint> shaders);
GLuint create_program(const GLuint *shaders, uint num_shaders);
/* Those are in bits */
struct channel_sizes
{
int red = 8;
int green = 8;
int blue = 8;
int depth = 24;
int stencil = 8;
};
struct minimal_context_cfg
{
channel_sizes sizes;
bool use_double_buffer = true;
};
SDL_GLContext create_context(SDL_Window *window);
SDL_GLContext create_context(SDL_Window *window, minimal_context_cfg *cfg);
/* Loading opengl textures with SDL_image */
GLuint load_tex(std::string path);
GLuint load_cubemap(std::vector<std::string> file_paths);
glm::quat quat_from_axis_angle(glm::vec3 axis, float angle);
#endif /* OPENGL_SDL_UTILS_H */