summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-04-17 22:34:22 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-04-17 22:34:22 -0700
commit28f63394f9057de75de670ca16ab9802ae7d5d38 (patch)
tree6d0550c9993d3837271ce5c274838a5b8084d81e
Initial commit
-rw-r--r--Makefile.am24
-rwxr-xr-xautogen.sh12
-rw-r--r--configure.ac67
-rw-r--r--include/glu3.h141
-rw-r--r--include/glu3_scalar.h298
-rw-r--r--src/Makefile.am25
-rw-r--r--src/matrix.c119
-rw-r--r--src/matrix.obin0 -> 4920 bytes
8 files changed, 686 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..51d21bb
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,24 @@
+# Copyright © 2009 Ian D. Romanick
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+# USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AUTOMAKE_OPTIONS = foreign
+SUBDIRS = src
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..904cd67
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..009a98f
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,67 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT(GLU3, 20090417, idr@freedesktop.org, GLU3)
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_CONFIG_HEADER([config.h])
+
+AM_INIT_AUTOMAKE
+
+AM_MAINTAINER_MODE
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_HEADER_STDC
+
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug],
+ [use debug compiler flags and macros @<:@default=disabled@:>@])],
+ [enable_debug="$enableval"],
+ [enable_debug=no]
+)
+if test "x$enable_debug" = xyes; then
+ DEFINES="$DEFINES -DDEBUG"
+ if test "x$GCC" = xyes; then
+ CFLAGS="$CFLAGS -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2"
+ fi
+ if test "x$GXX" = xyes; then
+ CXXFLAGS="$CXXFLAGS -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2"
+ fi
+fi
+
+
+if test "x$GCC" = xyes ; then
+ WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector"
+else
+ WARN=""
+fi
+CFLAGS="$CFLAGS $WARN"
+
+if test "x$GXX" = xyes ; then
+ WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector"
+else
+ WARN=""
+fi
+CXXFLAGS="$CXXFLAGS $WARN"
+
+AC_OUTPUT([Makefile
+ src/Makefile])
+
diff --git a/include/glu3.h b/include/glu3.h
new file mode 100644
index 0000000..8130b3e
--- /dev/null
+++ b/include/glu3.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2009 Ian D. Romanick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __glu3_h__
+#define __glu3_h__
+
+#include <GL/gl.h>
+
+#define GLU_VERSION_3_0
+
+struct GLUvec4 {
+ GLfloat values[4];
+
+#ifdef __cplusplus
+ inline GLUvec4(GLfloat x , GLfloat y, GLfloat z, GLfloat w)
+ {
+ values[0] = x;
+ values[1] = y;
+ values[2] = z;
+ values[3] = w;
+ }
+
+ GLUvec4 operator *(const GLUmat4 &) const;
+ GLUvec4 operator *(const GLUvec4 &) const;
+ GLUvec4 operator *(GLfloat) const;
+
+ GLUvec4 operator +(const GLUvec4 &) const;
+ GLUvec4 operator -(const GLUvec4 &) const;
+#endif /* __cplusplus */
+};
+
+
+struct GLUmat4 {
+ struct GLUvec4 col[4];
+
+#ifdef __cplusplus
+ inline GLUmat4(const GLUvec4 & c0, const GLUvec4 & c1,
+ const GLUvec4 & c2, const GLUvec4 & c3)
+ {
+ col[0] = c0;
+ col[1] = c1;
+ col[2] = c2;
+ col[3] = c3;
+ }
+
+ GLUvec4 operator *(const GLUvec4 &) const;
+ GLUmat4 operator *(const GLUmat4 &) const;
+ GLUmat4 operator *(GLfloat) const;
+
+ GLUmat4 operator *(const GLUmat4 &) const;
+ GLUmat4 operator -(const GLUmat4 &) const;
+#endif /* __cplusplus */
+};
+
+#define GLU_MAX_STACK_DEPTH 32
+
+struct GLUmat4Stack {
+ struct GLUmat4 stack[GLU_MAX_STACK_DEPTH];
+ unsigned top;
+
+#ifdef __cplusplus
+ GLUmat4Stack() : top(0)
+ {
+ /* empty */
+ }
+#endif /* __cplusplus */
+};
+
+#ifndef __cplusplus
+typedef struct GLUvec4 GLUvec4;
+typedef struct GLUmat4 GLUmat4;
+typedef struct GLUmat4Stack GLUmat4Stack;
+#endif /* __cplusplus */
+
+
+GLfloat gluDot4_4v(const GLUvec4 *, const GLUvec4 *);
+GLfloat gluDot3_4v(const GLUvec4 *, const GLUvec4 *);
+GLfloat gluDot2_4v(const GLUvec4 *, const GLUvec4 *);
+
+#ifdef __cplusplus
+GLfloat gluDot4(const GLUvec4 &, const GLUvec4 &);
+GLfloat gluDot3(const GLUvec4 &, const GLUvec4 &);
+GLfloat gluDot2(const GLUvec4 &, const GLUvec4 &);
+#endif
+
+GLUvec4 gluCross4v(const GLUvec4 *, const GLUvec4 *);
+GLUvec4 gluNormalize4v(const GLUvec4 *);
+GLfloat gluLength4v(const GLUvec4 *);
+GLfloat gluLengthSqr4v(const GLUvec4 *);
+GLUmat4 gluOuter4v(const GLUvec4 *, const GLUvec4 *);
+
+#ifdef __cplusplus
+GLUvec4 gluCross(const GLUvec4 &, const GLUvec4 &);
+GLUvec4 gluNormalize(const GLUvec4 &);
+GLfloat gluLength(const GLUvec4 &);
+GLfloat gluLengthSqr(const GLUvec4 &);
+#endif /* __cplusplus */
+
+GLUvec4 gluMult4v_4v(const GLUvec4 *, const GLUvec4 *);
+GLUvec4 gluDiv4v_4v(const GLUvec4 *, const GLUvec4 *);
+GLUvec4 gluAdd4v_4v(const GLUvec4 *, const GLUvec4 *);
+GLUvec4 gluSub4v_4v(const GLUvec4 *, const GLUvec4 *);
+
+GLUvec4 gluMult4v_f(const GLUvec4 *, GLfloat);
+GLUvec4 gluDiv4v_f(const GLUvec4 *, GLfloat);
+GLUvec4 gluAdd4v_f(const GLUvec4 *, GLfloat);
+GLUvec4 gluSub4v_f(const GLUvec4 *, GLfloat);
+
+GLUmat4 gluMult4m_4m(const GLUmat4 *, const GLUmat4 *);
+GLUmat4 gluAdd4m_4m(const GLUmat4 *, const GLUmat4 *);
+GLUmat4 gluSub4m_4m(const GLUmat4 *, const GLUmat4 *);
+
+GLUmat4 gluMult4m_f(const GLUmat4 *, GLfloat);
+
+GLUmat4 gluScale4v(const GLUvec4 *);
+GLUmat4 gluTranslate4v(const GLUvec4 *);
+GLUmat4 gluLookAt(const GLUvec4 *, const GLUvec4 *, const GLUvec4 *);
+
+#include "glu3_scalar.h"
+
+#endif /* __glu3_h__ */
diff --git a/include/glu3_scalar.h b/include/glu3_scalar.h
new file mode 100644
index 0000000..020952a
--- /dev/null
+++ b/include/glu3_scalar.h
@@ -0,0 +1,298 @@
+#include <math.h>
+
+extern inline GLUvec4 gluMult4v_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] * v2->values[0];
+ result.values[1] = v1->values[1] * v2->values[1];
+ result.values[2] = v1->values[2] * v2->values[2];
+ result.values[3] = v1->values[3] * v2->values[3];
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluDiv4v_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] / v2->values[0];
+ result.values[1] = v1->values[1] / v2->values[1];
+ result.values[2] = v1->values[2] / v2->values[2];
+ result.values[3] = v1->values[3] / v2->values[3];
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluAdd4v_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] + v2->values[0];
+ result.values[1] = v1->values[1] + v2->values[1];
+ result.values[2] = v1->values[2] + v2->values[2];
+ result.values[3] = v1->values[3] + v2->values[3];
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluSub4v_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] - v2->values[0];
+ result.values[1] = v1->values[1] - v2->values[1];
+ result.values[2] = v1->values[2] - v2->values[2];
+ result.values[3] = v1->values[3] - v2->values[3];
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluMult4v_f(const GLUvec4 *v1, GLfloat f)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] * f;
+ result.values[1] = v1->values[1] * f;
+ result.values[2] = v1->values[2] * f;
+ result.values[3] = v1->values[3] * f;
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluDiv4v_f(const GLUvec4 *v1, GLfloat f)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] / f;
+ result.values[1] = v1->values[1] / f;
+ result.values[2] = v1->values[2] / f;
+ result.values[3] = v1->values[3] / f;
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluAdd4v_f(const GLUvec4 *v1, GLfloat f)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] + f;
+ result.values[1] = v1->values[1] + f;
+ result.values[2] = v1->values[2] + f;
+ result.values[3] = v1->values[3] + f;
+
+ return result;
+}
+
+
+extern inline GLUvec4 gluSub4v_f(const GLUvec4 *v1, GLfloat f)
+{
+ GLUvec4 result;
+
+ result.values[0] = v1->values[0] - f;
+ result.values[1] = v1->values[1] - f;
+ result.values[2] = v1->values[2] - f;
+ result.values[3] = v1->values[3] - f;
+
+ return result;
+}
+
+
+extern inline GLfloat gluDot4_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ return v1->values[0] * v2->values[0]
+ + v1->values[1] * v2->values[1]
+ + v1->values[2] * v2->values[2]
+ + v1->values[3] * v2->values[3];
+}
+
+
+extern inline GLfloat gluDot3_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ return v1->values[0] * v2->values[0]
+ + v1->values[1] * v2->values[1]
+ + v1->values[2] * v2->values[2];
+}
+
+
+extern inline GLfloat gluDot2_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ return v1->values[0] * v2->values[0]
+ + v1->values[1] * v2->values[1];
+}
+
+
+extern inline GLUvec4 gluCross4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUvec4 result;
+
+ result.values[0] = (v1->values[1] * v2->values[2])
+ - (v1->values[2] * v2->values[1]);
+ result.values[1] = (v1->values[2] * v2->values[0])
+ - (v1->values[0] * v2->values[2]);
+ result.values[2] = (v1->values[0] * v2->values[1])
+ - (v1->values[1] * v2->values[0]);
+ result.values[3] = 0.0;
+
+ return result;
+}
+
+
+extern inline GLUmat4 gluOuter4v(const GLUvec4 *v1, const GLUvec4 *v2)
+{
+ GLUmat4 result;
+
+ result.col[0] = gluMult4v_f(v1, v2->values[0]);
+ result.col[1] = gluMult4v_f(v1, v2->values[1]);
+ result.col[2] = gluMult4v_f(v1, v2->values[2]);
+ result.col[3] = gluMult4v_f(v1, v2->values[3]);
+
+ return result;
+}
+
+
+extern inline GLfloat gluLengthSqr4v(const GLUvec4 *v)
+{
+ return gluDot4_4v(v, v);
+}
+
+
+extern inline GLfloat gluLength4v(const GLUvec4 *v)
+{
+ return sqrt(gluLengthSqr4v(v));
+}
+
+
+extern inline GLUvec4 gluNormalize4v(const GLUvec4 *v)
+{
+ return gluDiv4v_f(v, gluLength4v(v));
+}
+
+
+
+extern inline GLUmat4 gluTranspose4(const GLUmat4 *m)
+{
+ unsigned i;
+ unsigned j;
+ GLUmat4 result;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ result.col[i].values[j] = m->col[j].values[i];
+ }
+ }
+
+ return result;
+}
+
+
+#ifdef __cplusplus
+extern inline GLfloat gluDot4(const GLUvec4 &v1, const GLUvec4 &v2)
+{
+ return v1.values[0] * v2.values[0]
+ + v1.values[1] * v2.values[1]
+ + v1.values[2] * v2.values[2]
+ + v1.values[3] * v2.values[3];
+}
+
+
+extern inline GLfloat gluDot3(const GLUvec4 &v1, const GLUvec4 &v2)
+{
+ return v1.values[0] * v2.values[0]
+ + v1.values[1] * v2.values[1]
+ + v1.values[2] * v2.values[2];
+}
+
+
+extern inline GLfloat gluDot2(const GLUvec4 &v1, const GLUvec4 &v2)
+{
+ return v1.values[0] * v2.values[0]
+ + v1.values[1] * v2.values[1];
+}
+
+
+inline GLUvec4 GLUvec4::operator+(const GLUvec4 &v) const
+{
+ return GLUvec4(values[0] + v.values[0],
+ values[1] + v.values[1],
+ values[2] + v.values[2],
+ values[3] + v.values[3]);
+}
+
+
+inline GLUvec4 GLUvec4::operator-(const GLUvec4 &v) const
+{
+ return GLUvec4(values[0] - v.values[0],
+ values[1] - v.values[1],
+ values[2] - v.values[2],
+ values[3] - v.values[3]);
+}
+
+
+inline GLUvec4 GLUvec4::operator*(const GLUvec4 &v) const
+{
+ return GLUvec4(values[0] * v.values[0],
+ values[1] * v.values[1],
+ values[2] * v.values[2],
+ values[3] * v.values[3]);
+}
+
+
+inline GLUvec4 GLUvec4::operator*(GLfloat f) const
+{
+ return GLUvec4(values[0] * f,
+ values[1] * f,
+ values[2] * f,
+ values[3] * f);
+}
+
+
+inline GLUvec4 GLUvec4::operator*(const GLUmat4 &m) const
+{
+ return GLUvev4(gluDot4(*this, m.col[0]),
+ gluDot4(*this, m.col[1]),
+ gluDot4(*this, m.col[2]),
+ gluDot4(*this, m.col[3]));
+}
+
+
+inline GLUmat4 GLUmat4::operator+(const GLUmat4 &m) const
+{
+ return GLUmat4(col[0] + m.col[0],
+ col[1] + m.col[1],
+ col[2] + m.col[2],
+ col[3] + m.col[3]);
+}
+
+
+inline GLUmat4 GLUmat4::operator-(const GLUmat4 &m) const
+{
+ return GLUmat4(col[0] - m.col[0],
+ col[1] - m.col[1],
+ col[2] - m.col[2],
+ col[3] - m.col[3]);
+}
+
+
+inline GLUmat4 GLUmat4::operator*(GLfloat f) const
+{
+ return GLUmat4(col[0] * f, col[1] * f, col[2] * f, col[3] * f);
+}
+
+
+inline GLUvec4 GLUmat4::operator*(const GLUvec4 &v) const
+{
+ return (col[0] * v.value[0])
+ + (col[1] * v.value[1])
+ + (col[2] * v.value[2])
+ + (col[3] * v.value[3]);
+}
+
+
+#endif /* __cplusplus */
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..b56ac8c
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,25 @@
+# Copyright © 2009 Ian D. Romanick
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+# USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AM_CXXFLAGS=-I../include
+lib_LIBRARIES = libGLU3.a
+libGLU3_a_SOURCES = matrix.c
diff --git a/src/matrix.c b/src/matrix.c
new file mode 100644
index 0000000..0ddedd8
--- /dev/null
+++ b/src/matrix.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright © 2009 Ian D. Romanick
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include "glu3.h"
+
+static const GLUmat4 identity = {
+ {
+ { { 1.0f, 0.0f, 0.0f, 0.0f } },
+ { { 0.0f, 1.0f, 0.0f, 0.0f } },
+ { { 0.0f, 0.0f, 1.0f, 0.0f } },
+ { { 0.0f, 0.0f, 0.0f, 1.0f } }
+ }
+};
+
+
+GLUmat4 gluTranslate4v(const GLUvec4 *t)
+{
+ GLUmat4 result;
+
+ memcpy(& result, & identity, sizeof(identity));
+ result.col[3] = *t;
+ result.col[3].values[3] = 1.0f;
+
+ return result;
+}
+
+
+GLUmat4 gluScale4v(const GLUvec4 *t)
+{
+ GLUmat4 result;
+
+ memcpy(& result, & identity, sizeof(identity));
+ result.col[0].values[0] = t->values[0];
+ result.col[1].values[1] = t->values[1];
+ result.col[2].values[2] = t->values[2];
+
+ return result;
+}
+
+
+GLUmat4 gluLookAt(const GLUvec4 *eye,
+ const GLUvec4 *center,
+ const GLUvec4 *up)
+{
+ static const GLUvec4 col3 = { { 0.0f, 0.0f, 0.0f, 1.0f } };
+ const GLUvec4 e = {
+ { -eye->values[0], -eye->values[1], -eye->values[2], 0.0f }
+ };
+ const GLUmat4 translate = gluTranslate4v(& e);
+ GLUmat4 rotate;
+ GLUvec4 f;
+ GLUvec4 s;
+ GLUvec4 u;
+
+
+ f = gluSub4v_4v(center, eye);
+ f = gluNormalize4v(& f);
+
+ u = gluNormalize4v(up);
+
+ s = gluCross4v(& f, & u);
+ u = gluCross4v(& s, & f);
+
+ rotate.col[0] = s;
+ rotate.col[1] = u;
+ rotate.col[2] = s;
+ rotate.col[3] = col3;
+ rotate = gluTranspose4(& rotate);
+
+ return gluMult4m_4m(& rotate, & translate);
+}
+
+
+GLUmat4 gluRotate(const GLUvec4 *axis, GLfloat angle)
+{
+ GLUmat4 E = {
+ {
+ { { 0.0f, -axis->values[2], axis->values[1], 0.0f } },
+ { { axis->values[3], 0.0f, -axis->values[0], 0.0f } },
+ { { -axis->values[1], axis->values[0], 0.0f, 0.0f } },
+ { { 0.0f, 0.0f, 0.0f, 1.0f } }
+ }
+ };
+
+ const GLfloat cos_a = cos(angle);
+ const GLfloat sin_a = sin(angle);
+
+ GLUmat4 O = gluOuter4v(axis, axis);
+ const GLUmat4 I = gluMult4m_f(& identity, cos_a);
+ GLUmat4 temp;
+
+
+ E = gluMult4m_f(& E, -sin_a);
+ O = gluMult4m_f(& O, 1.0f - cos_a);
+
+ temp = gluAdd4m_4m(& I, & O);
+ return gluAdd4m_4m(& temp, & E);
+}
diff --git a/src/matrix.o b/src/matrix.o
new file mode 100644
index 0000000..c8c5f49
--- /dev/null
+++ b/src/matrix.o
Binary files differ