mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-07 15:35:09 +00:00
Implemented proper debug levels
This commit is contained in:
parent
aae1deef70
commit
fb8fd0a2d7
27 changed files with 207 additions and 194 deletions
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#define CHECK_AL_ERROR \
|
||||
{ \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \
|
||||
int err = alGetError(); \
|
||||
if (err != AL_NO_ERROR) { \
|
||||
jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
/* only available if deviceaddress is specified in method */
|
||||
#define CHECK_ALC_ERROR \
|
||||
{ \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \
|
||||
int err = alcGetError((ALCdevice*) deviceaddress); \
|
||||
if (err != AL_NO_ERROR) { \
|
||||
jclass cls = env->FindClass("org/lwjgl/openal/OpenALException"); \
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#define CHECK_GL_ERROR \
|
||||
{ \
|
||||
if (ATDEBUGLEVEL()) { \
|
||||
if (ATDEBUGLEVEL(org_lwjgl_Sys_DEBUG)) { \
|
||||
int err = glGetError(); \
|
||||
if (err != GL_NO_ERROR) { \
|
||||
jclass cls = env->FindClass("org/lwjgl/opengl/OpenGLException"); \
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@
|
|||
|
||||
#include "common_tools.h"
|
||||
|
||||
int debug_level = org_lwjgl_Sys_DEBUG_DISABLED;
|
||||
int debug_level = org_lwjgl_Sys_NONE;
|
||||
|
||||
void setDebugLevel(int level) {
|
||||
debug_level = level;
|
||||
}
|
||||
|
||||
int printfDebug(const char *format, ...) {
|
||||
void printfDebug(int level, const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int result = vprintf(format, ap);
|
||||
if (debug_level >= level)
|
||||
vprintf(format, ap);
|
||||
va_end(ap);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void incListStart(event_queue_t *queue) {
|
||||
|
|
@ -65,7 +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) {
|
||||
printfDebug("Event buffer overflow!\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Event buffer overflow!\n");
|
||||
return;
|
||||
}
|
||||
queue->input_event_buffer[queue->list_end] = byte;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ 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)
|
||||
#define ATDEBUGLEVEL(level) (debug_level >= level)
|
||||
|
||||
typedef struct {
|
||||
unsigned char input_event_buffer[EVENT_BUFFER_SIZE];
|
||||
|
|
@ -65,6 +65,6 @@ 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, ...);
|
||||
extern void printfDebug(int level, const char *format, ...);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ static void *NativeGetFunctionPointer(const char *function) {
|
|||
static void* GetFunctionPointer(const char* function) {
|
||||
void *p = NativeGetFunctionPointer(function);
|
||||
if (p == NULL) {
|
||||
printfDebug("Could not locate symbol %s\n", function);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", function);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
@ -193,11 +193,11 @@ static void* GetFunctionPointer(const char* function) {
|
|||
static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||
|
||||
jsize pathcount = env->GetArrayLength(oalPaths);
|
||||
printfDebug("Found %d OpenAL paths\n", (int)pathcount);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "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);
|
||||
printfDebug("Testing '%s'\n", path_str);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Testing '%s'\n", path_str);
|
||||
#ifdef _WIN32
|
||||
handleOAL = LoadLibrary(path_str);
|
||||
#endif
|
||||
|
|
@ -208,7 +208,7 @@ static bool LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
|||
handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
#endif
|
||||
if (handleOAL != NULL) {
|
||||
printfDebug("Found OpenAL at '%s'\n", path_str);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Found OpenAL at '%s'\n", path_str);
|
||||
return true;
|
||||
}
|
||||
env->ReleaseStringUTFChars(path, path_str);
|
||||
|
|
|
|||
|
|
@ -1339,7 +1339,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
err = FindFolder (kSystemDomain, kFrameworksFolderType, false, &fileRefParam.ioVRefNum, &fileRefParam.ioDirID);
|
||||
if (noErr != err)
|
||||
{
|
||||
printfDebug("Could not find frameworks folder\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not find frameworks folder\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1350,7 +1350,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
|
||||
if (noErr != err)
|
||||
{
|
||||
printfDebug("Could make FSref to frameworks folder\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could make FSref to frameworks folder\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1359,7 +1359,7 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, &fileRef);
|
||||
if (!bundleURLOpenGL)
|
||||
{
|
||||
printfDebug("Could create framework URL\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could create framework URL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1367,14 +1367,14 @@ static CFBundleRef loadBundle(const Str255 frameworkName)
|
|||
CFRelease (bundleURLOpenGL);
|
||||
if (bundle_ref == NULL)
|
||||
{
|
||||
printfDebug("Could not load framework\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "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");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not load MachO executable\n");
|
||||
CFRelease(bundle_ref);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1403,7 +1403,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
{
|
||||
t = GetProcAddress(lib_glu_handle, name);
|
||||
if (t == NULL) {
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1420,7 +1420,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
{
|
||||
t = dlsym(lib_glu_handle, name);
|
||||
if (t == NULL) {
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1434,7 +1434,7 @@ static void *extgl_GetProcAddress(char *name)
|
|||
if (func_pointer == NULL) {
|
||||
func_pointer = CFBundleGetFunctionPointerForName(agl_bundle_ref, str);
|
||||
if (func_pointer == NULL) {
|
||||
printfDebug("Could not locate symbol %s\n", name);
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Could not locate symbol %s\n", name);
|
||||
extgl_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1449,7 +1449,7 @@ static bool QueryExtension(JNIEnv *env, jobject ext_set, const GLubyte*extension
|
|||
GLubyte *where, *terminator;
|
||||
|
||||
if (extensions == NULL) {
|
||||
printfDebug("NULL extension string\n");
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "NULL extension string\n");
|
||||
extgl_error = true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3291,12 +3291,12 @@ bool extgl_Open()
|
|||
{
|
||||
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());
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "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) {
|
||||
printfDebug("Error loading libGLU.so.1: %s\n", dlerror());
|
||||
printfDebug(org_lwjgl_Sys_DEBUG, "Error loading libGLU.so.1: %s\n", dlerror());
|
||||
dlclose(lib_gl_handle);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,18 @@
|
|||
#ifdef __cplusplus
|
||||
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_DEBUG
|
||||
#define org_lwjgl_Sys_DEBUG 6L
|
||||
#undef org_lwjgl_Sys_INFO
|
||||
#define org_lwjgl_Sys_INFO 5L
|
||||
#undef org_lwjgl_Sys_WARN
|
||||
#define org_lwjgl_Sys_WARN 4L
|
||||
#undef org_lwjgl_Sys_ERROR
|
||||
#define org_lwjgl_Sys_ERROR 3L
|
||||
#undef org_lwjgl_Sys_FATAL
|
||||
#define org_lwjgl_Sys_FATAL 2L
|
||||
#undef org_lwjgl_Sys_NONE
|
||||
#define org_lwjgl_Sys_NONE 1L
|
||||
#undef org_lwjgl_Sys_LOW_PRIORITY
|
||||
#define org_lwjgl_Sys_LOW_PRIORITY -1L
|
||||
#undef org_lwjgl_Sys_NORMAL_PRIORITY
|
||||
|
|
@ -21,8 +28,7 @@ extern "C" {
|
|||
#undef org_lwjgl_Sys_REALTIME_PRIORITY
|
||||
#define org_lwjgl_Sys_REALTIME_PRIORITY 2L
|
||||
/* Inaccessible static: LIBRARY_NAME */
|
||||
/* Inaccessible static: DEBUG */
|
||||
/* Inaccessible static: class_00024org_00024lwjgl_00024Sys */
|
||||
/* Inaccessible static: debug_level */
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: setDebugLevel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue