Horizon
Loading...
Searching...
No Matches
gl_util.hpp
1#include "util/gl_inc.h"
2#include <string>
3#include <sstream>
4#include <array>
5#include <glm/fwd.hpp>
6
7namespace horizon {
8// GLuint gl_create_shader (int type, char *src);
9GLuint gl_create_program_from_resource(const char *vertex_resource, const char *fragment_resource,
10 const char *geometry_resource);
11
12void gl_show_error(const std::string &s);
13void gl_color_to_uniform_3f(GLuint loc, const class Color &c);
14void gl_color_to_uniform_4f(GLuint loc, const class Color &c, float alpha = 1);
15GLint gl_clamp_samples(GLint samples);
16
17void gl_mat3_to_array(std::array<float, 12> &dest, const glm::mat3 &src);
18std::array<float, 4> gl_array_from_color(const Color &c);
19
20#define GET_LOC(d, loc) \
21 do { \
22 d->loc##_loc = glGetUniformLocation(d->program, #loc); \
23 } while (0);
24
25#define GET_LOC2(d, loc) \
26 do { \
27 (d).loc##_loc = glGetUniformLocation((d).program, #loc); \
28 } while (0);
29
30#define GL_CHECK_ERROR \
31 if (int e = glGetError()) { \
32 std::stringstream ss; \
33 ss << "gl error " << e << " in " << __FILE__ << ":" << __LINE__; \
34 gl_show_error(ss.str()); \
35 abort(); \
36 }
37} // namespace horizon
Definition common.hpp:278