Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6954/src/native/common Modified Files: Makefile.am checkALerror.h common_tools.h org_lwjgl_opengl_GLContext.h Added Files: common_tools.c extal.c extgl.c org_lwjgl_openal_AL.c org_lwjgl_openal_AL10.c org_lwjgl_openal_ALC.c org_lwjgl_openal_eax_EAX.c org_lwjgl_openal_eax_EAX20.c org_lwjgl_openal_eax_EAXBufferProperties.c org_lwjgl_openal_eax_EAXListenerProperties.c org_lwjgl_opengl_GL11.c org_lwjgl_opengl_GL12.c org_lwjgl_opengl_GL13.c org_lwjgl_opengl_GL14.c org_lwjgl_opengl_GL15.c org_lwjgl_opengl_GL20.c org_lwjgl_opengl_GLContext.c Removed Files: common_tools.cpp extal.cpp extgl.cpp org_lwjgl_openal_AL.cpp org_lwjgl_openal_AL10.cpp org_lwjgl_openal_ALC.cpp org_lwjgl_openal_eax_EAX.cpp org_lwjgl_openal_eax_EAX20.cpp org_lwjgl_openal_eax_EAXBufferProperties.cpp org_lwjgl_openal_eax_EAXListenerProperties.cpp org_lwjgl_opengl_GL11.cpp org_lwjgl_opengl_GL12.cpp org_lwjgl_opengl_GL13.cpp org_lwjgl_opengl_GL14.cpp org_lwjgl_opengl_GL15.cpp org_lwjgl_opengl_GL20.cpp org_lwjgl_opengl_GLContext.cpp Log Message: Converted native code from C++ (.cpp files) to C (.c files), thus avoiding an annoying dependency on the standard C++ library on Linux. We weren't using any particular C++ features anyway. --- org_lwjgl_opengl_GL14.cpp DELETED --- --- extgl.cpp DELETED --- --- org_lwjgl_opengl_GL20.cpp DELETED --- --- NEW FILE: common_tools.c --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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: common_tools.c,v 1.1 2004/09/10 08:13:47 elias_naur Exp $ * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include <stdlib.h> #include "common_tools.h" static bool debug = false; static const char* VERSION = "0.92"; JavaVM *jvm; void initAttribList(attrib_list_t *list) { list->current_index = 0; } void putAttrib(attrib_list_t *list, int attrib) { if (list->current_index == ATTRIB_LIST_SIZE) { printfDebug("Ignoring attrib %d: attrib list size too small", attrib); return; } list->attribs[list->current_index] = attrib; list->current_index++; } jstring getVersionString(JNIEnv *env) { return (*env)->NewStringUTF(env, VERSION); } bool isDebugEnabled(void) { return debug; } void setDebugEnabled(bool enable) { debug = enable; } void printfDebug(const char *format, ...) { va_list ap; va_start(ap, format); if (isDebugEnabled()) vfprintf(stderr, format, ap); va_end(ap); } static void incListStart(event_queue_t *queue) { queue->list_start = (queue->list_start + 1)%EVENT_BUFFER_SIZE; } void initEventQueue(event_queue_t *event_queue) { event_queue->list_start = 0; event_queue->list_end = 0; } void putEventElement(event_queue_t *queue, unsigned char byte) { int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; if (next_index == queue->list_start) { printfDebug("Event buffer overflow!\n"); return; } queue->input_event_buffer[queue->list_end] = byte; queue->list_end = next_index; } static bool hasMoreEvents(event_queue_t *queue) { return queue->list_start != queue->list_end; } static void copyEvent(event_queue_t *queue, unsigned char *output_event_buffer, int output_index, int event_size) { int i; for (i = 0; i < event_size; i++) { output_event_buffer[output_index] = queue->input_event_buffer[queue->list_start]; incListStart(queue); output_index++; } } int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size) { int num_events = 0; int index = 0; while (index + event_size <= buffer_size && hasMoreEvents(event_queue)) { copyEvent(event_queue, output_event_buffer, index, event_size); num_events++; index += event_size; } return num_events; } static void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) { if ((*env)->ExceptionCheck(env) == JNI_TRUE) return; // The JVM crashes if we try to throw two exceptions from one native call jclass cls = (*env)->FindClass(env, exception_name); (*env)->ThrowNew(env, cls, err); (*env)->DeleteLocalRef(env, cls); } void throwOpenALException(JNIEnv * env, const char * err) { throwGeneralException(env, "org/lwjgl/openal/OpenALException", err); } void throwFMODException(JNIEnv * env, const char * err) { throwGeneralException(env, "org/lwjgl/fmod3/FMODException", err); } void throwException(JNIEnv * env, const char * err) { throwGeneralException(env, "org/lwjgl/LWJGLException", err); } bool ext_InitializeFunctions(ExtGetProcAddressPROC gpa, int num_functions, ExtFunction *functions) { int i; for (i = 0; i < num_functions; i++) { ExtFunction *function = functions + i; if (function->ext_function_name != NULL) { void *ext_func_pointer = gpa(function->ext_function_name); if (ext_func_pointer == NULL) return false; void **ext_function_pointer_pointer = function->ext_function_pointer; *ext_function_pointer_pointer = ext_func_pointer; } } return true; } void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, int num_functions, JavaMethodAndExtFunction *functions) { if (clazz == NULL) { throwException(env, "Null class"); return; } JNINativeMethod *methods = (JNINativeMethod *)malloc(num_functions*sizeof(JNINativeMethod)); int i; for (i = 0; i < num_functions; i++) { JavaMethodAndExtFunction *function = functions + i; if (function->ext_function_name != NULL) { void *ext_func_pointer = gpa(function->ext_function_name); if (ext_func_pointer == NULL) { free(methods); throwException(env, "Missing driver symbols"); return; } void **ext_function_pointer_pointer = function->ext_function_pointer; *ext_function_pointer_pointer = ext_func_pointer; } JNINativeMethod *method = methods + i; method->name = function->method_name; method->signature = function->signature; method->fnPtr = function->method_pointer; } (*env)->RegisterNatives(env, clazz, methods, num_functions); free(methods); } bool getBooleanProperty(JNIEnv *env, const char* propertyName) { jstring property = (*env)->NewStringUTF(env, propertyName); jclass booleanClass = (*env)->FindClass(env, "java/lang/Boolean"); jmethodID getBoolean = (*env)->GetStaticMethodID(env, booleanClass, "getBoolean", "(Ljava/lang/String;)Z"); return (*env)->CallStaticBooleanMethod(env, booleanClass, getBoolean, property) ? true : false; } JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { jvm = vm; return JNI_VERSION_1_4; } JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { } Index: checkALerror.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/checkALerror.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- checkALerror.h 12 Jun 2004 20:28:29 -0000 1.11 +++ checkALerror.h 10 Sep 2004 08:13:47 -0000 1.12 @@ -42,9 +42,9 @@ if (isDebugEnabled()) { \ int err = alGetError(); \ if (err != AL_NO_ERROR) { \ - jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \ - env->ThrowNew(cls, (const char*) alGetString(err)); \ - env->DeleteLocalRef(cls); \ + jclass cls = (*env)->FindClass(env, "org/lwjgl/openal/OpenALException"); \ + (*env)->ThrowNew(env, cls, (const char*) alGetString(err)); \ + (*env)->DeleteLocalRef(env, cls); \ } \ } \ } @@ -54,9 +54,9 @@ if (isDebugEnabled()) { \ int err = alcGetError((ALCdevice*) deviceaddress); \ if (err != AL_NO_ERROR) { \ - jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \ - env->ThrowNew(cls, (const char*) alcGetString((ALCdevice*) deviceaddress, err)); \ - env->DeleteLocalRef(cls); \ + jclass cls = (*env)->FindClass(env, "org/lwjgl/openal/OpenALException"); \ + (*env)->ThrowNew(env, cls, (const char*) alcGetString((ALCdevice*) deviceaddress, err)); \ + (*env)->DeleteLocalRef(env, cls); \ } \ } \ } --- common_tools.cpp DELETED --- Index: common_tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- common_tools.h 4 Jul 2004 13:14:06 -0000 1.20 +++ common_tools.h 10 Sep 2004 08:13:47 -0000 1.21 @@ -62,6 +62,12 @@ int attribs[ATTRIB_LIST_SIZE]; } attrib_list_t; +#ifndef __cplusplus +typedef unsigned char bool; +#define true 1 +#define false 0 +#endif + extern void initAttribList(attrib_list_t *list); extern void putAttrib(attrib_list_t *list, int attrib); @@ -71,7 +77,6 @@ extern int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size); extern void putEventElement(event_queue_t *queue, unsigned char byte); extern unsigned char *getOutputList(event_queue_t *queue); -//extern int getEventBufferSize(event_queue_t *event_queue); extern void throwException(JNIEnv *env, const char *msg); extern void throwOpenALException(JNIEnv * env, const char * err); extern void throwFMODException(JNIEnv * env, const char * err); @@ -83,14 +88,14 @@ if (buffer == NULL) return NULL; else - return (void *)((char *)env->GetDirectBufferAddress(buffer) + offset); + return (void *)((char *)(*env)->GetDirectBufferAddress(env, buffer) + offset); } static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) { if (p == NULL) return NULL; else - return env->NewDirectByteBuffer(p, size); + return (*env)->NewDirectByteBuffer(env, p, size); } static inline const void *offsetToPointer(jint offset) { --- NEW FILE: org_lwjgl_opengl_GL14.c --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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_opengl_GL14.c,v 1.1 2004/09/10 08:13:49 elias_naur Exp $ * * Core OpenGL functions. * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ #include "extgl.h" #include "common_tools.h" typedef void (APIENTRY * glBlendColorPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (APIENTRY * glBlendEquationPROC) (GLenum mode); typedef void (APIENTRY * glFogCoordfPROC) (GLfloat coord); typedef void (APIENTRY * glFogCoordPointerPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRY * glMultiDrawArraysPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); typedef void (APIENTRY * glPointParameterfPROC) (GLenum pname, GLfloat param); typedef void (APIENTRY * glPointParameterfvPROC) (GLenum pname, GLfloat *params); typedef void (APIENTRY * glSecondaryColor3bPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (APIENTRY * glSecondaryColor3fPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (APIENTRY * glSecondaryColor3ubPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (APIENTRY * glSecondaryColorPointerPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRY * glBlendFuncSeparatePROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRY * glWindowPos2fPROC) (GLfloat x, GLfloat y); typedef void (APIENTRY * glWindowPos2iPROC) (GLint x, GLint y); typedef void (APIENTRY * glWindowPos3fPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRY * glWindowPos3iPROC) (GLint x, GLint y, GLint z); static glFogCoordfPROC glFogCoordf; static glFogCoordPointerPROC glFogCoordPointer; static glMultiDrawArraysPROC glMultiDrawArrays; static glPointParameterfPROC glPointParameterf; static glPointParameterfvPROC glPointParameterfv; static glSecondaryColor3bPROC glSecondaryColor3b; static glSecondaryColor3fPROC glSecondaryColor3f; static glSecondaryColor3ubPROC glSecondaryColor3ub; static glSecondaryColorPointerPROC glSecondaryColorPointer; static glBlendFuncSeparatePROC glBlendFuncSeparate; static glWindowPos2fPROC glWindowPos2f; static glWindowPos2iPROC glWindowPos2i; static glWindowPos3fPROC glWindowPos3f; static glWindowPos3iPROC glWindowPos3i; static glBlendColorPROC glBlendColor; static glBlendEquationPROC glBlendEquation; static void JNICALL Java_org_lwjgl_opengl_GL14_glBlendEquation (JNIEnv *env, jclass clazz, jint mode) { glBlendEquation(mode); } static void JNICALL Java_org_lwjgl_opengl_GL14_glBlendColor(JNIEnv * env, jclass clazz, jfloat p0, jfloat p1, jfloat p2, jfloat p3) { glBlendColor((GLfloat) p0, (GLfloat) p1, (GLfloat) p2, (GLfloat) p3); } /* * Class: org_lwjgl_opengl_GL14 * Method: glFogCoordf * Signature: (F)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glFogCoordf (JNIEnv *env, jclass clazz, jfloat f) { glFogCoordf(f); } /* * Class: org_lwjgl_opengl_GL14 * Method: nglFogCoordPointer * Signature: (IILjava/nio/Buffer;)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglFogCoordPointer (JNIEnv *env, jclass clazz, jint p1, jint p2, jobject buffer, jint offset) { GLvoid *address = (GLvoid *)(offset + (GLbyte *)(*env)->GetDirectBufferAddress(env, buffer)); glFogCoordPointer(p1, p2, address); } /* * Class: org_lwjgl_opengl_GL14 * Method: nglFogCoordPointerVBO * Signature: (IILjava/nio/Buffer;)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglFogCoordPointerVBO (JNIEnv *env, jclass clazz, jint p1, jint p2, jint buffer_offset) { glFogCoordPointer(p1, p2, offsetToPointer(buffer_offset)); } /* * Class: org_lwjgl_opengl_GL14 * Method: glMultiDrawArrays * Signature: (IIII)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglMultiDrawArrays (JNIEnv *env, jclass clazz, jint mode, jobject first, jint first_offset, jobject count, jint count_offset, jint primcount) { GLint *address = first_offset + (GLint *)(*env)->GetDirectBufferAddress(env, first); GLsizei *address2 = count_offset + (GLsizei *)(*env)->GetDirectBufferAddress(env, count); glMultiDrawArrays(mode, address, address2, (GLsizei)primcount); } /* * Class: org_lwjgl_opengl_GL14 * Method: glPointParameterf * Signature: (IF)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glPointParameterf (JNIEnv *env, jclass clazz, jint p1, jfloat p2) { glPointParameterf(p1, p2); } /* * Class: org_lwjgl_opengl_GL14 * Method: glPointParameterfv * Signature: (ILjava/nio/FloatBuffer;)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglPointParameterfv (JNIEnv *env, jclass clazz, jint p1, jobject buffer, jint offset) { GLfloat *address = offset + (GLfloat *)(*env)->GetDirectBufferAddress(env, buffer); glPointParameterfv(p1, address); } /* * Class: org_lwjgl_opengl_GL14 * Method: glSecondaryColor3b * Signature: (BBB)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glSecondaryColor3b (JNIEnv *env, jclass clazz, jbyte p1, jbyte p2, jbyte p3) { glSecondaryColor3b(p1, p2, p3); } /* * Class: org_lwjgl_opengl_GL14 * Method: glSecondaryColor3f * Signature: (FFF)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glSecondaryColor3f (JNIEnv *env, jclass clazz, jfloat p1, jfloat p2, jfloat p3) { glSecondaryColor3f(p1, p2, p3); } /* * Class: org_lwjgl_opengl_GL14 * Method: glSecondaryColor3ub * Signature: (BBB)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glSecondaryColor3ub (JNIEnv *env, jclass clazz, jbyte p1, jbyte p2, jbyte p3) { glSecondaryColor3ub(p1, p2, p3); } /* * Class: org_lwjgl_opengl_GL14 * Method: nglSecondaryColorPointer * Signature: (IIILjava/nio/Buffer;)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglSecondaryColorPointer (JNIEnv *env, jclass clazz, jint p1, jint p2, jint p3, jobject buffer, jint offset) { const GLvoid *address = (const GLvoid *)(offset + (GLbyte *)(*env)->GetDirectBufferAddress(env, buffer)); glSecondaryColorPointer(p1, p2, p3, address); } /* * Class: org_lwjgl_opengl_GL14 * Method: nglSecondaryColorPointerVBO * Signature: (IIILjava/nio/Buffer;)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_nglSecondaryColorPointerVBO (JNIEnv *env, jclass clazz, jint p1, jint p2, jint p3, jint buffer_offset) { glSecondaryColorPointer(p1, p2, p3, offsetToPointer(buffer_offset)); } /* * Class: org_lwjgl_opengl_GL14 * Method: glBlendFuncSeparate * Signature: (IIII)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glBlendFuncSeparate (JNIEnv *env, jclass clazz, jint p1, jint p2, jint p3, jint p4) { glBlendFuncSeparate(p1, p2, p3, p4); } /* * Class: org_lwjgl_opengl_GL14 * Method: glWindowPos2f * Signature: (FF)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glWindowPos2f (JNIEnv *env, jclass clazz, jfloat p1, jfloat p2) { glWindowPos2f(p1, p2); } /* * Class: org_lwjgl_opengl_GL14 * Method: glWindowPos2i * Signature: (II)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glWindowPos2i (JNIEnv *env, jclass clazz, jint p1, jint p2) { glWindowPos2i(p1, p2); } /* * Class: org_lwjgl_opengl_GL14 * Method: glWindowPos3f * Signature: (FFF)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glWindowPos3f (JNIEnv *env, jclass clazz, jfloat p1, jfloat p2, jfloat p3) { glWindowPos3f(p1, p2, p3); } /* * Class: org_lwjgl_opengl_GL14 * Method: glWindowPos3i * Signature: (III)V */ static void JNICALL Java_org_lwjgl_opengl_GL14_glWindowPos3i (JNIEnv *env, jclass clazz, jint p1, jint p2, jint p3) { glWindowPos3i(p1, p2, p3); } #ifdef __cplusplus extern "C" { #endif JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL14_initNativeStubs(JNIEnv *env, jclass clazz) { JavaMethodAndExtFunction functions[] = { {"glBlendEquation", "(I)V", (void*)&Java_org_lwjgl_opengl_GL14_glBlendEquation, "glBlendEquation", (void*)&glBlendEquation}, {"glBlendColor", "(FFFF)V", (void*)&Java_org_lwjgl_opengl_GL14_glBlendColor, "glBlendColor", (void*)&glBlendColor}, {"glFogCoordf", "(F)V", (void*)&Java_org_lwjgl_opengl_GL14_glFogCoordf, "glFogCoordf", (void*)&glFogCoordf}, {"nglFogCoordPointer", "(IILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_opengl_GL14_nglFogCoordPointer, "glFogCoordPointer", (void*)&glFogCoordPointer}, {"nglFogCoordPointerVBO", "(III)V", (void*)&Java_org_lwjgl_opengl_GL14_nglFogCoordPointerVBO, NULL, NULL}, {"nglMultiDrawArrays", "(ILjava/nio/IntBuffer;ILjava/nio/IntBuffer;II)V", (void*)&Java_org_lwjgl_opengl_GL14_nglMultiDrawArrays, "glMultiDrawArrays", (void*)&glMultiDrawArrays}, {"glPointParameterf", "(IF)V", (void*)&Java_org_lwjgl_opengl_GL14_glPointParameterf, "glPointParameterf", (void*)&glPointParameterf}, {"nglPointParameterfv", "(ILjava/nio/FloatBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL14_nglPointParameterfv, "glPointParameterfv", (void*)&glPointParameterfv}, {"glSecondaryColor3b", "(BBB)V", (void*)&Java_org_lwjgl_opengl_GL14_glSecondaryColor3b, "glSecondaryColor3b", (void*)&glSecondaryColor3b}, {"glSecondaryColor3f", "(FFF)V", (void*)&Java_org_lwjgl_opengl_GL14_glSecondaryColor3f, "glSecondaryColor3f", (void*)&glSecondaryColor3f}, {"glSecondaryColor3ub", "(BBB)V", (void*)&Java_org_lwjgl_opengl_GL14_glSecondaryColor3ub, "glSecondaryColor3ub", (void*)&glSecondaryColor3ub}, {"nglSecondaryColorPointer", "(IIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_opengl_GL14_nglSecondaryColorPointer, "glSecondaryColorPointer", (void*)&glSecondaryColorPointer}, {"nglSecondaryColorPointerVBO", "(IIII)V", (void*)&Java_org_lwjgl_opengl_GL14_nglSecondaryColorPointerVBO, NULL, NULL}, {"glBlendFuncSeparate", "(IIII)V", (void*)&Java_org_lwjgl_opengl_GL14_glBlendFuncSeparate, "glBlendFuncSeparate", (void*)&glBlendFuncSeparate}, {"glWindowPos2f", "(FF)V", (void*)&Java_org_lwjgl_opengl_GL14_glWindowPos2f, "glWindowPos2f", (void*)&glWindowPos2f}, {"glWindowPos2i", "(II)V", (void*)&Java_org_lwjgl_opengl_GL14_glWindowPos2i, "glWindowPos2i", (void*)&glWindowPos2i}, {"glWindowPos3f", "(FFF)V", (void*)&Java_org_lwjgl_opengl_GL14_glWindowPos3f, "glWindowPos3f", (void*)&glWindowPos3f}, {"glWindowPos3i", "(III)V", (void*)&Java_org_lwjgl_opengl_GL14_glWindowPos3i, "glWindowPos3i", (void*)&glWindowPos3i} }; int num_functions = NUMFUNCTIONS(functions); extgl_InitializeClass(env, clazz, num_functions, functions); } #ifdef __cplusplus } #endif --- NEW FILE: org_lwjgl_openal_eax_EAXBufferProperties.c --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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 <stddef.h> #ifdef _WIN32 #include <eax.h> #endif /* * Class: org_lwjgl_openal_eax_EAXBufferProperties * Method: sizeOfEaxBufferProperties * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_sizeOfEaxBufferProperties(JNIEnv *env, jclass clazz) { #ifdef _WIN32 return sizeof(EAXBUFFERPROPERTIES); #else return 0; #endif } /* * Class: org_lwjgl_openal_eax_EAXBufferProperties * Method: assignOffsets * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXBufferProperties_assignOffsets(JNIEnv *env, jclass clazz) { #ifdef _WIN32 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)); #endif } --- NEW FILE: org_lwjgl_opengl_GL15.c --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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. */ // ---------------------------------- // IMPLEMENTATION OF NATIVE METHODS FOR CLASS: org.lwjgl.opengl.GL15 // ---------------------------------- #include "extgl.h" #include "common_tools.h" typedef int GLintptr; typedef unsigned int GLsizeiptr; typedef void (APIENTRY * glBindBufferPROC) (GLenum target, GLuint buffer); typedef void (APIENTRY * glDeleteBuffersPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRY * glGenBuffersPROC) (GLsizei n, GLuint *buffers); typedef GLboolean (APIENTRY * glIsBufferPROC) (GLuint buffer); typedef void (APIENTRY * glBufferDataPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); typedef void (APIENTRY * glBufferSubDataPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); typedef void (APIENTRY * glGetBufferSubDataPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); typedef void * (APIENTRY * glMapBufferPROC) (GLenum target, GLenum access); typedef GLboolean (APIENTRY * glUnmapBufferPROC) (GLenum target); typedef void (APIENTRY * glGetBufferParameterivPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * glGetBufferPointervPROC) (GLenum target, GLenum pname, GLvoid **params); typedef void (APIENTRY * glGenQueriesPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRY * glDeleteQueriesPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRY * glIsQueryPROC) (GLuint id); typedef void (APIENTRY * glBeginQueryPROC) (GLenum target, GLuint id); typedef void (APIENTRY * glEndQueryPROC) (GLenum target); typedef void (APIENTRY * glGetQueryivPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * glGetQueryObjectivPROC) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRY * glGetQueryObjectuivPROC) (GLuint id, GLenum pname, GLuint *params); static glBindBufferPROC glBindBuffer; static glDeleteBuffersPROC glDeleteBuffers; static glGenBuffersPROC glGenBuffers; static glIsBufferPROC glIsBuffer; static glBufferDataPROC glBufferData; static glBufferSubDataPROC glBufferSubData; static glGetBufferSubDataPROC glGetBufferSubData; static glMapBufferPROC glMapBuffer; static glUnmapBufferPROC glUnmapBuffer; static glGetBufferParameterivPROC glGetBufferParameteriv; static glGetBufferPointervPROC glGetBufferPointerv; static glGenQueriesPROC glGenQueries; static glDeleteQueriesPROC glDeleteQueries; static glIsQueryPROC glIsQuery; static glBeginQueryPROC glBeginQuery; static glEndQueryPROC glEndQuery; static glGetQueryivPROC glGetQueryiv; static glGetQueryObjectivPROC glGetQueryObjectiv; static glGetQueryObjectuivPROC glGetQueryObjectuiv; /* * Class: org.lwjgl.opengl.GL15 * Method: nglBindBuffer */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglBindBuffer (JNIEnv * env, jclass clazz, jint target, jint buffer) { glBindBuffer(target, buffer); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglDeleteBuffers */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglDeleteBuffers (JNIEnv * env, jclass clazz, jint n, jobject buffers, jint buffers_offset) { GLuint *buffers_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, buffers) + buffers_offset; glDeleteBuffers(n, buffers_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGenBuffers */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGenBuffers (JNIEnv * env, jclass clazz, jint n, jobject buffers, jint buffers_offset) { GLuint *buffers_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, buffers) + buffers_offset; glGenBuffers(n, buffers_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: glIsBuffer */ static jboolean JNICALL Java_org_lwjgl_opengl_GL15_glIsBuffer (JNIEnv * env, jclass clazz, jint buffer) { GLboolean result = glIsBuffer(buffer); return result; } /* * Class: org.lwjgl.opengl.GL15 * Method: nglBufferData */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglBufferData (JNIEnv * env, jclass clazz, jint target, jint size, jobject data, jint data_offset, jint usage) { GLvoid *data_ptr = (GLvoid *)safeGetBufferAddress(env, data, data_offset); glBufferData(target, size, data_ptr, usage); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglBufferSubData */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglBufferSubData (JNIEnv * env, jclass clazz, jint target, jint offset, jint size, jobject data, jint data_offset) { GLvoid *data_ptr = (GLvoid *)((GLubyte *)(*env)->GetDirectBufferAddress(env, data) + data_offset); glBufferSubData(target, offset, size, data_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGetBufferSubData */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGetBufferSubData (JNIEnv * env, jclass clazz, jint target, jint offset, jint size, jobject data, jint data_offset) { GLvoid *data_ptr = (GLvoid *)((GLubyte *)(*env)->GetDirectBufferAddress(env, data) + data_offset); glGetBufferSubData(target, offset, size, data_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: glMapBuffer */ static jobject JNICALL Java_org_lwjgl_opengl_GL15_glMapBuffer (JNIEnv * env, jclass clazz, jint target, jint access, jint size, jobject oldBuffer) { void *buffer_address = glMapBuffer((GLenum)target, (GLenum)access); if (oldBuffer != NULL) { void *old_buffer_address = (*env)->GetDirectBufferAddress(env, oldBuffer); if (old_buffer_address == buffer_address) return oldBuffer; } return safeNewBuffer(env, buffer_address, size); } /* * Class: org.lwjgl.opengl.GL15 * Method: glUnmapBuffer */ static jboolean JNICALL Java_org_lwjgl_opengl_GL15_glUnmapBuffer (JNIEnv * env, jclass clazz, jint target) { GLboolean result = glUnmapBuffer(target); return result; } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGetBufferParameteriv */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGetBufferParameteriv (JNIEnv * env, jclass clazz, jint target, jint pname, jobject params, jint params_offset) { GLint *params_ptr = (GLint *)(*env)->GetDirectBufferAddress(env, params) + params_offset; glGetBufferParameteriv(target, pname, params_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: glGetBufferPointer */ static jobject JNICALL Java_org_lwjgl_opengl_GL15_glGetBufferPointer (JNIEnv * env, jclass clazz, jint target, jint pname, jint size) { void *pointer; glGetBufferPointerv((GLenum)target, (GLenum)pname, &pointer); return safeNewBuffer(env, pointer, size); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGenQueries */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGenQueries (JNIEnv * env, jclass clazz, jint n, jobject ids, jint idsOffset) { GLuint *ids_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, ids) + idsOffset; glGenQueries(n, ids_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglDeleteQueries */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglDeleteQueries (JNIEnv * env, jclass clazz, jint n, jobject ids, jint idsOffset) { GLuint *ids_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, ids) + idsOffset; glDeleteQueries(n, ids_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: glIsQuery */ static jboolean JNICALL Java_org_lwjgl_opengl_GL15_glIsQuery (JNIEnv * env, jclass clazz, jint id) { GLboolean result = glIsQuery(id); return result; } /* * Class: org.lwjgl.opengl.GL15 * Method: glBeginQuery */ static void JNICALL Java_org_lwjgl_opengl_GL15_glBeginQuery (JNIEnv * env, jclass clazz, jint target, jint id) { glBeginQuery(target, id); } /* * Class: org.lwjgl.opengl.GL15 * Method: glEndQuery */ static void JNICALL Java_org_lwjgl_opengl_GL15_glEndQuery (JNIEnv * env, jclass clazz, jint target) { glEndQuery(target); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGetQueryiv */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGetQueryiv (JNIEnv * env, jclass clazz, jint target, jint pname, jobject params, jint paramsOffset) { GLint *params_ptr = (GLint *)(*env)->GetDirectBufferAddress(env, params) + paramsOffset; glGetQueryiv(target, pname, params_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGetQueryObjectiv */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGetQueryObjectiv (JNIEnv * env, jclass clazz, jint id, jint pname, jobject params, jint paramsOffset) { GLint *params_ptr = (GLint *)(*env)->GetDirectBufferAddress(env, params) + paramsOffset; glGetQueryObjectiv(id, pname, params_ptr); } /* * Class: org.lwjgl.opengl.GL15 * Method: nglGetQueryObjectuiv */ static void JNICALL Java_org_lwjgl_opengl_GL15_nglGetQueryObjectuiv (JNIEnv * env, jclass clazz, jint id, jint pname, jobject params, jint paramsOffset) { GLuint *params_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, params) + paramsOffset; glGetQueryObjectuiv(id, pname, params_ptr); } #ifdef __cplusplus extern "C" { #endif JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL15_initNativeStubs(JNIEnv *env, jclass clazz) { JavaMethodAndExtFunction functions[] = { {"nglBindBuffer", "(II)V", (void*)&Java_org_lwjgl_opengl_GL15_nglBindBuffer, "glBindBuffer", (void*)&glBindBuffer}, {"nglDeleteBuffers", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglDeleteBuffers, "glDeleteBuffers", (void*)&glDeleteBuffers}, {"nglGenBuffers", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGenBuffers, "glGenBuffers", (void*)&glGenBuffers}, {"glIsBuffer", "(I)Z", (void*)&Java_org_lwjgl_opengl_GL15_glIsBuffer, "glIsBuffer", (void*)&glIsBuffer}, {"nglBufferData", "(IILjava/nio/Buffer;II)V", (void*)&Java_org_lwjgl_opengl_GL15_nglBufferData, "glBufferData", (void*)&glBufferData}, {"nglBufferSubData", "(IIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglBufferSubData, "glBufferSubData", (void*)&glBufferSubData}, {"nglGetBufferSubData", "(IIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGetBufferSubData, "glGetBufferSubData", (void*)&glGetBufferSubData}, {"glMapBuffer", "(IIILjava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_opengl_GL15_glMapBuffer, "glMapBuffer", (void*)&glMapBuffer}, {"glUnmapBuffer", "(I)Z", (void*)&Java_org_lwjgl_opengl_GL15_glUnmapBuffer, "glUnmapBuffer", (void*)&glUnmapBuffer}, {"nglGetBufferParameteriv", "(IILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGetBufferParameteriv, "glGetBufferParameteriv", (void*)&glGetBufferParameteriv}, {"glGetBufferPointer", "(III)Ljava/nio/ByteBuffer;", (void*)&Java_org_lwjgl_opengl_GL15_glGetBufferPointer, "glGetBufferPointerv", (void*)&glGetBufferPointerv}, {"nglGenQueries", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGenQueries, "glGenQueries", (void*)&glGenQueries}, {"nglDeleteQueries", "(ILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglDeleteQueries, "glDeleteQueries", (void*)&glDeleteQueries}, {"glIsQuery", "(I)Z", (void*)&Java_org_lwjgl_opengl_GL15_glIsQuery, "glIsQuery", (void*)&glIsQuery}, {"glBeginQuery", "(II)V", (void*)&Java_org_lwjgl_opengl_GL15_glBeginQuery, "glBeginQuery", (void*)&glBeginQuery}, {"glEndQuery", "(I)V", (void*)&Java_org_lwjgl_opengl_GL15_glEndQuery, "glEndQuery", (void*)&glEndQuery}, {"nglGetQueryiv", "(IILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGetQueryiv, "glGetQueryiv", (void*)&glGetQueryiv}, {"nglGetQueryObjectiv", "(IILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGetQueryObjectiv, "glGetQueryObjectiv", (void*)&glGetQueryObjectiv}, {"nglGetQueryObjectuiv", "(IILjava/nio/IntBuffer;I)V", (void*)&Java_org_lwjgl_opengl_GL15_nglGetQueryObjectuiv, "glGetQueryObjectuiv", (void*)&glGetQueryObjectuiv} }; int num_functions = NUMFUNCTIONS(functions); extgl_InitializeClass(env, clazz, num_functions, functions); } #ifdef __cplusplus } #endif --- org_lwjgl_openal_eax_EAX.cpp DELETED --- --- org_lwjgl_openal_eax_EAXListenerProperties.cpp DELETED --- --- org_lwjgl_openal_eax_EAXBufferProperties.cpp DELETED --- --- NEW FILE: org_lwjgl_openal_eax_EAXListenerProperties.c --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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 <stddef.h> #ifdef _WIN32 #include <eax.h> #endif /* * Class: org_lwjgl_openal_eax_EAXListenerProperties * Method: sizeOfEaxListenerProperties * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_sizeOfEaxListenerProperties(JNIEnv *env, jclass clazz) { #ifdef _WIN32 return sizeof(EAXLISTENERPROPERTIES); #else return 0; #endif } /* * Class: org_lwjgl_openal_eax_EAXListenerProperties * Method: assignOffsets * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_openal_eax_EAXListenerProperties_assignOffsets (JNIEnv *env, jclass clazz) { #ifdef _WIN32 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)); #endif } Index: Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/Makefile.am,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Makefile.am 9 Sep 2004 23:51:16 -0000 1.24 +++ Makefile.am 10 Sep 2004 08:13:47 -0000 1.25 @@ -9,38 +9,23 @@ DEP_LIBS=libtools.la arb/libarb.la ati/libati.la ext/libext.la nv/libnv.la TOOLS = \ - common_tools.cpp \ + common_tools.c \ common_tools.h COMMON = \ - extal.cpp \ - extal.h \ - extgl.cpp \ - extgl.h \ - org_lwjgl_Display.h \ - org_lwjgl_Sys.h \ - org_lwjgl_input_GamePad.h \ - org_lwjgl_input_Joystick.h \ - org_lwjgl_input_Keyboard.h \ - org_lwjgl_input_Mouse.h \ - org_lwjgl_openal_ALC.cpp \ - org_lwjgl_openal_ALC.h \ - org_lwjgl_openal_AL.cpp \ - org_lwjgl_openal_AL.h \ - org_lwjgl_openal_AL10.cpp \ - org_lwjgl_openal_AL10.h \ - org_lwjgl_openal_eax_EAX.cpp \ - org_lwjgl_openal_eax_EAX.h \ - org_lwjgl_openal_eax_EAX20.cpp \ - org_lwjgl_openal_eax_EAX.h \ - org_lwjgl_openal_eax_EAXBufferProperties.cpp \ - org_lwjgl_openal_eax_EAXBufferProperties.h \ - org_lwjgl_openal_eax_EAXListenerProperties.cpp \ - org_lwjgl_openal_eax_EAXListenerProperties.h \ - org_lwjgl_opengl_GLContext.cpp \ - org_lwjgl_opengl_GL11.cpp \ - org_lwjgl_opengl_GL12.cpp \ - org_lwjgl_opengl_GL13.cpp \ - org_lwjgl_opengl_GL14.cpp \ - org_lwjgl_opengl_GL15.cpp \ - org_lwjgl_opengl_GL20.cpp + extal.c \ + extgl.c \ + org_lwjgl_openal_ALC.c \ + org_lwjgl_openal_AL.c \ + org_lwjgl_openal_AL10.c \ + org_lwjgl_openal_eax_EAX.c \ + org_lwjgl_openal_eax_EAX20.c \ + org_lwjgl_openal_eax_EAXBufferProperties.c \ + org_lwjgl_openal_eax_EAXListenerProperties.c \ + org_lwjgl_opengl_GLContext.c \ + org_lwjgl_opengl_GL11.c \ + org_lwjgl_opengl_GL12.c \ + org_lwjgl_opengl_GL13.c \ + org_lwjgl_opengl_GL14.c \ + org_lwjgl_opengl_GL15.c \ + org_lwjgl_opengl_GL20.c --- NEW FILE: 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, 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. ------------------------------------------------------------------------------*/ /* Lev Povalahev le...@gm... http://www.uni-karlsruhe.de/~uli2/ */ #include <stdio.h> #include <string.h> #include "extgl.h" #include "common_tools.h" /* turn off the warning for the borland compiler*/ #ifdef __BORLANDC__ #pragma warn -8064 #pragma warn -8065 #endif /* __BORLANDC__ */ #ifdef _X11 #include <dlfcn.h> #endif #ifdef _AGL aglChoosePixelFormatPROC aglChoosePixelFormat = NULL; aglDestroyPixelFormatPROC aglDestroyPixelFormat = NULL; aglNextPixelFormatPROC aglNextPixelFormat = NULL; aglDescribePixelFormatPROC aglDescribePixelFormat = NULL; aglDevicesOfPixelFormatPROC aglDevicesOfPixelFormat = NULL; aglQueryRendererInfoPROC aglQueryRendererInfo = NULL; aglDestroyRendererInfoPROC aglDestroyRendererInfo = NULL; aglNextRendererInfoPROC aglNextRendererInfo = NULL; aglDescribeRendererPROC aglDescribeRenderer = NULL; aglCreateContextPROC aglCreateContext = NULL; aglDestroyContextPROC aglDestroyContext = NULL; aglCopyContextPROC aglCopyContext = NULL; aglUpdateContextPROC aglUpdateContext = NULL; aglSetCurrentContextPROC aglSetCurrentContext = NULL; aglGetCurrentContextPROC aglGetCurrentContext = NULL; aglSetDrawablePROC aglSetDrawable = NULL; aglSetOffScreenPROC aglSetOffScreen = NULL; aglSetFullScreenPROC aglSetFullScreen = NULL; aglGetDrawablePROC aglGetDrawable = NULL; aglSetVirtualScreenPROC aglSetVirtualScreen = NULL; aglGetVirtualScreenPROC aglGetVirtualScreen = NULL; aglGetVersionPROC aglGetVersion = NULL; aglSwapBuffersPROC aglSwapBuffers = NULL; aglEnablePROC aglEnable = NULL; aglDisablePROC aglDisable = NULL; aglIsEnabledPROC aglIsEnabled = NULL; aglSetIntegerPROC aglSetInteger = NULL; aglGetIntegerPROC aglGetInteger = NULL; aglUseFontPROC aglUseFont = NULL; aglGetErrorPROC aglGetError = NULL; aglErrorStringPROC aglErrorString = NULL; aglResetLibraryPROC aglResetLibrary = NULL; aglSurfaceTexturePROC aglSurfaceTexture = NULL; #endif struct ExtensionTypes extgl_Extensions; #ifdef _WIN32 HMODULE lib_gl_handle = NULL; #endif #ifdef _X11 void * lib_gl_handle = NULL; typedef void * (APIENTRY * glXGetProcAddressARBPROC) (const GLubyte *procName); static glXGetProcAddressARBPROC glXGetProcAddressARB; #endif #ifdef _AGL CFBundleRef opengl_bundle_ref = NULL; CFBundleRef agl_bundle_ref = NULL; #endif /* getProcAddress */ void *extgl_GetProcAddress(const char *name) { #ifdef _WIN32 void *t = wglGetProcAddress(name); if (t == NULL) { t = GetProcAddress(lib_gl_handle, name); if (t == NULL) { printfDebug("Could not locate symbol %s\n", name); } } return t; #endif #ifdef _X11 void *t = (void*)glXGetProcAddressARB((const GLubyte*)name); if (t == NULL) { t = dlsym(lib_gl_handle, name); if (t == NULL) { printfDebug("Could not locate symbol %s\n", name); } } return t; #endif #ifdef _AGL CFStringRef str = CFStringCreateWithCStringNoCopy(NULL, name, kCFStringEncodingUTF8, kCFAllocatorNull); void *func_pointer = CFBundleGetFunctionPointerForName(opengl_bundle_ref, str); if (func_pointer == NULL) { func_pointer = CFBundleGetFunctionPointerForName(agl_bundle_ref, str); if (func_pointer == NULL) { printfDebug("Could not locate symbol %s\n", name); } } CFRelease(str); return func_pointer; #endif } void extgl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions) { ext_InitializeClass(env, clazz, &extgl_GetProcAddress, num_functions, functions); } bool extgl_InitializeFunctions(int num_functions, ExtFunction *functions) { return ext_InitializeFunctions(&extgl_GetProcAddress, num_functions, functions); } #ifdef _AGL // ------------------------- static CFBundleRef loadBundle(const Str255 frameworkName) { OSStatus err = noErr; FSRefParam fileRefParam; FSRef fileRef; CFURLRef bundleURLOpenGL; CFBundleRef bundle_ref; memset(&fileRefParam, 0, sizeof(fileRefParam)); memset(&fileRef, 0, sizeof(fileRef)); fileRefParam.ioNamePtr = frameworkName; fileRefParam.newRef = &fileRef; // Frameworks directory/folder // err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID); if (noErr != err) { printfDebug("Could not find frameworks folder\n"); return NULL; } // make FSRef for folder // err = PBMakeFSRefSync (&fileRefParam); if (noErr != err) { printfDebug("Could make FSref to frameworks folder\n"); return NULL; } // create URL to folder // bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef); if (!bundleURLOpenGL) { printfDebug("Could create framework URL\n"); return NULL; } bundle_ref = CFBundleCreate(kCFAllocatorDefault,bundleURLOpenGL); CFRelease (bundleURLOpenGL); if (bundle_ref == NULL) { printfDebug("Could not load framework\n"); return NULL; } // if the code was successfully loaded, look for our function. if (!CFBundleLoadExecutable(bundle_ref)) { printfDebug("Could not load MachO executable\n"); CFRelease(bundle_ref); return NULL; } return bundle_ref; } static void aglUnloadFramework(CFBundleRef f) { CFBundleUnloadExecutable(f); CFRelease(f); } #endif bool extgl_QueryExtension(JNIEnv *env, const GLubyte*extensions, const char *name) { const GLubyte *start; GLubyte *where, *terminator; if (extensions == NULL) { printfDebug("NULL extension string\n"); return false; } /* Extension names should not have spaces. */ where = (GLubyte *) strchr(name, ' '); if (where || *name == '\0') return false; /* It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc. */ start = extensions; for (;;) { where = (GLubyte *) strstr((const char *) start, name); if (!where) break; terminator = where + strlen(name); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') { return true; } start = terminator; } return false; } /*-----------------------------------------------------*/ /* AGL stuff BEGIN*/ /*-----------------------------------------------------*/ #ifdef _AGL bool extgl_InitAGL(JNIEnv *env) { aglChoosePixelFormat = (aglChoosePixelFormatPROC)extgl_GetProcAddress("aglChoosePixelFormat"); aglDestroyPixelFormat = (aglDestroyPixelFormatPROC)extgl_GetProcAddress("aglDestroyPixelFormat"); aglNextPixelFormat = (aglNextPixelFormatPROC)extgl_GetProcAddress("aglNextPixelFormat"); aglDescribePixelFormat = (aglDescribePixelFormatPROC)extgl_GetProcAddress("aglDescribePixelFormat"); aglDevicesOfPixelFormat = (aglDevicesOfPixelFormatPROC)extgl_GetProcAddress("aglDevicesOfPixelFormat"); aglQueryRendererInfo = (aglQueryRendererInfoPROC)extgl_GetProcAddress("aglQueryRendererInfo"); aglDestroyRendererInfo = (aglDestroyRendererInfoPROC)extgl_GetProcAddress("aglDestroyRendererInfo"); aglNextRendererInfo = (aglNextRendererInfoPROC)extgl_GetProcAddress("aglNextRendererInfo"); aglDescribeRenderer = (aglDescribeRendererPROC)extgl_GetProcAddress("aglDescribeRenderer"); aglCreateContext = (aglCreateContextPROC)extgl_GetProcAddress("aglCreateContext"); aglDestroyContext = (aglDestroyContextPROC)extgl_GetProcAddress("aglDestroyContext"); aglCopyContext = (aglCopyContextPROC)extgl_GetProcAddress("aglCopyContext"); aglUpdateContext = (aglUpdateContextPROC)extgl_GetProcAddress("aglUpdateContext"); aglSetCurrentContext = (aglSetCurrentContextPROC)extgl_GetProcAddress("aglSetCurrentContext"); aglGetCurrentContext = (aglGetCurrentContextPROC)extgl_GetProcAddress("aglGetCurrentContext"); aglSetDrawable = (aglSetDrawablePROC)extgl_GetProcAddress("aglSetDrawable"); aglSetOffScreen = (aglSetOffScreenPROC)extgl_GetProcAddress("aglSetOffScreen"); aglSetFullScreen = (aglSetFullScreenPROC)extgl_GetProcAddress("aglSetFullScreen"); aglGetDrawable = (aglGetDrawablePROC)extgl_GetProcAddress("aglGetDrawable"); aglSetVirtualScreen = (aglSetVirtualScreenPROC)extgl_GetProcAddress("aglSetVirtualScreen"); aglGetVirtualScreen = (aglGetVirtualScreenPROC)extgl_GetProcAddress("aglGetVirtualScreen"); aglGetVersion = (aglGetVersionPROC)extgl_GetProcAddress("aglGetVersion"); aglSwapBuffers = (aglSwapBuffersPROC)extgl_GetProcAddress("aglSwapBuffers"); aglEnable = (aglEnablePROC)extgl_GetProcAddress("aglEnable"); aglDisable = (aglDisablePROC)extgl_GetProcAddress("aglDisable"); aglIsEnabled = (aglIsEnabledPROC)extgl_GetProcAddress("aglIsEnabled"); aglSetInteger = (aglSetIntegerPROC)extgl_GetProcAddress("aglSetInteger"); aglGetInteger = (aglGetIntegerPROC)extgl_GetProcAddress("aglGetInteger"); aglUseFont = (aglUseFontPROC)extgl_GetProcAddress("aglUseFont"); aglGetError = (aglGetErrorPROC)extgl_GetProcAddress("aglGetError"); aglErrorString = (aglErrorStringPROC)extgl_GetProcAddress("aglErrorString"); aglResetLibrary = (aglResetLibraryPROC)extgl_GetProcAddress("aglResetLibrary"); aglSurfaceTexture = (aglSurfaceTexturePROC)extgl_GetProcAddress("aglSurfaceTexture"); return !extgl_error; // Split out AGL into extgl_agl.cpp like wgl and glx and replace with InitializeFunctions } #endif /*-----------------------------------------------------*/ /* AGL stuff END*/ /*-----------------------------------------------------*/ #ifdef _AGL bool extgl_Open(void) { if (opengl_bundle_ref != NULL) return true; opengl_bundle_ref = loadBundle("\pOpenGL.framework"); if (opengl_bundle_ref == NULL) return false; agl_bundle_ref = loadBundle("\pAGL.framework"); if (agl_bundle_ref == NULL) { aglUnloadFramework(opengl_bundle_ref); return false; } return true; } #endif #ifdef _X11 bool extgl_Open() { if (lib_gl_handle != NULL) return true; lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); if (lib_gl_handle == NULL) { printfDebug("Error loading libGL.so.1: %s\n", dlerror... [truncated message content] |