erebus

annotate src/opengl.cc @ 2:474a0244f57d

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