Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv11929 Modified Files: MatrixOpCommon.cpp MatrixOpCommon.h org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp Log Message: Cleaned up the code, all test cases I have sent at it work. check current compatibility at: http://www.happypedestrian.com/lwjgl/matrixop.html Index: MatrixOpCommon.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MatrixOpCommon.cpp 7 Sep 2002 19:52:01 -0000 1.2 +++ MatrixOpCommon.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -70,7 +70,7 @@ } -SrcMatrix::SrcMatrix ( jint addr, jint s, +MatrixSrc::MatrixSrc ( jint addr, jint s, jint w, jint h, jint e, jboolean t): Matrix(addr, s, e), @@ -102,16 +102,16 @@ if (elements == 1) { - // fool the nextRecord function into returning a value + // fool the nextMatrix function into returning a value elements = 2; - nextRecord(); + nextMatrix(); elements = 1; } } -SrcMatrix::~SrcMatrix() +MatrixSrc::~MatrixSrc() { - //cout << "SrcMatrix destructor \n"; + //cout << "MatrixSrc destructor \n"; delete [] record; @@ -119,7 +119,7 @@ delete [] transpose_record; } -float * SrcMatrix::nextRecord() +float * MatrixSrc::nextMatrix() { if (elements > 1) { @@ -159,7 +159,7 @@ return current_record_ptr; } -DstMatrix::DstMatrix (jint addr, jint s, jint w, jint h, jint e, jboolean t): +MatrixDst::MatrixDst (jint addr, jint s, jint w, jint h, jint e, jboolean t): Matrix(addr, s, e) { width = w; @@ -181,9 +181,9 @@ record_offset = address - stride; } -DstMatrix::~DstMatrix() +MatrixDst::~MatrixDst() { - //cout << "DstMatrix destructor \n"; + //cout << "MatrixDst destructor \n"; delete [] record; if (transpose_record != 0) @@ -206,7 +206,7 @@ } } -void DstMatrix::configureBuffer(SrcMatrix & a, SrcMatrix & b) +void MatrixDst::configureBuffer(MatrixSrc & a, MatrixSrc & b) { @@ -226,7 +226,7 @@ createBuffer(); } -void DstMatrix::configureBuffer(SrcMatrix & a) +void MatrixDst::configureBuffer(MatrixSrc & a) { if (identicalDataSpaces(a)) record_buffered = JNI_TRUE; @@ -234,14 +234,14 @@ createBuffer(); } -void DstMatrix::createBuffer() +void MatrixDst::createBuffer() { data_buffered = JNI_TRUE; buffer = new char[ elements * stride ]; record_offset = buffer - stride; } -float * DstMatrix::nextRecord() +float * MatrixDst::nextMatrix() { record_offset = &record_offset[stride]; @@ -258,7 +258,7 @@ } -void DstMatrix::writeRecord() +void MatrixDst::writeComplete() { if (last_record_in_temp) { Index: MatrixOpCommon.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MatrixOpCommon.h 28 Aug 2002 16:45:24 -0000 1.1 +++ MatrixOpCommon.h 8 Sep 2002 23:57:33 -0000 1.2 @@ -43,7 +43,7 @@ // Src Matrix ////////////////////////////////////////////////////////////////////////////////////// -class SrcMatrix: public Matrix +class MatrixSrc: public Matrix { private: char * record_offset; // the offset of this record in memory @@ -51,41 +51,46 @@ 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 nextRecord() function + // returned by the nextMatrix() function jint record_size; // the total floats in each record public: - SrcMatrix ( jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); + MatrixSrc ( jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); + ~MatrixSrc(); + void rewind() { record_offset = address; } - float * nextRecord(); - ~SrcMatrix(); + float * nextMatrix(); + }; /////////////////////////////////////////////////////////////////////////////////////// // Dst Matrix ////////////////////////////////////////////////////////////////////////////////////// -class DstMatrix: public Matrix +class MatrixDst: public Matrix { - 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 + private: + char * record_offset; // the offset of the record in memory - jint record_size; + 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: - DstMatrix (jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); - void configureBuffer(SrcMatrix & a, SrcMatrix & b); - void configureBuffer(SrcMatrix & a); - void createBuffer(); - float * nextRecord(); - void writeRecord(); - ~DstMatrix(); + 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(); + }; Index: org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -68,32 +68,33 @@ jboolean transposeDest ) { - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); dest.configureBuffer(left, right); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < left.elements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (int k = (dest.width * dest.height) - 1; k >= 0; k--) - destRecord[k] = leftRecord[k] + rightRecord[k]; + int k = dest.width * dest.height; + while (k--) + destMatrix[k] = leftMatrix[k] + rightMatrix[k]; - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -68,33 +68,33 @@ jboolean transposeDest ) { - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < leftElements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < rightElements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (int k = (leftSourceWidth * rightSourceWidth) - 1; k >= 0; k--) - destRecord[k] = leftRecord[k] + rightRecord[k]; + int k = dest.width * dest.height; + while (k--) + destMatrix[k] = leftMatrix[k] + rightMatrix[k]; - dest.writeRecord(); + dest.writeComplete(); } } - } Index: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -68,21 +68,22 @@ transposeDest = false; } - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); dest.configureBuffer(source); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; + int matrixByteCount = source.width*source.height*sizeof(jfloat); for (int i = 0; i < source.elements; i++) { - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); // just do a straight memory copy - memcpy(destRecord, sourceRecord, source.width*source.height*sizeof(jfloat)); - dest.writeRecord(); + memcpy(destMatrix, srcMatrix, matrixByteCount); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -69,18 +69,19 @@ transposeDest = false; } - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; + int matrixByteCount = source.width*source.height*sizeof(jfloat); for (int i = 0; i < source.elements; i++) { - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); // just do a straight memory copy - memcpy(destRecord, sourceRecord, source.width * source.height * sizeof(jfloat)); - dest.writeRecord(); + memcpy(destMatrix, srcMatrix, matrixByteCount); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp 7 Sep 2002 19:52:01 -0000 1.3 +++ org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -65,25 +65,25 @@ // We are under the assumption that sourceWidth == sourceHeight and the matrix // defined within is invertable - SrcMatrix source (sourceAddress, sourceStride, + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); dest.configureBuffer(source); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; int temp_side = source.width-1; float temp_matrix [temp_side*temp_side]; for (int i = 0; i < source.elements; i++) { - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); // calculate the determinant - float det = determinant(sourceRecord, source.width); + float det = determinant(srcMatrix, source.width); #ifdef _DEBUG printf("Determinant: %f\n", det); @@ -108,10 +108,10 @@ for (int row = 0; row < source.height; row++) { // get the sub matrix - subMatrix(sourceRecord, source.width, temp_matrix, col, row); + subMatrix(srcMatrix, source.width, temp_matrix, col, row); // transpose the result - destRecord[col + row * source.height] + destMatrix[col + row * source.height] = (sign / det) * determinant(temp_matrix, temp_side); // swap signs @@ -119,6 +119,6 @@ } } - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp 7 Sep 2002 19:52:01 -0000 1.3 +++ org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -71,23 +71,23 @@ // We are under the assumption that sourceWidth == sourceHeight and the matrix // defined within is invertable - SrcMatrix source (sourceAddress, sourceStride, + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; int temp_side = source.width-1; float temp_matrix [temp_side*temp_side]; for (int i = 0; i < source.elements; i++) { - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); // calculate the determinant - float det = determinant(sourceRecord, source.width); + float det = determinant(srcMatrix, source.width); #ifdef _DEBUG printf("Determinant: %f\n", det); @@ -112,10 +112,10 @@ for (int row = 0; row < source.height; row++) { // get the sub matrix - subMatrix(sourceRecord, source.width, temp_matrix, col, row); + subMatrix(srcMatrix, source.width, temp_matrix, col, row); // transpose the result - destRecord[col + row * source.height] + destMatrix[col + row * source.height] = (sign / det) * determinant(temp_matrix, temp_side); // swap signs @@ -123,6 +123,6 @@ } } - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp 7 Sep 2002 19:52:01 -0000 1.3 +++ org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -77,16 +77,16 @@ } - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, right.width, left.height, left.elements * right.elements, transposeDest); dest.configureBuffer(left, right); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; // check out discussions envolving ordering @@ -94,17 +94,17 @@ left.rewind(); for (int i = 0; i < left.elements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); // zero the elements of the destination matrix for (int d = 0; d < dest.width * dest.height; d++) - destRecord[d] = 0; + destMatrix[d] = 0; // loop through each column of the right matrix int rightCell = 0; @@ -119,16 +119,16 @@ { for (int leftRow = 0; leftRow < left.height; leftRow++) { - destRecord[leftRow] += rightRecord[rightCell] * leftRecord[leftCell++]; + destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; } rightCell ++ ; } - //rightRecord = &rightRecord[right.height]; - destRecord = &destRecord[dest.height]; + //rightMatrix = &rightMatrix[right.height]; + destMatrix = &destMatrix[dest.height]; } - dest.writeRecord(); + dest.writeComplete(); } } } Index: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp 7 Sep 2002 19:52:01 -0000 1.3 +++ org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -79,14 +79,14 @@ } - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, right.width, left.height, left.elements * right.elements, transposeDest); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; // check out discussions envolving ordering @@ -94,17 +94,17 @@ left.rewind(); for (int i = 0; i < left.elements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); // zero the elements of the destination matrix for (int d = 0; d < dest.width * dest.height; d++) - destRecord[d] = 0; + destMatrix[d] = 0; // loop through each column of the right matrix int rightCell = 0; @@ -119,16 +119,16 @@ { for (int leftRow = 0; leftRow < left.height; leftRow++) { - destRecord[leftRow] += rightRecord[rightCell] * leftRecord[leftCell++]; + destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; } rightCell ++ ; } - //rightRecord = &rightRecord[right.height]; - destRecord = &destRecord[dest.height]; + //rightMatrix = &rightMatrix[right.height]; + destMatrix = &destMatrix[dest.height]; } - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -62,25 +62,26 @@ jboolean transposeDest ) { - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); dest.configureBuffer(source); - int * sourceRecord, * destRecord; + int * srcMatrix, * destMatrix; for (int i = 0; i < source.elements; i++) { - sourceRecord = (int *) source.nextRecord(); - destRecord = (int *) dest.nextRecord(); + 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 - for (int j = 0; j < sourceWidth*sourceHeight; j++) - destRecord[j] = sourceRecord[j] ^ 0x80000000; + int j = source.width*source.height; + while (j--) + destMatrix[j] = srcMatrix[j] ^ 0x80000000; - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -62,23 +62,24 @@ jboolean transposeDest ) { - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); - int * sourceRecord, * destRecord; + int * srcMatrix, * destMatrix; for (int i = 0; i < source.elements; i++) { - sourceRecord = (int *) source.nextRecord(); - destRecord = (int *) dest.nextRecord(); + 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 - for (int j = 0; j < sourceWidth*sourceHeight; j++) - destRecord[j] = sourceRecord[j] ^ 0x80000000; + int j = source.width*source.height; + while (j--) + destMatrix[j] = srcMatrix[j] ^ 0x80000000; - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp 29 Aug 2002 21:40:44 -0000 1.3 +++ org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -66,31 +66,32 @@ jboolean transposeDest ) { - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); dest.configureBuffer(source); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; float magnitude, magnitude_squared; - int i, j; + int i, j, matrixFloatCount = source.width * source.height; for (i = 0; i < source.elements; i++) { - magnitude_squared = 0; - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (j = 0 ; j < sourceWidth*sourceHeight; j++) - magnitude_squared += sourceRecord[j] * sourceRecord[j]; + j = matrixFloatCount; + while (j--) + magnitude_squared += srcMatrix[j] * srcMatrix[j]; magnitude = (float) sqrt((double) magnitude_squared); - for (j = 0; j < sourceWidth*sourceHeight; j++) - destRecord[j] = sourceRecord[j] / magnitude; + j = matrixFloatCount; + while (j--) + destMatrix[j] = srcMatrix[j] / magnitude; - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp 29 Aug 2002 21:40:44 -0000 1.3 +++ org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.4 @@ -66,29 +66,30 @@ jboolean transposeDest ) { - SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); - DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); - float * sourceRecord, * destRecord; + float * srcMatrix, * destMatrix; float magnitude, magnitude_squared; - int i, j; + int i, j, matrixFloatCount = source.width * source.height; for (i = 0; i < source.elements; i++) { - magnitude_squared = 0; - sourceRecord = source.nextRecord(); - destRecord = dest.nextRecord(); + srcMatrix = source.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (j = 0 ; j < sourceWidth*sourceHeight; j++) - magnitude_squared += sourceRecord[j] * sourceRecord[j]; + j = matrixFloatCount; + while (j--) + magnitude_squared += srcMatrix[j] * srcMatrix[j]; magnitude = (float) sqrt((double) magnitude_squared); - for (j = 0; j < sourceWidth*sourceHeight; j++) - destRecord[j] = sourceRecord[j] / magnitude; + j = matrixFloatCount; + while (j--) + destMatrix[j] = srcMatrix[j] / magnitude; - dest.writeRecord(); + dest.writeComplete(); } } Index: org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -75,32 +75,33 @@ transposeDest = !transposeDest; } - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); dest.configureBuffer(left, right); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < left.elements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (int k = (left.width * left.height) - 1; k >= 0; k--) - destRecord[k] = leftRecord[k] - rightRecord[k]; + int k = dest.width * dest.height; + while (k--) + destMatrix[k] = leftMatrix[k] - rightMatrix[k]; - dest.writeRecord(); + dest.writeComplete(); } } } Index: org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 +++ org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp 8 Sep 2002 23:57:33 -0000 1.3 @@ -76,30 +76,31 @@ transposeDest = !transposeDest; } - SrcMatrix left (leftSourceAddress, leftSourceStride, + MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); - SrcMatrix right (rightSourceAddress, leftSourceStride, + MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); - DstMatrix dest (destAddress, destStride, + MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); - float * leftRecord, * rightRecord, * destRecord; + float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < left.elements; i++) { - leftRecord = left.nextRecord(); + leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { - rightRecord = right.nextRecord(); - destRecord = dest.nextRecord(); + rightMatrix = right.nextMatrix(); + destMatrix = dest.nextMatrix(); - for (int k = (left.width * left.height) - 1; k >= 0; k--) - destRecord[k] = leftRecord[k] - rightRecord[k]; + int k = dest.width * dest.height; + while (k--) + destMatrix[k] = leftMatrix[k] - rightMatrix[k]; - dest.writeRecord(); + dest.writeComplete(); } } } |