erebus

view src/opengl.cc @ 48:9971a08f4104

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 24 Feb 2016 00:29:31 +0200
parents
children
line source
1 #include "opengl.h"
2 #include <vmath/vmath.h>
6 void load_matrix(const Matrix4x4 &m)
7 {
8 #ifdef SINGLE_PRECISION_MATH
9 if(glLoadTransposeMatrixfARB) {
10 glLoadTransposeMatrixfARB((float*)&m);
11 } else {
12 Matrix4x4 tmat = m.transposed();
13 glLoadMatrixf((float*)&tmat);
14 }
15 #else
16 if(glLoadTransposeMatrixdARB) {
17 glLoadTransposeMatrixdARB((double*)&m);
18 } else {
19 Matrix4x4 tmat = m.transposed();
20 glLoadMatrixd((double*)&tmat);
21 }
22 #endif
23 }
25 void mult_matrix(const Matrix4x4 &m)
26 {
27 #ifdef SINGLE_PRECISION_MATH
28 if(glMultTransposeMatrixfARB) {
29 glMultTransposeMatrixfARB((float*)&m);
30 } else {
31 Matrix4x4 tmat = m.transposed();
32 glMultMatrixf((float*)&tmat);
33 }
34 #else
35 if(glMultTransposeMatrixdARB) {
36 glMultTransposeMatrixdARB((double*)&m);
37 } else {
38 Matrix4x4 tmat = m.transposed();
39 glMultMatrixd((double*)&tmat);
40 }
41 #endif
42 }
44 const char *strglerr(int err)
45 {
46 static const char *errnames[] = {
47 "GL_INVALID_ENUM",
48 "GL_INVALID_VALUE",
49 "GL_INVALID_OPERATION",
50 "GL_STACK_OVERFLOW",
51 "GL_STACK_UNDERFLOW",
52 "GL_OUT_OF_MEMORY",
53 "GL_INVALID_FRAMEBUFFER_OPERATION"
54 };
56 if(!err) {
57 return "GL_NO_ERROR";
58 }
59 if(err < GL_INVALID_ENUM || err > GL_OUT_OF_MEMORY) {
60 return "<invalid gl error>";
61 }
62 return errnames[err - GL_INVALID_ENUM];
63 }