vrchess

view src/opengl.cc @ 12:778ed91cb7fd

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