Browse Source

Basic utility function to display matrices.

legacy
Sam Hocevar sam 13 years ago
parent
commit
0d6f9ef185
2 changed files with 31 additions and 0 deletions
  1. +29
    -0
      src/matrix.cpp
  2. +2
    -0
      src/matrix.h

+ 29
- 0
src/matrix.cpp View File

@@ -12,6 +12,10 @@
# include "config.h"
#endif

#ifdef ANDROID_NDK
# include <android/log.h>
#endif

#include <cstdio>
#include <cstdlib> /* free() */
#include <cstring> /* strdup() */
@@ -65,6 +69,31 @@ template<> mat4 mat4::invert() const
return ret;
}

template<> void mat4::printf() const
{
mat4 const &p = *this;

#ifdef ANDROID_NDK
__android_log_print(ANDROID_LOG_INFO, "LOL",
"[ %6.6f %6.6f %6.6f %6.6f", p[0][0], p[1][0], p[2][0], p[3][0]);
__android_log_print(ANDROID_LOG_INFO, "LOL",
" %6.6f %6.6f %6.6f %6.6f", p[0][1], p[1][1], p[2][1], p[3][1]);
__android_log_print(ANDROID_LOG_INFO, "LOL",
" %6.6f %6.6f %6.6f %6.6f", p[0][2], p[1][2], p[2][2], p[3][2]);
__android_log_print(ANDROID_LOG_INFO, "LOL",
" %6.6f %6.6f %6.6f %6.6f ]", p[0][3], p[1][3], p[2][3], p[3][3]);
#else
fprintf(stderr, "[ %6.6f %6.6f %6.6f %6.6f\n",
p[0][0], p[1][0], p[2][0], p[3][0]);
fprintf(stderr, " %6.6f %6.6f %6.6f %6.6f\n",
p[0][1], p[1][1], p[2][1], p[3][1]);
fprintf(stderr, " %6.6f %6.6f %6.6f %6.6f\n",
p[0][2], p[1][2], p[2][2], p[3][2]);
fprintf(stderr, " %6.6f %6.6f %6.6f %6.6f ]\n",
p[0][3], p[1][3], p[2][3], p[3][3]);
#endif
}

template<> mat4 mat4::ortho(float left, float right, float bottom,
float top, float near, float far)
{


+ 2
- 0
src/matrix.h View File

@@ -215,6 +215,8 @@ template <typename T> struct Mat4
static Mat4<T> translate(T x, T y, T z);
static Mat4<T> rotate(T theta, T x, T y, T z);

void printf() const;

inline Mat4<T> operator +(Mat4<T> const val) const
{
Mat4<T> ret;


Loading…
Cancel
Save