mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-20 05:44:03 +00:00
Replaced debug libraries with runtime debug condition
This commit is contained in:
parent
cd2a1cc13f
commit
472b5337d4
28 changed files with 679 additions and 952 deletions
|
|
@ -10,36 +10,32 @@
|
|||
#ifndef _CHECKALERROR_H_INCLUDED_
|
||||
#define _CHECKALERROR_H_INCLUDED_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#include <jni.h>
|
||||
#include "extal.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
#define CHECK_AL_ERROR \
|
||||
{ \
|
||||
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); \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
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); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
/* only available if deviceaddress is specified in method */
|
||||
#define CHECK_ALC_ERROR \
|
||||
{ \
|
||||
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); \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
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); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define CHECK_AL_ERROR
|
||||
#define CHECK_ALC_ERROR
|
||||
|
||||
#endif /* _DEBUG */
|
||||
|
||||
#endif /* _CHECKALERROR_H_INCLUDED_ */
|
||||
|
|
|
|||
|
|
@ -10,18 +10,19 @@
|
|||
#ifndef _CHECKGLERROR_H_INCLUDED_
|
||||
#define _CHECKGLERROR_H_INCLUDED_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#include <jni.h>
|
||||
#include "extgl.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
#define CHECK_GL_ERROR \
|
||||
{ \
|
||||
int err = glGetError(); \
|
||||
if (err != GL_NO_ERROR) { \
|
||||
jclass cls = env->FindClass("org/lwjgl/opengl/OpenGLException"); \
|
||||
env->ThrowNew(cls, (const char *)gluErrorString(err)); \
|
||||
env->DeleteLocalRef(cls); \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
int err = glGetError(); \
|
||||
if (err != GL_NO_ERROR) { \
|
||||
jclass cls = env->FindClass("org/lwjgl/opengl/OpenGLException"); \
|
||||
env->ThrowNew(cls, (const char *)gluErrorString(err)); \
|
||||
env->DeleteLocalRef(cls); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
@ -34,11 +35,4 @@
|
|||
} \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
#define CHECK_GL_ERROR
|
||||
#define CHECK_EXISTS(f)
|
||||
|
||||
#endif /* _DEBUG */
|
||||
|
||||
#endif /* _CHECKGLERROR_H_INCLUDED_ */
|
||||
|
|
|
|||
|
|
@ -39,6 +39,20 @@
|
|||
|
||||
#include "common_tools.h"
|
||||
|
||||
int debug_level = org_lwjgl_Sys_DEBUG_DISABLED;
|
||||
|
||||
void setDebugLevel(int level) {
|
||||
debug_level = level;
|
||||
}
|
||||
|
||||
int printfDebug(const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int result = vprintf(format, ap);
|
||||
va_end(ap);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void incListStart(event_queue_t *queue) {
|
||||
queue->list_start = (queue->list_start + 1)%EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
|
@ -51,9 +65,7 @@ void initEventQueue(event_queue_t *event_queue) {
|
|||
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) {
|
||||
#ifdef _DEBUG
|
||||
printf("Event buffer overflow!\n");
|
||||
#endif
|
||||
printfDebug("Event buffer overflow!\n");
|
||||
return;
|
||||
}
|
||||
queue->input_event_buffer[queue->list_end] = byte;
|
||||
|
|
|
|||
|
|
@ -41,9 +41,13 @@
|
|||
#define _COMMON_TOOLS_H
|
||||
|
||||
#include <jni.h>
|
||||
#include "org_lwjgl_Sys.h"
|
||||
|
||||
extern int debug_level;
|
||||
|
||||
// Must be x * max_event_size + 1
|
||||
#define EVENT_BUFFER_SIZE (25 * 4 + 1)
|
||||
#define ATDEBUGLEVEL() (debug_level >= org_lwjgl_Sys_DEBUG_ENABLED)
|
||||
|
||||
typedef struct {
|
||||
unsigned char input_event_buffer[EVENT_BUFFER_SIZE];
|
||||
|
|
@ -60,5 +64,7 @@ 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 setDebugLevel(int level);
|
||||
extern int printfDebug(const char *format, ...);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -182,9 +182,7 @@ static void *NativeGetFunctionPointer(const char *function) {
|
|||
static void* GetFunctionPointer(const char* function) {
|
||||
void *p = NativeGetFunctionPointer(function);
|
||||
if (p == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not locate symbol %s\n", function);
|
||||
#endif
|
||||
printfDebug("Could not locate symbol %s\n", function);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
@ -195,15 +193,11 @@ static void* GetFunctionPointer(const char* function) {
|
|||
static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
|
||||
jsize pathcount = env->GetArrayLength(oalPaths);
|
||||
#ifdef _DEBUG
|
||||
printf("Found %d OpenAL paths\n", (int)pathcount);
|
||||
#endif
|
||||
printfDebug("Found %d OpenAL paths\n", (int)pathcount);
|
||||
for(int i=0;i<pathcount;i++) {
|
||||
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
||||
const char *path_str = env->GetStringUTFChars(path, NULL);
|
||||
#ifdef _DEBUG
|
||||
printf("Testing '%s'\n", path_str);
|
||||
#endif
|
||||
printfDebug("Testing '%s'\n", path_str);
|
||||
#ifdef _WIN32
|
||||
handleOAL = LoadLibrary(path_str);
|
||||
#endif
|
||||
|
|
@ -214,9 +208,7 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
|||
handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
#endif
|
||||
if (handleOAL != NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Found OpenAL at '%s'\n", path_str);
|
||||
#endif
|
||||
printfDebug("Found OpenAL at '%s'\n", path_str);
|
||||
return true;
|
||||
}
|
||||
env->ReleaseStringUTFChars(path, path_str);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include "extgl.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "extgl.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
/* turn off the warning for the borland compiler*/
|
||||
#ifdef __BORLANDC__
|
||||
|
|
@ -1338,9 +1339,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID);
|
||||
if (noErr != err)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Could not find frameworks folder\n");
|
||||
#endif
|
||||
printfDebug("Could not find frameworks folder\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1351,9 +1350,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
|
||||
if (noErr != err)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Could make FSref to frameworks folder\n");
|
||||
#endif
|
||||
printfDebug("Could make FSref to frameworks folder\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1362,9 +1359,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef);
|
||||
if (!bundleURLOpenGL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Could create framework URL\n");
|
||||
#endif
|
||||
printfDebug("Could create framework URL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1372,18 +1367,14 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
CFRelease (bundleURLOpenGL);
|
||||
if (bundle_ref == NULL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Could not load framework\n");
|
||||
#endif
|
||||
printfDebug("Could not load framework\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if the code was successfully loaded, look for our function.
|
||||
if (!CFBundleLoadExecutable(bundle_ref))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Could not load MachO executable\n");
|
||||
#endif
|
||||
printfDebug("Could not load MachO executable\n");
|
||||
CFRelease(bundle_ref);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1412,9 +1403,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
{
|
||||
t = GetProcAddress(lib_glu_handle, name);
|
||||
if (t == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not locate symbol %s\n", name);
|
||||
#endif
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1431,9 +1420,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
{
|
||||
t = dlsym(lib_glu_handle, name);
|
||||
if (t == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not locate symbol %s\n", name);
|
||||
#endif
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1447,9 +1434,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
if (func_pointer == NULL) {
|
||||
func_pointer = CFBundleGetFunctionPointerForName(agl_bundle_ref, str);
|
||||
if (func_pointer == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Could not locate symbol %s\n", name);
|
||||
#endif
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1464,9 +1449,7 @@ static bool QueryExtension(JNIEnv *env, jobject ext_set, const GLubyte*extension
|
|||
GLubyte *where, *terminator;
|
||||
|
||||
if (extensions == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("NULL extension string\n");
|
||||
#endif
|
||||
printfDebug("NULL extension string\n");
|
||||
extgl_error = true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3308,16 +3291,12 @@ bool extgl_Open()
|
|||
{
|
||||
lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (lib_gl_handle == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Error loading libGL.so.1: %s\n", dlerror());
|
||||
#endif
|
||||
printfDebug("Error loading libGL.so.1: %s\n", dlerror());
|
||||
return false;
|
||||
}
|
||||
lib_glu_handle = dlopen("libGLU.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (lib_glu_handle == NULL) {
|
||||
#ifdef _DEBUG
|
||||
printf("Error loading libGLU.so.1: %s\n", dlerror());
|
||||
#endif
|
||||
printfDebug("Error loading libGLU.so.1: %s\n", dlerror());
|
||||
dlclose(lib_gl_handle);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
/* Inaccessible static: _00024assertionsDisabled */
|
||||
#undef org_lwjgl_Sys_DEBUG_DISABLED
|
||||
#define org_lwjgl_Sys_DEBUG_DISABLED 1L
|
||||
#undef org_lwjgl_Sys_DEBUG_ENABLED
|
||||
#define org_lwjgl_Sys_DEBUG_ENABLED 2L
|
||||
#undef org_lwjgl_Sys_LOW_PRIORITY
|
||||
#define org_lwjgl_Sys_LOW_PRIORITY -1L
|
||||
#undef org_lwjgl_Sys_NORMAL_PRIORITY
|
||||
|
|
@ -18,8 +22,15 @@ extern "C" {
|
|||
#define org_lwjgl_Sys_REALTIME_PRIORITY 2L
|
||||
/* Inaccessible static: LIBRARY_NAME */
|
||||
/* Inaccessible static: DEBUG */
|
||||
/* Inaccessible static: _debug */
|
||||
/* Inaccessible static: class_00024org_00024lwjgl_00024Sys */
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: setDebugLevel
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebugLevel
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: getTimerResolution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue