Improve GUI on Android, add OpenAsset function

This commit is contained in:
Milan Nikolic 2017-02-02 02:05:14 +01:00
parent 8fc94a8d3d
commit 56debbf236
7 changed files with 181 additions and 109 deletions

View file

@ -6,26 +6,26 @@ package raylib
#include <android/log.h>
#include <stdlib.h>
void logInfo(const char *msg) {
void log_info(const char *msg) {
__android_log_print(ANDROID_LOG_INFO, "raylib", msg);
}
void logWarn(const char *msg) {
void log_warn(const char *msg) {
__android_log_print(ANDROID_LOG_WARN, "raylib", msg);
}
void logError(const char *msg) {
void log_error(const char *msg) {
__android_log_print(ANDROID_LOG_ERROR, "raylib", msg);
}
void logDebug(const char *msg) {
void log_debug(const char *msg) {
__android_log_print(ANDROID_LOG_DEBUG, "raylib", msg);
}
void logInfo(const char *msg);
void logWarn(const char *msg);
void logError(const char *msg);
void logDebug(const char *msg);
void log_info(const char *msg);
void log_warn(const char *msg);
void log_error(const char *msg);
void log_debug(const char *msg);
*/
import "C"
@ -45,30 +45,32 @@ const (
var traceDebugMsgs = false
// Set debug messages
func SetDebug(enabled bool) {
traceDebugMsgs = enabled
}
// Trace log
func TraceLog(msgType int, text string, v ...interface{}) {
switch msgType {
case LogInfo:
msg := C.CString(fmt.Sprintf("INFO: "+text, v...))
defer C.free(unsafe.Pointer(msg))
C.logInfo(msg)
C.log_info(msg)
case LogError:
msg := C.CString(fmt.Sprintf("ERROR: "+text, v...))
defer C.free(unsafe.Pointer(msg))
C.logError(msg)
C.log_error(msg)
os.Exit(1)
case LogWarning:
msg := C.CString(fmt.Sprintf("WARNING: "+text, v...))
defer C.free(unsafe.Pointer(msg))
C.logWarn(msg)
C.log_warn(msg)
case LogDebug:
if traceDebugMsgs {
msg := C.CString(fmt.Sprintf("DEBUG: "+text, v...))
defer C.free(unsafe.Pointer(msg))
C.logDebug(msg)
C.log_debug(msg)
}
}
}
func SetDebug(enabled bool) {
traceDebugMsgs = enabled
}