You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
|
3
|
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
|
11
|
12
|
13
|
14
|
15
(1) |
16
(21) |
17
(5) |
|
18
(5) |
19
(14) |
20
(5) |
21
|
22
|
23
(2) |
24
(18) |
|
25
(3) |
26
(22) |
27
(8) |
28
(10) |
29
(11) |
30
(9) |
31
|
|
From: Brian M. <ma...@us...> - 2002-08-28 23:41:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv18308 Modified Files: org_lwjgl_openal_ALUT.cpp Log Message: fix: don't check for errors after the exit! - will crash since no current context Index: org_lwjgl_openal_ALUT.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_openal_ALUT.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_openal_ALUT.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_openal_ALUT.cpp 28 Aug 2002 22:46:54 -0000 1.6 +++ org_lwjgl_openal_ALUT.cpp 28 Aug 2002 23:41:05 -0000 1.7 @@ -202,5 +202,4 @@ */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_exit (JNIEnv *env, jobject obj) { alutExit(); - CHECK_AL_ERROR } |
|
From: Brian M. <ma...@us...> - 2002-08-28 22:46:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv4170 Modified Files: org_lwjgl_openal_ALUT.cpp Log Message: fix: now uses ByteBuffer address to load buffer when using alutLoadWAVMemory fix: minor cleanup Index: org_lwjgl_openal_ALUT.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_openal_ALUT.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_openal_ALUT.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_openal_ALUT.cpp 26 Aug 2002 18:23:11 -0000 1.5 +++ org_lwjgl_openal_ALUT.cpp 28 Aug 2002 22:46:54 -0000 1.6 @@ -106,7 +106,7 @@ /* class type to find */ jclass alutLoadWAVFile_class = NULL; - /* method id - will be set to constructor of alutLoadWAVFile */ + /* method id - will be set to constructor of alutLoadWAVData */ jmethodID methodID = NULL; /* sound data vars */ @@ -141,7 +141,7 @@ * ALvoid alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvoid **data,ALsizei * *size,ALsizei *freq,ALboolean *loop) */ -JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory (JNIEnv *env, jobject obj, jbyteArray buffer) { +JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory (JNIEnv *env, jobject obj, jint buffer) { /* * NOTE: Since Java doesn't support modification of supplied @@ -158,17 +158,16 @@ /* class type to find */ jclass alutLoadWAVFile_class = NULL; - /* method id - will be set to constructor of alutLoadWAVFile */ + /* method id - will be set to constructor of alutLoadWAVData */ jmethodID methodID = NULL; /* sound data vars */ jint format, size, freq; jboolean loop; void* data; - ALbyte* bufferlocation = (ALbyte*) (env->GetByteArrayElements(buffer, 0)); - + /* load wave from mem */ - alutLoadWAVMemory(bufferlocation, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop); + alutLoadWAVMemory((ALbyte*) buffer, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop); /* get class */ alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData"); @@ -178,9 +177,6 @@ /* create object */ alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop); - - /* release bytearray again */ - env->ReleaseByteArrayElements(buffer, (jbyte*) bufferlocation, 0); CHECK_AL_ERROR return alutLoadWAVFile_object; |
|
From: Brian M. <ma...@us...> - 2002-08-28 22:45:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory usw-pr-cvs1:/tmp/cvs-serv3867 Modified Files: org_lwjgl_openal_ALUT.h Log Message: fix: now uses ByteBuffer address to load buffer when using alutLoadWAVMemory Index: org_lwjgl_openal_ALUT.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_openal_ALUT.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_openal_ALUT.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- org_lwjgl_openal_ALUT.h 18 Aug 2002 13:41:35 -0000 1.4 +++ org_lwjgl_openal_ALUT.h 28 Aug 2002 22:45:46 -0000 1.5 @@ -50,7 +50,7 @@ /* * Class: org_lwjgl_openal_ALUT * Method: loadWAVFile - * Signature: (Ljava/lang/String;)Lorg/lwjgl/openal/ALUTLoadWAVFile; + * Signature: (Ljava/lang/String;)Lorg/lwjgl/openal/ALUTLoadWAVData; */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile (JNIEnv *, jobject, jstring); @@ -58,10 +58,10 @@ /* * Class: org_lwjgl_openal_ALUT * Method: loadWAVMemory - * Signature: ([B)Lorg/lwjgl/openal/ALUTLoadWAVFile; + * Signature: (I)Lorg/lwjgl/openal/ALUTLoadWAVData; */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVMemory - (JNIEnv *, jobject, jbyteArray); + (JNIEnv *, jobject, jint); /* * Class: org_lwjgl_openal_ALUT |
|
From: Brian M. <ma...@us...> - 2002-08-28 22:31:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory usw-pr-cvs1:/tmp/cvs-serv32138/org/lwjgl/openal/test Modified Files: PlayTest.java Log Message: rem: not needed imports Index: PlayTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/PlayTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/PlayTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- PlayTest.java 27 Aug 2002 23:28:52 -0000 1.5 +++ PlayTest.java 28 Aug 2002 22:31:15 -0000 1.6 @@ -38,8 +38,6 @@ import org.lwjgl.openal.ALUT; import org.lwjgl.openal.ALUTLoadWAVData; -import java.io.*; -import java.net.*; /** * $Id$ * |
|
From: Caspian Rychlik-P. <ci...@us...> - 2002-08-28 21:58:18
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory usw-pr-cvs1:/tmp/cvs-serv21286/src/java/org/lwjgl/input Modified Files: Joystick.java Mouse.java Keyboard.java Log Message: Stuff Index: Joystick.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Joystick.java 26 Aug 2002 21:05:20 -0000 1.6 +++ Joystick.java 28 Aug 2002 21:58:14 -0000 1.7 @@ -179,6 +179,19 @@ } /** + * See if a particular mouse button is down. + * + * @param button The index of the button you wish to test (0..getNumButtons()) + * @return true if the specified button is down + * @see #getNumButtons() + */ + public static boolean isButtonDown(int button) { + assert created : "The joystick has not been created."; + return Joystick.button[button]; + } + + + /** * Native implementation of hasZValue() */ private static native boolean nHasZValue(); Index: Mouse.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Mouse.java 26 Aug 2002 21:05:20 -0000 1.8 +++ Mouse.java 28 Aug 2002 21:58:14 -0000 1.9 @@ -182,6 +182,18 @@ private static native boolean nHasZValue(); /** + * See if a particular mouse button is down. + * + * @param button The index of the button you wish to test (0..getNumButtons()) + * @return true if the specified button is down + * @see #getNumButtons() + */ + public static boolean isButtonDown(int button) { + assert created : "The mouse has not been created."; + return Mouse.button[button]; + } + + /** * Enable mouse buffering. Must be called after the mouse is created. * @return the size of the mouse buffer in events, or 0 if no buffering * can be enabled for any reason Index: Keyboard.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Keyboard.java 26 Aug 2002 21:05:20 -0000 1.8 +++ Keyboard.java 28 Aug 2002 21:58:14 -0000 1.9 @@ -173,6 +173,128 @@ public static final int KEY_POWER = 0xDE; public static final int KEY_SLEEP = 0xDF; + // Maps keycodes to ascii characters + private static final char map[] = + { + 0, + 0, + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '0', + '-', + '=', + 0, + 0, + 'q', + 'w', + 'e', + 'r', + 't', + 'y', + 'u', + 'i', + 'o', + 'p', + '[', + ']', + '*', + '*', + 'a', + 's', + 'd', + 'f', + 'g', + 'h', + 'j', + 'k', + 'l', + ';', + '\'', + '#', + '*', + '\\', + 'z', + 'x', + 'c', + 'v', + 'b', + 'n', + 'm', + ',', + '.', + '/', + '*', + '*', + '*', + ' ' }; + private static final char shiftMap[] = + { + 0, + 0, + '!', + '"', + '*', + '$', + '%', + '^', + '&', + '*', + '(', + ')', + '_', + '+', + '*', + '*', + 'Q', + 'W', + 'E', + 'R', + 'T', + 'Y', + 'U', + 'I', + 'O', + 'P', + '{', + '}', + 0, + 0, + 'A', + 'S', + 'D', + 'F', + 'G', + 'H', + 'J', + 'K', + 'L', + ':', + '@', + '~', + 0, + '|', + 'Z', + 'X', + 'C', + 'V', + 'B', + 'N', + 'M', + '<', + '>', + '?', + 0, + 0, + 0, + ' ' }; + static { initialize(); } @@ -343,5 +465,23 @@ } else return false; + } + + /** + * Maps a keycode to a character. + * @param keyCode The keycode + * @return the corresponding ASCII character or 0 if no mapping is possible + */ + public static char map(int keyCode) { + char c; + + if (keyCode < 0 || keyCode >= map.length) + return 0; + else if (isKeyDown(KEY_LSHIFT) || isKeyDown(KEY_RSHIFT)) { + c = shiftMap[keyCode]; + } else { + c = map[keyCode]; + } + return c; } } |
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv1539 Modified Files: 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 Added Files: MatrixOpCommon.cpp MatrixOpCommon.h Log Message: First draft of ANSIC++ Vector code. Needs to be tested. --- NEW FILE: MatrixOpCommon.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.cpp //#include <iostream> #include <jni.h> #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)); } } SrcMatrix::SrcMatrix ( 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 nextRecord function into returning a value elements = 2; nextRecord(); elements = 1; } } SrcMatrix::~SrcMatrix() { //cout << "SrcMatrix destructor \n"; delete [] record; if (transpose_record != 0) delete [] transpose_record; } float * SrcMatrix::nextRecord() { 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; } DstMatrix::DstMatrix (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; } DstMatrix::~DstMatrix() { //cout << "DstMatrix 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 DstMatrix::configureBuffer(SrcMatrix & a, SrcMatrix & 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 DstMatrix::configureBuffer(SrcMatrix & a) { if (identicalDataSpaces(a)) record_buffered = JNI_TRUE; else if (intersectingDataSpaces(a)) createBuffer(); } void DstMatrix::createBuffer() { data_buffered = JNI_TRUE; buffer = new char[ elements * stride ]; record_offset = buffer - stride; } float * DstMatrix::nextRecord() { record_offset = &record_offset[stride]; if ((((unsigned int)(record_offset)) & FLOAT_ALIGNMENT) || transpose || record_buffered) { last_record_in_temp = JNI_TRUE; return record; } else { last_record_in_temp = JNI_FALSE; return (float *) record_offset; } } void DstMatrix::writeRecord() { 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, 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; for (int c = 0; c < side; c++) { if (c == col_omit) continue; for (int r = 0; r < side; r++) { if (r == row_omit) continue; dst[index++] = src[r + c * side]; } } } 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 det = matrix[0] * matrix[3] - matrix[2] * matrix[1]; else { int temp_side = side - 1; float temp_matrix [temp_side * temp_side]; float sign = 1; for (int i = 0; i < side; i++) { // get a sub matrix by eliminating the ith row and the 0th column subMatrix(matrix, side, temp_matrix, 0, i); // add to the determinant sign * [a]i0 * [M]i0 det += sign * matrix[i] * determinant (temp_matrix, temp_side); // alternate the sign sign = (sign == 1) ? -1 : 1; } } return det; } --- NEW FILE: MatrixOpCommon.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/MatrixOpCommon.h /* * Matrix.h * * * Created by tristan on Sat Aug 24 2002. * Copyright (c) 2001 __MyCompanyName__. All rights reserved. * */ #define FLOAT_ALIGNMENT 0x00000003 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 SrcMatrix: 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 nextRecord() function jint record_size; // the total floats in each record public: SrcMatrix ( jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); void rewind() { record_offset = address; } float * nextRecord(); ~SrcMatrix(); }; /////////////////////////////////////////////////////////////////////////////////////// // Dst Matrix ////////////////////////////////////////////////////////////////////////////////////// class DstMatrix: 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 jint record_size; 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(); }; 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -1,75 +1,101 @@ -/* - * 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 <ci...@us...> - * @version $Revision$ - */ - -#include <windows.h> -#include "org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.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 - ) -{ - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; -} +/* + * 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 <ci...@us...> + * @version $Revision$ + */ + +#include <windows.h> +#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 + ) +{ + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + left.width, left.height, left.elements * right.elements, transposeDest); + + dest.configureBuffer(left, right); + + float * leftRecord, * rightRecord, * destRecord; + + left.rewind(); + for (int i = 0; i < left.elements; i++) + { + leftRecord = left.nextRecord(); + + right.rewind(); + for (int j = 0; j < right.elements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + for (int k = (dest.width * dest.height) - 1; k >= 0; k--) + destRecord[k] = leftRecord[k] + rightRecord[k]; + + dest.writeRecord(); + } + } + +} 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe * Method: execute @@ -67,9 +68,33 @@ jboolean transposeDest ) { - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + left.width, left.height, left.elements * right.elements, transposeDest); + + float * leftRecord, * rightRecord, * destRecord; + + left.rewind(); + for (int i = 0; i < leftElements; i++) + { + leftRecord = left.nextRecord(); + right.rewind(); + + for (int j = 0; j < rightElements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + for (int k = (leftSourceWidth * rightSourceWidth) - 1; k >= 0; k--) + destRecord[k] = leftRecord[k] + rightRecord[k]; + + dest.writeRecord(); + } + } + } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect * Method: execute @@ -61,8 +62,29 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + if (transposeSource == transposeDest) + { + transposeSource = false; + transposeDest = false; + } + + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + + dest.configureBuffer(source); + + float * sourceRecord, * destRecord; + + for (int i = 0; i < source.elements; i++) + { + sourceRecord = source.nextRecord(); + destRecord = dest.nextRecord(); + + // just do a straight memory copy + memcpy(destRecord, sourceRecord, source.width*source.height*sizeof(jfloat)); + dest.writeRecord(); + } } + 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe * Method: execute @@ -61,6 +62,25 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + // remove any unnecessary copying + if (transposeSource == transposeDest) + { + transposeSource = false; + transposeDest = false; + } + + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + + float * sourceRecord, * destRecord; + + for (int i = 0; i < source.elements; i++) + { + sourceRecord = source.nextRecord(); + destRecord = dest.nextRecord(); + + // just do a straight memory copy + memcpy(destRecord, sourceRecord, source.width * source.height * sizeof(jfloat)); + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect * Method: execute @@ -61,6 +62,47 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + // We are under the assumption that sourceWidth == sourceHeight and the matrix + // defined within is invertable + + SrcMatrix source (sourceAddress, sourceStride, + sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, + source.width, source.height, source.elements, transposeDest); + + dest.configureBuffer(source); + + float * sourceRecord, * destRecord; + + 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(); + + float det = determinant(sourceRecord, sourceWidth); + float sign; + + for (int c = 0; c < source.width; c++) + { + sign = (c & 1) ? 1.0f : -1.0f; + + for (int r = 0; r < source.width; r++) + { + // get the sub matrix + subMatrix(sourceRecord, source.width, temp_matrix, c, r); + + // transpose the result + destRecord[r + c * source.width] + = (sign / det) * determinant(temp_matrix, temp_side); + + // swap signs + sign = (sign == 1) ? -1.0f : 1.0f; + } + } + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,9 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.h" +#include "MatrixOpCommon.h" + + /* * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe * Method: execute @@ -61,6 +64,45 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + // We are under the assumption that sourceWidth == sourceHeight and the matrix + // defined within is invertable + + SrcMatrix source (sourceAddress, sourceStride, + sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, + source.width, source.height, source.elements, transposeDest); + + float * sourceRecord, * destRecord; + + 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(); + + float det = determinant(sourceRecord, sourceWidth); + float sign; + + for (int c = 0; c < source.width; c++) + { + sign = (c & 1) ? 1.0f : -1.0f; + + for (int r = 0; r < source.width; r++) + { + // get the sub matrix + subMatrix(sourceRecord, source.width, temp_matrix, c, r); + + // transpose the result + destRecord[r + c * source.width] + = (sign / det) * determinant(temp_matrix, temp_side); + + // swap signs + sign = (sign == 1) ? -1.0f : 1.0f; + } + } + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,8 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.h" +#include "MatrixOpCommon.h" +#include <cstring> /* * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect * Method: execute @@ -67,9 +69,55 @@ jboolean transposeDest ) { - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; -} + if (transposeLeftSource && transposeRightSource) + { + transposeLeftSource = false; + transposeRightSource = false; + transposeDest = !transposeDest; + } + + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + right.width, left.height, left.elements * right.elements, transposeDest); + + dest.configureBuffer(left, right); + + float * leftRecord, * rightRecord, * destRecord; + + // check out discussions envolving ordering + + + left.rewind(); + for (int i = 0; i < leftElements; i++) + { + leftRecord = left.nextRecord(); + + right.rewind(); + for (int j = 0; j < rightElements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + memset(destRecord, 0, dest.width * dest.height * sizeof(jfloat)); + + for (int rightCol = 0; rightCol < right.width; rightCol++) + { + for (int leftIndex = 0; leftIndex < left.width*left.height; leftIndex++) + { + destRecord[i % dest.height] += leftRecord[i] * rightRecord[i / leftSourceHeight]; + } + + rightRecord = &rightRecord[right.height]; + destRecord = &destRecord[dest.height]; + + } + dest.writeRecord(); + } + } + +} 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,9 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.h" +#include "MatrixOpCommon.h" +#include <cstring> + /* * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe * Method: execute @@ -67,9 +70,54 @@ jboolean transposeDest ) { - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; + if (transposeLeftSource && transposeRightSource) + { + transposeLeftSource = false; + transposeRightSource = false; + transposeDest = !transposeDest; + } + + + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + right.width, left.height, left.elements * right.elements, transposeDest); + + float * leftRecord, * rightRecord, * destRecord; + + // check out discussions envolving ordering + + + left.rewind(); + for (int i = 0; i < leftElements; i++) + { + leftRecord = left.nextRecord(); + + right.rewind(); + for (int j = 0; j < rightElements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + memset(destRecord, 0, dest.width * dest.height * sizeof(jfloat)); + + for (int rightCol = 0; rightCol < right.width; rightCol++) + { + for (int leftIndex = 0; leftIndex < left.width*left.height; leftIndex++) + { + destRecord[i % dest.height] += leftRecord[i] * rightRecord[i / leftSourceHeight]; + } + + rightRecord = &rightRecord[right.height]; + destRecord = &destRecord[dest.height]; + + } + dest.writeRecord(); + } + } + } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect * Method: execute @@ -61,6 +62,25 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + + dest.configureBuffer(source); + + int * sourceRecord, * destRecord; + + for (int i = 0; i < source.elements; i++) + { + sourceRecord = (int *) source.nextRecord(); + destRecord = (int *) dest.nextRecord(); + + // 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; + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpNegate_MatrixOpSafe * Method: execute @@ -61,6 +62,23 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, numElements, transposeDest); + + int * sourceRecord, * destRecord; + + for (int i = 0; i < source.elements; i++) + { + sourceRecord = (int *) source.nextRecord(); + destRecord = (int *) dest.nextRecord(); + + // 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; + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,11 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect.h" +#include "MatrixOpCommon.h" +#include <cmath> + +using namespace std; + /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpDirect * Method: execute @@ -61,6 +66,32 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + + dest.configureBuffer(source); + + float * sourceRecord, * destRecord; + float magnitude, magnitude_squared; + + int i; + register int j; + + for (i = 0; i < source.elements; i++) + { + + magnitude_squared = 0; + sourceRecord = source.nextRecord(); + destRecord = dest.nextRecord(); + + for (j = 0 ; j < sourceWidth*sourceHeight; i++) + magnitude_squared += sourceRecord[j] * sourceRecord[j]; + + magnitude = (float) sqrt((double) magnitude_squared); + + for (j = 0; j < sourceWidth*sourceHeight; i++) + destRecord[j] = sourceRecord[j] / magnitude; + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,11 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.h" +#include "MatrixOpCommon.h" +#include <cmath> + +using namespace std; + /* * Class: org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe * Method: execute @@ -61,6 +66,30 @@ jboolean transposeDest ) { - float * source = (float *) sourceAddress; - float * dest = (float *) destAddress; + SrcMatrix source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); + DstMatrix dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); + + float * sourceRecord, * destRecord; + float magnitude, magnitude_squared; + + int i; + register int j; + + for (i = 0; i < source.elements; i++) + { + + magnitude_squared = 0; + sourceRecord = source.nextRecord(); + destRecord = dest.nextRecord(); + + for (j = 0 ; j < sourceWidth*sourceHeight; i++) + magnitude_squared += sourceRecord[j] * sourceRecord[j]; + + magnitude = (float) sqrt((double) magnitude_squared); + + for (j = 0; j < sourceWidth*sourceHeight; i++) + destRecord[j] = sourceRecord[j] / magnitude; + + dest.writeRecord(); + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,7 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect.h" +#include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpSubtract_MatrixOpDirect * Method: execute @@ -67,9 +68,41 @@ jboolean transposeDest ) { - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; + if (transposeLeftSource && transposeRightSource) + { + transposeLeftSource = false; + transposeRightSource = false; + transposeDest = !transposeDest; + } + + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + left.width, left.height, left.elements * right.elements, transposeDest); + + dest.configureBuffer(left, right); + + float * leftRecord, * rightRecord, * destRecord; + + left.rewind(); + for (int i = 0; i < left.elements; i++) + { + leftRecord = left.nextRecord(); + + right.rewind(); + for (int j = 0; j < right.elements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + for (int k = (left.width * left.height) - 1; k >= 0; k--) + destRecord[k] = leftRecord[k] - rightRecord[k]; + + dest.writeRecord(); + } + } } 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.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp 24 Aug 2002 21:16:53 -0000 1.1 +++ org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.cpp 28 Aug 2002 16:45:24 -0000 1.2 @@ -41,6 +41,8 @@ #include <windows.h> #include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.h" +#include "MatrixOpCommon.h" + /* * Class: org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe * Method: execute @@ -67,9 +69,40 @@ jboolean transposeDest ) { - float * leftSource = (float *) leftSourceAddress; - float * rightSource = (float *) rightSourceAddress; - float * dest = (float *) destAddress; + if (transposeLeftSource && transposeRightSource) + { + transposeLeftSource = false; + transposeRightSource = false; + transposeDest = !transposeDest; + } + + SrcMatrix left (leftSourceAddress, leftSourceStride, + leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); + SrcMatrix right (rightSourceAddress, leftSourceStride, + rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); + DstMatrix dest (destAddress, destStride, + left.width, left.height, left.elements * right.elements, transposeDest); + + float * leftRecord, * rightRecord, * destRecord; + + left.rewind(); + for (int i = 0; i < left.elements; i++) + { + leftRecord = left.nextRecord(); + + right.rewind(); + for (int j = 0; j < right.elements; j++) + { + rightRecord = right.nextRecord(); + destRecord = dest.nextRecord(); + + for (int k = (left.width * left.height) - 1; k >= 0; k--) + destRecord[k] = leftRecord[k] - rightRecord[k]; + + dest.writeRecord(); + } + } } + |
|
From: Brian M. <ma...@us...> - 2002-08-28 14:17:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory usw-pr-cvs1:/tmp/cvs-serv22616/org/lwjgl/openal/test Modified Files: ALTest.java Log Message: add: more tests Index: ALTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ALTest.java 28 Aug 2002 01:19:59 -0000 1.1 +++ ALTest.java 28 Aug 2002 14:17:06 -0000 1.2 @@ -504,18 +504,18 @@ do { System.out.print("\n\n\nAutomated Test Series:\n\n"); - System.out.print("A) Run Fully Automated Tests\n"); - System.out.print("B) Run Semi-Automated Tests\n"); + System.out.print("*A) Run Fully Automated Tests\n"); + System.out.print("*B) Run Semi-Automated Tests\n"); System.out.print("\nInteractive Tests:\n\n"); System.out.print("1 Position Test\n"); System.out.print("2 Looping Test\n"); - System.out.print("3 EAX 2.0 Test\n"); [...1085 lines suppressed...] + if ((error = al.getError()) != AL.NO_ERROR) + displayALError("alSourcePlay : ", error); + + // Delay a little + delay_ms(100); + } + break; + case '2': + al.sourceStopv(numSources, Sources); + if ((error = al.getError()) != AL.NO_ERROR) + displayALError("alSourceStopv : ", error); + break; + } + } while (ch != 'Q'); + + // Delete the Sources + al.deleteSources(numSources, Sources); } /** |
|
From: Brian M. <ma...@us...> - 2002-08-28 12:57:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal In directory usw-pr-cvs1:/tmp/cvs-serv12139/org/lwjgl/openal Added Files: OpenALException.java Log Message: initial import --- NEW FILE: OpenALException.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/OpenALException.java /* * 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. */ package org.lwjgl.openal; /** * $Id: OpenALException.java,v 1.1 2002/08/28 12:56:55 matzon Exp $ * * Thrown by the debug build library of the LWJGL if any OpenAL operation * causes an error. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class OpenALException extends RuntimeException { /** * Constructor for OpenALException. */ public OpenALException() { super(); } /** * Constructor for OpenALException. * @param message */ public OpenALException(String message) { super(message); } /** * Constructor for OpenALException. * @param message * @param cause */ public OpenALException(String message, Throwable cause) { super(message, cause); } /** * Constructor for OpenALException. * @param cause */ public OpenALException(Throwable cause) { super(cause); } } |
|
From: Brian M. <ma...@us...> - 2002-08-28 01:20:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory usw-pr-cvs1:/tmp/cvs-serv11094/org/lwjgl/openal/test Added Files: ALTest.java Log Message: initial import of ALTest - conversion of altest.c - work in progress --- NEW FILE: ALTest.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java /* * 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. */ package org.lwjgl.openal.test; import org.lwjgl.openal.AL; import org.lwjgl.openal.ALC; import org.lwjgl.openal.ALCcontext; import org.lwjgl.openal.ALCdevice; import org.lwjgl.openal.ALUT; import org.lwjgl.openal.ALUTLoadWAVData; import org.lwjgl.Sys; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.io.IOException; /** * $Id: ALTest.java,v 1.1 2002/08/28 01:19:59 matzon Exp $ * * This class tests al functionality, much like altest.c * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ public class ALTest extends BasicTest { /** number of buffers used */ public static final int NUM_BUFFERS = 7; /** buffers used */ protected int[] buffers = new int[NUM_BUFFERS]; /** enumerations string */ protected String[] enumerationString = new String[]{ "AL_INVALID", "AL_INVALID", "ALC_INVALID", "AL_NONE", "AL_FALSE", "ALC_FALSE", "AL_TRUE", "ALC_TRUE", "AL_SOURCE_RELATIVE", "AL_CONE_INNER_ANGLE", "AL_CONE_OUTER_ANGLE", "AL_PITCH", "AL_POSITION", "AL_DIRECTION", "AL_VELOCITY", "AL_LOOPING", "AL_BUFFER", "AL_GAIN", "AL_MIN_GAIN", "AL_MAX_GAIN", "AL_ORIENTATION", "AL_REFERENCE_DISTANCE", "AL_ROLLOFF_FACTOR", "AL_CONE_OUTER_GAIN", "AL_MAX_DISTANCE", "AL_SOURCE_STATE", "AL_INITIAL", "AL_PLAYING", "AL_PAUSED", "AL_STOPPED", "AL_BUFFERS_QUEUED", "AL_BUFFERS_PROCESSED", "AL_FORMAT_MONO8", "AL_FORMAT_MONO16", "AL_FORMAT_STEREO8", "AL_FORMAT_STEREO16", "AL_FREQUENCY", "AL_SIZE", "AL_UNUSED", "AL_PENDING", "AL_PROCESSED", "ALC_MAJOR_VERSION", "ALC_MINOR_VERSION", "ALC_ATTRIBUTES_SIZE", "ALC_ALL_ATTRIBUTES", "ALC_DEFAULT_DEVICE_SPECIFIER", "ALC_DEVICE_SPECIFIER", "ALC_EXTENSIONS", "ALC_FREQUENCY", "ALC_REFRESH", "ALC_SYNC", "AL_NO_ERROR", "AL_INVALID_NAME", "AL_INVALID_ENUM", "AL_INVALID_VALUE", "AL_INVALID_OPERATION", "AL_OUT_OF_MEMORY", "ALC_NO_ERROR", "ALC_INVALID_DEVICE", "ALC_INVALID_CONTEXT", "ALC_INVALID_ENUM", "ALC_INVALID_VALUE", "ALC_OUT_OF_MEMORY", "AL_VENDOR", "AL_VERSION", "AL_RENDERER", "AL_EXTENSIONS", "AL_DOPPLER_FACTOR", "AL_DOPPLER_VELOCITY", "AL_DISTANCE_MODEL", "AL_INVERSE_DISTANCE", "AL_INVERSE_DISTANCE_CLAMPED" }; /** enumerations string */ protected int[] enumeration = new int[]{ AL.INVALID, AL.INVALID, ALC.INVALID, AL.NONE, AL.FALSE, ALC.FALSE, AL.TRUE, ALC.TRUE, AL.SOURCE_RELATIVE, AL.CONE_INNER_ANGLE, AL.CONE_OUTER_ANGLE, AL.PITCH, AL.POSITION, AL.DIRECTION, AL.VELOCITY, AL.LOOPING, AL.BUFFER, AL.GAIN, AL.MIN_GAIN, AL.MAX_GAIN, AL.ORIENTATION, AL.REFERENCE_DISTANCE, AL.ROLLOFF_FACTOR, AL.CONE_OUTER_GAIN, AL.MAX_DISTANCE, AL.SOURCE_STATE, AL.INITIAL, AL.PLAYING, AL.PAUSED, AL.STOPPED, AL.BUFFERS_QUEUED, AL.BUFFERS_PROCESSED, AL.FORMAT_MONO8, AL.FORMAT_MONO16, AL.FORMAT_STEREO8, AL.FORMAT_STEREO16, AL.FREQUENCY, AL.SIZE, AL.UNUSED, AL.PENDING, AL.PROCESSED, ALC.MAJOR_VERSION, ALC.MINOR_VERSION, ALC.ATTRIBUTES_SIZE, ALC.ALL_ATTRIBUTES, ALC.DEFAULT_DEVICE_SPECIFIER, ALC.DEVICE_SPECIFIER, ALC.EXTENSIONS, ALC.FREQUENCY, ALC.REFRESH, ALC.SYNC, AL.NO_ERROR, AL.INVALID_NAME, AL.INVALID_ENUM, AL.INVALID_VALUE, AL.INVALID_OPERATION, AL.OUT_OF_MEMORY, ALC.NO_ERROR, ALC.INVALID_DEVICE, ALC.INVALID_CONTEXT, ALC.INVALID_ENUM, ALC.INVALID_VALUE, ALC.OUT_OF_MEMORY, AL.VENDOR, AL.VERSION, AL.RENDERER, AL.EXTENSIONS, AL.DOPPLER_FACTOR, AL.DOPPLER_VELOCITY, AL.DISTANCE_MODEL, AL.INVERSE_DISTANCE, AL.INVERSE_DISTANCE_CLAMPED }; /** * Creates an instance of ALTest */ public ALTest() { super(); } /** * Sleeeeeep */ protected void delay_ms(long ms) { try { Thread.sleep(ms); } catch (InterruptedException inte) { inte.printStackTrace(); } } /** * Display error */ protected void displayALError(String text, int errorcode) { System.out.println(text + " - " + al.getString(errorcode)); } /** * Runs the actual test, using supplied arguments */ protected void execute(String[] args) { String szEAX = "EAX"; String szFnName; int ch = -1; int error; ALCcontext context; ALCdevice device; ByteBuffer listenerPos = ByteBuffer.allocateDirect(12); listenerPos.order(ByteOrder.nativeOrder()); listenerPos.putFloat(0.0f); listenerPos.putFloat(0.0f); listenerPos.putFloat(0.0f); ByteBuffer listenerVel = ByteBuffer.allocateDirect(12); listenerVel.order(ByteOrder.nativeOrder()); listenerVel.putFloat(0.0f); listenerVel.putFloat(0.0f); listenerVel.putFloat(0.0f); ByteBuffer listenerOri = ByteBuffer.allocateDirect(24); listenerOri.order(ByteOrder.nativeOrder()); listenerOri.putFloat(0.0f); listenerOri.putFloat(0.0f); listenerOri.putFloat(-1.0f); listenerOri.putFloat(0.0f); listenerOri.putFloat(1.0f); listenerOri.putFloat(0.0f); System.out.print("OpenAL Test Application (Java!)\n"); System.out.print("=======================\n\n"); // Initialize Open AL manually //Open device device = alc.openDevice("DirectSound3D"); //Create context(s) context = alc.createContext(device, 0); //Set active context alc.makeContextCurrent(context); // Clear Error Code al.getError(); // Set Listener attributes // Position ... al.listenerfv(AL.POSITION, Sys.getDirectBufferAddress(listenerPos)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alListenerfv POSITION : ", error); System.exit(-1); } // Velocity ... al.listenerfv(AL.VELOCITY, Sys.getDirectBufferAddress(listenerVel)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alListenerfv VELOCITY : ", error); System.exit(-1); } // Orientation ... al.listenerfv(AL.ORIENTATION, Sys.getDirectBufferAddress(listenerOri)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alListenerfv ORIENTATION : ", error); System.exit(-1); } // Generate Buffers al.genBuffers(NUM_BUFFERS, buffers); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alGenBuffers :", error); System.exit(-1); } // Load in samples to be used by Test functions // Load footsteps.wav ALUTLoadWAVData data = alut.loadWAVFile("footsteps.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile footsteps.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy footsteps.wav data into AL Buffer 0 al.bufferData(buffers[0], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 0 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload footsteps.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load ding.wav data = alut.loadWAVFile("ding.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile ding.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy ding.wav data into AL Buffer 1 al.bufferData(buffers[1], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 1 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload footsteps.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load wave1.wav data = alut.loadWAVFile("wave1.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave1.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy wave1.wav data into AL Buffer 2 al.bufferData(buffers[2], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 2 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload wave1.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load Wave2.wav data = alut.loadWAVFile("Wave2.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile Wave2.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy Wave2.wav data into AL Buffer 3 al.bufferData(buffers[3], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 3 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload Wave2.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load wave3.wav data = alut.loadWAVFile("wave3.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave3.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy wave3.wav data into AL Buffer 4 al.bufferData(buffers[4], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 4 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload wave3.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load wave4.wav data = alut.loadWAVFile("wave4.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave4.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy wave4.wav data into AL Buffer 5 al.bufferData(buffers[5], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 5 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload wave4.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Load stereo.wav data = alut.loadWAVFile("stereo.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile stereo.wav : ", error); // Delete Buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Copy stereo.wav data into AL Buffer 6 al.bufferData(buffers[6], data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alBufferData buffer 6 : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } // Unload stereo.wav alut.unloadWAV(data.format, data.data, data.size, data.freq); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutUnloadWAV : ", error); // Delete buffers al.deleteBuffers(NUM_BUFFERS, buffers); System.exit(-1); } do { System.out.print("\n\n\nAutomated Test Series:\n\n"); System.out.print("A) Run Fully Automated Tests\n"); System.out.print("B) Run Semi-Automated Tests\n"); System.out.print("\nInteractive Tests:\n\n"); System.out.print("1 Position Test\n"); System.out.print("2 Looping Test\n"); System.out.print("3 EAX 2.0 Test\n"); System.out.print("4 Queue Test\n"); System.out.print("5 Buffer Test\n"); System.out.print("6 Frequency Test\n"); System.out.print("7 Stereo Test\n"); System.out.print("8 Gain Test\n"); System.out.print("9 Streaming Test\n"); System.out.print("0 Multiple Sources Test\n"); System.out.print("\nQ to quit\n\n\n"); try { ch = System.in.read(); } catch (IOException ioe) { } switch (ch) { case 'A': fullAutoTests(); break; case 'B': semiAutoTests(); break; case '1': i_PositionTest(); break; case '2': i_LoopingTest(); break; case '3': i_EAXTest(); break; case '4': i_QueueTest(); break; case '5': i_BufferTest(); break; case '6': i_FreqTest(); break; case '7': i_StereoTest(); break; case '8': i_GainTest(); break; case '9': i_StreamingTest(); break; case '0': i_MultipleSourcesTest(); break; default: break; } } while (ch != 'Q'); } protected void fullAutoTests() { System.out.println("fullAutoTests"); delay_ms(3000); } protected void semiAutoTests() { System.out.println("semiAutoTests"); delay_ms(3000); } protected void i_PositionTest() { int error; int[] source = new int[2]; int ch = -1; ByteBuffer source0Pos = ByteBuffer.allocateDirect(12); source0Pos.order(ByteOrder.nativeOrder()); source0Pos.putFloat(-2.0f); source0Pos.putFloat(0.0f); source0Pos.putFloat(2.0f); ByteBuffer source0Vel = ByteBuffer.allocateDirect(12); source0Vel.order(ByteOrder.nativeOrder()); source0Vel.putFloat(0.0f); source0Vel.putFloat(0.0f); source0Vel.putFloat(0.0f); ByteBuffer source1Pos = ByteBuffer.allocateDirect(12); source1Pos.order(ByteOrder.nativeOrder()); source1Pos.putFloat(2.0f); source1Pos.putFloat(0.0f); source1Pos.putFloat(-2.0f); ByteBuffer source1Vel = ByteBuffer.allocateDirect(12); source1Vel.order(ByteOrder.nativeOrder()); source1Vel.putFloat(0.0f); source1Vel.putFloat(0.0f); source1Vel.putFloat(0.0f); al.genSources(2, source); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alGenSources 2 : ", error); return; } al.sourcef(source[0],AL.PITCH,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 0 AL_PITCH : \n", error); } al.sourcef(source[0],AL.GAIN,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 0 AL_GAIN : \n", error); } al.sourcefv(source[0],AL.POSITION,Sys.getDirectBufferAddress(source0Pos)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 0 AL_POSITION : \n", error); } al.sourcefv(source[0],AL.VELOCITY,Sys.getDirectBufferAddress(source0Vel)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 0 AL_VELOCITY : \n", error); } al.sourcei(source[0],AL.BUFFER, buffers[1]); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 0 AL_BUFFER buffer 0 : \n", error); } al.sourcei(source[0],AL.LOOPING,AL.TRUE); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 0 AL_LOOPING true: \n", error); } al.sourcef(source[1],AL.PITCH,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 1 AL_PITCH : \n", error); } al.sourcef(source[1],AL.GAIN,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 1 AL_GAIN : \n", error); } al.sourcefv(source[1],AL.POSITION,Sys.getDirectBufferAddress(source1Pos)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 1 AL_POSITION : \n", error); } al.sourcefv(source[1],AL.VELOCITY,Sys.getDirectBufferAddress(source1Vel)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 1 AL_VELOCITY : \n", error); } al.sourcei(source[1],AL.BUFFER, buffers[1]); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 1 AL_BUFFER buffer 1 : \n", error); } al.sourcei(source[1],AL.LOOPING,AL.FALSE); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 1 AL_LOOPING false: \n", error); } System.out.print("Position Test\n"); System.out.print("Press '1' to play source 0 (looping) rear left of listener\n"); System.out.print("Press '2' to play source 1 once (single shot) front right of listener\n"); System.out.print("Press '3' to stop source 0\n"); System.out.print("Press '4' to stop source 1\n"); System.out.print("Press 'Q' to quit\n"); do { try { ch = System.in.read(); } catch (IOException ioe) { } switch (ch) { case '1': al.sourcePlay(source[0]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourcePlay source 0 : ", error); break; case '2': al.sourcePlay(source[1]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourcePlay source 1 : ", error); break; case '3': al.sourceStop(source[0]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourceStop source 0 : ", error); break; case '4': al.sourceStop(source[1]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourceStop source 1 : ", error); break; } } while (ch != 'Q'); // Release resources al.sourceStopv(2, source); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourceStopv 2 : ", error); al.deleteSources(2, source); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alDeleteSources 2 : ", error); return; } protected void i_LoopingTest() { int error; int[] source = new int[2]; int ch = -1; int bLooping0 = AL.FALSE; int bLooping1 = AL.FALSE; ByteBuffer source0Pos = ByteBuffer.allocateDirect(12); source0Pos.order(ByteOrder.nativeOrder()); source0Pos.putFloat(-2.0f); source0Pos.putFloat(0.0f); source0Pos.putFloat(-2.0f); ByteBuffer source0Vel = ByteBuffer.allocateDirect(12); source0Vel.order(ByteOrder.nativeOrder()); source0Vel.putFloat(0.0f); source0Vel.putFloat(0.0f); source0Vel.putFloat(0.0f); ByteBuffer source1Pos = ByteBuffer.allocateDirect(12); source1Pos.order(ByteOrder.nativeOrder()); source1Pos.putFloat(2.0f); source1Pos.putFloat(0.0f); source1Pos.putFloat(-2.0f); ByteBuffer source1Vel = ByteBuffer.allocateDirect(12); source1Vel.order(ByteOrder.nativeOrder()); source1Vel.putFloat(0.0f); source1Vel.putFloat(0.0f); source1Vel.putFloat(0.0f); // Clear Error Code al.getError(); al.genSources(2,source); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alGenSources 1 : ", error); return; } al.sourcef(source[0],AL.PITCH,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 0 AL_PITCH : \n", error); } al.sourcef(source[0],AL.GAIN,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 0 AL_GAIN : \n", error); } al.sourcefv(source[0],AL.POSITION,Sys.getDirectBufferAddress(source0Pos)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 0 AL_POSITION : \n", error); } al.sourcefv(source[0],AL.VELOCITY,Sys.getDirectBufferAddress(source0Vel)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 0 AL_VELOCITY : \n", error); } al.sourcei(source[0],AL.BUFFER, buffers[0]); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 0 AL_BUFFER buffer 0 : \n", error); } al.sourcei(source[0],AL.LOOPING,AL.FALSE); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 0 AL_LOOPING false : \n", error); } al.sourcef(source[1],AL.PITCH,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 1 AL_PITCH : \n", error); } al.sourcef(source[1],AL.GAIN,1.0f); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcef 1 AL_GAIN : \n", error); } al.sourcefv(source[1],AL.POSITION,Sys.getDirectBufferAddress(source1Pos)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 1 AL_POSITION : \n", error); } al.sourcefv(source[1],AL.VELOCITY,Sys.getDirectBufferAddress(source1Vel)); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcefv 1 AL_VELOCITY : \n", error); } al.sourcei(source[1],AL.BUFFER, buffers[1]); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 1 AL_BUFFER buffer 1 : \n", error); } al.sourcei(source[1],AL.LOOPING,AL.FALSE); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alSourcei 1 AL_LOOPING false: \n", error); } System.out.print("Looping Test\n"); System.out.print("Press '1' to play source 0 once (single shot)\n"); System.out.print("Press '2' to toggle looping on source 0\n"); System.out.print("Press '3' to play source 1 once (single shot)\n"); System.out.print("Press '4' to toggle looping on source 1\n"); System.out.print("Press 'Q' to quit\n"); System.out.print("\nSource 0 : Not looping Source 1 : Not looping\n"); do { try { ch = System.in.read(); } catch (IOException ioe) { } switch (ch) { case '1': al.sourcePlay(source[0]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourcePlay source 0 : ", error); break; case '2': if (bLooping0 == AL.FALSE) { bLooping0 = AL.TRUE; if (bLooping1 == AL.TRUE) System.out.print("Source 0 : Looping Source 1 : Looping \n"); else System.out.print("Source 0 : Looping Source 1 : Not looping\n"); } else { bLooping0 = AL.FALSE; if (bLooping1 == AL.TRUE) System.out.print("Source 0 : Not looping Source 1 : Looping \n"); else System.out.print("Source 0 : Not looping Source 1 : Not looping\n"); } al.sourcei(source[0], AL.LOOPING, bLooping0); break; case '3': al.sourcePlay(source[1]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourcePlay source 1 : ", error); break; case '4': if (bLooping1 == AL.FALSE) { bLooping1 = AL.TRUE; if (bLooping0 == AL.TRUE) System.out.print("Source 0 : Looping Source 1 : Looping \n"); else System.out.print("Source 0 : Not looping Source 1 : Looping \n"); } else { bLooping1 = AL.FALSE; if (bLooping0 == AL.TRUE) System.out.print("Source 0 : Looping Source 1 : Not looping\n"); else System.out.print("Source 0 : Not looping Source 1 : Not looping\n"); } al.sourcei(source[1], AL.LOOPING, bLooping1); break; } } while (ch != 'Q'); System.out.print("\n"); // Release resources al.sourceStop(source[0]); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourceStop source 1 : ", error); al.deleteSources(2, source); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alDeleteSources 1 : ", error); return; } protected void i_EAXTest() { System.out.println("i_EAXTest"); delay_ms(3000); } protected void i_QueueTest() { System.out.println("i_QueueTest"); delay_ms(3000); } protected void i_BufferTest() { System.out.println("i_BufferTest"); delay_ms(3000); } protected void i_FreqTest() { System.out.println("i_FreqTest"); delay_ms(3000); } protected void i_StereoTest() { System.out.println("i_StereoTest"); delay_ms(3000); } protected void i_GainTest() { System.out.println("i_GainTest"); delay_ms(3000); } protected void i_StreamingTest() { System.out.println("i_StreamingTest"); delay_ms(3000); } protected void i_MultipleSourcesTest() { System.out.println("i_MultipleSourcesTest"); delay_ms(3000); } /** * main entry point * * @param args String array containing arguments */ public static void main(String[] args) { ALTest alTest = new ALTest(); alTest.execute(args); } } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2002-08-28 00:06:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector In directory usw-pr-cvs1:/tmp/cvs-serv15688/src/java/org/lwjgl/vector Modified Files: Matrix2f.java Vector3f.java Matrix4f.java Vector2f.java Vector.java Matrix.java Matrix3f.java Log Message: Fixes Index: Matrix2f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix2f.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Matrix2f.java 26 Aug 2002 20:24:29 -0000 1.7 +++ Matrix2f.java 28 Aug 2002 00:05:45 -0000 1.8 @@ -84,8 +84,8 @@ public Matrix load(FloatBuffer buf) { m00 = buf.get(); - m10 = buf.get(); m01 = buf.get(); + m10 = buf.get(); m11 = buf.get(); return this; @@ -101,8 +101,8 @@ public Matrix loadTranspose(FloatBuffer buf) { m00 = buf.get(); - m01 = buf.get(); m10 = buf.get(); + m01 = buf.get(); m11 = buf.get(); return this; @@ -115,8 +115,8 @@ */ public Matrix store(FloatBuffer buf) { buf.put(m00); - buf.put(m10); buf.put(m01); + buf.put(m10); buf.put(m11); return this; } @@ -128,8 +128,8 @@ */ public Matrix storeTranspose(FloatBuffer buf) { buf.put(m00); - buf.put(m01); buf.put(m10); + buf.put(m01); buf.put(m11); return this; } @@ -293,6 +293,7 @@ * @return this */ public Matrix invert() { + assert false : "Not implemented yet!"; return this; } @@ -356,6 +357,7 @@ * @see org.lwjgl.vector.Matrix#determinant() */ public float determinant() { + assert false : "Not implemented yet!"; return 0; } Index: Vector3f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector3f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector3f.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Vector3f.java 26 Aug 2002 20:24:29 -0000 1.5 +++ Vector3f.java 28 Aug 2002 00:05:45 -0000 1.6 @@ -143,6 +143,32 @@ return dest.set(left.x - right.x, left.y - right.y, left.z - right.z); } } + + /** + * The cross product of two vectors. + * + * @param left The LHS vector + * @param right The RHS vector + * @param dest The destination result, or null if a new vector is to be created + * @return left cross right + */ + public static Vector3f cross( + Vector3f left, + Vector3f right, + Vector3f dest) + { + + if (dest == null) + dest = new Vector3f(); + + dest.set( + left.y * right.z - left.z * right.y, + right.x * left.z - right.z * left.x, + left.x * right.y - left.y * right.x + ); + + return dest; + } Index: Matrix4f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix4f.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Matrix4f.java 26 Aug 2002 20:24:29 -0000 1.8 +++ Matrix4f.java 28 Aug 2002 00:05:45 -0000 1.9 @@ -39,6 +39,16 @@ * @author foo */ public class Matrix4f extends Matrix { + + public float m00 = 1.0f, m01, m02, m03, m10, m11 = 1.0f, m12, m13, m20, m21, m22 = 1.0f, m23, m30, m31, m32, m33 = 1.0f; + + /** + * Construct a Matrix4f + */ + public Matrix4f() { + super(); + } + /** * Set this matrix to be the identity matrix. * @return this @@ -91,15 +101,6 @@ } - - public float m00 = 1.0f, m01, m02, m03, m10, m11 = 1.0f, m12, m13, m20, m21, m22 = 1.0f, m23, m30, m31, m32, m33 = 1.0f; - - /** - * Construct a Matrix4f - */ - public Matrix4f() { - super(); - } /** * Load from another matrix4f * @param src The source matrix @@ -137,20 +138,20 @@ public Matrix load(FloatBuffer buf) { m00 = buf.get(); - m10 = buf.get(); - m20 = buf.get(); - m30 = buf.get(); m01 = buf.get(); - m11 = buf.get(); - m21 = buf.get(); - m31 = buf.get(); m02 = buf.get(); - m12 = buf.get(); - m22 = buf.get(); - m32 = buf.get(); m03 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); m13 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); m23 = buf.get(); + m30 = buf.get(); + m31 = buf.get(); + m32 = buf.get(); m33 = buf.get(); return this; @@ -166,20 +167,20 @@ public Matrix loadTranspose(FloatBuffer buf) { m00 = buf.get(); - m01 = buf.get(); - m02 = buf.get(); - m03 = buf.get(); m10 = buf.get(); - m11 = buf.get(); - m12 = buf.get(); - m13 = buf.get(); m20 = buf.get(); - m21 = buf.get(); - m22 = buf.get(); - m23 = buf.get(); m30 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); m31 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); m32 = buf.get(); + m03 = buf.get(); + m13 = buf.get(); + m23 = buf.get(); m33 = buf.get(); return this; @@ -192,20 +193,20 @@ */ public Matrix store(FloatBuffer buf) { buf.put(m00); - buf.put(m10); - buf.put(m20); - buf.put(m30); buf.put(m01); - buf.put(m11); - buf.put(m21); - buf.put(m31); buf.put(m02); - buf.put(m12); - buf.put(m22); - buf.put(m32); buf.put(m03); + buf.put(m10); + buf.put(m11); + buf.put(m12); buf.put(m13); + buf.put(m20); + buf.put(m21); + buf.put(m22); buf.put(m23); + buf.put(m30); + buf.put(m31); + buf.put(m32); buf.put(m33); return this; } @@ -217,20 +218,20 @@ */ public Matrix storeTranspose(FloatBuffer buf) { buf.put(m00); - buf.put(m01); - buf.put(m02); - buf.put(m03); buf.put(m10); - buf.put(m11); - buf.put(m12); - buf.put(m13); buf.put(m20); - buf.put(m21); - buf.put(m22); - buf.put(m23); buf.put(m30); + buf.put(m01); + buf.put(m11); + buf.put(m21); buf.put(m31); + buf.put(m02); + buf.put(m12); + buf.put(m22); buf.put(m32); + buf.put(m03); + buf.put(m13); + buf.put(m23); buf.put(m33); return this; } @@ -425,6 +426,76 @@ } /** + * Translate this matrix + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector2f vec) { + m30 += m00 * vec.x + m10 * vec.y; + m31 += m01 * vec.x + m11 * vec.y; + m32 += m02 * vec.x + m12 * vec.y; + m33 += m03 * vec.x + m13 * vec.y; + return this; + } + + /** + * Translate this matrix + * @param vec The vector to translate by + * @return this + */ + public Matrix4f translate(Vector3f vec) { + m30 += m00 * vec.x + m10 * vec.y + m20 * vec.z; + m31 += m01 * vec.x + m11 * vec.y + m21 * vec.z; + m32 += m02 * vec.x + m12 * vec.y + m22 * vec.z; + m33 += m03 * vec.x + m13 * vec.y + m23 * vec.z; + return this; + } + + + + /** + * Translate this matrix and stash the result in another matrix + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector3f vec, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + else if (dest == this) + return translate(vec); + + dest.m30 += m00 * vec.x + m10 * vec.y + m20 * vec.z; + dest.m31 += m01 * vec.x + m11 * vec.y + m21 * vec.z; + dest.m32 += m02 * vec.x + m12 * vec.y + m22 * vec.z; + dest.m33 += m03 * vec.x + m13 * vec.y + m23 * vec.z; + + return dest; + } + + /** + * Translate this matrix and stash the result in another matrix + * @param vec The vector to translate by + * @param dest The destination matrix or null if a new matrix is to be created + * @return the translated matrix + */ + public Matrix4f translate(Vector2f vec, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + else if (dest == this) + return translate(vec); + + dest.m30 += m00 * vec.x + m10 * vec.y; + dest.m31 += m01 * vec.x + m11 * vec.y; + dest.m32 += m02 * vec.x + m12 * vec.y; + dest.m33 += m03 * vec.x + m13 * vec.y; + + return dest; + } + + + + /** * Transpose this matrix and place the result in another matrix * @param dest The destination matrix or null if a new matrix is to be created * @return the transposed matrix @@ -488,6 +559,7 @@ * @return this */ public Matrix invert() { + assert false : "Not implemented yet!"; return this; } Index: Vector2f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector2f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector2f.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Vector2f.java 26 Aug 2002 20:24:29 -0000 1.5 +++ Vector2f.java 28 Aug 2002 00:05:45 -0000 1.6 @@ -151,7 +151,7 @@ /** * The dot product of two vectors is calculated as - * v1.x * v2.x + v1.y * v2.y + * v1.x * v2.x + v1.y * v2.y + v1.z * v2.z * @param left The LHS vector * @param right The RHS vector * @return left dot right @@ -159,6 +159,8 @@ public static float dot(Vector2f left, Vector2f right) { return left.x * right.x + left.y * right.y; } + + /** * Calculate the angle between two vectors, in degrees Index: Vector.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Vector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Vector.java 26 Aug 2002 20:24:29 -0000 1.2 +++ Vector.java 28 Aug 2002 00:05:45 -0000 1.3 @@ -83,7 +83,7 @@ * Normalise this vector * @return this */ - public final Vector normalise() { + public final Vector normalize() { float l = 1.0f / length(); return scale(l); } Index: Matrix.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Matrix.java 26 Aug 2002 20:24:29 -0000 1.3 +++ Matrix.java 28 Aug 2002 00:05:45 -0000 1.4 @@ -36,7 +36,8 @@ /** * $Id$ * - * Base class for matrices. + * Base class for matrices. When a matrix is constructed it will be the identity + * matrix unless otherwise stated. * * @author cix_foo <ci...@us...> * @version $Revision$ Index: Matrix3f.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/vector/Matrix3f.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Matrix3f.java 26 Aug 2002 20:24:29 -0000 1.8 +++ Matrix3f.java 28 Aug 2002 00:05:45 -0000 1.9 @@ -90,13 +90,13 @@ public Matrix load(FloatBuffer buf) { m00 = buf.get(); - m10 = buf.get(); - m20 = buf.get(); m01 = buf.get(); - m11 = buf.get(); - m21 = buf.get(); m02 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); m12 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); m22 = buf.get(); return this; @@ -112,13 +112,13 @@ public Matrix loadTranspose(FloatBuffer buf) { m00 = buf.get(); - m01 = buf.get(); - m02 = buf.get(); m10 = buf.get(); - m11 = buf.get(); - m12 = buf.get(); m20 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); m21 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); m22 = buf.get(); return this; @@ -131,13 +131,13 @@ */ public Matrix store(FloatBuffer buf) { buf.put(m00); - buf.put(m10); - buf.put(m20); buf.put(m01); - buf.put(m11); - buf.put(m21); buf.put(m02); + buf.put(m10); + buf.put(m11); buf.put(m12); + buf.put(m20); + buf.put(m21); buf.put(m22); return this; } @@ -149,13 +149,13 @@ */ public Matrix storeTranspose(FloatBuffer buf) { buf.put(m00); - buf.put(m01); - buf.put(m02); buf.put(m10); - buf.put(m11); - buf.put(m12); buf.put(m20); + buf.put(m01); + buf.put(m11); buf.put(m21); + buf.put(m02); + buf.put(m12); buf.put(m22); return this; } @@ -366,6 +366,7 @@ * @return this */ public Matrix invert() { + assert false : "Not implemented yet!"; return this; } |