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 * [x0 x1 x2]'.
33 void multiply_3x3_matrix_float3(const Matrix3x3 M, float x0, float x1, float x2, float *y0, float *y1, float *y2);
35 // Compute m^-1. Result is undefined if the matrix is singular or near-singular.
36 void invert_3x3_matrix(const Matrix3x3 m, Matrix3x3 result);
38 // Print a 3x3 matrix to standard output. Useful for debugging.
39 void print_3x3_matrix(const Matrix3x3 m);
44 #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); } }
47 #endif // !defined(_UTIL_H)