From c8139a4ea24691a5693173ce786d6787e4558ac4 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 25 Nov 2002 00:09:47 +0000 Subject: [PATCH] Synced math operations with win32 --- ...g_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp | 13 +++++++++++-- ...org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp | 15 ++++++++++++--- ...wjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp | 2 +- ..._lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp index d690d60a..9f5a3ec0 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp +++ b/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp @@ -64,7 +64,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire jboolean transposeDest ) { - if (transposeSource == transposeDest) + static float * temp_matrix = 0; + static int temp_matrix_size = 0; + + if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; @@ -84,7 +87,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire float * srcMatrix, * destMatrix; int temp_side = source.width-1; - float temp_matrix [temp_side*temp_side]; + + if (temp_matrix_size < temp_side) { + if (temp_matrix) + delete[] temp_matrix; + temp_matrix = new float[temp_side * temp_side]; + temp_matrix_size = temp_side; + } for (int i = 0; i < source.elements; i++) { diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp index 701ec628..a1f88d33 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp +++ b/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp @@ -67,7 +67,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe ) { - if (transposeSource == transposeDest) + static float * temp_matrix = 0; + static int temp_matrix_size = 0; + + if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; @@ -84,9 +87,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe float * srcMatrix, * destMatrix; int temp_side = source.width-1; - float temp_matrix [temp_side*temp_side]; - for (int i = 0; i < source.elements; i++) + if (temp_matrix_size < temp_side) { + if (temp_matrix) + delete[] temp_matrix; + temp_matrix = new float[temp_side * temp_side]; + temp_matrix_size = temp_side; + } + + for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp index 36bc27e7..86bcca0a 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp +++ b/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp @@ -43,7 +43,7 @@ #include "MatrixOpCommon.h" #include -using namespace std; +//using namespace std; /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp index 433a492d..50fcfaae 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp +++ b/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp @@ -43,7 +43,7 @@ #include "MatrixOpCommon.h" #include -using namespace std; +//using namespace std; /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe