glshim: added log output
This commit is contained in:
@@ -41,7 +41,7 @@ LOCAL_SRC_FILES := \
|
|||||||
src/glx/lookup.c \
|
src/glx/lookup.c \
|
||||||
src/glx/streaming.c
|
src/glx/streaming.c
|
||||||
|
|
||||||
LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DBCMHOST
|
LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DBCMHOST -include include/android_debug.h
|
||||||
|
|
||||||
LOCAL_LDLIBS := -ldl -llog -lEGL
|
LOCAL_LDLIBS := -ldl -llog -lEGL
|
||||||
|
|
||||||
|
|||||||
69
project/jni/glshim/include/android_debug.h
Normal file
69
project/jni/glshim/include/android_debug.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef __ANDROID_DEBUG_H__
|
||||||
|
#define __ANDROID_DEBUG_H__
|
||||||
|
|
||||||
|
// Redirect printf() to Android log
|
||||||
|
// Put this file into CFLAGS: "-include ../android_debug.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
// Include everything beforehand, so we wont' get compiler eerors because of our #define
|
||||||
|
#include <string>
|
||||||
|
#include <ios>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
class android_cout: public ostringstream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
android_cout() {}
|
||||||
|
template <class T>
|
||||||
|
android_cout &operator<<(const T &v)
|
||||||
|
{
|
||||||
|
*((ostringstream*)this) << v;
|
||||||
|
if( this->str().find('\n') != ::std::string::npos )
|
||||||
|
{
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "glshim", "%s", this->str().c_str());
|
||||||
|
this->str().clear();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~android_cout()
|
||||||
|
{
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "glshim", "%s", this->str().c_str());
|
||||||
|
this->str().clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static const char * android_endl = "\n";
|
||||||
|
}
|
||||||
|
#define cout android_cout()
|
||||||
|
#define cerr android_cout()
|
||||||
|
#define endl android_endl
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define printf(...) __android_log_print(ANDROID_LOG_INFO, "glshim", __VA_ARGS__)
|
||||||
|
|
||||||
|
// Override fprintf(stderr, ...) constructs
|
||||||
|
static inline int __sdl_logged_fprintf(FILE *stream, const char *format, ...)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
if( stream == stderr || stream == stdout )
|
||||||
|
ret = __android_log_vprint(ANDROID_LOG_INFO, "glshim", format, args);
|
||||||
|
else
|
||||||
|
ret = vfprintf(stream, format, args);
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define fprintf(...) __sdl_logged_fprintf(__VA_ARGS__)
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include "../gl/gl.h"
|
#include "../gl/gl.h"
|
||||||
#include <android/log.h>
|
|
||||||
#else
|
#else
|
||||||
#include "glx.h"
|
#include "glx.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -445,11 +444,8 @@ void *glXGetProcAddressARB(const char *name) {
|
|||||||
STUB(glIndexPointerEXT);
|
STUB(glIndexPointerEXT);
|
||||||
STUB(glIndexPointer);
|
STUB(glIndexPointer);
|
||||||
|
|
||||||
#ifdef ANDROID
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "glshim","glXGetProcAddress: %s not found.\n", name);
|
|
||||||
#else
|
|
||||||
printf("glXGetProcAddress: %s not found.\n", name);
|
printf("glXGetProcAddress: %s not found.\n", name);
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user