conworlds

annotate src/opengl.cc @ 16:7a2041ddb7e7

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