erebus
diff src/opengl.cc @ 0:4abdce1361b9
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 27 Apr 2014 16:02:47 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/opengl.cc Sun Apr 27 16:02:47 2014 +0300 1.3 @@ -0,0 +1,63 @@ 1.4 +#include "opengl.h" 1.5 +#include <vmath/vmath.h> 1.6 + 1.7 + 1.8 + 1.9 +void load_matrix(const Matrix4x4 &m) 1.10 +{ 1.11 +#ifdef SINGLE_PRECISION_MATH 1.12 + if(glLoadTransposeMatrixfARB) { 1.13 + glLoadTransposeMatrixfARB((float*)&m); 1.14 + } else { 1.15 + Matrix4x4 tmat = m.transposed(); 1.16 + glLoadMatrixf((float*)&tmat); 1.17 + } 1.18 +#else 1.19 + if(glLoadTransposeMatrixdARB) { 1.20 + glLoadTransposeMatrixdARB((double*)&m); 1.21 + } else { 1.22 + Matrix4x4 tmat = m.transposed(); 1.23 + glLoadMatrixd((double*)&tmat); 1.24 + } 1.25 +#endif 1.26 +} 1.27 + 1.28 +void mult_matrix(const Matrix4x4 &m) 1.29 +{ 1.30 +#ifdef SINGLE_PRECISION_MATH 1.31 + if(glMultTransposeMatrixfARB) { 1.32 + glMultTransposeMatrixfARB((float*)&m); 1.33 + } else { 1.34 + Matrix4x4 tmat = m.transposed(); 1.35 + glMultMatrixf((float*)&tmat); 1.36 + } 1.37 +#else 1.38 + if(glMultTransposeMatrixdARB) { 1.39 + glMultTransposeMatrixdARB((double*)&m); 1.40 + } else { 1.41 + Matrix4x4 tmat = m.transposed(); 1.42 + glMultMatrixd((double*)&tmat); 1.43 + } 1.44 +#endif 1.45 +} 1.46 + 1.47 +const char *strglerr(int err) 1.48 +{ 1.49 + static const char *errnames[] = { 1.50 + "GL_INVALID_ENUM", 1.51 + "GL_INVALID_VALUE", 1.52 + "GL_INVALID_OPERATION", 1.53 + "GL_STACK_OVERFLOW", 1.54 + "GL_STACK_UNDERFLOW", 1.55 + "GL_OUT_OF_MEMORY", 1.56 + "GL_INVALID_FRAMEBUFFER_OPERATION" 1.57 + }; 1.58 + 1.59 + if(!err) { 1.60 + return "GL_NO_ERROR"; 1.61 + } 1.62 + if(err < GL_INVALID_ENUM || err > GL_OUT_OF_MEMORY) { 1.63 + return "<invalid gl error>"; 1.64 + } 1.65 + return errnames[err - GL_INVALID_ENUM]; 1.66 +}