dungeon_crawler

annotate prototype/src/opengl.cc @ 64:0b130c6e534d

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