13 #define BUFFER_OFFSET(i) ((char *)NULL + (i))
15 // Converts a HSV color to RGB. Assumes h in [0, 2pi> or [-pi, pi>
16 void hsv2rgb(float h, float s, float v, float *r, float *g, float *b);
18 // Column major (same as OpenGL).
19 typedef double Matrix3x3[9];
21 // Read a file from disk and return its contents.
22 // Dies if the file does not exist.
23 std::string read_file(const std::string &filename);
25 // Compile the given GLSL shader (typically a vertex or fragment shader)
26 // and return the object number.
27 GLuint compile_shader(const std::string &shader_src, GLenum type);
30 void multiply_3x3_matrices(const Matrix3x3 a, const Matrix3x3 b, Matrix3x3 result);
32 // Compute m^-1. Result is undefined if the matrix is singular or near-singular.
33 void invert_3x3_matrix(const Matrix3x3 m, Matrix3x3 result);
35 // Print a 3x3 matrix to standard output. Useful for debugging.
36 void print_3x3_matrix(const Matrix3x3 m);
41 #define check_error() { int err = glGetError(); if (err != GL_NO_ERROR) { printf("GL error 0x%x at %s:%d\n", err, __FILE__, __LINE__); exit(1); } }
44 #endif // !defined(_UTIL_H)