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
|
From: Elias N. <eli...@us...> - 2002-11-19 14:22:06
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory sc8-pr-cvs1:/tmp/cvs-serv7967/java/org/lwjgl/openal/test Modified Files: ALTest.java Log Message: Fixed filenames in ALTest.java 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.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- ALTest.java 12 Sep 2002 01:31:20 -0000 1.13 +++ ALTest.java 19 Nov 2002 14:22:02 -0000 1.14 @@ -299,7 +299,7 @@ // Initialize Open AL manually //Open device - device = alc.openDevice("DirectSound3D"); + device = alc.openDevice(null); //Create context(s) context = alc.createContext(device, 0); //Set active context @@ -341,7 +341,7 @@ // Load in samples to be used by Test functions // Load footsteps.wav - ALUTLoadWAVData data = alut.loadWAVFile("footsteps.wav"); + ALUTLoadWAVData data = alut.loadWAVFile("Footsteps.wav"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile footsteps.wav : ", error); // Delete Buffers @@ -395,7 +395,7 @@ } // Load wave1.wav - data = alut.loadWAVFile("wave1.wav"); + data = alut.loadWAVFile("Wave1.WAV"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave1.wav : ", error); // Delete Buffers @@ -422,7 +422,7 @@ } // Load Wave2.wav - data = alut.loadWAVFile("Wave2.wav"); + data = alut.loadWAVFile("Wave2.WAV"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile Wave2.wav : ", error); // Delete Buffers @@ -449,7 +449,7 @@ } // Load wave3.wav - data = alut.loadWAVFile("wave3.wav"); + data = alut.loadWAVFile("Wave3.WAV"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave3.wav : ", error); // Delete Buffers @@ -476,7 +476,7 @@ } // Load wave4.wav - data = alut.loadWAVFile("wave4.wav"); + data = alut.loadWAVFile("Wave4.WAV"); if ((error = al.getError()) != AL.NO_ERROR) { displayALError("alutLoadWAVFile wave4.wav : ", error); // Delete Buffers @@ -3279,4 +3279,4 @@ ALTest alTest = new ALTest(); alTest.execute(args); } -} \ No newline at end of file +} |
From: Elias N. <eli...@us...> - 2002-11-19 14:08:24
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv3348 Modified Files: Makefile Added Files: org_lwjgl_openal_ALC.cpp org_lwjgl_openal_ALUT.cpp org_lwjgl_openal_BaseAL.cpp org_lwjgl_openal_CoreAL.cpp org_lwjgl_openal_eax_EAXBufferProperties.cpp org_lwjgl_openal_eax_EAXListenerProperties.cpp Log Message: Initial OpenAL linux support --- NEW FILE: org_lwjgl_openal_ALC.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_ALC.cpp /* * 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: org_lwjgl_openal_ALC.cpp,v 1.1 2002/11/19 14:08:21 elias_naur Exp $ * * This is the actual JNI implementation of the OpenAL context/device library. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_openal_ALC.h" #include "checkALerror.h" /* OpenAL includes */ #include <AL/alc.h> /* * Class: org_lwjgl_openal_ALC * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_nCreate (JNIEnv *env, jobject obj) { return true; } /* * Class: org_lwjgl_openal_ALC * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_nDestroy (JNIEnv *env, jobject obj) { } /** * This function returns strings related to the context. * * C Specification: * ALubyte * alcGetString(ALCdevice *device, ALenum token); */ JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_ALC_getString (JNIEnv *env, jobject obj, jobject device, jint token) { jclass class_device = env->GetObjectClass(device); jfieldID field_device = env->GetFieldID(class_device, "device", "I"); jint deviceaddress = env->GetIntField(device, field_device); const char* alcString = (const char*) alcGetString((ALCdevice*) deviceaddress, (ALenum) token); if(alcString == NULL) { return NULL; } jstring string = env->NewStringUTF(alcString); CHECK_ALC_ERROR return string; } /** * This function returns integers related to the context. * * C Specification: * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_getIntegerv (JNIEnv *env, jobject obj, jobject device, jint token, jint size, jint dest) { jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); alcGetIntegerv((ALCdevice*) deviceaddress, (ALenum) token, (ALsizei) size, (ALint*) dest); CHECK_ALC_ERROR } /** * This function opens a device by name. * * C Specification: * ALCdevice *alcOpenDevice( const ALubyte *tokstr ); */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_openDevice (JNIEnv *env, jobject obj, jstring tokstr) { ALubyte* tokenstring; if(tokstr != NULL) { tokenstring = (ALubyte*) (env->GetStringUTFChars(tokstr, 0)); } else { tokenstring = NULL; } /* get device */ ALCdevice* device = alcOpenDevice(tokenstring); /* if error - cleanup and get out */ if(device == NULL) { if(tokenstring != NULL) { env->ReleaseStringUTFChars((jstring)tokenstring, 0); } return NULL; } /* get ready to create ALCdevice instance */ jobject alcDevice_object = NULL; jclass alcDevice_class = NULL; jmethodID alcDevice_method = NULL; /* find class and constructor */ alcDevice_class = env->FindClass("org/lwjgl/openal/ALCdevice"); alcDevice_method = env->GetMethodID(alcDevice_class, "<init>", "(I)V"); /* create instance */ alcDevice_object = env->NewObject(alcDevice_class, alcDevice_method, (int) device); /* clean up */ env->ReleaseStringUTFChars((jstring)tokenstring, 0); return alcDevice_object; } /** * This function closes a device by name. * * C Specification: * void alcCloseDevice( ALCdevice *dev ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_closeDevice (JNIEnv *env, jobject obj, jobject device) { jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); alcCloseDevice((ALCdevice*) deviceaddress); CHECK_ALC_ERROR } /** * This function creates a context using a specified device. * * C Specification: * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist ); */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_createContext (JNIEnv *env, jobject obj, jobject device, jint attrlist) { /* get device address */ jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); ALCcontext* context = alcCreateContext((ALCdevice*) deviceaddress, (ALint*) attrlist); /* if error - get out */ if(context == NULL) { return NULL; } /* get ready to create ALCcontext instance */ jobject alcContext_object = NULL; jclass alcContext_class = NULL; jmethodID alcContext_method = NULL; /* find class and constructor */ alcContext_class = env->FindClass("org/lwjgl/openal/ALCcontext"); alcContext_method = env->GetMethodID(alcContext_class, "<init>", "(I)V"); /* create instance */ alcContext_object = env->NewObject(alcContext_class, alcContext_method, (int) context); CHECK_ALC_ERROR return alcContext_object; } /** * This function makes a specified context the current context. * * C Specification: * ALCboolean alcMakeContextCurrent(ALCcontext *context); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_makeContextCurrent (JNIEnv *env, jobject obj, jobject context) { if(context == NULL) { return alcMakeContextCurrent(NULL); } /* get context address */ jclass context_class = env->GetObjectClass(context); jfieldID context_field = env->GetFieldID(context_class, "context", "I"); jint contextaddress = env->GetIntField(context, context_field); return alcMakeContextCurrent((ALCcontext*) contextaddress); } /** * This function tells a context to begin processing. * * C Specification: * void alcProcessContext(ALCcontext *context); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_processContext (JNIEnv *env, jobject obj, jobject context) { /* get context address */ jclass context_class = env->GetObjectClass(context); jfieldID context_field = env->GetFieldID(context_class, "context", "I"); jint contextaddress = env->GetIntField(context, context_field); alcProcessContext((ALCcontext*) contextaddress); } /** * This function retrieves the current context. * * C Specification: * ALCcontext* alcGetCurrentContext( ALvoid ); */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_getCurrentContext (JNIEnv *env, jobject obj) { ALCcontext* context = alcGetCurrentContext(); if(context == NULL) { return NULL; } /* get ready to create ALCcontext instance */ jobject alcContext_object = NULL; jclass alcContext_class = NULL; jmethodID alcContext_method = NULL; /* find class and constructor */ alcContext_class = env->FindClass("org/lwjgl/openal/ALCcontext"); alcContext_method = env->GetMethodID(alcContext_class, "<init>", "(I)V"); /* create instance */ alcContext_object = env->NewObject(alcContext_class, alcContext_method, (int) context); return alcContext_object; } /** * This function retrieves the specified contexts device * * C Specification: * ALCdevice* alcGetContextsDevice(ALCcontext *context); */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALC_getContextsDevice (JNIEnv *env, jobject obj, jobject context) { /* get context address */ jclass context_class = env->GetObjectClass(context); jfieldID context_field = env->GetFieldID(context_class, "context", "I"); jint contextaddress = env->GetIntField(context, context_field); ALCdevice* device = alcGetContextsDevice((ALCcontext*) contextaddress); if(device == NULL) { return NULL; } /* get ready to create ALCdevice instance */ jobject alcDevice_object = NULL; jclass alcDevice_class = NULL; jmethodID alcDevice_method = NULL; /* find class and constructor */ alcDevice_class = env->FindClass("org/lwjgl/openal/ALCdevice"); alcDevice_method = env->GetMethodID(alcDevice_class, "<init>", "(I)V"); /* create instance */ alcDevice_object = env->NewObject(alcDevice_class, alcDevice_method, (int) device); return alcDevice_object; } /** * This function suspends processing on a specified context. * * C Specification: * void alcSuspendContext(ALCcontext *context); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_suspendContext (JNIEnv *env, jobject obj, jobject context) { /* get context address */ jclass context_class = env->GetObjectClass(context); jfieldID context_field = env->GetFieldID(context_class, "context", "I"); jint contextaddress = env->GetIntField(context, context_field); alcSuspendContext((ALCcontext*) contextaddress); } /** * This function destroys a context. * * C Specification: * void alcDestroyContext(ALCcontext *context); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_destroyContext (JNIEnv *env, jobject obj, jobject context) { /* get context address */ jclass context_class = env->GetObjectClass(context); jfieldID context_field = env->GetFieldID(context_class, "context", "I"); jint contextaddress = env->GetIntField(context, context_field); alcDestroyContext((ALCcontext*) contextaddress); } /** * This function retrieves the specified devices context error state. * * C Specification: * ALCenum alcGetError(ALCdevice *device); */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_ALC_getError (JNIEnv *env, jobject obj, jobject device) { /* get device address */ jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); jint result = alcGetError((ALCdevice*) deviceaddress); CHECK_ALC_ERROR return result; } /** * This function queries if a specified context extension is available. * * C Specification: * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALC_isExtensionPresent (JNIEnv *env, jobject obj, jobject device, jstring extName) { /* get device address */ jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); /* get extension */ ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(extName, 0)); jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*) deviceaddress, functionname); env->ReleaseStringUTFChars((jstring)functionname, 0); CHECK_ALC_ERROR return result; } /** * This function retrieves the enum value for a specified enumeration name. * * C Specification: * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName); */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_ALC_getEnumValue (JNIEnv *env, jobject obj, jobject device, jstring enumName) { /* get device address */ jclass device_class = env->GetObjectClass(device); jfieldID device_field = env->GetFieldID(device_class, "device", "I"); jint deviceaddress = env->GetIntField(device, device_field); /* get extension */ ALubyte* enumerationname = (ALubyte*) (env->GetStringUTFChars(enumName, 0)); jint result = (jint) alcGetEnumValue((ALCdevice*) deviceaddress, enumerationname); env->ReleaseStringUTFChars((jstring)enumerationname, 0); CHECK_ALC_ERROR return result; } --- NEW FILE: org_lwjgl_openal_ALUT.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_ALUT.cpp /* * 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: org_lwjgl_openal_ALUT.cpp,v 1.1 2002/11/19 14:08:21 elias_naur Exp $ * * This is the actual JNI implementation of the OpenAL utility library. * It handles whatever is needed for proper OpenAL support via using Java. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_openal_ALUT.h" #include "checkALerror.h" /* OpenAL includes */ #include <AL/alut.h> #include <stdlib.h> /* * Class: org_lwjgl_openal_ALUT * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_ALUT_nCreate (JNIEnv *env, jobject obj) { return true; } /* * Class: org_lwjgl_openal_ALUT * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_nDestroy (JNIEnv *env, jobject obj) { } /** * This function initializes OpenAL. * * C Specification: * void alutInit(int *argc, char *argv[]); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_init (JNIEnv *env, jobject obj, jobjectArray jargv) { /* obtain the size the array */ jsize argc = env->GetArrayLength(jargv); /* Declare a char array for argv */ const char* argv[128]; int i; for (i=0;i<argc;i++) { /* obtain the current object from the object array */ jstring string = (jstring) env->GetObjectArrayElement(jargv, i); /* Convert the object just obtained into a String */ const char *str = env->GetStringUTFChars(string, 0); /* Build the argv array */ argv[i] = str; /* Free up memory to prevent memory leaks */ env->ReleaseStringUTFChars(string, str); } /* Increment argc to adjust the difference between Java and C arguments */ argc++; /* call the actual implementation */ alutInit((ALint*) &argc,(char**) argv); CHECK_AL_ERROR } /* * This function loads a WAV file into memory from a file. * * C Specification: * ALboolean alutLoadWAVFile(const char *fname, ALsizei *format, ALsizei *size, ALsizei *bits, * ALsizei *freq, ALboolean *loop ); */ JNIEXPORT jobject JNICALL Java_org_lwjgl_openal_ALUT_loadWAVFile (JNIEnv *env, jobject obj, jstring file) { /* * NOTE: Since Java doesn't support modification of supplied * variables (pass by value). We will return a class that * holds what is needed to unload the file again. * The data field contains the offset at whcih the data * segment begins (ie. a pointer). This will *not* work * on 64 bit platforms, since we use an jint for this. */ /* actual file info object */ jobject alutLoadWAVFile_object = NULL; /* class type to find */ jclass alutLoadWAVFile_class = NULL; /* method id - will be set to constructor of alutLoadWAVData */ jmethodID methodID = NULL; /* sound data vars */ jint format, size, freq; jboolean loop; void* data; ALbyte* filename = (ALbyte*) (env->GetStringUTFChars(file, 0)); /* load wave file */ alutLoadWAVFile(filename, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop); /* get class */ alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData"); /* get constructor */ methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V"); /* create object */ alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop); /* release chars */ env->ReleaseStringUTFChars((jstring)filename, 0); CHECK_AL_ERROR return alutLoadWAVFile_object; } /** * This function loads a WAV file into memory from another memory location. * * C Specification: * 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, jint buffer) { /* * NOTE: Since Java doesn't support modification of supplied * variables (pass by value). We will return a class that * holds what is needed to unload the file again. * The data field contains the offset at whcih the data * segment begins (ie. a pointer). This will *not* work * on 64 bit platforms, since we use an jint for this. */ /* actual file info object */ jobject alutLoadWAVFile_object = NULL; /* class type to find */ jclass alutLoadWAVFile_class = NULL; /* method id - will be set to constructor of alutLoadWAVData */ jmethodID methodID = NULL; /* sound data vars */ jint format, size, freq; jboolean loop; void* data; /* load wave from mem */ alutLoadWAVMemory((ALbyte*) buffer, (ALenum*) &format, (void**) &data, (ALsizei*) &size, (ALsizei*) &freq, (ALboolean*) &loop); /* get class */ alutLoadWAVFile_class = env->FindClass("org/lwjgl/openal/ALUTLoadWAVData"); /* get constructor */ methodID = env->GetMethodID(alutLoadWAVFile_class, "<init>", "(IIIIZ)V"); /* create object */ alutLoadWAVFile_object = env->NewObject(alutLoadWAVFile_class, methodID, format, (int) data, size, freq, loop); CHECK_AL_ERROR return alutLoadWAVFile_object; } /** * This function unloads a WAV file from memory and is normally used after copying the data into a buffer * after an alutLoad* function. * * C Specification: * ALvoid alutUnloadWAV(ALenum format, ALvoid *data, ALsizei size, ALsizei freq) */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_unloadWAV (JNIEnv *env, jobject obj, jint format, jint data, jint size, jint freq) { alutUnloadWAV(format, (void**) data, size, freq); CHECK_AL_ERROR } /** * This function exits OpenAL. * * C Specification: * void alutExit(ALvoid); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALUT_exit (JNIEnv *env, jobject obj) { alutExit(); } --- NEW FILE: org_lwjgl_openal_BaseAL.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_BaseAL.cpp /* * 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. */ #include "org_lwjgl_openal_BaseAL.h" /* * Class: org_lwjgl_openal_BaseAL * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_BaseAL_nCreate (JNIEnv *env, jobject obj) { return true; } /* * Class: org_lwjgl_openal_BaseAL * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_BaseAL_nDestroy(JNIEnv *env, jobject obj) { } --- NEW FILE: org_lwjgl_openal_CoreAL.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_CoreAL.cpp /* * 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: org_lwjgl_openal_CoreAL.cpp,v 1.1 2002/11/19 14:08:21 elias_naur Exp $ * * This is the actual JNI implementation of the OpenAL core. It handles * whatever is needed for proper OpenAL support via using Java. * * @author Brian Matzon <br...@ma...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_openal_CoreAL.h" #include "checkALerror.h" /* OpenAL includes */ #include <AL/al.h> /** * This function enables a feature of the OpenAL driver. * * C Specification: * ALvoid alEnable(ALenum capability); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_enable (JNIEnv *env, jobject obj, jint capability) { alEnable((ALenum) capability); CHECK_AL_ERROR } /** * This function disables a feature of the OpenAL driver. * * C Specification: * ALvoid alDisable(ALenum capability); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_disable (JNIEnv *env, jobject obj, jint capability) { alDisable((ALenum) capability); CHECK_AL_ERROR } /** * This function returns a boolean indicating if a specific feature is enabled in the OpenAL driver. * * C Specification: * Alboolean alIsEnabled(ALenum capability); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isEnabled (JNIEnv *env, jobject obj, jint capability) { jboolean result = (jboolean) alIsEnabled((ALenum) capability); CHECK_AL_ERROR return result; } /** * This function Enables a feature of the OpenAL driver. * * C Specification * ALvoid alHint(ALenum target, ALenum mode); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_hint (JNIEnv *env, jobject obj, jint target, jint mode) { //alHint((ALint)target, (ALint)mode); //cannot link with above statement return; } /** * This function returns a boolean OpenAL state. * * C Specification: * Alboolean alGetBoolean(ALenum pname); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_getBoolean (JNIEnv *env, jobject obj, jint pname) { jboolean result = (jboolean) alGetBoolean((ALenum) pname); CHECK_AL_ERROR return result; } /** * This function returns an integer OpenAL state. * * C Specification: * Alint alGetInteger(ALenum pname); */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getInteger (JNIEnv *env, jobject obj, jint pname) { jint result = (jint) alGetInteger((ALenum) pname); CHECK_AL_ERROR return result; } /** * This function returns a floating point OpenAL state. * * C Specification: * ALfloat alGetFloat(ALenum pname); */ JNIEXPORT jfloat JNICALL Java_org_lwjgl_openal_CoreAL_getFloat (JNIEnv *env, jobject obj, jint pname) { jfloat result = (jfloat) alGetFloat((ALenum) pname); CHECK_AL_ERROR return result; } /** * This function returns a double precision floating point OpenAL state. * * C Specification: * Aldouble alGetDouble(ALenum pname); */ JNIEXPORT jdouble JNICALL Java_org_lwjgl_openal_CoreAL_getDouble (JNIEnv *env, jobject obj, jint pname) { jdouble result = (jdouble) alGetDouble((ALenum) pname); CHECK_AL_ERROR return result; } /** * This function retrieves a boolean OpenAL state. * * C Specification: * ALvoid alGetBooleanv(ALenum pname,ALboolean *data); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBooleanv (JNIEnv *env, jobject obj, jint pname, jint data) { alGetBooleanv((ALenum) pname, (ALboolean*) data); CHECK_AL_ERROR } /** * This function retrieves an integer OpenAL state. * * C Specification: * ALvoid alGetIntegerv(ALenum pname,ALint *data); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getIntegerv (JNIEnv *env, jobject obj, jint pname, jint data) { alGetIntegerv((ALenum) pname, (ALint*) data); CHECK_AL_ERROR } /** * This function retrieves a floating point OpenAL state. * * C Specification: * ALvoid alGetFloatv(ALenum pname,ALfloat *data); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getFloatv (JNIEnv *env, jobject obj, jint pname, jint data) { alGetFloatv((ALenum) pname, (ALfloat*) data); CHECK_AL_ERROR } /** * This function retrieves a double precision floating point OpenAL state. * * C Specification: * ALvoid alGetDoublev(ALenum pname,ALdouble *data); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getDoublev (JNIEnv *env, jobject obj, jint pname, jint data) { alGetDoublev((ALenum) pname, (ALdouble*) data); CHECK_AL_ERROR } /** * This function retrieves an OpenAL string property. * * C Specification: * ALubyte * alGetString(ALenum pname); */ JNIEXPORT jstring JNICALL Java_org_lwjgl_openal_CoreAL_getString (JNIEnv *env, jobject obj, jint param) { jstring string = (jstring) env->NewStringUTF((const char*) alGetString((ALenum)param)); CHECK_AL_ERROR return string; } /** * This function returns the current error state and then clears the error state. * * C Specification: * ALenum alGetError(ALvoid); */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getError (JNIEnv *env, jobject obj) { jint result = (jint) alGetError(); CHECK_AL_ERROR return result; } /** * This function tests if a specific extension is available for the OpenAL driver. * * C Specification: * ALboolean alIsExtensionPresent(ALubyte *extName); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isExtensionPresent (JNIEnv *env, jobject obj, jstring fname) { ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(fname, 0)); jboolean result = (jboolean) alIsExtensionPresent(functionname); env->ReleaseStringUTFChars((jstring)functionname, 0); CHECK_AL_ERROR return result; } /** * This function returns the enumeration value of an OpenAL enum described by a string. * * C Specification: * ALenum alGetEnumValue(ALubyte *enumName); */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_CoreAL_getEnumValue (JNIEnv *env, jobject obj, jstring ename) { ALubyte* functionname = (ALubyte*) (env->GetStringUTFChars(ename, 0)); jint result = (jint) alGetEnumValue(functionname); env->ReleaseStringUTFChars((jstring)functionname, 0); CHECK_AL_ERROR return result; } /** * This function sets an integer property of the listener. * * C Specification: * ALvoid alListeneri(ALenum pname,ALint value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listeneri (JNIEnv *env, jobject obj, jint pname, jint value) { alListeneri((ALenum) pname, (ALint) value); CHECK_AL_ERROR } /** * This function sets a floating point property for the listener. * * C Specification: * ALvoid alListenerf(ALenum pname,ALfloat value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listenerf (JNIEnv *env, jobject obj, jint pname, jfloat value) { alListenerf((ALenum) pname, (ALfloat) value); CHECK_AL_ERROR } /** * This function sets a floating point property for the listener. * * C Specification: * ALvoid alListener3f(ALenum pname,ALfloat v1,ALfloat v2,ALfloat v3); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listener3f (JNIEnv *env, jobject obj, jint pname, jfloat v1, jfloat v2, jfloat v3) { alListener3f((ALenum) pname, (ALfloat) v1, (ALfloat) v2, (ALfloat) v3); CHECK_AL_ERROR } /** * This function sets a floating point-vector property of the listener. * * C Specification: * ALvoid alListenerfv(ALenum pname,ALfloat *values); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_listenerfv (JNIEnv *env, jobject obj, jint pname, jint values) { alListenerfv((ALenum) pname, (ALfloat*) values); CHECK_AL_ERROR } /** * This function retrieves an integer property of the listener. * * C Specification: * ALvoid alGetListeneri(ALenum pname,ALint *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListeneri (JNIEnv *env, jobject obj, jint pname, jint value) { alGetListeneri((ALenum) pname, (ALint*) value); CHECK_AL_ERROR } /** * This function retrieves a floating point property of the listener. * * C Specification: * ALvoid alGetListenerf(ALenum pname,ALfloat *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerf (JNIEnv *env, jobject obj, jint pname, jint value) { alGetListenerf((ALenum) pname, (ALfloat*) value); CHECK_AL_ERROR } /** * This function retrieves a set of three floating point values from a property of the listener. * * C Specification: * ALvoid alGetListener3f(ALenum pname,ALfloat *v1,ALfloat *v2,ALfloat *v3); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListener3f (JNIEnv *env, jobject obj, jint pname, jint v1, jint v2, jint v3) { alGetListener3f((ALenum) pname, (ALfloat*) v1, (ALfloat*) v2, (ALfloat*) v3); CHECK_AL_ERROR } /** * This function retrieves a floating point-vector property of the listener. * * C Specification: * ALvoid alGetListenerfv(ALenum pname,ALfloat *values); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getListenerfv (JNIEnv *env, jobject obj, jint pname, jint values) { alGetListenerfv((ALenum) pname, (ALfloat*) values); CHECK_AL_ERROR } /** * This function generates one or more sources. * * C Specification: * ALvoid alGenSources(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genSources (JNIEnv *env, jobject obj, jint n, jint sources) { alGenSources(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function deletes one or more sources. * * C Specification: * ALvoid alDeleteSources(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteSources (JNIEnv *env, jobject obj, jint n, jint sources) { alDeleteSources(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function tests if a source name is valid. * * C Specification: * Alboolean alIsSource(ALuint source); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isSource (JNIEnv *env, jobject obj, jint source) { jboolean result = (jboolean) alIsSource((ALuint) source); CHECK_AL_ERROR return result; } /** * This function sets an integer property of a source. * * C Specification: * ALvoid alSourcei(ALuint source,ALenum pname,ALint value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcei (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { alSourcei((ALuint) source, (ALenum) pname, (ALint) value); CHECK_AL_ERROR } /** * This function sets a floating point property of a source. * * C Specification: * ALvoid alSourcef(ALuint source,ALenum pname,ALfloat value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcef (JNIEnv *env, jobject obj, jint source, jint pname, jfloat value) { alSourcef((ALuint) source, (ALenum) pname, (ALfloat) value); CHECK_AL_ERROR } /** * This function sets a source property requiring three floating point values. * C Specification: * ALvoid alSource3f(ALuint source,ALenum pname,ALfloat v1,ALfloat v2,ALfloat v3); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_source3f (JNIEnv *env, jobject obj, jint source, jint pname, jfloat v1, jfloat v2, jfloat v3) { alSource3f((ALuint) source, (ALenum) pname, (ALfloat) v1, (ALfloat) v2, (ALfloat) v3); CHECK_AL_ERROR } /** * This function sets a floating point-vector property of a source. * * C Specification: * ALvoid alSourcefv(ALuint source,ALenum pname,ALfloat *values); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcefv (JNIEnv *env, jobject obj, jint source, jint pname, jint values) { alSourcefv((ALuint) source, (ALenum) pname, (ALfloat*) values); CHECK_AL_ERROR } /** * This function retrieves an integer property of a source. * C Specification: * ALvoid alGetSourcei(ALuint source,ALenum pname,ALint *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcei (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { alGetSourcei((ALuint) source, (ALenum) pname, (ALint*) value); CHECK_AL_ERROR } /** * This function retrieves a floating point property of a source. * * C Specification: * ALvoid alGetSourcef(ALuint source,ALenum pname,ALfloat *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcef (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { alGetSourcef((ALuint) source, (ALenum) pname, (ALfloat*) value); CHECK_AL_ERROR } /* * This function retrieves a set of three floating point values from a property of a source. * * C Specification: * ALvoid alGetSource3f(ALuint source, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSource3f (JNIEnv *env, jobject obj, jint source, jint pname, jint v1, jint v2, jint v3) { #warning FIXME: alGetSource3f /* alGetSource3f((ALuint) source, (ALenum) pname, (ALfloat*) v1, (ALfloat*) v2, (ALfloat*) v3);*/ CHECK_AL_ERROR } /** * This function retrieves a floating point-vector property of a source. * * C Specification: * ALvoid alGetSourcefv(ALuint source,ALenum pname,ALfloat *values); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getSourcefv (JNIEnv *env, jobject obj, jint source, jint pname, jint values) { alGetSourcefv((ALuint) source, (ALenum) pname, (ALfloat*) values); CHECK_AL_ERROR } /** * This function plays a set of sources. * * C Specification: * ALvoid alSourcePlayv(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlayv (JNIEnv *env, jobject obj, jint n, jint sources) { alSourcePlayv(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function pauses a set of sources. * * C Specification: * ALvoid alSourcePausev(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePausev (JNIEnv *env, jobject obj, jint n, jint sources) { alSourcePausev(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function stops a set of sources. * * C Specification: * ALvoid alSourceStopv(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStopv (JNIEnv *env, jobject obj, jint n, jint sources) { alSourceStopv(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function stops a set of sources and sets all their states to AL_INITIAL. * * C Specification: * ALvoid alSourceRewindv(ALsizei n,ALuint *sources); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewindv (JNIEnv *env, jobject obj, jint n, jint sources) { alSourceRewindv(n, (ALuint*) sources); CHECK_AL_ERROR } /** * This function plays a source. * * C Specification: * ALvoid alSourcePlay(ALuint source); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePlay (JNIEnv *env, jobject obj, jint source) { alSourcePlay((ALuint) source); CHECK_AL_ERROR } /* * This function pauses a source. * * C Specification: * ALvoid alSourcePause(ALuint source); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourcePause (JNIEnv *env, jobject obj, jint source) { alSourcePause((ALuint) source); CHECK_AL_ERROR } /** * This function stops a source. * * C Specification: * ALvoid alSourceStop(ALuint source); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceStop (JNIEnv *env, jobject obj, jint source) { alSourceStop((ALuint) source); CHECK_AL_ERROR } /** * This function stops the source and sets its state to AL_INITIAL. * * C Specification: * ALvoid alSourceRewind(ALuint source); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceRewind (JNIEnv *env, jobject obj, jint source) { alSourceRewind((ALuint) source); CHECK_AL_ERROR } /** * This function generates one or more buffers. * * C Specification: * ALvoid alGenBuffers(ALsizei n,ALuint *buffers); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_genBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) { alGenBuffers(n, (ALuint*) buffers); CHECK_AL_ERROR } /** * This function deletes one or more buffers. * * C Specification: * ALvoid alDeleteBuffers(ALsizei n,ALuint *buffers); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_deleteBuffers (JNIEnv *env, jobject obj, jint n, jint buffers) { alDeleteBuffers(n, (ALuint*) buffers); CHECK_AL_ERROR } /** * This function tests if a buffer name is valid. * * C Specification: * Alboolean alIsBuffer(ALuint buffer); */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_openal_CoreAL_isBuffer (JNIEnv *env, jobject obj, jint buffer) { jboolean result = (jboolean) alIsBuffer((ALuint) buffer); CHECK_AL_ERROR return result; } /** * This function fills a buffer with audio data. * * C Specification: * ALvoid alBufferData(ALuint buffer,ALenum format,ALvoid *data,ALsizei size,ALsizei freq); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_bufferData (JNIEnv *env, jobject obj, jint buffer, jint format, jint data, jint size, jint freq) { alBufferData(buffer, format, (void**) data, size, freq); CHECK_AL_ERROR } /** * This function retrieves an integer property of a buffer. * * C Specification: * ALvoid alGetBufferi(ALuint buffer,ALenum pname,ALint *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferi (JNIEnv *env, jobject obj, jint buffer, jint pname, jint value) { alGetBufferi((ALuint) buffer, (ALenum) pname, (ALint*) value); CHECK_AL_ERROR } /** * This function retrieves a floating point property of a buffer. * * C Specification: * ALvoid alGetBufferf(ALuint buffer,ALenum pname,ALfloat *value); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_getBufferf (JNIEnv *env, jobject obj, jint buffer, jint pname, jint value) { alGetBufferf((ALuint) buffer, (ALenum) pname, (ALfloat*) value); CHECK_AL_ERROR } /** * This function queues a set of buffers on a source. * * C Specification: * ALvoid alSourceQueueBuffers( ALuint source, ALsizei n, ALuint* buffers ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceQueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jint buffers) { alSourceQueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers); CHECK_AL_ERROR } /** * This function unqueues a set of buffers attached to a source. * * C Specification: * ALvoid alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint* buffers ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_sourceUnqueueBuffers (JNIEnv *env, jobject obj, jint source, jint n, jint buffers) { alSourceUnqueueBuffers((ALuint) source, (ALsizei) n, (ALuint*) buffers); CHECK_AL_ERROR } /** * This function selects the OpenAL distance model. * * C Specification: * ALvoid alDistanceModel( ALenum value ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_distanceModel (JNIEnv *env, jobject obj, jint value) { alDistanceModel((ALenum) value); CHECK_AL_ERROR } /** * This function selects the OpenAL Doppler factor value. * * C Specification: * ALvoid alDopplerFactor( ALfloat value ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_dopplerFactor (JNIEnv *env, jobject obj, jfloat value) { alDopplerFactor((ALfloat) value); CHECK_AL_ERROR } /** * This function selects the OpenAL Doppler velocity value. * * C Specification: * ALvoid alDopplerVelocity( ALfloat value ); */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_CoreAL_dopplerVelocity (JNIEnv *env, jobject obj, jfloat value) { alDopplerVelocity((ALfloat) value); CHECK_AL_ERROR } --- NEW FILE: org_lwjgl_openal_eax_EAXBufferProperties.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_eax_EAXBufferProperties.cpp /* * 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. */ #include "org_lwjgl_openal_eax_EAXBufferProperties.h" //#include <eax.h> #include <stddef.h> /* * Class: org_lwjgl_openal_eax_EAXBufferProperties * Method: sizeOfEaxBufferProperties * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_sizeOfEaxBufferProperties(JNIEnv *env, jobject obj) { // return sizeof(EAXBUFFERPROPERTIES); } /* * Class: org_lwjgl_openal_eax_EAXBufferProperties * Method: assignOffsets * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_assignOffsets(JNIEnv *env, jobject obj) { /* jclass listener_class; jfieldID field; //get class/fields listener_class = env->FindClass("org/lwjgl/openal/eax/EAXBufferProperties"); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "direct_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirect)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "directHF_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirectHF)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "room_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoom)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoomHF)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flRoomRolloffFactor)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "obstruction_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lObstruction)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "obstructionLFRatio_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flObstructionLFRatio)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "occlusion_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOcclusion)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "occlusionLFRatio_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionLFRatio)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "occlusionRoomRatio_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionRoomRatio)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "outsideVolumeHF_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOutsideVolumeHF)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "airAbsorptionFactor_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flAirAbsorptionFactor)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, dwFlags));*/ } --- NEW FILE: org_lwjgl_openal_eax_EAXListenerProperties.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_openal_eax_EAXListenerProperties.cpp /* * 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. */ #include "org_lwjgl_openal_eax_EAXListenerProperties.h" //#include <eax.h> #include <stddef.h> /* * Class: org_lwjgl_openal_eax_EAXListenerProperties * Method: sizeOfEaxListenerProperties * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_sizeOfEaxListenerProperties(JNIEnv *env, jobject obj) { // return sizeof(EAXLISTENERPROPERTIES); } /* * Class: org_lwjgl_openal_eax_EAXListenerProperties * Method: assignOffsets * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_assignOffsets (JNIEnv *env, jobject obj) { /* jclass listener_class; jfieldID field; //get class/fields listener_class = env->FindClass("org/lwjgl/openal/eax/EAXListenerProperties"); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "room_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoom)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoomHF)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flRoomRolloffFactor)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "decayTime_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayTime)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "decayHFRatio_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayHFRatio)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "reflections_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReflections)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "reflectionsDelay_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReflectionsDelay)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "reverb_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReverb)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "reverbDelay_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReverbDelay)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "environment_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwEnvironment)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "environmentSize_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentSize)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "environmentDiffusion_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentDiffusion)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "airAbsorptionHF_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flAirAbsorptionHF)); //set environmentDiffusion_offset field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwFlags));*/ } Index: Makefile CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile 19 Nov 2002 08:50:57 -0000 1.7 +++ Makefile 19 Nov 2002 14:08:21 -0000 1.8 @@ -48,7 +48,7 @@ LIBCOBJS=$(LIBCSRC:.c=.o) LIBOBJS=$(LIBCOBJS) $(LIBCPPOBJS) #DEBUG_FLAGS=-D_DEBUG -LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU +LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU -lopenal all: liblwjgl.so |
From: Elias N. <eli...@us...> - 2002-11-19 09:08:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test In directory sc8-pr-cvs1:/tmp/cvs-serv18752/java/org/lwjgl/test Added Files: MathTest.java Log Message: Added MathTest.java --- NEW FILE: MathTest.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/MathTest.java package org.lwjgl.test; import java.nio.*; import org.lwjgl.*; public class MathTest { public static void main(String[] args) { ByteBuffer buf = ByteBuffer.allocateDirect(100); buf.order(ByteOrder.nativeOrder()); FloatBuffer float_buf = buf.asFloatBuffer(); float f = 0f; while (float_buf.hasRemaining()) { f += 0.5f; float_buf.put(f); } float_buf.rewind(); System.out.println("Src buffer:"); while (float_buf.hasRemaining()) System.out.print(float_buf.get() + " "); System.out.println(""); int buf_address = Sys.getDirectBufferAddress(float_buf); org.lwjgl.Math.matrixOp(org.lwjgl.Math.MATRIXOP_NEGATE, buf_address, 0, 100, 1, 1, false, buf_address, 0, false); System.out.println("Negated result:"); float_buf.rewind(); while (float_buf.hasRemaining()) System.out.print(float_buf.get() + " "); System.out.println(""); } } |
From: Elias N. <eli...@us...> - 2002-11-19 08:58:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test In directory sc8-pr-cvs1:/tmp/cvs-serv15333/test Log Message: Directory /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test added to the repository |
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv11750 Modified Files: Makefile Added Files: MatrixOpCommon.cpp MatrixOpCommon.h org_lwjgl_Display.cpp org_lwjgl_Math.cpp 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 org_lwjgl_Sys.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_BaseGL.cpp org_lwjgl_opengl_CoreGL.cpp org_lwjgl_opengl_GL.cpp org_lwjgl_opengl_GLU.cpp Removed Files: org_lwjgl_Display.c org_lwjgl_Sys.c org_lwjgl_input_Keyboard.c org_lwjgl_input_Mouse.c org_lwjgl_opengl_BaseGL.c org_lwjgl_opengl_CoreGL.c org_lwjgl_opengl_GL.c org_lwjgl_opengl_GLU.c Log Message: Ported to C++. ported Math ops --- NEW FILE: MatrixOpCommon.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/MatrixOpCommon.cpp //#include <iostream> #include <jni.h> #include <memory.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)); } } MatrixSrc::MatrixSrc ( jint addr, jint s, jint w, jint h, jint e, jboolean t): Matrix(addr, s, e), record_offset((char *) addr), record_size (w*h) { if (t) { width = h; height = w; } else { width = w; height = h; } elements = e; record = new float[width * height]; // vectors do not need to be transposed transpose = (t == JNI_TRUE) && (w != 1) && (h != 1); if (transpose && (width != height)) // only need temp storage for transpose if the matrix is not square transpose_record = new float[width*height]; else transpose_record = 0; if (elements == 1) { // fool the nextMatrix function into returning a value elements = 2; nextMatrix(); elements = 1; } } MatrixSrc::~MatrixSrc() { //cout << "MatrixSrc destructor \n"; delete [] record; if (transpose_record != 0) delete [] transpose_record; } float * MatrixSrc::nextMatrix() { if (elements > 1) { //cout << "Elements: " << elements << "\n"; //cout << "Address: " << (unsigned int) (record_offset) << "\n"; // the record is not properly aligned if ((unsigned int) (record_offset) & FLOAT_ALIGNMENT) { // copy the floats into a buffer so that they are aligned // on 4 byte margins (not necessary on intel, but a good thing) memcpy (record, record_offset, record_size * sizeof(float)); if (transpose) transposeMatrix (record, height, width); record_offset = &record_offset[stride]; current_record_ptr = record; } // the record is aligned but it has to be transposed else if (transpose) { transposeMatrix ((float *) (record_offset), record, height, width); record_offset = &record_offset[stride]; current_record_ptr = record; } // nothing has to be done to the record else { // the floats are aligned in memory current_record_ptr = (float *) record_offset; record_offset = &record_offset[stride]; } } return current_record_ptr; } MatrixDst::MatrixDst (jint addr, jint s, jint w, jint h, jint e, jboolean t): Matrix(addr, s, e) { width = w; height = h; record_size = width * height; record = new float[record_size]; // vectors do not need to be transposed transpose = (t) && (w != 1) && (h != 1); if (transpose) transpose_record = new float[width*height]; else transpose_record = 0; data_buffered = JNI_FALSE; record_buffered = JNI_FALSE; record_offset = address - stride; } MatrixDst::~MatrixDst() { //cout << "MatrixDst destructor \n"; delete [] record; if (transpose_record != 0) delete [] transpose_record; // copy back any buffered data if (data_buffered) { char * src = buffer; char * dest = address; for (int i = 0; i < elements; i++) { memcpy(dest, src, record_size * sizeof(float)); src += stride; dest += stride; } delete [] buffer; } } void MatrixDst::configureBuffer(MatrixSrc & a, MatrixSrc & b) { if (!a.intersectingDataSpaces(b)) { // as long as the output only overlays 1 of the sources, and the other // source only has 1 matrix in it, only a record_buffer is required if (a.elements == 1 && identicalDataSpaces(b)) record_buffered = JNI_TRUE; else if (b.elements == 1 && identicalDataSpaces(a)) record_buffered = JNI_TRUE; else // otherwise all of the output has to be buffered createBuffer(); } else createBuffer(); } void MatrixDst::configureBuffer(MatrixSrc & a) { if (identicalDataSpaces(a)) record_buffered = JNI_TRUE; else if (intersectingDataSpaces(a)) createBuffer(); } void MatrixDst::createBuffer() { data_buffered = JNI_TRUE; buffer = new char[ elements * stride ]; record_offset = buffer - stride; } float * MatrixDst::nextMatrix() { record_offset = &record_offset[stride]; int alignment = ((unsigned int)(record_offset)) & FLOAT_ALIGNMENT; if (transpose || record_buffered || alignment) { last_record_in_temp = JNI_TRUE; return record; } else { last_record_in_temp = JNI_FALSE; return (float *) record_offset; } } void MatrixDst::writeComplete() { if (last_record_in_temp) { // 3 reasons why the record would be in temp // // 1. The record is not aligned // 2. The result will need to be transposed // 3. Direct Mode where result would overlay an operand if (((unsigned int)(record_offset)) & FLOAT_ALIGNMENT) { if (transpose) transposeMatrix(record, width, height); memcpy (record, record_offset, record_size * sizeof(jfloat)); } else if (transpose) { transposeMatrix(record, (float *) &record_offset[0], width, height); } else memcpy (record_offset, record, record_size * sizeof(jfloat)); } } /////////////////////////////////////////////////////////////////////////// void subMatrix (const float * src, int side, float * dst , int col_omit, int row_omit) { int index = 0; int src_index = 0; for (int c = 0; c < side; c++) { if (c == col_omit) { src_index += side; continue; } for (int r = 0; r < side; r++) { if (r == row_omit) { src_index++; continue; } dst[index++] = src[src_index++]; } } } float determinant (const float * matrix , int side) { // we are assuming for this case that the data is in column major format float det = 0; if (side == 2) // your basic cross product aka 2x2 determinant det = matrix[0] * matrix[3] - matrix[2] * matrix[1]; else { // create room to store the sub matrix int temp_side = side - 1; // the dimensions of the sub matrix float * temp_matrix = new float[temp_side * temp_side]; // keep the sign (this way we avoid an additional branch in the inner loop) float sign = 1; for (int row = 0; row < side; row++) { // get a sub matrix by eliminating the 0th col and the specified row subMatrix(matrix, side, temp_matrix, 0, row); // add to the determinant sign * [a]i0 * [M]i0 det += sign * matrix[row] * determinant (temp_matrix, temp_side); // alternate the sign sign *= -1; } delete [] temp_matrix; } return det; } --- NEW FILE: MatrixOpCommon.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/MatrixOpCommon.h /* * Matrix.h * * * Created by tristan on Sat Aug 24 2002. * Copyright (c) 2001 __MyCompanyName__. All rights reserved. * */ //////////////////////////////////////////////////////////////////////////////////////// // Utility Functions //////////////////////////////////////////////////////////////////////////////////////// #define FLOAT_ALIGNMENT 0x00000003 // 23 bit mantisa on a float (we need error for checking if two nums are equal) // for now use error of 1/2^18, this could be refined up to 1/2^22 if needed #define FLOATING_POINT_ERROR (1.0f/262144.0f) // check if two numbers are approximately equal, used when floating point errors // occur. Should NEVER check to see if two floats are identical inline bool approxEqual(float a, float b) { a -= b; a = (a < 0) ? -a: a; return (a < FLOATING_POINT_ERROR); } float determinant (const float * matrix , int side); void subMatrix (const float * src, int side, float * dst , int col_omit, int row_omit); /////////////////////////////////////////////////////////////////////////////////////// // Matrix ////////////////////////////////////////////////////////////////////////////////////// class Matrix { protected: float * transpose_record; // to use while transposing the record public: char * address; // the start of the data jint stride; // the distance between each record jint width, // the width of the matrix height, // the height of the matrix elements; // the number of matricies jboolean transpose; // whether this matrix is or will be transposed Matrix (jint a, jint s, jint e): address((char *)a), stride(s), elements(e) {} bool identicalDataSpaces (Matrix & other); bool intersectingDataSpaces(Matrix & other); void transposeMatrix(float * src, float * dst, int src_width, int src_height); void transposeMatrix(float * mat, int src_width, int src_height); }; /////////////////////////////////////////////////////////////////////////////////////// // Src Matrix ////////////////////////////////////////////////////////////////////////////////////// class MatrixSrc: public Matrix { private: char * record_offset; // the offset of this record in memory float * record; // temporary storage to store a fully aligned and transposed // copy of the record, if the one in memory is not so float * current_record_ptr; // the address of the memory containing the record last // returned by the nextMatrix() function jint record_size; // the total floats in each record public: MatrixSrc ( jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); ~MatrixSrc(); void rewind() { record_offset = address; } float * nextMatrix(); }; /////////////////////////////////////////////////////////////////////////////////////// // Dst Matrix ////////////////////////////////////////////////////////////////////////////////////// class MatrixDst: public Matrix { private: char * record_offset; // the offset of the record in memory jboolean data_buffered; // if all of the data has to be buffered char * buffer; // a buffer used when data_buffered jboolean last_record_in_temp; jboolean record_buffered; // if only a single record is buffered float * record; // to store data if source is unaligned jint record_size; void createBuffer(); public: MatrixDst (jint address, jint stride, jint width, jint height, jint elements, jboolean transpose); ~MatrixDst(); void configureBuffer(MatrixSrc & a, MatrixSrc & b); void configureBuffer(MatrixSrc & a); float * nextMatrix(); void writeComplete(); }; --- NEW FILE: org_lwjgl_Display.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Display.cpp /* * 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: org_lwjgl_Display.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * Linux specific library for display handling. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include <X11/X.h> #include <X11/Xlib.h> #include <X11/extensions/xf86vmode.h> #include <GL/glx.h> #include <X11/Xutil.h> #include <GL/gl.h> #include <GL/glu.h> #include <stdio.h> #include <jni.h> #include "org_lwjgl_Display.h" Display * disp; int screen; int current_fullscreen; Window win; XF86VidModeModeInfo **avail_modes; XVisualInfo * vis_info; void waitMapped(Display *disp, Window win) { XEvent event; do { XMaskEvent(disp, StructureNotifyMask, &event); } while ((event.type != MapNotify) || (event.xmap.event != win)); } int getDisplayModes(Display *disp, int screen, int *num_modes, XF86VidModeModeInfo ***avail_modes) { int event_base, error_base, xvid_ver, xvid_rev; if (!XF86VidModeQueryExtension(disp, &event_base, &error_base)) { #ifdef _DEBUG printf("XF86VidMode extention not available\n"); #endif return 0; } XF86VidModeQueryVersion(disp, &xvid_ver, &xvid_rev); #ifdef _DEBUG printf("XF86VidMode extention version %i.%i\n", xvid_ver, xvid_rev); #endif XF86VidModeGetAllModeLines(disp, screen, num_modes, avail_modes); return 1; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate(JNIEnv * env, jclass clazz, jint width, jint height, jint bpp, jint freq, jboolean fullscreen) { Window root_win; XSetWindowAttributes attribs; Colormap cmap; int attribmask; int bpe = bpp/4; int attriblist[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_RED_SIZE, bpe, GLX_GREEN_SIZE, bpe, GLX_BLUE_SIZE, bpe, GLX_ALPHA_SIZE, bpe, None}; int num_modes, i; current_fullscreen = fullscreen; disp = XOpenDisplay(NULL); if (disp == NULL) { #ifdef _DEBUG printf("Could not open X connection\n"); #endif return JNI_FALSE; } screen = DefaultScreen(disp); if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { XCloseDisplay(disp); #ifdef _DEBUG printf("Could not get display modes\n"); #endif return JNI_FALSE; } root_win = RootWindow(disp, screen); vis_info = glXChooseVisual(disp, screen, attriblist); if (vis_info == NULL) { XCloseDisplay(disp); #ifdef _DEBUG printf("Could not choose glx visual\n"); #endif return JNI_FALSE; } cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone); attribs.colormap = cmap; attribs.event_mask = ExposureMask | FocusChangeMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribs.background_pixel = 0xFF000000; attribs.event_mask = StructureNotifyMask; attribmask = CWColormap | CWBackPixel | CWEventMask; if (fullscreen) { attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } win = XCreateWindow(disp, root_win, 0, 0, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); #ifdef _DEBUG printf("Created window\n"); #endif if (fullscreen) { XMapRaised(disp, win); waitMapped(disp, win); for ( i = 0; i < num_modes; ++i ) { #ifdef _DEBUG printf("Mode %d: %dx%d\n", i, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay); #endif if (avail_modes[i]->hdisplay == width && avail_modes[i]->vdisplay == height) { if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[i])) { XFree(vis_info); XFree(avail_modes); XDestroyWindow(disp, win); XCloseDisplay(disp); #ifdef _DEBUG printf("Could not switch mode\n"); #endif return JNI_FALSE; } } } XF86VidModeSetViewPort(disp, screen, 0, 0); } else { XMapWindow(disp, win); waitMapped(disp, win); } XClearWindow(disp, win); XSync(disp, True); return JNI_TRUE; } JNIEXPORT void JNICALL Java_org_lwjgl_Display_nDestroy(JNIEnv * env, jclass clazz) { XDestroyWindow(disp, win); if (current_fullscreen) { if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[0])) { #ifdef _DEBUG printf("Could not switch mode\n"); #endif } } XFree(avail_modes); XFree(vis_info); XCloseDisplay(disp); #ifdef _DEBUG printf("Closed X connection\n"); #endif } /* * Class: org_lwjgl_Display * Method: getAvailableDisplayModes * Signature: ()[Lorg/lwjgl/DisplayMode; */ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_getAvailableDisplayModes (JNIEnv * env, jclass clazz) { int num_modes, i; Display *disp = XOpenDisplay(NULL); int screen = DefaultScreen(disp); XF86VidModeModeInfo **avail_modes; int depth = DefaultDepth(disp, screen); if (disp == NULL) { #ifdef _DEBUG printf("Could not open X connection\n"); #endif return NULL; } if (!getDisplayModes(disp, screen, &num_modes, &avail_modes)) { #ifdef _DEBUG printf("Could not get display modes\n"); #endif return NULL; } // Allocate an array of DisplayModes big enough jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode"); jobjectArray ret = env->NewObjectArray(num_modes, displayModeClass, NULL); jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V"); for (i = 0; i < num_modes; i++) { jobject displayMode = env->NewObject(displayModeClass, displayModeConstructor, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay, depth, 0); env->SetObjectArrayElement(ret, i, displayMode); } XFree(avail_modes); XCloseDisplay(disp); return ret; } --- NEW FILE: org_lwjgl_Math.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math.cpp /* * 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: org_lwjgl_Math.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * Win32 maths library. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ //#include "org_lwjgl_Math.h" --- NEW FILE: org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp /* * 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: org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect.h" #include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpAdd_MatrixOpDirect * Method: execute * Signature: (IIIIIZIIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpAdd_00024MatrixOpDirect_execute ( JNIEnv * env, jobject obj, jint leftSourceAddress, jint leftSourceStride, jint leftElements, jint leftSourceWidth, jint leftSourceHeight, jboolean transposeLeftSource, jint rightSourceAddress, jint rightSourceStride, jint rightElements, jint rightSourceWidth, jint rightSourceHeight, jboolean transposeRightSource, jint destAddress, jint destStride, jboolean transposeDest ) { MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); dest.configureBuffer(left, right); float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < left.elements; i++) { leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { rightMatrix = right.nextMatrix(); destMatrix = dest.nextMatrix(); int k = dest.width * dest.height; while (k--) destMatrix[k] = leftMatrix[k] + rightMatrix[k]; dest.writeComplete(); } } } --- NEW FILE: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp /* * 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: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe.h" #include "MatrixOpCommon.h" /* * Class: org_lwjgl_Math_MatrixOpAdd_MatrixOpSafe * Method: execute * Signature: (IIIIIZIIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpAdd_00024MatrixOpSafe_execute ( JNIEnv * env, jobject obj, jint leftSourceAddress, jint leftSourceStride, jint leftElements, jint leftSourceWidth, jint leftSourceHeight, jboolean transposeLeftSource, jint rightSourceAddress, jint rightSourceStride, jint rightElements, jint rightSourceWidth, jint rightSourceHeight, jboolean transposeRightSource, jint destAddress, jint destStride, jboolean transposeDest ) { MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); MatrixDst dest (destAddress, destStride, left.width, left.height, left.elements * right.elements, transposeDest); float * leftMatrix, * rightMatrix, * destMatrix; left.rewind(); for (int i = 0; i < leftElements; i++) { leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < rightElements; j++) { rightMatrix = right.nextMatrix(); destMatrix = dest.nextMatrix(); int k = dest.width * dest.height; while (k--) destMatrix[k] = leftMatrix[k] + rightMatrix[k]; dest.writeComplete(); } } } --- NEW FILE: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp /* * 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: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect.h" #include "MatrixOpCommon.h" #include <string.h> /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpDirect * Method: execute * Signature: (IIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpDirect_execute ( JNIEnv * env, jobject obj, jint sourceAddress, jint sourceStride, jint numElements, jint sourceWidth, jint sourceHeight, jboolean transposeSource, jint destAddress, jint destStride, jboolean transposeDest ) { if (transposeSource == transposeDest) { transposeSource = false; transposeDest = false; } MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); dest.configureBuffer(source); float * srcMatrix, * destMatrix; int matrixByteCount = source.width*source.height*sizeof(jfloat); for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); // just do a straight memory copy memcpy(destMatrix, srcMatrix, matrixByteCount); dest.writeComplete(); } } --- NEW FILE: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp /* * 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: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe.h" #include "MatrixOpCommon.h" #include <string.h> /* * Class: org_lwjgl_Math_MatrixOpCopy_MatrixOpSafe * Method: execute * Signature: (IIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpCopy_00024MatrixOpSafe_execute ( JNIEnv * env, jobject obj, jint sourceAddress, jint sourceStride, jint numElements, jint sourceWidth, jint sourceHeight, jboolean transposeSource, jint destAddress, jint destStride, jboolean transposeDest ) { // remove any unnecessary copying if (transposeSource == transposeDest) { transposeSource = false; transposeDest = false; } MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); float * srcMatrix, * destMatrix; int matrixByteCount = source.width*source.height*sizeof(jfloat); for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); // just do a straight memory copy memcpy(destMatrix, srcMatrix, matrixByteCount); dest.writeComplete(); } } --- NEW FILE: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp /* * 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: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * Win32 math library. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect.h" #include "MatrixOpCommon.h" #ifdef _DEBUG #include <stdio.h> #endif /* * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpDirect * Method: execute * Signature: (IIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDirect_execute ( JNIEnv * env, jobject obj, jint sourceAddress, jint sourceStride, jint numElements, jint sourceWidth, jint sourceHeight, jboolean transposeSource, jint destAddress, jint destStride, jboolean transposeDest ) { if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; } // We are under the assumption that sourceWidth == sourceHeight and the matrix // defined within is invertable MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); dest.configureBuffer(source); float * srcMatrix, * destMatrix; int temp_side = source.width-1; float temp_matrix [temp_side*temp_side]; for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest .nextMatrix(); // calculate the determinant float det = determinant(srcMatrix, source.width); #ifdef _DEBUG printf("Matrix Determinant: %f\n", det); printf("Matrix Determinant - 1 = %f\n", det -1); #endif float sign; for (int col = 0; col < source.width; col++) { /* Maintain sign: + - + - ... - + - + .. + - + - .. - + - + .. : : : : \ */ sign = (col & 1) ? -1.0f : 1.0f; for (int row = 0; row < source.height; row++) { // get the sub matrix subMatrix(srcMatrix, source.width, temp_matrix, col, row); // transpose the result destMatrix[col + row * source.height] = (sign / det) * determinant(temp_matrix, temp_side); // swap signs sign *= -1.0f; } } dest.writeComplete(); } } --- NEW FILE: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp /* * 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: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe.h" #include "MatrixOpCommon.h" #ifdef _DEBUG #include <stdio.h> #endif /* * Class: org_lwjgl_Math_MatrixOpInvert_MatrixOpSafe * Method: execute * Signature: (IIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe_execute ( JNIEnv * env, jobject obj, jint sourceAddress, jint sourceStride, jint numElements, jint sourceWidth, jint sourceHeight, jboolean transposeSource, jint destAddress, jint destStride, jboolean transposeDest ) { if (transposeSource == transposeDest) { transposeSource = JNI_FALSE; transposeDest = JNI_FALSE; } // We are under the assumption that sourceWidth == sourceHeight and the matrix // defined within is invertable MatrixSrc source (sourceAddress, sourceStride, sourceWidth, sourceHeight, numElements, transposeSource); MatrixDst dest (destAddress, destStride, source.width, source.height, source.elements, transposeDest); float * srcMatrix, * destMatrix; int temp_side = source.width-1; float temp_matrix [temp_side*temp_side]; for (int i = 0; i < source.elements; i++) { srcMatrix = source.nextMatrix(); destMatrix = dest.nextMatrix(); // calculate the determinant float det = determinant(srcMatrix, source.width); #ifdef _DEBUG printf("Matrix Determinant: %f\n", det); printf("Matrix Determinant - 1: %f\n", det-1); #endif float sign; for (int col = 0; col < source.width; col++) { /* Maintain sign: + - + - ... - + - + .. + - + - .. - + - + .. : : : : \ */ sign = (col & 1) ? -1.0f : 1.0f; for (int row = 0; row < source.height; row++) { // get the sub matrix subMatrix(srcMatrix, source.width, temp_matrix, col, row); // transpose the result destMatrix[col + row * source.height] = (sign / det) * determinant(temp_matrix, temp_side); // swap signs sign *= -1.0f; } } dest.writeComplete(); } } --- NEW FILE: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp /* * 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: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect.h" #include "MatrixOpCommon.h" #include <cstring> /* * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpDirect * Method: execute * Signature: (IIIIIZIIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpMultiply_00024MatrixOpDirect_execute ( JNIEnv * env, jobject obj, jint leftSourceAddress, jint leftSourceStride, jint leftElements, jint leftSourceWidth, jint leftSourceHeight, jboolean transposeLeftSource, jint rightSourceAddress, jint rightSourceStride, jint rightElements, jint rightSourceWidth, jint rightSourceHeight, jboolean transposeRightSource, jint destAddress, jint destStride, jboolean transposeDest ) { if (transposeLeftSource && transposeRightSource) { transposeLeftSource = false; transposeRightSource = false; transposeDest = !transposeDest; } MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); MatrixDst dest (destAddress, destStride, right.width, left.height, left.elements * right.elements, transposeDest); dest.configureBuffer(left, right); float * leftMatrix, * rightMatrix, * destMatrix; // check out discussions envolving ordering left.rewind(); for (int i = 0; i < left.elements; i++) { leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { rightMatrix = right.nextMatrix(); destMatrix = dest.nextMatrix(); // zero the elements of the destination matrix for (int d = 0; d < dest.width * dest.height; d++) destMatrix[d] = 0; // loop through each column of the right matrix int rightCell = 0; for (int rightCol = 0; rightCol < right.width; rightCol++) { // [RxC] * [RxC] // dest has same height as left // dest has same width as right int leftCell = 0; for (int leftCol = 0; leftCol < left.width; leftCol++) { for (int leftRow = 0; leftRow < left.height; leftRow++) { destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; } rightCell ++ ; } //rightMatrix = &rightMatrix[right.height]; destMatrix = &destMatrix[dest.height]; } dest.writeComplete(); } } } --- NEW FILE: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp /* * 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: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.cpp,v 1.1 2002/11/19 08:50:57 elias_naur Exp $ * * linux math library. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe.h" #include "MatrixOpCommon.h" #include <cstring> /* * Class: org_lwjgl_Math_MatrixOpMultiply_MatrixOpSafe * Method: execute * Signature: (IIIIIZIIIIIZIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpMultiply_00024MatrixOpSafe_execute ( JNIEnv * env, jobject obj, jint leftSourceAddress, jint leftSourceStride, jint leftElements, jint leftSourceWidth, jint leftSourceHeight, jboolean transposeLeftSource, jint rightSourceAddress, jint rightSourceStride, jint rightElements, jint rightSourceWidth, jint rightSourceHeight, jboolean transposeRightSource, jint destAddress, jint destStride, jboolean transposeDest ) { if (transposeLeftSource && transposeRightSource) { transposeLeftSource = false; transposeRightSource = false; transposeDest = !transposeDest; } MatrixSrc left (leftSourceAddress, leftSourceStride, leftSourceWidth, leftSourceHeight, leftElements, transposeLeftSource); MatrixSrc right (rightSourceAddress, leftSourceStride, rightSourceWidth, rightSourceHeight, rightElements, transposeRightSource); MatrixDst dest (destAddress, destStride, right.width, left.height, left.elements * right.elements, transposeDest); float * leftMatrix, * rightMatrix, * destMatrix; // check out discussions envolving ordering left.rewind(); for (int i = 0; i < left.elements; i++) { leftMatrix = left.nextMatrix(); right.rewind(); for (int j = 0; j < right.elements; j++) { rightMatrix = right.nextMatrix(); destMatrix = dest.nextMatrix(); // zero the elements of the destination matrix for (int d = 0; d < dest.width * dest.height; d++) destMatrix[d] = 0; // loop through each column of the right matrix int rightCell = 0; for (int rightCol = 0; rightCol < right.width; rightCol++) { // [RxC] * [RxC] // dest has same height as left // dest has same width as right int leftCell = 0; for (int leftCol = 0; leftCol < left.width; leftCol++) { for (int leftRow = 0; leftRow < left.height; leftRow++) { destMatrix[leftRow] += rightMatrix[rightCell] * leftMatrix[leftCell++]; } rightCell ++ ; } //rightMatrix = &rightMatrix[right.height]; destMatrix = &destMatrix[dest.height]; } dest.writeComplete(); } } } --- NEW FILE: org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_Math_MatrixOpNegate_MatrixOpDirect.cpp /* * 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 ... [truncated message content] |
From: Elias N. <eli...@us...> - 2002-11-19 07:51:30
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/test In directory sc8-pr-cvs1:/tmp/cvs-serv19245/java/org/lwjgl/opengl/test Added Files: Game.java Log Message: Moved Game.java opengl test to java/org/lwjgl/opengl/test --- NEW FILE: Game.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/test/Game.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. */ /** * $Id: Game.java,v 1.1 2002/11/19 07:51:27 elias_naur Exp $ * * Simple java test program. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ package org.lwjgl.opengl.test; import org.lwjgl.*; import org.lwjgl.opengl.*; import org.lwjgl.input.*; import java.nio.*; public final class Game { static { try { DisplayMode[] modes = Display.getAvailableDisplayModes(); System.out.println("Available display modes:"); for (int i = 0; i < modes.length; i ++) System.out.println(modes[i]); // For now let's just pick a mode we're certain to have Display.create(new DisplayMode(640, 480, 16, 60), true); System.out.println("Created display."); } catch (Exception e) { System.err.println("Failed to create display due to "+e); System.exit(1); } } public static final GL gl = new GL(16, 0, 16, 8); public static final GLU glu = new GLU(gl); static { try { gl.create(); System.out.println("Created OpenGL."); } catch (Exception e) { System.err.println("Failed to create OpenGL due to "+e); System.exit(1); } } /** Is the game finished? */ private static boolean finished; /** A rotating square! */ private static float angle; /** * No construction allowed */ private Game() { } public static void main(String[] arguments) { try { init(); while (!finished) { // Keyboard.poll(); mainLoop(); render(); gl.swapBuffers(); } } catch (Throwable t) { t.printStackTrace(); } finally { cleanup(); } } /** * All calculations are done in here */ private static void mainLoop() { angle += 1f; if (angle > 360.0f) angle = 0.0f; Mouse.poll(); if (Mouse.dx != 0 || Mouse.dy != 0 || Mouse.dz != 0) System.out.println("Mouse moved " + Mouse.dx + " " + Mouse.dy + " " + Mouse.dz); for (int i = 0; i < 8; i++) if (Mouse.isButtonDown(i)) System.out.println("Button " + i + " down"); /* Keyboard.poll(); if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) finished = true;*/ Keyboard.read(); for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); if (Keyboard.key == Keyboard.KEY_ESCAPE && Keyboard.state) finished = true; if (Keyboard.key == Keyboard.KEY_T && Keyboard.state) System.out.println("Current time: " + Sys.getTime()); } } /** * All rendering is done in here */ private static void render() { gl.clear(GL.COLOR_BUFFER_BIT); gl.pushMatrix(); gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); gl.rotatef(angle, 0, 0, 1.0f); gl.begin(GL.QUADS); gl.vertex2i(-50, -50); gl.vertex2i(50, -50); gl.vertex2i(50, 50); gl.vertex2i(-50, 50); gl.end(); gl.popMatrix(); } /** * Initialize */ private static void init() throws Exception { Keyboard.create(); Keyboard.enableBuffer(); Mouse.create(); Sys.setTime(0); Sys.setProcessPriority(Sys.REALTIME_PRIORITY); System.out.println("Timer resolution: " + Sys.getTimerResolution()); // Go into orthographic projection mode. gl.matrixMode(GL.PROJECTION); gl.loadIdentity(); glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight()); gl.matrixMode(GL.MODELVIEW); gl.loadIdentity(); gl.viewport(0, 0, Display.getWidth(), Display.getHeight()); ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4); num_tex_units_buf.order(ByteOrder.nativeOrder()); int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf); gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr); System.out.println("Number of texture units: " + num_tex_units_buf.getInt()); // Fix the refresh rate to the display frequency. // gl.wglSwapIntervalEXT(1); } /** * Cleanup */ private static void cleanup() { Keyboard.destroy(); Mouse.destroy(); gl.destroy(); Display.destroy(); } } |
From: Elias N. <eli...@us...> - 2002-11-19 07:51:30
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv19245/native/linux Removed Files: Game.java Log Message: Moved Game.java opengl test to java/org/lwjgl/opengl/test --- Game.java DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Game.java |
From: Elias N. <eli...@us...> - 2002-11-19 07:48:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/test In directory sc8-pr-cvs1:/tmp/cvs-serv18605/test Log Message: Directory /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/test added to the repository |
From: Elias N. <eli...@us...> - 2002-11-19 07:42:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv17197/linux Modified Files: Makefile org_lwjgl_opengl_BaseGL.c Removed Files: checkGLerror.h extgl.c extgl.h Log Message: Updated extgl.h/c and checkGLerror.h Index: Makefile CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile 18 Nov 2002 20:07:00 -0000 1.5 +++ Makefile 19 Nov 2002 07:42:54 -0000 1.6 @@ -42,7 +42,7 @@ GCC = gcc LINK = gcc JAVAHOME=/usr/java/j2sdk1.4.1_01 -LIBOBJS=extgl.o org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o +LIBOBJS=../common/extgl.o org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o #DEBUG_FLAGS=-D_DEBUG LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU Index: org_lwjgl_opengl_BaseGL.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_BaseGL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_BaseGL.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_opengl_BaseGL.c 18 Nov 2002 20:22:00 -0000 1.3 +++ org_lwjgl_opengl_BaseGL.c 19 Nov 2002 07:42:55 -0000 1.4 @@ -39,7 +39,7 @@ * @version $Revision$ */ -#include <GL/glx.h> +#include "extgl.h" #include "org_lwjgl_opengl_BaseGL.h" GLXContext context = NULL; // OpenGL rendering context --- checkGLerror.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/checkGLerror.h --- extgl.c DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/extgl.c --- extgl.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/extgl.h |
From: Elias N. <eli...@us...> - 2002-11-19 07:42:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv17197/common Modified Files: checkGLerror.h Added Files: extgl.c extgl.h Log Message: Updated extgl.h/c and checkGLerror.h --- NEW FILE: extgl.c --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/extgl.c /* ---------------------------------------------------------------------------- Copyright (c) 2001-2002, Lev Povalahev 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. * The name of the author 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, [...2182 lines suppressed...] #ifdef _WIN32 extgl_InitializeWGL(); #endif SupportedExtensions = extgl_Extensions; return extgl_error; } /* deprecated function please do not use it, use extgl_Initialize() instead */ int glInitialize() { return extgl_Initialize(); } /* turn on the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn .8064 #pragma warn .8065 #endif /* __BORLANDC__ */ --- NEW FILE: extgl.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/extgl.h /* Small parts were taken from glext.h, here's the lisence: */ /* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free ** Software License B, Version 1.1 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: ** ** http://oss.sgi.com/projects/FreeB ** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. ** [...4958 lines suppressed...] int SGIX_depth_texture; int OpenGL12; int OpenGL13; int OpenGL14; }; extern struct ExtensionTypes extgl_Extensions; extern struct ExtensionTypes SupportedExtensions; /* deprecated, please do not use */ /* initializes everything, call this right after the rc is created. the function returns 0 if successful */ int extgl_Initialize(); int glInitialize(); /* deprecated, please do not use */ #ifdef __cplusplus } #endif #endif /* __EXTGL_H__ */ Index: checkGLerror.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/checkGLerror.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/checkGLerror.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- checkGLerror.h 15 Aug 2002 16:11:43 -0000 1.3 +++ checkGLerror.h 19 Nov 2002 07:42:54 -0000 1.4 @@ -13,7 +13,7 @@ #ifdef _DEBUG #include <jni.h> -#include <gl/glu.h> +#include <GL/glu.h> #define CHECK_GL_ERROR \ { \ @@ -31,4 +31,4 @@ #endif /* _DEBUG */ -#endif /* _CHECKGLERROR_H_INCLUDED_ */ \ No newline at end of file +#endif /* _CHECKGLERROR_H_INCLUDED_ */ |
From: Elias N. <eli...@us...> - 2002-11-19 07:42:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv17197/win32 Removed Files: extgl.c extgl.h Log Message: Updated extgl.h/c and checkGLerror.h --- extgl.c DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/extgl.c --- extgl.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/extgl.h |
From: Elias N. <eli...@pr...> - 2002-11-18 20:29:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv20760 Modified Files: Game.java Log Message: Added small GL extension test to Game.java Index: Game.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Game.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Game.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Game.java 17 Nov 2002 17:09:40 -0000 1.6 +++ Game.java 18 Nov 2002 20:29:48 -0000 1.7 @@ -42,7 +42,8 @@ import org.lwjgl.*; import org.lwjgl.opengl.*; import org.lwjgl.input.*; - + +import java.nio.*; public final class Game { static { @@ -161,8 +162,13 @@ gl.matrixMode(GL.MODELVIEW); gl.loadIdentity(); gl.viewport(0, 0, Display.getWidth(), Display.getHeight()); + ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4); + num_tex_units_buf.order(ByteOrder.nativeOrder()); + int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf); + gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr); + System.out.println("Number of texture units: " + num_tex_units_buf.getInt()); // Fix the refresh rate to the display frequency. - gl.wglSwapIntervalEXT(1); +// gl.wglSwapIntervalEXT(1); } /** |
From: Elias N. <eli...@pr...> - 2002-11-18 20:22:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv17610 Modified Files: org_lwjgl_opengl_BaseGL.c org_lwjgl_opengl_CoreGL.c Log Message: GL extensions fixes Index: org_lwjgl_opengl_BaseGL.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_BaseGL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_BaseGL.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_BaseGL.c 15 Nov 2002 11:10:32 -0000 1.2 +++ org_lwjgl_opengl_BaseGL.c 18 Nov 2002 20:22:00 -0000 1.3 @@ -70,6 +70,12 @@ return JNI_FALSE; } + if (extgl_Initialize() != 0) { +#ifdef _DEBUG + printf("Could not init gl function pointers\n"); +#endif + return JNI_FALSE; + } return JNI_TRUE; } Index: org_lwjgl_opengl_CoreGL.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_CoreGL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_CoreGL.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_CoreGL.c 15 Nov 2002 11:10:32 -0000 1.2 +++ org_lwjgl_opengl_CoreGL.c 18 Nov 2002 20:22:01 -0000 1.3 @@ -41,7 +41,7 @@ #include "org_lwjgl_opengl_CoreGL.h" #include "checkGLerror.h" -#include <GL/gl.h> +#include "extgl.h" /* * Class: org_lwjgl_opengl_CoreGL |
From: Elias N. <eli...@pr...> - 2002-11-18 20:07:05
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv11085 Modified Files: Makefile Log Message: Cleanup makefile Index: Makefile CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile 18 Nov 2002 20:02:03 -0000 1.4 +++ Makefile 18 Nov 2002 20:07:00 -0000 1.5 @@ -43,7 +43,7 @@ LINK = gcc JAVAHOME=/usr/java/j2sdk1.4.1_01 LIBOBJS=extgl.o org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o -DEBUG_FLAGS=-D_DEBUG +#DEBUG_FLAGS=-D_DEBUG LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU all: liblwjgl.so |
From: Elias N. <eli...@pr...> - 2002-11-18 20:02:29
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv8799 Modified Files: Makefile org_lwjgl_opengl_GL.c Added Files: extgl.c extgl.h Log Message: Added support for GL extensions --- NEW FILE: extgl.c --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/extgl.c /* ---------------------------------------------------------------------------- Copyright (c) 2001-2002, Lev Povalahev 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. * The name of the author 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, [...2182 lines suppressed...] #ifdef _WIN32 extgl_InitializeWGL(); #endif SupportedExtensions = extgl_Extensions; return extgl_error; } /* deprecated function please do not use it, use extgl_Initialize() instead */ int glInitialize() { return extgl_Initialize(); } /* turn on the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn .8064 #pragma warn .8065 #endif /* __BORLANDC__ */ --- NEW FILE: extgl.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/extgl.h /* Small parts were taken from glext.h, here's the lisence: */ /* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free ** Software License B, Version 1.1 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: ** ** http://oss.sgi.com/projects/FreeB ** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. ** [...4958 lines suppressed...] int SGIX_depth_texture; int OpenGL12; int OpenGL13; int OpenGL14; }; extern struct ExtensionTypes extgl_Extensions; extern struct ExtensionTypes SupportedExtensions; /* deprecated, please do not use */ /* initializes everything, call this right after the rc is created. the function returns 0 if successful */ int extgl_Initialize(); int glInitialize(); /* deprecated, please do not use */ #ifdef __cplusplus } #endif #endif /* __EXTGL_H__ */ Index: Makefile CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/Makefile =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile 17 Nov 2002 17:09:40 -0000 1.3 +++ Makefile 18 Nov 2002 20:02:03 -0000 1.4 @@ -42,7 +42,7 @@ GCC = gcc LINK = gcc JAVAHOME=/usr/java/j2sdk1.4.1_01 -LIBOBJS=org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o +LIBOBJS=extgl.o org_lwjgl_Display.o org_lwjgl_Sys.o org_lwjgl_opengl_BaseGL.o org_lwjgl_opengl_GL.o org_lwjgl_opengl_CoreGL.o org_lwjgl_input_Keyboard.o org_lwjgl_opengl_GLU.o org_lwjgl_input_Mouse.o DEBUG_FLAGS=-D_DEBUG LINKOPTS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGL -lGLU Index: org_lwjgl_opengl_GL.c CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_GL.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_GL.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_GL.c 15 Nov 2002 11:10:32 -0000 1.2 +++ org_lwjgl_opengl_GL.c 18 Nov 2002 20:02:17 -0000 1.3 @@ -35,11 +35,12 @@ * * GL extensions library. * - * @author elias_naur <eli...@us...> + * @author cix_foo <ci...@us...> * @version $Revision$ */ #include "org_lwjgl_opengl_GL.h" +#include "extgl.h" #include "checkGLerror.h" [...4348 lines suppressed...] JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL_checkWGLExtensionsString(JNIEnv * env, jclass clazz) { -//jfieldID fid_WGL_ARB_extensions_string = env->GetStaticFieldID(clazz, "WGL_ARB_extensions_string", "Z"); -//jfieldID fid_WGL_EXT_extensions_string = env->GetStaticFieldID(clazz, "WGL_EXT_extensions_string", "Z"); - -//if (wglGetExtensionsStringARB) -// env->SetStaticBooleanField(clazz, fid_WGL_ARB_extensions_string, JNI_TRUE); -//if (wglGetExtensionsStringEXT) -// env->SetStaticBooleanField(clazz, fid_WGL_EXT_extensions_string, JNI_TRUE); +/* jfieldID fid_WGL_ARB_extensions_string = (*env)->GetStaticFieldID(env, clazz, "WGL_ARB_extensions_string", "Z"); + jfieldID fid_WGL_EXT_extensions_string = (*env)->GetStaticFieldID(env, clazz, "WGL_EXT_extensions_string", "Z"); + if (wglGetExtensionsStringARB) + (*env)->SetStaticBooleanField(env, clazz, fid_WGL_ARB_extensions_string, JNI_TRUE); + if (wglGetExtensionsStringEXT) + (*env)->SetStaticBooleanField(env, clazz, fid_WGL_EXT_extensions_string, JNI_TRUE); +*/ } |
From: Brian M. <ma...@pr...> - 2002-11-18 17:59:05
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv23805 Modified Files: org_lwjgl_input_Joystick.cpp Log Message: fix: made joystick static, according to specs Index: org_lwjgl_input_Joystick.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_input_Joystick.cpp 18 Nov 2002 06:16:12 -0000 1.3 +++ org_lwjgl_input_Joystick.cpp 18 Nov 2002 17:49:27 -0000 1.4 @@ -64,7 +64,6 @@ // Cached fields of Joystick.java jclass clsJoystick; -jobject objJoystick; jfieldID fidButtonCount; jfieldID fidHasZAxis; jfieldID fidHasPOV; @@ -83,9 +82,9 @@ void CreateJoystick(LPCDIDEVICEINSTANCE lpddi); void SetupJoystick(); void InitializeFields(); +void CacheFields(); void UpdateFields(); void SetCapabilities(); -void CacheFields(jobject obj); void PrintError(HRESULT error); /** @@ -93,15 +92,16 @@ */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs(JNIEnv * env, jclass clazz) { environment = env; + clsJoystick = clazz; + + /* Cache fields in Joystick */ + CacheFields(); } /** * Called when the Joystick instance is to be created */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jobject obj) { - /* Cache fields in Joystick */ - CacheFields(obj); - +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jclass clazz) { // Create the DirectInput object. HRESULT hr; hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); @@ -145,7 +145,7 @@ * Method: nDestroy * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobject obj) { +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jclass clazz) { Shutdown(); } @@ -154,7 +154,7 @@ * Method: nPoll * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) { +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jclass clazz) { HRESULT hRes; // poll the joystick to read the current state @@ -184,11 +184,6 @@ lpDI->Release(); lpDI = NULL; } - - // Delete are global reference to the Joystick - if(objJoystick != NULL) { - environment->DeleteGlobalRef(objJoystick); - } } /** @@ -325,7 +320,7 @@ void InitializeFields() { //set buttons array jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); - environment->SetObjectField(objJoystick, fidButtons, buttonsArray); + environment->SetStaticObjectField(clsJoystick, fidButtons, buttonsArray); } /** @@ -350,21 +345,21 @@ } //axis's - environment->SetIntField(objJoystick, fidX, js.lX); - environment->SetIntField(objJoystick, fidY, js.lY); + environment->SetStaticIntField(clsJoystick, fidX, js.lX); + environment->SetStaticIntField(clsJoystick, fidY, js.lY); if(hasz) { - environment->SetIntField(objJoystick, fidZ, js.lZ); + environment->SetStaticIntField(clsJoystick, fidZ, js.lZ); } //buttons - jbooleanArray buttonsArray = (jbooleanArray) environment->GetObjectField(objJoystick, fidButtons); + jbooleanArray buttonsArray = (jbooleanArray) environment->GetStaticObjectField(clsJoystick, fidButtons); BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); memcpy(buttons, js.rgbButtons, 4); environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); //pov if(haspov) { - environment->SetIntField(objJoystick, fidPOV, js.rgdwPOV[0]); + environment->SetStaticIntField(clsJoystick, fidPOV, js.rgdwPOV[0]); } } @@ -373,30 +368,25 @@ */ void SetCapabilities() { //set buttoncount - environment->SetIntField(objJoystick, fidButtonCount, buttoncount); + environment->SetStaticIntField(clsJoystick, fidButtonCount, buttoncount); //set z axis - environment->SetIntField(objJoystick, fidHasZAxis, hasz); + environment->SetStaticIntField(clsJoystick, fidHasZAxis, hasz); //set pov - environment->SetIntField(objJoystick, fidHasPOV, haspov); + environment->SetStaticIntField(clsJoystick, fidHasPOV, haspov); } /** * Caches the field ids for quicker access */ -void CacheFields(jobject obj) { - /* make certain that we're caching from a global object, and not a local */ - objJoystick = environment->NewGlobalRef(obj); - clsJoystick = environment->GetObjectClass(objJoystick); - - /* cache fields */ - fidButtonCount = environment->GetFieldID(clsJoystick, "buttonCount", "I"); - fidHasZAxis = environment->GetFieldID(clsJoystick, "hasZAxis", "Z"); - fidHasPOV = environment->GetFieldID(clsJoystick, "hasPOV", "Z"); - fidButtons = environment->GetFieldID(clsJoystick, "buttons", "[Z"); - fidX = environment->GetFieldID(clsJoystick, "x", "I"); - fidY = environment->GetFieldID(clsJoystick, "y", "I"); - fidZ = environment->GetFieldID(clsJoystick, "z", "I"); - fidPOV = environment->GetFieldID(clsJoystick, "pov", "I"); +void CacheFields() { + fidButtonCount = environment->GetStaticFieldID(clsJoystick, "buttonCount", "I"); + fidHasZAxis = environment->GetStaticFieldID(clsJoystick, "hasZAxis", "Z"); + fidHasPOV = environment->GetStaticFieldID(clsJoystick, "hasPOV", "Z"); + fidButtons = environment->GetStaticFieldID(clsJoystick, "buttons", "[Z"); + fidX = environment->GetStaticFieldID(clsJoystick, "x", "I"); + fidY = environment->GetStaticFieldID(clsJoystick, "y", "I"); + fidZ = environment->GetStaticFieldID(clsJoystick, "z", "I"); + fidPOV = environment->GetStaticFieldID(clsJoystick, "pov", "I"); } |
From: Brian M. <ma...@pr...> - 2002-11-18 17:59:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test In directory sc8-pr-cvs1:/tmp/cvs-serv24091/test Modified Files: JoystickTest.java Log Message: fix: made joystick static, according to specs Index: JoystickTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/test/JoystickTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test/JoystickTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- JoystickTest.java 17 Nov 2002 18:15:01 -0000 1.1 +++ JoystickTest.java 18 Nov 2002 17:50:21 -0000 1.2 @@ -16,20 +16,17 @@ */ public class JoystickTest extends Panel { - private Joystick joystick = null; - private int counter = 0; public Thread animationThread; /** Creates a new instance of JoystickTest */ public JoystickTest() { - joystick = new Joystick(); try { - joystick.create(); + Joystick.create(); } catch (Exception e) { e.printStackTrace(); - joystick = null; + return; } animationThread = new Thread() { @@ -58,37 +55,34 @@ int y = 100; int x = 100; - if (joystick != null) { - joystick.poll(); - - g.setColor(Color.blue); - g.drawString("Buttoncount: " + joystick.buttonCount, x, y); - y += 20; - g.drawString("-----------------------------------------------", x, y); - y += 20; - g.drawString("x : " + joystick.x, x, y); + Joystick.poll(); + + g.setColor(Color.blue); + g.drawString("Buttoncount: " + Joystick.buttonCount, x, y); + y += 20; + g.drawString("-----------------------------------------------", x, y); + y += 20; + g.drawString("x : " + Joystick.x, x, y); + y += 20; + g.drawString("y : " + Joystick.y, x, y); + y += 20; + if(Joystick.hasZAxis) { + g.drawString("z : " + Joystick.z, x, y); y += 20; - g.drawString("y : " + joystick.y, x, y); + } + if(Joystick.hasPOV) { + g.drawString("pov: " + Joystick.pov, x, y); y += 20; - if(joystick.hasZAxis) { - g.drawString("z : " + joystick.z, x, y); - y += 20; - } - if(joystick.hasPOV) { - g.drawString("pov: " + joystick.pov, x, y); - y += 20; - } - - //paint buttons - g.drawString("btn: ", x, y); - x += g.getFontMetrics().stringWidth("btn: "); - for(int i=0; i<joystick.buttonCount; i++) { - if(joystick.isButtonDown(i)) { - g.drawString(i + ", ", x, y); - x+= 15; - } + } + + //paint buttons + g.drawString("btn: ", x, y); + x += g.getFontMetrics().stringWidth("btn: "); + for(int i=0; i<Joystick.buttonCount; i++) { + if(Joystick.isButtonDown(i)) { + g.drawString(i + ", ", x, y); + x+= 15; } - } } @@ -96,10 +90,15 @@ paint(g); } + public void disposing() { + Joystick.destroy(); + } + /** * @param args the command line arguments */ public static void main(String[] args) { + final JoystickTest p = new JoystickTest(); final Frame f = new Frame(); f.setLayout(null); f.setSize(640, 480); @@ -107,11 +106,11 @@ f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f.hide(); + p.disposing(); f.dispose(); } }); - JoystickTest p = new JoystickTest(); p.setSize(640, 480); p.setLocation(0, 0); p.setBackground(Color.RED); |
From: Brian M. <ma...@pr...> - 2002-11-18 17:59:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1:/tmp/cvs-serv24091 Modified Files: Joystick.java Log Message: fix: made joystick static, according to specs CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/Joystick.java |
From: Brian M. <ma...@pr...> - 2002-11-18 17:41:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv7777 Modified Files: org_lwjgl_input_Joystick.h Log Message: fix: made joystick static, according to specs Index: org_lwjgl_input_Joystick.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_input_Joystick.h 18 Nov 2002 06:16:31 -0000 1.3 +++ org_lwjgl_input_Joystick.h 18 Nov 2002 16:42:30 -0000 1.4 @@ -1,31 +1,66 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> +#include <jni.h> /* Header for class org_lwjgl_input_Joystick */ #ifndef _Included_org_lwjgl_input_Joystick -#define _Included_org_lwjgl_input_Joystick +#define _Included_org_lwjgl_input_Joystick #ifdef __cplusplus extern "C" { -#endif -/* Inaccessible static: _00024assertionsDisabled */ +#endif +/* Inaccessible static: _00024assertionsDisabled */ +/* Inaccessible static: created */ +/* Inaccessible static: buttons */ +/* Inaccessible static: x */ +/* Inaccessible static: y */ +/* Inaccessible static: z */ +/* Inaccessible static: pov */ #undef org_lwjgl_input_Joystick_POV_CENTER -#define org_lwjgl_input_Joystick_POV_CENTER -1L +#define org_lwjgl_input_Joystick_POV_CENTER -1L #undef org_lwjgl_input_Joystick_POV_NORTH -#define org_lwjgl_input_Joystick_POV_NORTH 0L +#define org_lwjgl_input_Joystick_POV_NORTH 0L #undef org_lwjgl_input_Joystick_POV_SOUTH -#define org_lwjgl_input_Joystick_POV_SOUTH 18000L +#define org_lwjgl_input_Joystick_POV_SOUTH 18000L #undef org_lwjgl_input_Joystick_POV_EAST -#define org_lwjgl_input_Joystick_POV_EAST 27000L +#define org_lwjgl_input_Joystick_POV_EAST 27000L #undef org_lwjgl_input_Joystick_POV_WEST -#define org_lwjgl_input_Joystick_POV_WEST 9000L -/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Joystick */ /* * Class: org_lwjgl_input_Joystick * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll (JNIEnv *, jobject); +#define org_lwjgl_input_Joystick_POV_WEST 9000L +/* Inaccessible static: buttonCount */ +/* Inaccessible static: hasZAxis */ +/* Inaccessible static: hasPOV */ +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Joystick */ +/* + * Class: org_lwjgl_input_Joystick + * Method: nPoll + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll + (JNIEnv *, jclass); -/* * Class: org_lwjgl_input_Joystick * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate (JNIEnv *, jobject); +/* + * Class: org_lwjgl_input_Joystick + * Method: nCreate + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate + (JNIEnv *, jclass); -/* * Class: org_lwjgl_input_Joystick * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy (JNIEnv *, jobject); +/* + * Class: org_lwjgl_input_Joystick + * Method: nDestroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy + (JNIEnv *, jclass); -/* * Class: org_lwjgl_input_Joystick * Method: initIDs * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs (JNIEnv *, jclass); +/* + * Class: org_lwjgl_input_Joystick + * Method: initIDs + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs + (JNIEnv *, jclass); #ifdef __cplusplus } -#endif #endif \ No newline at end of file +#endif +#endif |
From: Brian M. <ma...@pr...> - 2002-11-18 06:16:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv11534 Modified Files: org_lwjgl_input_Joystick.h Log Message: fix: formatting got fucked Index: org_lwjgl_input_Joystick.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Joystick.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_input_Joystick.h 17 Nov 2002 18:12:13 -0000 1.2 +++ org_lwjgl_input_Joystick.h 18 Nov 2002 06:16:31 -0000 1.3 @@ -18,40 +18,14 @@ #define org_lwjgl_input_Joystick_POV_EAST 27000L #undef org_lwjgl_input_Joystick_POV_WEST #define org_lwjgl_input_Joystick_POV_WEST 9000L -/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Joystick */ -/* - * Class: org_lwjgl_input_Joystick - * Method: nPoll - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll - (JNIEnv *, jobject); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nCreate - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate - (JNIEnv *, jobject); - -/* - * Class: org_lwjgl_input_Joystick - * Method: nDestroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy - (JNIEnv *, jobject); - -/* - * Class: org_lwjgl_input_Joystick - * Method: initIDs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs - (JNIEnv *, jclass); - +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Joystick */ /* * Class: org_lwjgl_input_Joystick * Method: nPoll * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll (JNIEnv *, jobject); + +/* * Class: org_lwjgl_input_Joystick * Method: nCreate * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate (JNIEnv *, jobject); + +/* * Class: org_lwjgl_input_Joystick * Method: nDestroy * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy (JNIEnv *, jobject); + +/* * Class: org_lwjgl_input_Joystick * Method: initIDs * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs (JNIEnv *, jclass); + #ifdef __cplusplus } -#endif -#endif +#endif #endif \ No newline at end of file |
From: Brian M. <ma...@pr...> - 2002-11-18 06:16:15
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv11367 Modified Files: org_lwjgl_input_Joystick.cpp Log Message: bulk commit, since cvs server was down while fixing :/ fix: formatting got fucked fix: multiple poll fix: removed AquireInput method Index: org_lwjgl_input_Joystick.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_input_Joystick.cpp 17 Nov 2002 18:13:46 -0000 1.2 +++ org_lwjgl_input_Joystick.cpp 18 Nov 2002 06:16:12 -0000 1.3 @@ -1,427 +1,402 @@ -/* - * 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 analogue joystick handling. - * - * @author Brian Matzon <br...@ma...> - * @version $Revision$ - */ -#define WIN32_LEAN_AND_MEAN - -#include "org_lwjgl_input_Joystick.h" - -#include <windows.h> -#undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0500 -#include <dinput.h> - -#define JOYMAX 1000 // Maxmimum range to which we'll gauge the swing -#define JOYMIN -1000 // Minimum range to which we'll gauge the swing - -extern HWND hwnd; // Handle to window - -IDirectInput* lpDI; // DI instance -IDirectInputDevice2* lpDIDevice; // DI Device instance -DIJOYSTATE2 js; // State of joystick - -int buttoncount = 0; // Temporary buttoncount -bool hasz; // Temporary zaxis check -bool haspov; // Temporary pov check - -JNIEnv* environment; // JNIEnvironment copy - -bool create_success; // bool used to determine successfull creation - -// Cached fields of Joystick.java -jclass clsJoystick; -jobject objJoystick; -jfieldID fidButtonCount; -jfieldID fidHasZAxis; -jfieldID fidHasPOV; -jfieldID fidButtons; -jfieldID fidX; -jfieldID fidY; -jfieldID fidZ; -jfieldID fidPOV; - -// Function prototypes (defined in the cpp file, since header file is generic across platforms -void EnumerateCapabilities(); -void EnumerateJoysticks(); -BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); -BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); -void Shutdown(); -void CreateJoystick(LPCDIDEVICEINSTANCE lpddi); -void SetupJoystick(); -void InitializeFields(); -void UpdateFields(); -void SetCapabilities(); -void CacheFields(jobject obj); -void PrintError(HRESULT error); - -/** - * Initializes any field ids - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs(JNIEnv * env, jclass clazz) { - environment = env; -} - -/** - * Called when the Joystick instance is to be created - */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jobject obj) { - /* Cache fields in Joystick */ - CacheFields(obj); - - // Create the DirectInput object. - HRESULT hr; - hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); - if (FAILED(hr)) { - Shutdown(); - return JNI_FALSE; - } - - /* Find all joysticks */ - EnumerateJoysticks(); - if (!create_success) { - Shutdown(); - return JNI_FALSE; - } - - /* Enumerate capabilities of joystick */ - EnumerateCapabilities(); - if (!create_success) { - Shutdown(); - return JNI_FALSE; - } - - /* Initialize any fields on the Joystick */ - InitializeFields(); - - /* Set capabilities */ - SetCapabilities(); - - /* Aquire the joystick */ - hr = lpDIDevice->Acquire(); - if(FAILED(hr)) { - Shutdown(); - return JNI_FALSE; - } - - return create_success; -} - -/* - * Class: org_lwjgl_input_Joystick - * Method: nDestroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobject obj) { - Shutdown(); -} - -/* - * Class: org_lwjgl_input_Joystick - * Method: nPoll - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) { - lpDIDevice->Poll(); - UpdateFields(); -} - -/** - * Shutdown DI - */ -void Shutdown() { - // release DI instance - if (lpDI != NULL) { - // release device - if (lpDIDevice != NULL) { - lpDIDevice->Unacquire(); - lpDIDevice->Release(); - lpDIDevice = NULL; - } - lpDI->Release(); - lpDI = NULL; - } - - // Delete are global reference to the Joystick - if(objJoystick != NULL) { - environment->DeleteGlobalRef(objJoystick); - } -} - -/** - * Enumerates the capabilities of the joystick attached to the system - */ -void EnumerateCapabilities() { - HRESULT hr; - hr = lpDIDevice->EnumObjects(EnumJoystickObjectsCallback, NULL, DIDFT_ALL); - if FAILED(hr) { - create_success = false; - return; - } - create_success = true; -} - -/** - * Enumerates the joysticks attached to the system - */ -void EnumerateJoysticks() { - HRESULT hr; - hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumJoystickCallback, 0, DIEDFL_ATTACHEDONLY); - if FAILED(hr) { - create_success = false; - return; - } - create_success = true; -} - -/** - * Callback from EnumDevices. Called for each joystick attached to the system - */ -BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { - /* Add the joystick */ - CreateJoystick(pdinst); - if(create_success) { - /* Do setup of joystick */ - SetupJoystick(); - } - - /* just stop after 1st joystick */ - return DIENUM_STOP; -} - -/** - * Callback from EnumObjects. Called for each "object" on the joystick. - */ -BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { - if(lpddoi->guidType == GUID_Button) { - buttoncount++; - } else if(lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis) { - //do nothing - } else if(lpddoi->guidType == GUID_ZAxis || strcmp("Throttle", lpddoi->tszName) == 0){ - hasz = true; - } else if (lpddoi->guidType == GUID_POV){ - haspov = true; - } else { -#ifdef _DEBUG - printf("Unhandled object found: %s\n", lpddoi->tszName); -#endif - } - return DIENUM_CONTINUE; -} - -/** - * Creates the specified device as a joystick - */ -void CreateJoystick(LPCDIDEVICEINSTANCE lpddi) { - HRESULT hr; - hr = lpDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &lpDIDevice, NULL); - if FAILED(hr) { - create_success = false; - return; - } - create_success = true; -} - -/** - * Sets up the joystick properties - */ -void SetupJoystick() { - // set joystick data format - if(lpDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { - create_success = false; - return; - } - - // set the cooperative level - if(lpDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { - create_success = false; - return; - } - - // set X-axis range to (-1000 ... +1000) - // This lets us test against 0 to see which way the stick is pointed. - DIPROPRANGE diprg; - diprg.diph.dwSize = sizeof(diprg); - diprg.diph.dwHeaderSize = sizeof(diprg.diph); - diprg.diph.dwObj = DIJOFS_X; - diprg.diph.dwHow = DIPH_BYOFFSET; - diprg.lMin = JOYMIN; - diprg.lMax = JOYMAX; - - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { - create_success = false; - return; - } - - // - // And again for Y-axis range - // - diprg.diph.dwObj = DIJOFS_Y; - - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) - { - create_success = false; - return; - } - - // - // And again for z-axis range (throttle) - // - diprg.diph.dwObj = DIJOFS_Z; - - if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { - create_success = false; - return; - } - create_success = true; -} - -/** - * Aquires the Joystick - */ -bool AcquireInput(void) { - HRESULT hRes; - - // if we have a device - if (lpDIDevice != NULL) { - // acquire the device - hRes = lpDIDevice->Acquire(); - - if (SUCCEEDED(hRes)) { - // acquisition successful - return TRUE; - } else { - // acquisition failed - return FALSE; - } - } else { - // we don't have a current device - return FALSE; - } -} - -/** - * Sets the fields on the Joystick - */ -void InitializeFields() { - //set buttons array - jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); - environment->SetObjectField(objJoystick, fidButtons, buttonsArray); -} - -/** - * Updates the fields on the Joystick - */ -void UpdateFields() { - HRESULT hRes; - - // poll the joystick to read the current state - hRes = lpDIDevice->Poll(); - if (FAILED(hRes)) { -#if _DEBUG - printf("Poll fail\n"); -#endif - return; - } - - // get data from the joystick - hRes = lpDIDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js); - - if (hRes != DI_OK) { - // did the read fail because we lost input for some reason? - // if so, then attempt to reacquire. - if(hRes == DIERR_INPUTLOST) { - AcquireInput(); -#if _DEBUG - printf("DIERR_INPUTLOST, reaquiring input\n"); -#endif - } - return; - } - - //axis's - environment->SetIntField(objJoystick, fidX, js.lX); - environment->SetIntField(objJoystick, fidY, js.lY); - if(hasz) { - environment->SetIntField(objJoystick, fidZ, js.lZ); - } - - //buttons - jbooleanArray buttonsArray = (jbooleanArray) environment->GetObjectField(objJoystick, fidButtons); - BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); - memcpy(buttons, js.rgbButtons, 4); - environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); - - //pov - if(haspov) { - environment->SetIntField(objJoystick, fidPOV, js.rgdwPOV[0]); - } -} - -/** - * Sets the capabilities of the joystick - */ -void SetCapabilities() { - //set buttoncount - environment->SetIntField(objJoystick, fidButtonCount, buttoncount); - - //set z axis - environment->SetIntField(objJoystick, fidHasZAxis, hasz); - - //set pov - environment->SetIntField(objJoystick, fidHasPOV, haspov); -} - -/** - * Caches the field ids for quicker access - */ -void CacheFields(jobject obj) { - /* make certain that we're caching from a global object, and not a local */ - objJoystick = environment->NewGlobalRef(obj); - clsJoystick = environment->GetObjectClass(objJoystick); - - /* cache fields */ - fidButtonCount = environment->GetFieldID(clsJoystick, "buttonCount", "I"); - fidHasZAxis = environment->GetFieldID(clsJoystick, "hasZAxis", "Z"); - fidHasPOV = environment->GetFieldID(clsJoystick, "hasPOV", "Z"); - fidButtons = environment->GetFieldID(clsJoystick, "buttons", "[Z"); - fidX = environment->GetFieldID(clsJoystick, "x", "I"); - fidY = environment->GetFieldID(clsJoystick, "y", "I"); - fidZ = environment->GetFieldID(clsJoystick, "z", "I"); - fidPOV = environment->GetFieldID(clsJoystick, "pov", "I"); +/* + * 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 analogue joystick handling. + * + * @author Brian Matzon <br...@ma...> + * @version $Revision$ + */ + +#define WIN32_LEAN_AND_MEAN +#include "org_lwjgl_input_Joystick.h" +#include <windows.h> +#undef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION 0x0500 +#include <dinput.h> + +#define JOYMAX 1000 // Maxmimum range to which we'll gauge the swing +#define JOYMIN -1000 // Minimum range to which we'll gauge the swing + +extern HWND hwnd; // Handle to window + +IDirectInput* lpDI; // DI instance +IDirectInputDevice2* lpDIDevice; // DI Device instance +DIJOYSTATE2 js; // State of joystick + +int buttoncount = 0; // Temporary buttoncount +bool hasz; // Temporary zaxis check +bool haspov; // Temporary pov check + +JNIEnv* environment; // JNIEnvironment copy + +bool create_success; // bool used to determine successfull creation + +// Cached fields of Joystick.java +jclass clsJoystick; +jobject objJoystick; +jfieldID fidButtonCount; +jfieldID fidHasZAxis; +jfieldID fidHasPOV; +jfieldID fidButtons; +jfieldID fidX; +jfieldID fidY; +jfieldID fidZ; +jfieldID fidPOV; + +// Function prototypes (defined in the cpp file, since header file is generic across platforms +void EnumerateCapabilities(); +void EnumerateJoysticks(); +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); +BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); +void Shutdown(); +void CreateJoystick(LPCDIDEVICEINSTANCE lpddi); +void SetupJoystick(); +void InitializeFields(); +void UpdateFields(); +void SetCapabilities(); +void CacheFields(jobject obj); +void PrintError(HRESULT error); + +/** + * Initializes any field ids + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs(JNIEnv * env, jclass clazz) { + environment = env; +} + +/** + * Called when the Joystick instance is to be created + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jobject obj) { + /* Cache fields in Joystick */ + CacheFields(obj); + + // Create the DirectInput object. + HRESULT hr; + hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); + if (FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + /* Find all joysticks */ + EnumerateJoysticks(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Enumerate capabilities of joystick */ + EnumerateCapabilities(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Initialize any fields on the Joystick */ + InitializeFields(); + + /* Set capabilities */ + SetCapabilities(); + + /* Aquire the joystick */ + hr = lpDIDevice->Acquire(); + if(FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + return create_success; +} + +/* + * Class: org_lwjgl_input_Joystick + * Method: nDestroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobject obj) { + Shutdown(); +} + +/* + * Class: org_lwjgl_input_Joystick + * Method: nPoll + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) { + HRESULT hRes; + + // poll the joystick to read the current state + hRes = lpDIDevice->Poll(); + if (FAILED(hRes)) { +#if _DEBUG + printf("Poll fail\n"); +#endif + return; + } + + UpdateFields(); +} + +/** + * Shutdown DI + */ +void Shutdown() { + // release DI instance + if (lpDI != NULL) { + // release device + if (lpDIDevice != NULL) { + lpDIDevice->Unacquire(); + lpDIDevice->Release(); + lpDIDevice = NULL; + } + lpDI->Release(); + lpDI = NULL; + } + + // Delete are global reference to the Joystick + if(objJoystick != NULL) { + environment->DeleteGlobalRef(objJoystick); + } +} + +/** + * Enumerates the capabilities of the joystick attached to the system + */ +void EnumerateCapabilities() { + HRESULT hr; + hr = lpDIDevice->EnumObjects(EnumJoystickObjectsCallback, NULL, DIDFT_ALL); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; +} + +/** + * Enumerates the joysticks attached to the system + */ +void EnumerateJoysticks() { + HRESULT hr; + hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumJoystickCallback, 0, DIEDFL_ATTACHEDONLY); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; +} + +/** + * Callback from EnumDevices. Called for each joystick attached to the system + */ +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { + /* Add the joystick */ + CreateJoystick(pdinst); + if(create_success) { + /* Do setup of joystick */ + SetupJoystick(); + } + + /* just stop after 1st joystick */ + return DIENUM_STOP; +} + +/** + * Callback from EnumObjects. Called for each "object" on the joystick. + */ +BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { + if(lpddoi->guidType == GUID_Button) { + buttoncount++; + } else if(lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis) { + //do nothing + } else if(lpddoi->guidType == GUID_ZAxis || strcmp("Throttle", lpddoi->tszName) == 0){ + hasz = true; + } else if (lpddoi->guidType == GUID_POV){ + haspov = true; + } else { +#ifdef _DEBUG + printf("Unhandled object found: %s\n", lpddoi->tszName); +#endif + } + return DIENUM_CONTINUE; +} + +/** + * Creates the specified device as a joystick + */ +void CreateJoystick(LPCDIDEVICEINSTANCE lpddi) { + HRESULT hr; + hr = lpDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &lpDIDevice, NULL); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; +} + +/** + * Sets up the joystick properties + */ +void SetupJoystick() { + // set joystick data format + if(lpDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { + create_success = false; + return; + } + + // set the cooperative level + if(lpDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + create_success = false; + return; + } + + // set X-axis range to (-1000 ... +1000) + // This lets us test against 0 to see which way the stick is pointed. + DIPROPRANGE diprg; + diprg.diph.dwSize = sizeof(diprg); + diprg.diph.dwHeaderSize = sizeof(diprg.diph); + diprg.diph.dwObj = DIJOFS_X; + diprg.diph.dwHow = DIPH_BYOFFSET; + diprg.lMin = JOYMIN; + diprg.lMax = JOYMAX; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { + create_success = false; + return; + } + + // + // And again for Y-axis range + // + diprg.diph.dwObj = DIJOFS_Y; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) + { + create_success = false; + return; + } + + // + // And again for z-axis range (throttle) + // + diprg.diph.dwObj = DIJOFS_Z; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { + create_success = false; + return; + } + create_success = true; +} + +/** + * Sets the fields on the Joystick + */ +void InitializeFields() { + //set buttons array + jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); + environment->SetObjectField(objJoystick, fidButtons, buttonsArray); +} + +/** + * Updates the fields on the Joystick + */ +void UpdateFields() { + HRESULT hRes; + + // get data from the joystick + hRes = lpDIDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js); + + if (hRes != DI_OK) { + // did the read fail because we lost input for some reason? + // if so, then attempt to reacquire. + if(hRes == DIERR_INPUTLOST) { + lpDIDevice->Acquire(); +#if _DEBUG + printf("DIERR_INPUTLOST, reaquiring input\n"); +#endif + } + return; + } + + //axis's + environment->SetIntField(objJoystick, fidX, js.lX); + environment->SetIntField(objJoystick, fidY, js.lY); + if(hasz) { + environment->SetIntField(objJoystick, fidZ, js.lZ); + } + + //buttons + jbooleanArray buttonsArray = (jbooleanArray) environment->GetObjectField(objJoystick, fidButtons); + BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); + memcpy(buttons, js.rgbButtons, 4); + environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); + + //pov + if(haspov) { + environment->SetIntField(objJoystick, fidPOV, js.rgdwPOV[0]); + } +} + +/** + * Sets the capabilities of the joystick + */ +void SetCapabilities() { + //set buttoncount + environment->SetIntField(objJoystick, fidButtonCount, buttoncount); + + //set z axis + environment->SetIntField(objJoystick, fidHasZAxis, hasz); + + //set pov + environment->SetIntField(objJoystick, fidHasPOV, haspov); +} + +/** + * Caches the field ids for quicker access + */ +void CacheFields(jobject obj) { + /* make certain that we're caching from a global object, and not a local */ + objJoystick = environment->NewGlobalRef(obj); + clsJoystick = environment->GetObjectClass(objJoystick); + + /* cache fields */ + fidButtonCount = environment->GetFieldID(clsJoystick, "buttonCount", "I"); + fidHasZAxis = environment->GetFieldID(clsJoystick, "hasZAxis", "Z"); + fidHasPOV = environment->GetFieldID(clsJoystick, "hasPOV", "Z"); + fidButtons = environment->GetFieldID(clsJoystick, "buttons", "[Z"); + fidX = environment->GetFieldID(clsJoystick, "x", "I"); + fidY = environment->GetFieldID(clsJoystick, "y", "I"); + fidZ = environment->GetFieldID(clsJoystick, "z", "I"); + fidPOV = environment->GetFieldID(clsJoystick, "pov", "I"); } |
From: Brian M. <ma...@us...> - 2002-11-17 18:15:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test In directory usw-pr-cvs1:/tmp/cvs-serv8702 Added Files: JoystickTest.java Log Message: accompanying test for the joystick implementation --- NEW FILE: JoystickTest.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/input/test/JoystickTest.java /* * JoystickTest.java * * Created on 13. november 2002, 22:49 */ package org.lwjgl.input.test; import java.awt.*; import java.awt.event.*; import org.lwjgl.input.Joystick; /** * * @author Brian Matzon */ public class JoystickTest extends Panel { private Joystick joystick = null; private int counter = 0; public Thread animationThread; /** Creates a new instance of JoystickTest */ public JoystickTest() { joystick = new Joystick(); try { joystick.create(); } catch (Exception e) { e.printStackTrace(); joystick = null; } animationThread = new Thread() { public void run() { while (true) { paint(getGraphics()); try { Thread.sleep(250); } catch (InterruptedException inte) { inte.printStackTrace(); } } } }; animationThread.setDaemon(true); } public void paint(Graphics g) { if (g == null) { return; } g.setColor(Color.white); g.fillRect(0, 0, 640, 480); int y = 100; int x = 100; if (joystick != null) { joystick.poll(); g.setColor(Color.blue); g.drawString("Buttoncount: " + joystick.buttonCount, x, y); y += 20; g.drawString("-----------------------------------------------", x, y); y += 20; g.drawString("x : " + joystick.x, x, y); y += 20; g.drawString("y : " + joystick.y, x, y); y += 20; if(joystick.hasZAxis) { g.drawString("z : " + joystick.z, x, y); y += 20; } if(joystick.hasPOV) { g.drawString("pov: " + joystick.pov, x, y); y += 20; } //paint buttons g.drawString("btn: ", x, y); x += g.getFontMetrics().stringWidth("btn: "); for(int i=0; i<joystick.buttonCount; i++) { if(joystick.isButtonDown(i)) { g.drawString(i + ", ", x, y); x+= 15; } } } } public void update(Graphics g) { paint(g); } /** * @param args the command line arguments */ public static void main(String[] args) { final Frame f = new Frame(); f.setLayout(null); f.setSize(640, 480); f.setLocation(100, 100); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { f.hide(); f.dispose(); } }); JoystickTest p = new JoystickTest(); p.setSize(640, 480); p.setLocation(0, 0); p.setBackground(Color.RED); f.add(p); f.show(); p.animationThread.start(); } } |
From: Brian M. <ma...@us...> - 2002-11-17 18:14:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test In directory usw-pr-cvs1:/tmp/cvs-serv7966/test Log Message: Directory /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/test added to the repository |
From: Brian M. <ma...@us...> - 2002-11-17 18:14:15
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory usw-pr-cvs1:/tmp/cvs-serv7681 Modified Files: Joystick.java Log Message: first stab at the joystick implementation 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.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Joystick.java 28 Aug 2002 21:58:14 -0000 1.7 +++ Joystick.java 17 Nov 2002 18:14:13 -0000 1.8 @@ -32,24 +32,24 @@ package org.lwjgl.input; -import java.nio.ByteBuffer; - -import org.lwjgl.Display; import org.lwjgl.Sys; /** * $Id$ - * + * <br> * A raw Joystick interface. This can be used to poll the current state of the * joystick buttons, and determine the joystick position. The joystick position - * is returned as floats in the range -1.0f to 1.0f. + * is returned as ints in the range -1000 to 1000. * * No buffering is available. - * - * Up to 8 buttons are available. A scrolly wheel or paddle, if present, is the z - * value. This will be in the range of 0.0f to 1.0f. - * - * @author cix_foo <ci...@us...> + * + * Currently n (native limits, currently 128) buttons, the x, y, z axis is supported along with a POV (or HAT), where the z axis + * represents a throttle. In the future the joystick may support more buttons and + * axises and other features. but this is a platform issue. + * + * The joystick implementation currently only supports the first attached joystick. + * + * @author Brian Matzon <br...@ma...> * @version $Revision$ */ public class Joystick { @@ -59,38 +59,47 @@ } /** Has the joystick been created? */ - private static boolean created; + private boolean created; - /** The joystick buttons status from the last poll */ - private static final boolean[] button = new boolean[8]; + /** The joystick buttons status */ + private boolean[] buttons; - /** X position, range -1.0f to 1.0f */ - public static float x; + /** X position, range -1000 to 1000 */ + public int x = -1; - /** Y position, range -1.0f to 1.0f */ - public static float y; + /** Y position, range -1000 to 1000 */ + public int y = -1; - /** Z position, range 0.0f to 1.0f */ - public static float z; + /** Z position, range -1000 to 1000 */ + public int z = -1; + + /** Position of Point of View from -1 to 27000 (360 degrees) */ + public int pov; + + /** Constant specifying centered POV */ + public static final int POV_CENTER = -1; - /** - * The joystick events from the last read: a sequence of Events - */ - private static ByteBuffer readBuffer; - - /** Address of the read buffer */ - private static int readBufferAddress; - - /** The size in bytes of a single joystick event */ - private static final int JOYSTICK_EVENT_SIZE = 20; + /** Constant specifying nortward POV */ + public static final int POV_NORTH = 0; + + /** Constant specifying southward POV */ + public static final int POV_SOUTH = 18000; + + /** Constant specifying eastward POV */ + public static final int POV_EAST = 27000; + + /** Constant specifying westward POV */ + public static final int POV_WEST = 9000; + + /* Joystick capabilities */ + public int buttonCount = -1; + public boolean hasZAxis = false; + public boolean hasPOV = false; - /** The stride in bytes of a single joystick event */ - private static final int JOYSTICK_EVENT_STRIDE = 32; - /** * Joystick cannot be constructed. */ - private Joystick() { + public Joystick() { } /** @@ -102,159 +111,71 @@ } /** - * Register fields with the native library - */ - private static native void initIDs(); - - /** * "Create" the joystick. The display must first have been created. * @throws Exception if the joystick could not be created for any reason */ - public static void create() throws Exception { - if (created) + public void create() throws Exception { + if (created) { return; - if (!Display.isCreated()) - throw new Exception("The display has not yet been created."); - if (!nCreate()) + } + + if (!nCreate()) { throw new Exception("The joystick could not be created."); + } created = true; } /** - * Native method to create the joystick - * - * @return true if the joystick was created - */ - private static native boolean nCreate(); - - /** * "Destroy" the joystick */ - public static void destroy() { - if (!created) + public void destroy() { + if (!created) { return; + } + created = false; nDestroy(); } - - /** - * Native method the destroy the joystick - */ - private static native void nDestroy(); /** * Polls the joystick. */ - public static void poll() { + public void poll() { assert created : "The joystick has not been created."; nPoll(); } /** - * Native method to poll the joystick - */ - private static native void nPoll(); - - /** - * Queries the number of buttons the joystick has - * @return the number of buttons the joystick has - */ - public static int getNumButtons() { - assert created : "The joystick has not been created."; - return nGetNumButtons(); - } - - /** - * Native implementation of getNumButtons() - */ - private static native int nGetNumButtons(); - - /** - * Queries whether the joystick has a Z value - * @return true if the joystick has a Z value - */ - public static boolean hasZValue() { - assert created : "The joystick has not been created."; - return 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) { + public boolean isButtonDown(int button) { assert created : "The joystick has not been created."; - return Joystick.button[button]; + return buttons[button]; } - - - /** - * Native implementation of hasZValue() - */ - private static native boolean nHasZValue(); - + /** - * Enable joystick buffering. Must be called after the joystick is created. - * @return the size of the joystick buffer in events, or 0 if no buffering - * can be enabled for any reason + * Native method to poll the joystick */ - public static int enableBuffer() { - assert created : "The joystick has not been created."; - return nEnableBuffer(); - } - + private native void nPoll(); + /** - * Native method to read the joystick buffer + * Native method to create the joystick * - * @param readBufferAddress the address of the joystick buffer - * @return the number of joystick events read - */ - private static native int nRead(int readBufferAddress); - - /** - * Reads the joystick buffer. + * @return true if the joystick was created */ - public static void read() { - assert created : "The joystick has not been created."; - assert readBuffer != null : "Joystick buffering has not been enabled."; - readBuffer.clear(); - readBuffer.limit(nRead(readBufferAddress) << 1); - } - - /** - * Native method to enable the buffer - * @return the size of the buffer allocated, in events (1 event is 2 bytes), - * or 0 if no buffer can be allocated + private native boolean nCreate(); + + /** + * Native method the destroy the joystick */ - private static native int nEnableBuffer(); - + private native void nDestroy(); + /** - * Gets the next joystick event. This returns its results as if a poll() had - * been called. - * - * @return true if a joystick event was read, false otherwise + * Register fields with the native library */ - public static boolean next() { - assert created : "The joystick has not been created."; - assert readBuffer != null : "Joystick buffering has not been enabled."; - - if (readBuffer.hasRemaining()) { - x = readBuffer.getFloat(); - y = readBuffer.getFloat(); - z = readBuffer.getFloat(); - for (int i = 0; i < button.length; i ++) - button[i] = readBuffer.get() != (byte)0; - readBuffer.position(readBuffer.position() + (JOYSTICK_EVENT_STRIDE - JOYSTICK_EVENT_SIZE)); - return true; - } else - return false; - - } - - - - -} + private static native void initIDs(); +} \ No newline at end of file |
From: Brian M. <ma...@us...> - 2002-11-17 18:13:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory usw-pr-cvs1:/tmp/cvs-serv7088 Modified Files: org_lwjgl_input_Joystick.cpp Log Message: first stab at the win32 joystick implementation Index: org_lwjgl_input_Joystick.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Joystick.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_input_Joystick.cpp 19 Oct 2002 14:27:26 -0000 1.1 +++ org_lwjgl_input_Joystick.cpp 17 Nov 2002 18:13:46 -0000 1.2 @@ -35,40 +35,111 @@ * * Win32 analogue joystick handling. * - * @author cix_foo <ci...@us...> + * @author Brian Matzon <br...@ma...> * @version $Revision$ */ - - #define WIN32_LEAN_AND_MEAN -#include <windows.h> #include "org_lwjgl_input_Joystick.h" + +#include <windows.h> #undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0300 +#define DIRECTINPUT_VERSION 0x0500 #include <dinput.h> -extern LPDIRECTINPUT lpdi; -LPDIRECTINPUTDEVICE lpdiJoystick; -extern HWND hwnd; // The display, which must have been created -/* - * Class: org_lwjgl_input_Joystick - * Method: initIDs - * Signature: ()V +#define JOYMAX 1000 // Maxmimum range to which we'll gauge the swing +#define JOYMIN -1000 // Minimum range to which we'll gauge the swing + +extern HWND hwnd; // Handle to window + +IDirectInput* lpDI; // DI instance +IDirectInputDevice2* lpDIDevice; // DI Device instance +DIJOYSTATE2 js; // State of joystick + +int buttoncount = 0; // Temporary buttoncount +bool hasz; // Temporary zaxis check +bool haspov; // Temporary pov check + +JNIEnv* environment; // JNIEnvironment copy + +bool create_success; // bool used to determine successfull creation + +// Cached fields of Joystick.java +jclass clsJoystick; +jobject objJoystick; +jfieldID fidButtonCount; +jfieldID fidHasZAxis; +jfieldID fidHasPOV; +jfieldID fidButtons; +jfieldID fidX; +jfieldID fidY; +jfieldID fidZ; +jfieldID fidPOV; + +// Function prototypes (defined in the cpp file, since header file is generic across platforms +void EnumerateCapabilities(); +void EnumerateJoysticks(); +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef); +BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); +void Shutdown(); +void CreateJoystick(LPCDIDEVICEINSTANCE lpddi); +void SetupJoystick(); +void InitializeFields(); +void UpdateFields(); +void SetCapabilities(); +void CacheFields(jobject obj); +void PrintError(HRESULT error); + +/** + * Initializes any field ids */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs - (JNIEnv * env, jclass clazz) {} +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_initIDs(JNIEnv * env, jclass clazz) { + environment = env; +} -/* - * Class: org_lwjgl_input_Joystick - * Method: nCreate - * Signature: ()Z +/** + * Called when the Joystick instance is to be created */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate - (JNIEnv * env, jclass clazz) -{ - printf("Joystick not implemented yet!\n"); - return JNI_FALSE; +JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nCreate(JNIEnv *env, jobject obj) { + /* Cache fields in Joystick */ + CacheFields(obj); + + // Create the DirectInput object. + HRESULT hr; + hr = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpDI, NULL); + if (FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + /* Find all joysticks */ + EnumerateJoysticks(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Enumerate capabilities of joystick */ + EnumerateCapabilities(); + if (!create_success) { + Shutdown(); + return JNI_FALSE; + } + + /* Initialize any fields on the Joystick */ + InitializeFields(); + + /* Set capabilities */ + SetCapabilities(); + + /* Aquire the joystick */ + hr = lpDIDevice->Acquire(); + if(FAILED(hr)) { + Shutdown(); + return JNI_FALSE; + } + + return create_success; } /* @@ -76,9 +147,8 @@ * Method: nDestroy * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nDestroy(JNIEnv *env, jobject obj) { + Shutdown(); } /* @@ -86,52 +156,272 @@ * Method: nPoll * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll - (JNIEnv * env, jclass clazz) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_input_Joystick_nPoll(JNIEnv * env, jobject obj) { + lpDIDevice->Poll(); + UpdateFields(); } -/* - * Class: org_lwjgl_input_Joystick - * Method: nGetNumButtons - * Signature: ()I +/** + * Shutdown DI */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nGetNumButtons - (JNIEnv * env, jclass clazz) -{ - return 0; +void Shutdown() { + // release DI instance + if (lpDI != NULL) { + // release device + if (lpDIDevice != NULL) { + lpDIDevice->Unacquire(); + lpDIDevice->Release(); + lpDIDevice = NULL; + } + lpDI->Release(); + lpDI = NULL; + } + + // Delete are global reference to the Joystick + if(objJoystick != NULL) { + environment->DeleteGlobalRef(objJoystick); + } } -/* - * Class: org_lwjgl_input_Joystick - * Method: nHasZValue - * Signature: ()Z +/** + * Enumerates the capabilities of the joystick attached to the system */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Joystick_nHasZValue - (JNIEnv * env, jclass clazz) -{ - return JNI_FALSE; +void EnumerateCapabilities() { + HRESULT hr; + hr = lpDIDevice->EnumObjects(EnumJoystickObjectsCallback, NULL, DIDFT_ALL); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; } -/* - * Class: org_lwjgl_input_Joystick - * Method: nRead - * Signature: (I)I +/** + * Enumerates the joysticks attached to the system */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nRead - (JNIEnv * env, jclass clazz, jint buf) -{ - int * bufPtr = (int *) buf; - return 0; +void EnumerateJoysticks() { + HRESULT hr; + hr = lpDI->EnumDevices(DIDEVTYPE_JOYSTICK, EnumJoystickCallback, 0, DIEDFL_ATTACHEDONLY); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; } -/* - * Class: org_lwjgl_input_Joystick - * Method: nEnableBuffer - * Signature: ()I +/** + * Callback from EnumDevices. Called for each joystick attached to the system */ -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Joystick_nEnableBuffer - (JNIEnv * env, jclass clazz) -{ - return 0; +BOOL CALLBACK EnumJoystickCallback(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef) { + /* Add the joystick */ + CreateJoystick(pdinst); + if(create_success) { + /* Do setup of joystick */ + SetupJoystick(); + } + + /* just stop after 1st joystick */ + return DIENUM_STOP; +} + +/** + * Callback from EnumObjects. Called for each "object" on the joystick. + */ +BOOL CALLBACK EnumJoystickObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { + if(lpddoi->guidType == GUID_Button) { + buttoncount++; + } else if(lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis) { + //do nothing + } else if(lpddoi->guidType == GUID_ZAxis || strcmp("Throttle", lpddoi->tszName) == 0){ + hasz = true; + } else if (lpddoi->guidType == GUID_POV){ + haspov = true; + } else { +#ifdef _DEBUG + printf("Unhandled object found: %s\n", lpddoi->tszName); +#endif + } + return DIENUM_CONTINUE; +} + +/** + * Creates the specified device as a joystick + */ +void CreateJoystick(LPCDIDEVICEINSTANCE lpddi) { + HRESULT hr; + hr = lpDI->CreateDevice(lpddi->guidInstance, (LPDIRECTINPUTDEVICE*) &lpDIDevice, NULL); + if FAILED(hr) { + create_success = false; + return; + } + create_success = true; +} + +/** + * Sets up the joystick properties + */ +void SetupJoystick() { + // set joystick data format + if(lpDIDevice->SetDataFormat(&c_dfDIJoystick2) != DI_OK) { + create_success = false; + return; + } + + // set the cooperative level + if(lpDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + create_success = false; + return; + } + + // set X-axis range to (-1000 ... +1000) + // This lets us test against 0 to see which way the stick is pointed. + DIPROPRANGE diprg; + diprg.diph.dwSize = sizeof(diprg); + diprg.diph.dwHeaderSize = sizeof(diprg.diph); + diprg.diph.dwObj = DIJOFS_X; + diprg.diph.dwHow = DIPH_BYOFFSET; + diprg.lMin = JOYMIN; + diprg.lMax = JOYMAX; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { + create_success = false; + return; + } + + // + // And again for Y-axis range + // + diprg.diph.dwObj = DIJOFS_Y; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) + { + create_success = false; + return; + } + + // + // And again for z-axis range (throttle) + // + diprg.diph.dwObj = DIJOFS_Z; + + if(lpDIDevice->SetProperty(DIPROP_RANGE, &diprg.diph) != DI_OK) { + create_success = false; + return; + } + create_success = true; } + +/** + * Aquires the Joystick + */ +bool AcquireInput(void) { + HRESULT hRes; + + // if we have a device + if (lpDIDevice != NULL) { + // acquire the device + hRes = lpDIDevice->Acquire(); + + if (SUCCEEDED(hRes)) { + // acquisition successful + return TRUE; + } else { + // acquisition failed + return FALSE; + } + } else { + // we don't have a current device + return FALSE; + } +} + +/** + * Sets the fields on the Joystick + */ +void InitializeFields() { + //set buttons array + jbooleanArray buttonsArray = environment->NewBooleanArray(buttoncount); + environment->SetObjectField(objJoystick, fidButtons, buttonsArray); +} + +/** + * Updates the fields on the Joystick + */ +void UpdateFields() { + HRESULT hRes; + + // poll the joystick to read the current state + hRes = lpDIDevice->Poll(); + if (FAILED(hRes)) { +#if _DEBUG + printf("Poll fail\n"); +#endif + return; + } + + // get data from the joystick + hRes = lpDIDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js); + + if (hRes != DI_OK) { + // did the read fail because we lost input for some reason? + // if so, then attempt to reacquire. + if(hRes == DIERR_INPUTLOST) { + AcquireInput(); +#if _DEBUG + printf("DIERR_INPUTLOST, reaquiring input\n"); +#endif + } + return; + } + + //axis's + environment->SetIntField(objJoystick, fidX, js.lX); + environment->SetIntField(objJoystick, fidY, js.lY); + if(hasz) { + environment->SetIntField(objJoystick, fidZ, js.lZ); + } + + //buttons + jbooleanArray buttonsArray = (jbooleanArray) environment->GetObjectField(objJoystick, fidButtons); + BYTE * buttons = (BYTE *) environment->GetPrimitiveArrayCritical(buttonsArray, NULL); + memcpy(buttons, js.rgbButtons, 4); + environment->ReleasePrimitiveArrayCritical(buttonsArray, buttons, 0); + + //pov + if(haspov) { + environment->SetIntField(objJoystick, fidPOV, js.rgdwPOV[0]); + } +} + +/** + * Sets the capabilities of the joystick + */ +void SetCapabilities() { + //set buttoncount + environment->SetIntField(objJoystick, fidButtonCount, buttoncount); + + //set z axis + environment->SetIntField(objJoystick, fidHasZAxis, hasz); + + //set pov + environment->SetIntField(objJoystick, fidHasPOV, haspov); +} + +/** + * Caches the field ids for quicker access + */ +void CacheFields(jobject obj) { + /* make certain that we're caching from a global object, and not a local */ + objJoystick = environment->NewGlobalRef(obj); + clsJoystick = environment->GetObjectClass(objJoystick); + + /* cache fields */ + fidButtonCount = environment->GetFieldID(clsJoystick, "buttonCount", "I"); + fidHasZAxis = environment->GetFieldID(clsJoystick, "hasZAxis", "Z"); + fidHasPOV = environment->GetFieldID(clsJoystick, "hasPOV", "Z"); + fidButtons = environment->GetFieldID(clsJoystick, "buttons", "[Z"); + fidX = environment->GetFieldID(clsJoystick, "x", "I"); + fidY = environment->GetFieldID(clsJoystick, "y", "I"); + fidZ = environment->GetFieldID(clsJoystick, "z", "I"); + fidPOV = environment->GetFieldID(clsJoystick, "pov", "I"); +} \ No newline at end of file |