From 50789dee611da6db0ec36197053a8483ebd83d06 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 13 May 2011 15:05:25 -0400 Subject: [PATCH] add guMatrix3x3 and guMatrix4x4To3x3() --- glslUtil/glslUtil.c | 9 +++++++++ glslUtil/glslUtil.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/glslUtil/glslUtil.c b/glslUtil/glslUtil.c index bfc948f..8c925f5 100644 --- a/glslUtil/glslUtil.c +++ b/glslUtil/glslUtil.c @@ -190,6 +190,15 @@ void guMatrixOrtho(guMatrix4x4 *m, guMatrixMult(m, m, &mult); } +void guMatrix4x4To3x3(guMatrix3x3 *out, const guMatrix4x4 *in) +{ + int i; + for (i = 0; i < 3; i++) + { + memcpy(&(*out)[i], &(*in)[i], sizeof((*out)[0][0] * 3)); + } +} + char *guGetShaderLog(GLuint id) { GLint log_length; diff --git a/glslUtil/glslUtil.h b/glslUtil/glslUtil.h index e9d5292..a1d2b21 100644 --- a/glslUtil/glslUtil.h +++ b/glslUtil/glslUtil.h @@ -8,6 +8,7 @@ #include #endif +typedef GLfloat guMatrix3x3[3][3]; typedef GLfloat guMatrix4x4[4][4]; typedef struct { GLuint index; @@ -35,6 +36,8 @@ void guMatrixOrtho(guMatrix4x4 *m, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far); +void guMatrix4x4To3x3(guMatrix3x3 *out, const guMatrix4x4 *in); + char *guGetShaderLog(GLuint id); char *guGetProgramLog(GLuint id); GLuint guMakeShaderFromFile(GLenum shaderType, const char *fname);