Horizon
gl_util.hpp
1 #include <epoxy/gl.h>
2 #include <string>
3 
4 namespace horizon {
5 // GLuint gl_create_shader (int type, char *src);
6 GLuint gl_create_program_from_resource(const char *vertex_resource, const char *fragment_resource,
7  const char *geometry_resource);
8 
9 void gl_show_error(const std::string &s);
10 void gl_color_to_uniform_3f(GLuint loc, const class Color &c);
11 void gl_color_to_uniform_4f(GLuint loc, const class Color &c, float alpha = 1);
12 
13 #define GET_LOC(d, loc) \
14  do { \
15  d->loc##_loc = glGetUniformLocation(d->program, #loc); \
16  } while (0);
17 
18 #define GET_LOC2(d, loc) \
19  do { \
20  (d).loc##_loc = glGetUniformLocation((d).program, #loc); \
21  } while (0);
22 
23 #define GL_CHECK_ERROR \
24  if (int e = glGetError()) { \
25  std::stringstream ss; \
26  ss << "gl error " << e << " in " << __FILE__ << ":" << __LINE__; \
27  gl_show_error(ss.str()); \
28  abort(); \
29  }
30 } // namespace horizon
Definition: block.cpp:9