diff --git a/src/native/linux/MatrixOpCommon.cpp b/src/native/common/MatrixOpCommon.cpp similarity index 100% rename from src/native/linux/MatrixOpCommon.cpp rename to src/native/common/MatrixOpCommon.cpp diff --git a/src/native/linux/MatrixOpCommon.h b/src/native/common/MatrixOpCommon.h old mode 100644 new mode 100755 similarity index 100% rename from src/native/linux/MatrixOpCommon.h rename to src/native/common/MatrixOpCommon.h diff --git a/src/native/win32/org_lwjgl_Math.cpp b/src/native/common/org_lwjgl_Math.cpp similarity index 97% rename from src/native/win32/org_lwjgl_Math.cpp rename to src/native/common/org_lwjgl_Math.cpp index 7b91d0bd..cec9e36f 100644 --- a/src/native/win32/org_lwjgl_Math.cpp +++ b/src/native/common/org_lwjgl_Math.cpp @@ -33,13 +33,14 @@ /** * $Id$ * - * Win32 maths library. + * maths library. * * @author cix_foo * @version $Revision$ */ - +#ifdef _WIN32 #include +#endif //#include "org_lwjgl_Math.h" #include "math.h" diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp similarity index 98% rename from src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp index c056e2fb..516b5beb 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp @@ -33,13 +33,15 @@ /** * $Id$ * - * Win32 math library. + * math library. * * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 #include +#endif #include "org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.h" #include "MatrixOpCommon.h" /* diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp similarity index 96% rename from src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp index a71e6ef6..a914b526 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp @@ -33,12 +33,15 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif #include "org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.h" #include "MatrixOpCommon.h" /* diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp similarity index 96% rename from src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp index 0a149dbb..f1fc5471 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp @@ -33,16 +33,17 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ - +#ifdef _WIN32 +#include +#endif #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.h" #include "MatrixOpCommon.h" #include - /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect * Method: execute diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp similarity index 96% rename from src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp index bc8a00e4..8b07db69 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp @@ -1,87 +1,90 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - // remove any unnecessary copying - if (transposeSource == transposeDest) - { - transposeSource = false; - transposeDest = false; - } - - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - - float * srcMatrix, * destMatrix; - int matrixByteCount = source.width*source.height*sizeof(jfloat); - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = source.nextMatrix(); - destMatrix = dest.nextMatrix(); - - // just do a straight memory copy - memcpy(destMatrix, srcMatrix, matrixByteCount); - dest.writeComplete(); - } -} +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * math library. + * + * @author cix_foo + * @version $Revision$ + */ + +#ifdef _WIN32 +#include +#endif +#include +#include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" +#include "MatrixOpCommon.h" +/* + * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe + * Method: execute + * Signature: (IIIIIZIIZ)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpSafe_execute + ( + JNIEnv * env, + jobject obj, + jint sourceAddress, + jint sourceStride, + jint numElements, + jint sourceWidth, + jint sourceHeight, + jboolean transposeSource, + jint destAddress, + jint destStride, + jboolean transposeDest + ) +{ + // remove any unnecessary copying + if (transposeSource == transposeDest) + { + transposeSource = false; + transposeDest = false; + } + + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + + float * srcMatrix, * destMatrix; + int matrixByteCount = source.width*source.height*sizeof(jfloat); + + for (int i = 0; i < source.elements; i++) + { + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); + + // just do a straight memory copy + memcpy(destMatrix, srcMatrix, matrixByteCount); + dest.writeComplete(); + } +} diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp index 9f5a3ec0..38a7db2f 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.h" #include "MatrixOpCommon.h" #ifdef _DEBUG diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp index a1f88d33..ba8e4d8b 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp @@ -33,12 +33,15 @@ /** * $Id$ * - * linux math library. + * Win32 math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.h" #include "MatrixOpCommon.h" diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp index 47b4a841..155937a2 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.h" #include "MatrixOpCommon.h" #include diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp index 3e0c6567..12afdf26 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp @@ -33,13 +33,15 @@ /** * $Id$ * - * linux math library. + * Win32 math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ - +#ifdef _WIN32 +#include +#endif #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.h" #include "MatrixOpCommon.h" #include diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp similarity index 96% rename from src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp index c9d3fcdb..7f22a7a1 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp @@ -1,87 +1,89 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); - - dest.configureBuffer(source); - - int * srcMatrix, * destMatrix; - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = (int *) source.nextMatrix(); - destMatrix = (int *) dest.nextMatrix(); - - // we can cheat and use the less expensive xor - // to switch the sign bit of the float - // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa - - int j = source.width*source.height; - while (j--) - destMatrix[j] = srcMatrix[j] ^ 0x80000000; - - dest.writeComplete(); - } -} +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * math library. + * + * @author cix_foo + * @version $Revision$ + */ + +#ifdef _WIN32 +#include +#endif +#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.h" +#include "MatrixOpCommon.h" +/* + * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect + * Method: execute + * Signature: (IIIIIZIIZ)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpDirect_execute + ( + JNIEnv * env, + jobject obj, + jint sourceAddress, + jint sourceStride, + jint numElements, + jint sourceWidth, + jint sourceHeight, + jboolean transposeSource, + jint destAddress, + jint destStride, + jboolean transposeDest + ) +{ + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + + dest.configureBuffer(source); + + int * srcMatrix, * destMatrix; + + for (int i = 0; i < source.elements; i++) + { + srcMatrix = (int *) source.nextMatrix(); + destMatrix = (int *) dest.nextMatrix(); + + // we can cheat and use the less expensive xor + // to switch the sign bit of the float + // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa + + int j = source.width*source.height; + while (j--) + destMatrix[j] = srcMatrix[j] ^ 0x80000000; + + dest.writeComplete(); + } +} diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp similarity index 96% rename from src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp index 41f4ed06..994ae0a2 100644 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp @@ -1,85 +1,88 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); - - int * srcMatrix, * destMatrix; - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = (int *) source.nextMatrix(); - destMatrix = (int *) dest.nextMatrix(); - - // we can cheat and use the less expensive xor - // to switch the sign bit of the float - // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa - - int j = source.width*source.height; - while (j--) - destMatrix[j] = srcMatrix[j] ^ 0x80000000; - - dest.writeComplete(); - } -} +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * math library. + * + * @author cix_foo + * @version $Revision$ + */ + +#ifdef _WIN32 +#include +#endif + +#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.h" +#include "MatrixOpCommon.h" +/* + * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe + * Method: execute + * Signature: (IIIIIZIIZ)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpSafe_execute + ( + JNIEnv * env, + jobject obj, + jint sourceAddress, + jint sourceStride, + jint numElements, + jint sourceWidth, + jint sourceHeight, + jboolean transposeSource, + jint destAddress, + jint destStride, + jboolean transposeDest + ) +{ + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + + int * srcMatrix, * destMatrix; + + for (int i = 0; i < source.elements; i++) + { + srcMatrix = (int *) source.nextMatrix(); + destMatrix = (int *) dest.nextMatrix(); + + // we can cheat and use the less expensive xor + // to switch the sign bit of the float + // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa + + int j = source.width*source.height; + while (j--) + destMatrix[j] = srcMatrix[j] ^ 0x80000000; + + dest.writeComplete(); + } +} diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp similarity index 96% rename from src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp index 86bcca0a..962abec4 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.h" #include "MatrixOpCommon.h" #include diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp similarity index 96% rename from src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp index 50fcfaae..2aa47221 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.h" #include "MatrixOpCommon.h" #include diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp b/src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp index 8021e4a3..10e47b34 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.h" #include "MatrixOpCommon.h" /* diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp b/src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp similarity index 97% rename from src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp rename to src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp index b61d7908..792a16f8 100644 --- a/src/native/linux/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp +++ b/src/native/common/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp @@ -33,12 +33,16 @@ /** * $Id$ * - * linux math library. + * math library. * - * @author elias_naur + * @author cix_foo * @version $Revision$ */ +#ifdef _WIN32 +#include +#endif + #include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.h" #include "MatrixOpCommon.h" diff --git a/src/native/linux/Makefile b/src/native/linux/Makefile index d45137d6..216695c1 100644 --- a/src/native/linux/Makefile +++ b/src/native/linux/Makefile @@ -43,8 +43,8 @@ GCC = gcc G++ = g++ LINK = g++ JAVAHOME=/usr/java/j2sdk1.4.1_01 -LIBCSRC=../common/extgl.c -LIBCPPSRC=$(shell find . -name \*.cpp -print|grep -v CVS) +LIBCSRC=$(shell find ../common -name \*.c -print|grep -v CVS) +LIBCPPSRC=$(shell find . -name \*.cpp -print|grep -v CVS) $(shell find ../common -name \*.cpp -print|grep -v CVS) LIBCPPOBJS=$(LIBCPPSRC:.cpp=.o) LIBCOBJS=$(LIBCSRC:.c=.o) LIBOBJS=$(LIBCOBJS) $(LIBCPPOBJS) @@ -76,5 +76,5 @@ testprog : main.o $(LINK) -o $@ $< -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU .PHONY clean: - rm -rf *.o *.so - rm -rf `find ../../ -name \*.class -print` + rm -rf *.so + rm -rf $(LIBOBJS) diff --git a/src/native/linux/org_lwjgl_Math.cpp b/src/native/linux/org_lwjgl_Math.cpp deleted file mode 100644 index 42fa2e37..00000000 --- a/src/native/linux/org_lwjgl_Math.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * linux maths library. - * - * @author elias_naur - * @version $Revision$ - */ - -//#include "org_lwjgl_Math.h" - diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp deleted file mode 100644 index 90689c12..00000000 --- a/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * linux math library. - * - * @author elias_naur - * @version $Revision$ - */ - -#include "org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpAdd_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - left.width, left.height, left.elements * right.elements, transposeDest); - - dest.configureBuffer(left, right); - - float * leftMatrix, * rightMatrix, * destMatrix; - - left.rewind(); - for (int i = 0; i < left.elements; i++) - { - leftMatrix = left.nextMatrix(); - - right.rewind(); - for (int j = 0; j < right.elements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - int k = dest.width * dest.height; - while (k--) - destMatrix[k] = leftMatrix[k] + rightMatrix[k]; - - dest.writeComplete(); - } - } - -} - diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp deleted file mode 100644 index c9602965..00000000 --- a/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * linux math library. - * - * @author elias_naur - * @version $Revision$ - */ - -#include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -#include - -/* - * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - // remove any unnecessary copying - if (transposeSource == transposeDest) - { - transposeSource = false; - transposeDest = false; - } - - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - - float * srcMatrix, * destMatrix; - int matrixByteCount = source.width*source.height*sizeof(jfloat); - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = source.nextMatrix(); - destMatrix = dest.nextMatrix(); - - // just do a straight memory copy - memcpy(destMatrix, srcMatrix, matrixByteCount); - dest.writeComplete(); - } -} diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp deleted file mode 100644 index ae7e8bc9..00000000 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * linux math library. - * - * @author elias_naur - * @version $Revision$ - */ - -#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); - - dest.configureBuffer(source); - - int * srcMatrix, * destMatrix; - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = (int *) source.nextMatrix(); - destMatrix = (int *) dest.nextMatrix(); - - // we can cheat and use the less expensive xor - // to switch the sign bit of the float - // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa - - int j = source.width*source.height; - while (j--) - destMatrix[j] = srcMatrix[j] ^ 0x80000000; - - dest.writeComplete(); - } -} diff --git a/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp b/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp deleted file mode 100644 index 9a89d64f..00000000 --- a/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * linux math library. - * - * @author elias_naur - * @version $Revision$ - */ - -#include "org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNegate_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); - - int * srcMatrix, * destMatrix; - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = (int *) source.nextMatrix(); - destMatrix = (int *) dest.nextMatrix(); - - // we can cheat and use the less expensive xor - // to switch the sign bit of the float - // single precision format 1 - sign 8 - exponent (excess 127) 23 - mantisa - - int j = source.width*source.height; - while (j--) - destMatrix[j] = srcMatrix[j] ^ 0x80000000; - - dest.writeComplete(); - } -} diff --git a/src/native/win32/MatrixOpCommon.cpp b/src/native/win32/MatrixOpCommon.cpp deleted file mode 100644 index 347ca765..00000000 --- a/src/native/win32/MatrixOpCommon.cpp +++ /dev/null @@ -1,346 +0,0 @@ - -//#include -#include -#include -#include "MatrixOpCommon.h" - -bool Matrix::identicalDataSpaces(Matrix & other) -{ - if (address != other.address) - return JNI_FALSE; - if (stride != other.stride) - return JNI_FALSE; - if ((width * height) != (other.width * other.height)) - return JNI_FALSE; - return JNI_TRUE; -} - -bool Matrix::intersectingDataSpaces(Matrix & other) -{ - char * my_max_address = &address[ stride * elements ]; - char * other_max_address = &other.address[ other.stride * other.elements]; - - if (address >= other.address || address <= other_max_address) return JNI_TRUE; - if (other.address >= address || other.address <= my_max_address) return JNI_TRUE; - return JNI_FALSE; -} - -void Matrix::transposeMatrix(float * src, float * dst, int src_width, int src_height) -{ - // square matrix transpose - if (src_width == src_height) - { - for (int i = 0; i < src_width; i++) - for (int j = 0; j < src_width; j++) - dst[i + src_width * j] = src[j + i * src_width]; - } - // non square matrix transpose - else - { - for (int i = 0; i < src_width; i ++) - for (int j = 0; j < src_height; j++) - dst[i + src_height * j] = src[j + i * src_height]; - } -} - -void Matrix::transposeMatrix(float * mat, int src_width, int src_height) -{ - float temp; - - // square matrix transpose - if (src_width == src_height) - { - for (int col = 0; col < src_width; col++) - { - for (int row = col+1; row < src_height; row++) - { - // swap the two elements - temp = mat [col * src_height + row]; - mat[col * src_height + row] = mat[row * src_width + col]; - mat[row * src_width + col] = temp; - } - } - } - // non square matrix transpose - else - { - transposeMatrix(mat, transpose_record, src_width, src_height); - memcpy(mat, transpose_record, src_width * src_height * sizeof(float)); - } - -} - - -MatrixSrc::MatrixSrc ( jint addr, jint s, - jint w, jint h, - jint e, jboolean t): - Matrix(addr, s, e), - record_offset((char *) addr), - record_size (w*h) -{ - if (t) { - width = h; - height = w; - } - else { - width = w; - height = h; - } - - elements = e; - record = new float[width * height]; - - // vectors do not need to be transposed - transpose = (t == JNI_TRUE) && (w != 1) && (h != 1); - - if (transpose && (width != height)) - // only need temp storage for transpose if the matrix is not square - transpose_record = new float[width*height]; - else - transpose_record = 0; - - if (elements == 1) - { - // fool the nextMatrix function into returning a value - elements = 2; - nextMatrix(); - elements = 1; - } -} - -MatrixSrc::~MatrixSrc() -{ - //cout << "MatrixSrc destructor \n"; - - delete [] record; - - if (transpose_record != 0) - delete [] transpose_record; -} - -float * MatrixSrc::nextMatrix() -{ - if (elements > 1) - { - //cout << "Elements: " << elements << "\n"; - //cout << "Address: " << (unsigned int) (record_offset) << "\n"; - - // the record is not properly aligned - if ((unsigned int) (record_offset) & FLOAT_ALIGNMENT) - { - // copy the floats into a buffer so that they are aligned - // on 4 byte margins (not necessary on intel, but a good thing) - - memcpy (record, record_offset, record_size * sizeof(float)); - - if (transpose) - transposeMatrix (record, height, width); - - record_offset = &record_offset[stride]; - current_record_ptr = record; - } - // the record is aligned but it has to be transposed - else if (transpose) - { - transposeMatrix ((float *) (record_offset), record, height, width); - record_offset = &record_offset[stride]; - current_record_ptr = record; - } - // nothing has to be done to the record - else - { - // the floats are aligned in memory - current_record_ptr = (float *) record_offset; - record_offset = &record_offset[stride]; - } - } - - return current_record_ptr; -} - -MatrixDst::MatrixDst (jint addr, jint s, jint w, jint h, jint e, jboolean t): - Matrix(addr, s, e) -{ - width = w; - height = h; - record_size = width * height; - record = new float[record_size]; - - // vectors do not need to be transposed - transpose = (t) && (w != 1) && (h != 1); - - if (transpose) - transpose_record = new float[width*height]; - else - transpose_record = 0; - - data_buffered = JNI_FALSE; - record_buffered = JNI_FALSE; - - record_offset = address - stride; -} - -MatrixDst::~MatrixDst() -{ - //cout << "MatrixDst destructor \n"; - - delete [] record; - if (transpose_record != 0) - delete [] transpose_record; - - // copy back any buffered data - if (data_buffered) - { - char * src = buffer; - char * dest = address; - - for (int i = 0; i < elements; i++) - { - memcpy(dest, src, record_size * sizeof(float)); - src += stride; - dest += stride; - } - - delete [] buffer; - } -} - -void MatrixDst::configureBuffer(MatrixSrc & a, MatrixSrc & b) -{ - - - if (!a.intersectingDataSpaces(b)) - { - // as long as the output only overlays 1 of the sources, and the other - // source only has 1 matrix in it, only a record_buffer is required - if (a.elements == 1 && identicalDataSpaces(b)) - record_buffered = JNI_TRUE; - else if (b.elements == 1 && identicalDataSpaces(a)) - record_buffered = JNI_TRUE; - else - // otherwise all of the output has to be buffered - createBuffer(); - } - else - createBuffer(); -} - -void MatrixDst::configureBuffer(MatrixSrc & a) -{ - if (identicalDataSpaces(a)) - record_buffered = JNI_TRUE; - else if (intersectingDataSpaces(a)) - createBuffer(); -} - -void MatrixDst::createBuffer() -{ - data_buffered = JNI_TRUE; - buffer = new char[ elements * stride ]; - record_offset = buffer - stride; -} - -float * MatrixDst::nextMatrix() -{ - record_offset = &record_offset[stride]; - int alignment = ((unsigned int)(record_offset)) & FLOAT_ALIGNMENT; - - if (transpose || record_buffered || alignment) - { - last_record_in_temp = JNI_TRUE; - return record; - } - else - { - last_record_in_temp = JNI_FALSE; - return (float *) record_offset; - } -} - - -void MatrixDst::writeComplete() -{ - if (last_record_in_temp) - { - // 3 reasons why the record would be in temp - // - // 1. The record is not aligned - // 2. The result will need to be transposed - // 3. Direct Mode where result would overlay an operand - - if (((unsigned int)(record_offset)) & FLOAT_ALIGNMENT) - { - if (transpose) - transposeMatrix(record, width, height); - memcpy (record, record_offset, record_size * sizeof(jfloat)); - } - else if (transpose) - { - transposeMatrix(record, (float *) &record_offset[0], width, height); - } - else - memcpy (record_offset, record, record_size * sizeof(jfloat)); - } -} - -/////////////////////////////////////////////////////////////////////////// - -void subMatrix (const float * src, int side, float * dst , int col_omit, int row_omit) -{ - int index = 0; - int src_index = 0; - - for (int c = 0; c < side; c++) - { - if (c == col_omit) - { src_index += side; - continue; - } - for (int r = 0; r < side; r++) - { - if (r == row_omit) - { src_index++; - continue; - } - dst[index++] = src[src_index++]; - } - } -} - -float determinant (const float * matrix , int side) -{ - - - // we are assuming for this case that the data is in column major format - - float det = 0; - - if (side == 2) - // your basic cross product aka 2x2 determinant - det = matrix[0] * matrix[3] - matrix[2] * matrix[1]; - else - { - // create room to store the sub matrix - int temp_side = side - 1; // the dimensions of the sub matrix - float * temp_matrix = new float[temp_side * temp_side]; - - // keep the sign (this way we avoid an additional branch in the inner loop) - float sign = 1; - - for (int row = 0; row < side; row++) - { - // get a sub matrix by eliminating the 0th col and the specified row - subMatrix(matrix, side, temp_matrix, 0, row); - - // add to the determinant sign * [a]i0 * [M]i0 - det += sign * matrix[row] * determinant (temp_matrix, temp_side); - - // alternate the sign - sign *= -1; - } - - delete [] temp_matrix; - } - - return det; -} diff --git a/src/native/win32/MatrixOpCommon.h b/src/native/win32/MatrixOpCommon.h deleted file mode 100755 index 181058ec..00000000 --- a/src/native/win32/MatrixOpCommon.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Matrix.h - * - * - * Created by tristan on Sat Aug 24 2002. - * Copyright (c) 2001 __MyCompanyName__. All rights reserved. - * - */ - - - -//////////////////////////////////////////////////////////////////////////////////////// -// Utility Functions -//////////////////////////////////////////////////////////////////////////////////////// - -#define FLOAT_ALIGNMENT 0x00000003 - -// 23 bit mantisa on a float (we need error for checking if two nums are equal) -// for now use error of 1/2^18, this could be refined up to 1/2^22 if needed -#define FLOATING_POINT_ERROR (1.0f/262144.0f) - -// check if two numbers are approximately equal, used when floating point errors -// occur. Should NEVER check to see if two floats are identical - -inline bool approxEqual(float a, float b) -{ - a -= b; - a = (a < 0) ? -a: a; - return (a < FLOATING_POINT_ERROR); -} - -float determinant (const float * matrix , int side); -void subMatrix (const float * src, int side, float * dst , int col_omit, int row_omit); - - - -/////////////////////////////////////////////////////////////////////////////////////// -// Matrix -////////////////////////////////////////////////////////////////////////////////////// - -class Matrix -{ - protected: - float * transpose_record; // to use while transposing the record - - public: - char * address; // the start of the data - jint stride; // the distance between each record - jint width, // the width of the matrix - height, // the height of the matrix - elements; // the number of matricies - jboolean transpose; // whether this matrix is or will be transposed - - Matrix (jint a, jint s, jint e): - address((char *)a), stride(s), elements(e) {} - bool identicalDataSpaces (Matrix & other); - bool intersectingDataSpaces(Matrix & other); - void transposeMatrix(float * src, float * dst, int src_width, int src_height); - void transposeMatrix(float * mat, int src_width, int src_height); -}; - -/////////////////////////////////////////////////////////////////////////////////////// -// Src Matrix -////////////////////////////////////////////////////////////////////////////////////// - -class MatrixSrc: public Matrix -{ - private: - char * record_offset; // the offset of this record in memory - - float * record; // temporary storage to store a fully aligned and transposed - // copy of the record, if the one in memory is not so - float * current_record_ptr; // the address of the memory containing the record last - // returned by the nextMatrix() function - jint record_size; // the total floats in each record - - public: - MatrixSrc ( jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); - ~MatrixSrc(); - - void rewind() { record_offset = address; } - float * nextMatrix(); - -}; - -/////////////////////////////////////////////////////////////////////////////////////// -// Dst Matrix -////////////////////////////////////////////////////////////////////////////////////// - -class MatrixDst: public Matrix -{ - private: - char * record_offset; // the offset of the record in memory - - jboolean data_buffered; // if all of the data has to be buffered - char * buffer; // a buffer used when data_buffered - - jboolean last_record_in_temp; - jboolean record_buffered; // if only a single record is buffered - float * record; // to store data if source is unaligned - - jint record_size; - void createBuffer(); - - public: - MatrixDst (jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); - ~MatrixDst(); - void configureBuffer(MatrixSrc & a, MatrixSrc & b); - void configureBuffer(MatrixSrc & a); - - float * nextMatrix(); - void writeComplete(); - -}; - - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp deleted file mode 100644 index 1bee1972..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpAdd_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - left.width, left.height, left.elements * right.elements, transposeDest); - - float * leftMatrix, * rightMatrix, * destMatrix; - - left.rewind(); - for (int i = 0; i < leftElements; i++) - { - leftMatrix = left.nextMatrix(); - right.rewind(); - - for (int j = 0; j < rightElements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - int k = dest.width * dest.height; - while (k--) - destMatrix[k] = leftMatrix[k] + rightMatrix[k]; - - dest.writeComplete(); - } - } -} - - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp deleted file mode 100644 index 35f2641d..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - if (transposeSource == transposeDest) - { - transposeSource = false; - transposeDest = false; - } - - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - - dest.configureBuffer(source); - - float * srcMatrix, * destMatrix; - int matrixByteCount = source.width*source.height*sizeof(jfloat); - - for (int i = 0; i < source.elements; i++) - { - srcMatrix = source.nextMatrix(); - destMatrix = dest.nextMatrix(); - - // just do a straight memory copy - memcpy(destMatrix, srcMatrix, matrixByteCount); - dest.writeComplete(); - } -} - - - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp deleted file mode 100644 index 36dabe13..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -#ifdef _DEBUG -#include -#endif -/* - * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - static float * temp_matrix = 0; - static int temp_matrix_size = 0; - - if (transposeSource == transposeDest) - { - transposeSource = JNI_FALSE; - transposeDest = JNI_FALSE; - } - - - // We are under the assumption that sourceWidth == sourceHeight and the matrix - // defined within is invertable - - MatrixSrc source (sourceAddress, sourceStride, - sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, - source.width, source.height, source.elements, transposeDest); - - dest.configureBuffer(source); - - float * srcMatrix, * destMatrix; - - int temp_side = source.width-1; - - 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(); - - // calculate the determinant - float det = determinant(srcMatrix, source.width); - -#ifdef _DEBUG - printf("Matrix Determinant: %f\n", det); - printf("Matrix Determinant - 1 = %f\n", det -1); -#endif - - float sign; - - for (int col = 0; col < source.width; col++) - { - /* - Maintain sign: - - + - + - ... - - + - + .. - + - + - .. - - + - + .. - : : : : \ - */ - - sign = (col & 1) ? -1.0f : 1.0f; - - for (int row = 0; row < source.height; row++) - { - // get the sub matrix - subMatrix(srcMatrix, source.width, temp_matrix, col, row); - - // transpose the result - destMatrix[col + row * source.height] - = (sign / det) * determinant(temp_matrix, temp_side); - - // swap signs - sign *= -1.0f; - } - } - - dest.writeComplete(); - } -} diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp deleted file mode 100644 index 1f06a495..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.h" -#include "MatrixOpCommon.h" - -#ifdef _DEBUG -#include -#endif - -/* - * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - - static float * temp_matrix = 0; - static int temp_matrix_size = 0; - - if (transposeSource == transposeDest) - { - transposeSource = JNI_FALSE; - transposeDest = JNI_FALSE; - } - - // We are under the assumption that sourceWidth == sourceHeight and the matrix - // defined within is invertable - - MatrixSrc source (sourceAddress, sourceStride, - sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, - source.width, source.height, source.elements, transposeDest); - - float * srcMatrix, * destMatrix; - - int temp_side = source.width-1; - - 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(); - - // calculate the determinant - float det = determinant(srcMatrix, source.width); - -#ifdef _DEBUG - printf("Matrix Determinant: %f\n", det); - printf("Matrix Determinant - 1: %f\n", det-1); -#endif - - float sign; - - for (int col = 0; col < source.width; col++) - { - /* - Maintain sign: - - + - + - ... - - + - + .. - + - + - .. - - + - + .. - : : : : \ - */ - - sign = (col & 1) ? -1.0f : 1.0f; - - for (int row = 0; row < source.height; row++) - { - // get the sub matrix - subMatrix(srcMatrix, source.width, temp_matrix, col, row); - - // transpose the result - destMatrix[col + row * source.height] - = (sign / det) * determinant(temp_matrix, temp_side); - - // swap signs - sign *= -1.0f; - } - } - - dest.writeComplete(); - - } -} diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp deleted file mode 100644 index e158aa1d..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -#include -/* - * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpMultiply_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - if (transposeLeftSource && transposeRightSource) - { - transposeLeftSource = false; - transposeRightSource = false; - transposeDest = !transposeDest; - } - - - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - right.width, left.height, left.elements * right.elements, transposeDest); - - dest.configureBuffer(left, right); - - float * leftMatrix, * rightMatrix, * destMatrix; - - // check out discussions envolving ordering - - - left.rewind(); - for (int i = 0; i < left.elements; i++) - { - leftMatrix = left.nextMatrix(); - - right.rewind(); - for (int j = 0; j < right.elements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - // zero the elements of the destination matrix - for (int d = 0; d < dest.width * dest.height; d++) - destMatrix[d] = 0; - - // loop through each column of the right matrix - int rightCell = 0; - for (int rightCol = 0; rightCol < right.width; rightCol++) - { - // [RxC] * [RxC] - // dest has same height as left - // dest has same width as right - - int leftCell = 0; - for (int leftCol = 0; leftCol < left.width; leftCol++) - { - for (int leftRow = 0; leftRow < left.height; leftRow++) - { - destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; - } - rightCell ++ ; - } - - //rightMatrix = &rightMatrix[right.height]; - destMatrix = &destMatrix[dest.height]; - - } - dest.writeComplete(); - } - } -} - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp deleted file mode 100644 index 86d0d3b1..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - - -#include -#include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -#include - -/* - * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpMultiply_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - if (transposeLeftSource && transposeRightSource) - { - transposeLeftSource = false; - transposeRightSource = false; - transposeDest = !transposeDest; - } - - - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - right.width, left.height, left.elements * right.elements, transposeDest); - - float * leftMatrix, * rightMatrix, * destMatrix; - - // check out discussions envolving ordering - - - left.rewind(); - for (int i = 0; i < left.elements; i++) - { - leftMatrix = left.nextMatrix(); - - right.rewind(); - for (int j = 0; j < right.elements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - // zero the elements of the destination matrix - for (int d = 0; d < dest.width * dest.height; d++) - destMatrix[d] = 0; - - // loop through each column of the right matrix - int rightCell = 0; - for (int rightCol = 0; rightCol < right.width; rightCol++) - { - // [RxC] * [RxC] - // dest has same height as left - // dest has same width as right - - int leftCell = 0; - for (int leftCol = 0; leftCol < left.width; leftCol++) - { - for (int leftRow = 0; leftRow < left.height; leftRow++) - { - destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; - } - rightCell ++ ; - } - - //rightMatrix = &rightMatrix[right.height]; - destMatrix = &destMatrix[dest.height]; - - } - dest.writeComplete(); - } - } - -} - - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp deleted file mode 100644 index b4e2c05f..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -#include - -//using namespace std; - -/* - * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - - dest.configureBuffer(source); - - float * srcMatrix, * destMatrix; - float magnitude, magnitude_squared; - - int i, j, matrixFloatCount = source.width * source.height; - - for (i = 0; i < source.elements; i++) - { - magnitude_squared = 0; - srcMatrix = source.nextMatrix(); - destMatrix = dest.nextMatrix(); - - j = matrixFloatCount; - while (j--) - magnitude_squared += srcMatrix[j] * srcMatrix[j]; - - magnitude = (float) sqrt((double) magnitude_squared); - - j = matrixFloatCount; - while (j--) - destMatrix[j] = srcMatrix[j] / magnitude; - - dest.writeComplete(); - } -} diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp deleted file mode 100644 index 7f3a6241..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.h" -#include "MatrixOpCommon.h" -#include - -//using namespace std; - -/* - * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint sourceAddress, - jint sourceStride, - jint numElements, - jint sourceWidth, - jint sourceHeight, - jboolean transposeSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - - float * srcMatrix, * destMatrix; - float magnitude, magnitude_squared; - - int i, j, matrixFloatCount = source.width * source.height; - - for (i = 0; i < source.elements; i++) - { - magnitude_squared = 0; - srcMatrix = source.nextMatrix(); - destMatrix = dest.nextMatrix(); - - j = matrixFloatCount; - while (j--) - magnitude_squared += srcMatrix[j] * srcMatrix[j]; - - magnitude = (float) sqrt((double) magnitude_squared); - - j = matrixFloatCount; - while (j--) - destMatrix[j] = srcMatrix[j] / magnitude; - - dest.writeComplete(); - } -} diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp deleted file mode 100644 index 6dde488b..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.h" -#include "MatrixOpCommon.h" -/* - * Class: org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpSubtract_00024MatrixOpDirect_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - if (transposeLeftSource && transposeRightSource) - { - transposeLeftSource = false; - transposeRightSource = false; - transposeDest = !transposeDest; - } - - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - left.width, left.height, left.elements * right.elements, transposeDest); - - dest.configureBuffer(left, right); - - float * leftMatrix, * rightMatrix, * destMatrix; - - left.rewind(); - for (int i = 0; i < left.elements; i++) - { - leftMatrix = left.nextMatrix(); - - right.rewind(); - for (int j = 0; j < right.elements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - int k = dest.width * dest.height; - while (k--) - destMatrix[k] = leftMatrix[k] - rightMatrix[k]; - - dest.writeComplete(); - } - } -} - - diff --git a/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp b/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp deleted file mode 100644 index 8be4b411..00000000 --- a/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Win32 math library. - * - * @author cix_foo - * @version $Revision$ - */ - -#include -#include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.h" -#include "MatrixOpCommon.h" - -/* - * Class: org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe - * Method: execute - * Signature: (IIIIIZIIIIIZIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpSubtract_00024MatrixOpSafe_execute - ( - JNIEnv * env, - jobject obj, - jint leftSourceAddress, - jint leftSourceStride, - jint leftElements, - jint leftSourceWidth, - jint leftSourceHeight, - jboolean transposeLeftSource, - jint rightSourceAddress, - jint rightSourceStride, - jint rightElements, - jint rightSourceWidth, - jint rightSourceHeight, - jboolean transposeRightSource, - jint destAddress, - jint destStride, - jboolean transposeDest - ) -{ - if (transposeLeftSource && transposeRightSource) - { - transposeLeftSource = false; - transposeRightSource = false; - transposeDest = !transposeDest; - } - - MatrixSrc left (leftSourceAddress, leftSourceStride, - leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - MatrixSrc right (rightSourceAddress, leftSourceStride, - rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - MatrixDst dest (destAddress, destStride, - left.width, left.height, left.elements * right.elements, transposeDest); - - float * leftMatrix, * rightMatrix, * destMatrix; - - left.rewind(); - for (int i = 0; i < left.elements; i++) - { - leftMatrix = left.nextMatrix(); - - right.rewind(); - for (int j = 0; j < right.elements; j++) - { - rightMatrix = right.nextMatrix(); - destMatrix = dest.nextMatrix(); - - int k = dest.width * dest.height; - while (k--) - destMatrix[k] = leftMatrix[k] - rightMatrix[k]; - - dest.writeComplete(); - } - } -} - - -