dungeon_crawler

view prototype/src/opengl.cc @ 18:5c41e6fcb300

- commandline arguments - stereoscopic rendering - FBO fixed
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Aug 2012 03:17:48 +0300
parents 8fb37db44fd8
children
line source
1 #include "opengl.h"
2 #include "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 }