2002-08-30 17:30:40 -04:00
|
|
|
/*
|
2004-06-12 16:28:34 -04:00
|
|
|
* Copyright (c) 2002-2004 LWJGL Project
|
2002-08-30 17:30:40 -04:00
|
|
|
* 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.
|
|
|
|
*
|
2004-06-12 16:28:34 -04:00
|
|
|
* * Neither the name of 'LWJGL' nor the names of
|
2002-08-30 17:30:40 -04:00
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
* This is the actual JNI implementation of the OpenAL EAX library.
|
|
|
|
*
|
|
|
|
* @author Brian Matzon <brian@matzon.dk>
|
|
|
|
* @version $Revision$
|
|
|
|
*/
|
2004-02-26 16:51:58 -05:00
|
|
|
#include "org_lwjgl_openal_eax_EAX20.h"
|
2002-11-28 15:25:10 -05:00
|
|
|
|
|
|
|
/* OpenAL includes */
|
2002-11-26 18:31:14 -05:00
|
|
|
#include "checkALerror.h"
|
2004-01-06 14:22:12 -05:00
|
|
|
#include "common_tools.h"
|
2002-12-14 07:49:16 -05:00
|
|
|
#include "extal.h"
|
2002-08-30 17:30:40 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determines available EAX extensions
|
|
|
|
*/
|
2004-02-26 16:51:58 -05:00
|
|
|
JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAX20_determineAvailableExtensions (JNIEnv *env, jclass clazz) {
|
2002-08-30 17:30:40 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
bool EAXSupported = false;
|
|
|
|
|
2002-09-11 21:42:49 -04:00
|
|
|
//check that we have a current context
|
|
|
|
if(alcGetCurrentContext() == NULL) {
|
2004-01-06 14:22:12 -05:00
|
|
|
throwOpenALException(env, "Unable to determine EAX Extensions: No current context");
|
2002-08-30 17:30:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//check for extension, and assign if available
|
2004-01-08 17:40:24 -05:00
|
|
|
if(alIsExtensionPresent((ALubyte*) "EAX") == AL_TRUE) {
|
2002-08-30 17:30:40 -04:00
|
|
|
eaxSet = (EAXSet)alGetProcAddress((ALubyte*) "EAXSet");
|
|
|
|
eaxGet = (EAXGet)alGetProcAddress((ALubyte*) "EAXGet");
|
|
|
|
EAXSupported = (eaxSet != NULL && eaxGet != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//throw exception if no EAX support
|
|
|
|
if(EAXSupported != true) {
|
2004-01-06 14:22:12 -05:00
|
|
|
throwOpenALException(env, "Unable to determine EAX Extensions");
|
2002-08-30 17:30:40 -04:00
|
|
|
}
|
|
|
|
#else
|
2004-01-06 14:22:12 -05:00
|
|
|
throwOpenALException(env, "EAX extensions not supported");
|
2002-08-30 17:45:48 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-08-30 17:30:40 -04:00
|
|
|
/*
|
|
|
|
* This function retrieves an EAX value.
|
|
|
|
*
|
|
|
|
* C Specification:
|
|
|
|
* ALenum EAXGet(const struct _GUID *propertySetID,ALuint property,ALuint source,ALvoid
|
|
|
|
* *value,ALuint size);
|
|
|
|
*/
|
2004-02-26 16:51:58 -05:00
|
|
|
JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAX20_neaxGet (JNIEnv *env, jclass clazz, jint propertySetID, jint property, jint source, jobject value, jint offset, jint size) {
|
2002-08-30 17:30:40 -04:00
|
|
|
#ifdef _WIN32
|
2004-01-06 14:22:12 -05:00
|
|
|
jint result = 0;
|
2002-09-11 21:42:49 -04:00
|
|
|
|
2004-01-06 14:22:12 -05:00
|
|
|
// determine buffer or listener
|
2004-02-26 16:51:58 -05:00
|
|
|
if (propertySetID == org_lwjgl_openal_eax_EAX20_BUFFER_GUID) {
|
2004-01-06 14:22:12 -05:00
|
|
|
result = (jint) eaxGet(&DSPROPSETID_EAX20_BufferProperties, (ALuint) property, (ALuint) source, (ALvoid*) (offset + (const char*) env->GetDirectBufferAddress(value)), (ALuint) size);
|
2004-02-26 16:51:58 -05:00
|
|
|
} else if (propertySetID == org_lwjgl_openal_eax_EAX20_LISTENER_GUID) {
|
2004-01-06 14:22:12 -05:00
|
|
|
result = (jint) eaxGet(&DSPROPSETID_EAX20_ListenerProperties, (ALuint) property, (ALuint) source, (ALvoid*) (offset + (const char*) env->GetDirectBufferAddress(value)), (ALuint) size);
|
|
|
|
}
|
|
|
|
CHECK_AL_ERROR
|
2002-08-30 17:30:40 -04:00
|
|
|
return result;
|
|
|
|
#else
|
2004-01-06 14:22:12 -05:00
|
|
|
throwOpenALException(env, "EAX extensions not supported");
|
2003-07-05 17:58:35 -04:00
|
|
|
return 0;
|
2002-08-30 17:30:40 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function sets an EAX value.
|
|
|
|
*
|
|
|
|
* C Specification:
|
2002-09-11 21:42:49 -04:00
|
|
|
* ALenum EAXSet(const struct _GUID *propertySetID,ALuint property,ALuint source,ALvoid
|
2002-08-30 17:30:40 -04:00
|
|
|
* *value,ALuint size);
|
|
|
|
*/
|
2004-02-26 16:51:58 -05:00
|
|
|
JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAX20_neaxSet (JNIEnv *env, jclass clazz, jint propertySetID, jint property, jint source, jobject value, jint offset, jint size) {
|
2002-09-11 21:42:49 -04:00
|
|
|
#ifdef _WIN32
|
2004-01-06 14:22:12 -05:00
|
|
|
jint result = 0;
|
|
|
|
|
|
|
|
// determine buffer or listener
|
2004-02-26 16:51:58 -05:00
|
|
|
if (propertySetID == org_lwjgl_openal_eax_EAX20_BUFFER_GUID) {
|
2004-01-06 14:22:12 -05:00
|
|
|
result = (jint) eaxSet(&DSPROPSETID_EAX20_BufferProperties, (ALuint) (property), source, (ALvoid*) (offset + (const char*) env->GetDirectBufferAddress(value)), (ALuint) size);
|
2004-02-26 16:51:58 -05:00
|
|
|
} else if (propertySetID == org_lwjgl_openal_eax_EAX20_LISTENER_GUID) {
|
2004-01-06 14:22:12 -05:00
|
|
|
result = (jint) eaxSet(&DSPROPSETID_EAX20_ListenerProperties, (ALuint) (property), source, (ALvoid*) (offset + (const char*) env->GetDirectBufferAddress(value)), (ALuint) size);
|
|
|
|
}
|
|
|
|
CHECK_AL_ERROR
|
2002-08-30 17:30:40 -04:00
|
|
|
return result;
|
|
|
|
#else
|
2004-01-06 14:22:12 -05:00
|
|
|
throwOpenALException(env, "EAX extensions not supported");
|
2003-07-05 17:58:35 -04:00
|
|
|
return 0;
|
2002-08-30 17:30:40 -04:00
|
|
|
#endif
|
2003-07-02 18:42:41 -04:00
|
|
|
}
|
|
|
|
|