Replace TraceLog() function by TRACELOG macro

Added SUPPORT_TRACELOG_DEBUG config
This commit is contained in:
Ray 2020-02-03 19:13:24 +01:00
parent 40b73a8a91
commit cde26c743c
9 changed files with 402 additions and 389 deletions

View file

@ -143,9 +143,10 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: utils - Configuration Flags // Module: utils - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Show TraceLog() output messages // Show TRACELOG() output messages
// NOTE: By default LOG_DEBUG traces not shown // NOTE: By default LOG_DEBUG traces not shown
#define SUPPORT_TRACELOG 1 #define SUPPORT_TRACELOG 1
//#define SUPPORT_TRACELOG_DEBUG 1
#endif //defined(RAYLIB_CMAKE) #endif //defined(RAYLIB_CMAKE)

View file

@ -119,6 +119,8 @@
#define RAYLIB_VERSION "3.0" #define RAYLIB_VERSION "3.0"
#endif #endif
#include "utils.h" // Required for: TRACELOG macros and fopen() Android mapping
#if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L #if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
@ -130,8 +132,6 @@
#define RLGL_IMPLEMENTATION #define RLGL_IMPLEMENTATION
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
#include "utils.h" // Required for: fopen() Android mapping
#if defined(SUPPORT_GESTURES_SYSTEM) #if defined(SUPPORT_GESTURES_SYSTEM)
#define GESTURES_IMPLEMENTATION #define GESTURES_IMPLEMENTATION
#include "gestures.h" // Gestures detection functionality #include "gestures.h" // Gestures detection functionality
@ -559,7 +559,7 @@ struct android_app *GetAndroidApp(void)
// Init terminal (block echo and signal short cuts) // Init terminal (block echo and signal short cuts)
static void InitTerminal(void) static void InitTerminal(void)
{ {
TraceLog(LOG_INFO, "Reconfigure Terminal ..."); TRACELOG(LOG_INFO, "Reconfigure Terminal ...");
// Save terminal keyboard settings and reconfigure terminal with new settings // Save terminal keyboard settings and reconfigure terminal with new settings
struct termios keyboardNewSettings; struct termios keyboardNewSettings;
tcgetattr(STDIN_FILENO, &CORE.Input.Keyboard.defaultSettings); // Get current keyboard settings tcgetattr(STDIN_FILENO, &CORE.Input.Keyboard.defaultSettings); // Get current keyboard settings
@ -578,7 +578,7 @@ static void InitTerminal(void)
if (ioctl(STDIN_FILENO, KDGKBMODE, &CORE.Input.Keyboard.defaultMode) < 0) if (ioctl(STDIN_FILENO, KDGKBMODE, &CORE.Input.Keyboard.defaultMode) < 0)
{ {
// NOTE: It could mean we are using a remote keyboard through ssh or from the desktop // NOTE: It could mean we are using a remote keyboard through ssh or from the desktop
TraceLog(LOG_WARNING, "Could not change keyboard mode (Not a local Terminal)"); TRACELOG(LOG_WARNING, "Could not change keyboard mode (Not a local Terminal)");
} }
else else
{ {
@ -592,7 +592,7 @@ static void InitTerminal(void)
// Restore terminal // Restore terminal
static void RestoreTerminal(void) static void RestoreTerminal(void)
{ {
TraceLog(LOG_INFO, "Restore Terminal ..."); TRACELOG(LOG_INFO, "Restore Terminal ...");
// Reset to default keyboard settings // Reset to default keyboard settings
tcsetattr(STDIN_FILENO, TCSANOW, &CORE.Input.Keyboard.defaultSettings); tcsetattr(STDIN_FILENO, TCSANOW, &CORE.Input.Keyboard.defaultSettings);
@ -605,7 +605,7 @@ static void RestoreTerminal(void)
// NOTE: data parameter could be used to pass any kind of required data to the initialization // NOTE: data parameter could be used to pass any kind of required data to the initialization
void InitWindow(int width, int height, const char *title) void InitWindow(int width, int height, const char *title)
{ {
TraceLog(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION); TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
CORE.Window.title = title; CORE.Window.title = title;
@ -628,19 +628,19 @@ void InitWindow(int width, int height, const char *title)
int orientation = AConfiguration_getOrientation(CORE.Android.app->config); int orientation = AConfiguration_getOrientation(CORE.Android.app->config);
if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(LOG_INFO, "PORTRAIT window orientation"); if (orientation == ACONFIGURATION_ORIENTATION_PORT) TRACELOG(LOG_INFO, "PORTRAIT window orientation");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(LOG_INFO, "LANDSCAPE window orientation"); else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TRACELOG(LOG_INFO, "LANDSCAPE window orientation");
// TODO: Automatic orientation doesn't seem to work // TODO: Automatic orientation doesn't seem to work
if (width <= height) if (width <= height)
{ {
AConfiguration_setOrientation(CORE.Android.app->config, ACONFIGURATION_ORIENTATION_PORT); AConfiguration_setOrientation(CORE.Android.app->config, ACONFIGURATION_ORIENTATION_PORT);
TraceLog(LOG_WARNING, "Window set to portraid mode"); TRACELOG(LOG_WARNING, "Window set to portraid mode");
} }
else else
{ {
AConfiguration_setOrientation(CORE.Android.app->config, ACONFIGURATION_ORIENTATION_LAND); AConfiguration_setOrientation(CORE.Android.app->config, ACONFIGURATION_ORIENTATION_LAND);
TraceLog(LOG_WARNING, "Window set to landscape mode"); TRACELOG(LOG_WARNING, "Window set to landscape mode");
} }
//AConfiguration_getDensity(CORE.Android.app->config); //AConfiguration_getDensity(CORE.Android.app->config);
@ -653,7 +653,7 @@ void InitWindow(int width, int height, const char *title)
InitAssetManager(CORE.Android.app->activity->assetManager); InitAssetManager(CORE.Android.app->activity->assetManager);
TraceLog(LOG_INFO, "Android app initialized successfully"); TRACELOG(LOG_INFO, "Android app initialized successfully");
// Android ALooper_pollAll() variables // Android ALooper_pollAll() variables
int pollResult = 0; int pollResult = 0;
@ -795,7 +795,7 @@ void CloseWindow(void)
if (CORE.Input.Gamepad.threadId) pthread_join(CORE.Input.Gamepad.threadId, NULL); if (CORE.Input.Gamepad.threadId) pthread_join(CORE.Input.Gamepad.threadId, NULL);
#endif #endif
TraceLog(LOG_INFO, "Window closed successfully"); TRACELOG(LOG_INFO, "Window closed successfully");
} }
// Check if window has been initialized successfully // Check if window has been initialized successfully
@ -880,7 +880,7 @@ void ToggleFullscreen(void)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
if (!monitor) if (!monitor)
{ {
TraceLog(LOG_WARNING, "Failed to get monitor"); TRACELOG(LOG_WARNING, "Failed to get monitor");
glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
return; return;
} }
@ -896,7 +896,7 @@ void ToggleFullscreen(void)
#endif #endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
TraceLog(LOG_WARNING, "Could not toggle to windowed mode"); TRACELOG(LOG_WARNING, "Could not toggle to windowed mode");
#endif #endif
} }
@ -917,7 +917,7 @@ void SetWindowIcon(Image image)
// NOTE 2: The specified image data is copied before this function returns // NOTE 2: The specified image data is copied before this function returns
glfwSetWindowIcon(CORE.Window.handle, 1, icon); glfwSetWindowIcon(CORE.Window.handle, 1, icon);
} }
else TraceLog(LOG_WARNING, "Window icon image must be in R8G8B8A8 pixel format"); else TRACELOG(LOG_WARNING, "Window icon image must be in R8G8B8A8 pixel format");
#endif #endif
} }
@ -947,12 +947,12 @@ void SetWindowMonitor(int monitor)
if ((monitor >= 0) && (monitor < monitorCount)) if ((monitor >= 0) && (monitor < monitorCount))
{ {
TraceLog(LOG_INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor])); TRACELOG(LOG_INFO, "Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate); glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
} }
@ -1046,7 +1046,7 @@ int GetMonitorWidth(int monitor)
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
return mode->width; return mode->width;
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0; return 0;
} }
@ -1063,7 +1063,7 @@ int GetMonitorHeight(int monitor)
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
return mode->height; return mode->height;
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0; return 0;
} }
@ -1081,7 +1081,7 @@ int GetMonitorPhysicalWidth(int monitor)
glfwGetMonitorPhysicalSize(monitors[monitor], &physicalWidth, NULL); glfwGetMonitorPhysicalSize(monitors[monitor], &physicalWidth, NULL);
return physicalWidth; return physicalWidth;
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0; return 0;
} }
@ -1099,7 +1099,7 @@ int GetMonitorPhysicalHeight(int monitor)
glfwGetMonitorPhysicalSize(monitors[monitor], NULL, &physicalHeight); glfwGetMonitorPhysicalSize(monitors[monitor], NULL, &physicalHeight);
return physicalHeight; return physicalHeight;
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0; return 0;
} }
@ -1126,7 +1126,7 @@ const char *GetMonitorName(int monitor)
{ {
return glfwGetMonitorName(monitors[monitor]); return glfwGetMonitorName(monitors[monitor]);
} }
else TraceLog(LOG_WARNING, "Selected monitor not found"); else TRACELOG(LOG_WARNING, "Selected monitor not found");
#endif #endif
return ""; return "";
} }
@ -1608,7 +1608,7 @@ void SetTargetFPS(int fps)
if (fps < 1) CORE.Time.target = 0.0; if (fps < 1) CORE.Time.target = 0.0;
else CORE.Time.target = 1.0/(double)fps; else CORE.Time.target = 1.0/(double)fps;
TraceLog(LOG_INFO, "Target time per frame: %02.03f milliseconds", (float)CORE.Time.target*1000); TRACELOG(LOG_INFO, "Target time per frame: %02.03f milliseconds", (float)CORE.Time.target*1000);
} }
// Returns current FPS // Returns current FPS
@ -1809,7 +1809,7 @@ void SetConfigFlags(unsigned int flags)
if (CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) CORE.Window.alwaysRun = true; if (CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) CORE.Window.alwaysRun = true;
} }
// NOTE TraceLog() function is located in [utils.h] // NOTE TRACELOG() function is located in [utils.h]
// Takes a screenshot of current screen (saved a .png) // Takes a screenshot of current screen (saved a .png)
// NOTE: This function could work in any platform but some platforms: PLATFORM_ANDROID and PLATFORM_WEB // NOTE: This function could work in any platform but some platforms: PLATFORM_ANDROID and PLATFORM_WEB
@ -1837,7 +1837,7 @@ void TakeScreenshot(const char *fileName)
emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", GetFileName(path), GetFileName(path))); emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", GetFileName(path), GetFileName(path)));
#endif #endif
TraceLog(LOG_INFO, "Screenshot taken: %s", path); TRACELOG(LOG_INFO, "Screenshot taken: %s", path);
} }
// Check if the file exists // Check if the file exists
@ -2046,7 +2046,7 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount)
closedir(dir); closedir(dir);
} }
else TraceLog(LOG_WARNING, "Can not open directory...\n"); // Maybe it's a file... else TRACELOG(LOG_WARNING, "Can not open directory...\n"); // Maybe it's a file...
dirFilesCount = counter; dirFilesCount = counter;
*fileCount = dirFilesCount; *fileCount = dirFilesCount;
@ -2162,7 +2162,7 @@ void StorageSaveValue(int position, int value)
// If file doesn't exist, create a new storage data file // If file doesn't exist, create a new storage data file
if (!storageFile) storageFile = fopen(path, "wb"); if (!storageFile) storageFile = fopen(path, "wb");
if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be created"); if (!storageFile) TRACELOG(LOG_WARNING, "Storage data file could not be created");
else else
{ {
// Get file size // Get file size
@ -2170,7 +2170,7 @@ void StorageSaveValue(int position, int value)
int fileSize = ftell(storageFile); // Size in bytes int fileSize = ftell(storageFile); // Size in bytes
fseek(storageFile, 0, SEEK_SET); fseek(storageFile, 0, SEEK_SET);
if (fileSize < (position*sizeof(int))) TraceLog(LOG_WARNING, "Storage position could not be found"); if (fileSize < (position*sizeof(int))) TRACELOG(LOG_WARNING, "Storage position could not be found");
else else
{ {
fseek(storageFile, (position*sizeof(int)), SEEK_SET); fseek(storageFile, (position*sizeof(int)), SEEK_SET);
@ -2199,7 +2199,7 @@ int StorageLoadValue(int position)
// Try open existing file to append data // Try open existing file to append data
FILE *storageFile = fopen(path, "rb"); FILE *storageFile = fopen(path, "rb");
if (!storageFile) TraceLog(LOG_WARNING, "Storage data file could not be found"); if (!storageFile) TRACELOG(LOG_WARNING, "Storage data file could not be found");
else else
{ {
// Get file size // Get file size
@ -2207,7 +2207,7 @@ int StorageLoadValue(int position)
int fileSize = ftell(storageFile); // Size in bytes int fileSize = ftell(storageFile); // Size in bytes
rewind(storageFile); rewind(storageFile);
if (fileSize < (position*4)) TraceLog(LOG_WARNING, "Storage position could not be found"); if (fileSize < (position*4)) TRACELOG(LOG_WARNING, "Storage position could not be found");
else else
{ {
fseek(storageFile, (position*4), SEEK_SET); fseek(storageFile, (position*4), SEEK_SET);
@ -2231,7 +2231,7 @@ void OpenURL(const char *url)
// sorry for the inconvenience when you hit this point... // sorry for the inconvenience when you hit this point...
if (strchr(url, '\'') != NULL) if (strchr(url, '\'') != NULL)
{ {
TraceLog(LOG_WARNING, "Provided URL does not seem to be valid."); TRACELOG(LOG_WARNING, "Provided URL does not seem to be valid.");
} }
else else
{ {
@ -2606,7 +2606,7 @@ Vector2 GetTouchPosition(int index)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index]; if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
else TraceLog(LOG_WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS); else TRACELOG(LOG_WARNING, "Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height)) if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height))
@ -2662,7 +2662,7 @@ static bool InitGraphicsDevice(int width, int height)
if (!glfwInit()) if (!glfwInit())
{ {
TraceLog(LOG_WARNING, "Failed to initialize GLFW"); TRACELOG(LOG_WARNING, "Failed to initialize GLFW");
return false; return false;
} }
@ -2672,7 +2672,7 @@ static bool InitGraphicsDevice(int width, int height)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
if (!monitor) if (!monitor)
{ {
TraceLog(LOG_WARNING, "Failed to get monitor"); TRACELOG(LOG_WARNING, "Failed to get monitor");
return false; return false;
} }
const GLFWvidmode *mode = glfwGetVideoMode(monitor); const GLFWvidmode *mode = glfwGetVideoMode(monitor);
@ -2793,7 +2793,7 @@ static bool InitGraphicsDevice(int width, int height)
} }
#endif #endif
TraceLog(LOG_WARNING, "Closest fullscreen videomode: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_WARNING, "Closest fullscreen videomode: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
// NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example, // NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example,
// for a desired screen size of 800x450 (16:9), closest supported videomode is 800x600 (4:3), // for a desired screen size of 800x450 (16:9), closest supported videomode is 800x600 (4:3),
@ -2837,18 +2837,18 @@ static bool InitGraphicsDevice(int width, int height)
if (!CORE.Window.handle) if (!CORE.Window.handle)
{ {
glfwTerminate(); glfwTerminate();
TraceLog(LOG_WARNING, "GLFW Failed to initialize Window"); TRACELOG(LOG_WARNING, "GLFW Failed to initialize Window");
return false; return false;
} }
else else
{ {
TraceLog(LOG_INFO, "Display device initialized successfully"); TRACELOG(LOG_INFO, "Display device initialized successfully");
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
TraceLog(LOG_INFO, "Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, "Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
#endif #endif
TraceLog(LOG_INFO, "Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, "Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
TraceLog(LOG_INFO, "Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, "Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); TRACELOG(LOG_INFO, "Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
} }
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default! glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default!
@ -2879,7 +2879,7 @@ static bool InitGraphicsDevice(int width, int height)
{ {
// WARNING: It seems to hits a critical render path in Intel HD Graphics // WARNING: It seems to hits a critical render path in Intel HD Graphics
glfwSwapInterval(1); glfwSwapInterval(1);
TraceLog(LOG_INFO, "Trying to enable VSYNC"); TRACELOG(LOG_INFO, "Trying to enable VSYNC");
} }
#endif // PLATFORM_DESKTOP || PLATFORM_WEB #endif // PLATFORM_DESKTOP || PLATFORM_WEB
@ -2907,7 +2907,7 @@ static bool InitGraphicsDevice(int width, int height)
{ {
samples = 4; samples = 4;
sampleBuffer = 1; sampleBuffer = 1;
TraceLog(LOG_INFO, "Trying to enable MSAA x4"); TRACELOG(LOG_INFO, "Trying to enable MSAA x4");
} }
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] =
@ -2985,7 +2985,7 @@ static bool InitGraphicsDevice(int width, int height)
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)(eglGetProcAddress("eglGetPlatformDisplayEXT")); PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)(eglGetProcAddress("eglGetPlatformDisplayEXT"));
if (!eglGetPlatformDisplayEXT) if (!eglGetPlatformDisplayEXT)
{ {
TraceLog(LOG_WARNING, "Failed to get function eglGetPlatformDisplayEXT"); TRACELOG(LOG_WARNING, "Failed to get function eglGetPlatformDisplayEXT");
return false; return false;
} }
@ -3003,7 +3003,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes);
if (CORE.Window.device == EGL_NO_DISPLAY) if (CORE.Window.device == EGL_NO_DISPLAY)
{ {
TraceLog(LOG_WARNING, "Failed to initialize EGL device"); TRACELOG(LOG_WARNING, "Failed to initialize EGL device");
return false; return false;
} }
@ -3013,7 +3013,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes);
if (CORE.Window.device == EGL_NO_DISPLAY) if (CORE.Window.device == EGL_NO_DISPLAY)
{ {
TraceLog(LOG_WARNING, "Failed to initialize EGL device"); TRACELOG(LOG_WARNING, "Failed to initialize EGL device");
return false; return false;
} }
@ -3023,14 +3023,14 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); CORE.Window.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes);
if (CORE.Window.device == EGL_NO_DISPLAY) if (CORE.Window.device == EGL_NO_DISPLAY)
{ {
TraceLog(LOG_WARNING, "Failed to initialize EGL device"); TRACELOG(LOG_WARNING, "Failed to initialize EGL device");
return false; return false;
} }
if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE) if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE)
{ {
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
TraceLog(LOG_WARNING, "Failed to initialize EGL"); TRACELOG(LOG_WARNING, "Failed to initialize EGL");
return false; return false;
} }
} }
@ -3039,7 +3039,7 @@ static bool InitGraphicsDevice(int width, int height)
EGLint numConfigs = 0; EGLint numConfigs = 0;
if ((eglChooseConfig(CORE.Window.device, framebufferAttribs, &CORE.Window.config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) if ((eglChooseConfig(CORE.Window.device, framebufferAttribs, &CORE.Window.config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0))
{ {
TraceLog(LOG_WARNING, "Failed to choose first EGLConfig"); TRACELOG(LOG_WARNING, "Failed to choose first EGLConfig");
return false; return false;
} }
@ -3077,14 +3077,14 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, handle, surfaceAttributes); CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, handle, surfaceAttributes);
if (CORE.Window.surface == EGL_NO_SURFACE) if (CORE.Window.surface == EGL_NO_SURFACE)
{ {
TraceLog(LOG_WARNING, "Failed to create EGL fullscreen surface"); TRACELOG(LOG_WARNING, "Failed to create EGL fullscreen surface");
return false; return false;
} }
CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs); CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs);
if (CORE.Window.context == EGL_NO_CONTEXT) if (CORE.Window.context == EGL_NO_CONTEXT)
{ {
TraceLog(LOG_WARNING, "Failed to create EGL context"); TRACELOG(LOG_WARNING, "Failed to create EGL context");
return false; return false;
} }
@ -3099,7 +3099,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.device = eglGetDisplay(EGL_DEFAULT_DISPLAY); CORE.Window.device = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (CORE.Window.device == EGL_NO_DISPLAY) if (CORE.Window.device == EGL_NO_DISPLAY)
{ {
TraceLog(LOG_WARNING, "Failed to initialize EGL device"); TRACELOG(LOG_WARNING, "Failed to initialize EGL device");
return false; return false;
} }
@ -3107,7 +3107,7 @@ static bool InitGraphicsDevice(int width, int height)
if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE) if (eglInitialize(CORE.Window.device, NULL, NULL) == EGL_FALSE)
{ {
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
TraceLog(LOG_WARNING, "Failed to initialize EGL"); TRACELOG(LOG_WARNING, "Failed to initialize EGL");
return false; return false;
} }
@ -3121,7 +3121,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs); CORE.Window.context = eglCreateContext(CORE.Window.device, CORE.Window.config, EGL_NO_CONTEXT, contextAttribs);
if (CORE.Window.context == EGL_NO_CONTEXT) if (CORE.Window.context == EGL_NO_CONTEXT)
{ {
TraceLog(LOG_WARNING, "Failed to create EGL context"); TRACELOG(LOG_WARNING, "Failed to create EGL context");
return false; return false;
} }
#endif #endif
@ -3193,7 +3193,7 @@ static bool InitGraphicsDevice(int width, int height)
if (eglMakeCurrent(CORE.Window.device, CORE.Window.surface, CORE.Window.surface, CORE.Window.context) == EGL_FALSE) if (eglMakeCurrent(CORE.Window.device, CORE.Window.surface, CORE.Window.surface, CORE.Window.context) == EGL_FALSE)
{ {
TraceLog(LOG_WARNING, "Unable to attach EGL rendering context to EGL surface"); TRACELOG(LOG_WARNING, "Unable to attach EGL rendering context to EGL surface");
return false; return false;
} }
else else
@ -3202,11 +3202,11 @@ static bool InitGraphicsDevice(int width, int height)
//eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &CORE.Window.render.width); //eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_WIDTH, &CORE.Window.render.width);
//eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_HEIGHT, &CORE.Window.render.height); //eglQuerySurface(CORE.Window.device, CORE.Window.surface, EGL_HEIGHT, &CORE.Window.render.height);
TraceLog(LOG_INFO, "Display device initialized successfully"); TRACELOG(LOG_INFO, "Display device initialized successfully");
TraceLog(LOG_INFO, "Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, "Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TraceLog(LOG_INFO, "Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, "Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
TraceLog(LOG_INFO, "Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, "Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); TRACELOG(LOG_INFO, "Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
} }
#endif // PLATFORM_ANDROID || PLATFORM_RPI #endif // PLATFORM_ANDROID || PLATFORM_RPI
@ -3270,7 +3270,7 @@ static void SetupFramebuffer(int width, int height)
// Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var) // Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var)
if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height)) if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height))
{ {
TraceLog(LOG_WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_WARNING, "DOWNSCALING: Required screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height);
// Downscaling to fit display with border-bars // Downscaling to fit display with border-bars
float widthRatio = (float)CORE.Window.display.width/(float)CORE.Window.screen.width; float widthRatio = (float)CORE.Window.display.width/(float)CORE.Window.screen.width;
@ -3300,12 +3300,12 @@ static void SetupFramebuffer(int width, int height)
CORE.Window.render.width = CORE.Window.display.width; CORE.Window.render.width = CORE.Window.display.width;
CORE.Window.render.height = CORE.Window.display.height; CORE.Window.render.height = CORE.Window.display.height;
TraceLog(LOG_WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_WARNING, "Downscale matrix generated, content will be rendered at: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
} }
else if ((CORE.Window.screen.width < CORE.Window.display.width) || (CORE.Window.screen.height < CORE.Window.display.height)) else if ((CORE.Window.screen.width < CORE.Window.display.width) || (CORE.Window.screen.height < CORE.Window.display.height))
{ {
// Required screen size is smaller than display size // Required screen size is smaller than display size
TraceLog(LOG_INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, "UPSCALING: Required screen size: %i x %i -> Display size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height);
// Upscaling to fit display with border-bars // Upscaling to fit display with border-bars
float displayRatio = (float)CORE.Window.display.width/(float)CORE.Window.display.height; float displayRatio = (float)CORE.Window.display.width/(float)CORE.Window.display.height;
@ -3351,7 +3351,7 @@ static void InitTimer(void)
{ {
CORE.Time.base = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec; CORE.Time.base = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec;
} }
else TraceLog(LOG_WARNING, "No hi-resolution timer available"); else TRACELOG(LOG_WARNING, "No hi-resolution timer available");
#endif #endif
CORE.Time.previous = GetTime(); // Get time as double CORE.Time.previous = GetTime(); // Get time as double
@ -3829,7 +3829,7 @@ static void PollInputEvents(void)
} }
else CORE.Input.Gamepad.currentState[i][button] = 0; else CORE.Input.Gamepad.currentState[i][button] = 0;
//TraceLog(LOG_DEBUG, "Gamepad %d, button %d: Digital: %d, Analog: %g", gamepadState.index, j, gamepadState.digitalButton[j], gamepadState.analogButton[j]); //TRACELOGD("Gamepad %d, button %d: Digital: %d, Analog: %g", gamepadState.index, j, gamepadState.digitalButton[j], gamepadState.analogButton[j]);
} }
// Register axis data for every connected gamepad // Register axis data for every connected gamepad
@ -3895,7 +3895,7 @@ static void SwapBuffers(void)
// GLFW3 Error Callback, runs on GLFW3 error // GLFW3 Error Callback, runs on GLFW3 error
static void ErrorCallback(int error, const char *description) static void ErrorCallback(int error, const char *description)
{ {
TraceLog(LOG_WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description); TRACELOG(LOG_WARNING, "[GLFW3 Error] Code: %i Decription: %s", error, description);
} }
// GLFW3 Srolling Callback, runs on mouse wheel // GLFW3 Srolling Callback, runs on mouse wheel
@ -3929,7 +3929,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", TextFormat("screenrec%03i.gif", screenshotCounter - 1), TextFormat("screenrec%03i.gif", screenshotCounter - 1))); emscripten_run_script(TextFormat("saveFileFromMEMFSToDisk('%s','%s')", TextFormat("screenrec%03i.gif", screenshotCounter - 1), TextFormat("screenrec%03i.gif", screenshotCounter - 1)));
#endif #endif
TraceLog(LOG_INFO, "End animated GIF recording"); TRACELOG(LOG_INFO, "End animated GIF recording");
} }
else else
{ {
@ -3949,7 +3949,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
GifBegin(path, CORE.Window.screen.width, CORE.Window.screen.height, (int)(GetFrameTime()*10.0f), 8, false); GifBegin(path, CORE.Window.screen.width, CORE.Window.screen.height, (int)(GetFrameTime()*10.0f), 8, false);
screenshotCounter++; screenshotCounter++;
TraceLog(LOG_INFO, "Begin animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter)); TRACELOG(LOG_INFO, "Begin animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
} }
} }
else else
@ -4336,11 +4336,11 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
if (event->isFullscreen) if (event->isFullscreen)
{ {
TraceLog(LOG_INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight); TRACELOG(LOG_INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight);
} }
else else
{ {
TraceLog(LOG_INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight); TRACELOG(LOG_INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight);
} }
// TODO: Depending on scaling factor (screen vs element), calculate factor to scale mouse/touch input // TODO: Depending on scaling factor (screen vs element), calculate factor to scale mouse/touch input
@ -4373,7 +4373,7 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
{ {
emscripten_exit_pointerlock(); emscripten_exit_pointerlock();
emscripten_get_pointerlock_status(&plce); emscripten_get_pointerlock_status(&plce);
//if (plce.isActive) TraceLog(LOG_WARNING, "Pointer lock exit did not work!"); //if (plce.isActive) TRACELOG(LOG_WARNING, "Pointer lock exit did not work!");
} }
CORE.Input.Mouse.cursorLockRequired = false; CORE.Input.Mouse.cursorLockRequired = false;
@ -4446,12 +4446,12 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData)
{ {
/* /*
TraceLog(LOG_DEBUG, "%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"", TRACELOGD("%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"",
eventType != 0? emscripten_event_type_to_string(eventType) : "Gamepad state", eventType != 0? emscripten_event_type_to_string(eventType) : "Gamepad state",
gamepadEvent->timestamp, gamepadEvent->connected, gamepadEvent->index, gamepadEvent->numAxes, gamepadEvent->numButtons, gamepadEvent->id, gamepadEvent->mapping); gamepadEvent->timestamp, gamepadEvent->connected, gamepadEvent->index, gamepadEvent->numAxes, gamepadEvent->numButtons, gamepadEvent->id, gamepadEvent->mapping);
for (int i = 0; i < gamepadEvent->numAxes; ++i) TraceLog(LOG_DEBUG, "Axis %d: %g", i, gamepadEvent->axis[i]); for (int i = 0; i < gamepadEvent->numAxes; ++i) TRACELOGD("Axis %d: %g", i, gamepadEvent->axis[i]);
for (int i = 0; i < gamepadEvent->numButtons; ++i) TraceLog(LOG_DEBUG, "Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]); for (int i = 0; i < gamepadEvent->numButtons; ++i) TRACELOGD("Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]);
*/ */
if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) CORE.Input.Gamepad.ready[gamepadEvent->index] = true; if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) CORE.Input.Gamepad.ready[gamepadEvent->index] = true;
@ -4496,7 +4496,7 @@ static void InitKeyboard(void)
if (ioctl(STDIN_FILENO, KDGKBMODE, &CORE.Input.Keyboard.defaultMode) < 0) if (ioctl(STDIN_FILENO, KDGKBMODE, &CORE.Input.Keyboard.defaultMode) < 0)
{ {
// NOTE: It could mean we are using a remote keyboard through ssh! // NOTE: It could mean we are using a remote keyboard through ssh!
TraceLog(LOG_WARNING, "Could not change keyboard mode (SSH keyboard?)"); TRACELOG(LOG_WARNING, "Could not change keyboard mode (SSH keyboard?)");
} }
else else
{ {
@ -4534,7 +4534,7 @@ static void ProcessKeyboard(void)
// Fill all read bytes (looking for keys) // Fill all read bytes (looking for keys)
for (int i = 0; i < bufferByteCount; i++) for (int i = 0; i < bufferByteCount; i++)
{ {
TraceLog(LOG_DEBUG, "Bytes on keysBuffer: %i", bufferByteCount); TRACELOGD("Bytes on keysBuffer: %i", bufferByteCount);
// NOTE: If (key == 0x1b), depending on next key, it could be a special keymap code! // NOTE: If (key == 0x1b), depending on next key, it could be a special keymap code!
// Up -> 1b 5b 41 / Left -> 1b 5b 44 / Right -> 1b 5b 43 / Down -> 1b 5b 42 // Up -> 1b 5b 41 / Left -> 1b 5b 44 / Right -> 1b 5b 43 / Down -> 1b 5b 42
@ -4603,7 +4603,7 @@ static void ProcessKeyboard(void)
} }
else else
{ {
TraceLog(LOG_DEBUG, "Pressed key (ASCII): 0x%02x", keysBuffer[i]); TRACELOGD("Pressed key (ASCII): 0x%02x", keysBuffer[i]);
// Translate lowercase a-z letters to A-Z // Translate lowercase a-z letters to A-Z
if ((keysBuffer[i] >= 97) && (keysBuffer[i] <= 122)) if ((keysBuffer[i] >= 97) && (keysBuffer[i] <= 122))
@ -4676,7 +4676,7 @@ static void InitEvdevInput(void)
closedir(directory); closedir(directory);
} }
else TraceLog(LOG_WARNING, "Unable to open linux event directory: %s", DEFAULT_EVDEV_PATH); else TRACELOG(LOG_WARNING, "Unable to open linux event directory: %s", DEFAULT_EVDEV_PATH);
} }
// Identifies a input device and spawns a thread to handle it if needed // Identifies a input device and spawns a thread to handle it if needed
@ -4722,7 +4722,7 @@ static void EventThreadSpawn(char *device)
} }
else else
{ {
TraceLog(LOG_WARNING, "Error creating input device thread for [%s]: Out of worker slots", device); TRACELOG(LOG_WARNING, "Error creating input device thread for [%s]: Out of worker slots", device);
return; return;
} }
@ -4730,7 +4730,7 @@ static void EventThreadSpawn(char *device)
fd = open(device, O_RDONLY | O_NONBLOCK); fd = open(device, O_RDONLY | O_NONBLOCK);
if (fd < 0) if (fd < 0)
{ {
TraceLog(LOG_WARNING, "Error creating input device thread for [%s]: Can't open device (Error: %d)", device, worker->fd); TRACELOG(LOG_WARNING, "Error creating input device thread for [%s]: Can't open device (Error: %d)", device, worker->fd);
return; return;
} }
worker->fd = fd; worker->fd = fd;
@ -4831,7 +4831,7 @@ static void EventThreadSpawn(char *device)
if (worker->isTouch || worker->isMouse || worker->isKeyboard) if (worker->isTouch || worker->isMouse || worker->isKeyboard)
{ {
// Looks like a interesting device // Looks like a interesting device
TraceLog(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device, TRACELOG(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device,
worker->isMouse? "mouse " : "", worker->isMouse? "mouse " : "",
worker->isMultitouch? "multitouch " : "", worker->isMultitouch? "multitouch " : "",
worker->isTouch? "touchscreen " : "", worker->isTouch? "touchscreen " : "",
@ -4842,7 +4842,7 @@ static void EventThreadSpawn(char *device)
int error = pthread_create(&worker->threadId, NULL, &EventThread, (void *)worker); int error = pthread_create(&worker->threadId, NULL, &EventThread, (void *)worker);
if (error != 0) if (error != 0)
{ {
TraceLog(LOG_WARNING, "Error creating input device thread for [%s]: Can't create thread (Error: %d)", device, error); TRACELOG(LOG_WARNING, "Error creating input device thread for [%s]: Can't create thread (Error: %d)", device, error);
worker->threadId = 0; worker->threadId = 0;
close(fd); close(fd);
} }
@ -4863,7 +4863,7 @@ static void EventThreadSpawn(char *device)
{ {
if (CORE.Input.eventWorker[i].threadId != 0) if (CORE.Input.eventWorker[i].threadId != 0)
{ {
TraceLog(LOG_WARNING, "Duplicate touchscreen found, killing touchscreen on event: %d", i); TRACELOG(LOG_WARNING, "Duplicate touchscreen found, killing touchscreen on event: %d", i);
pthread_cancel(CORE.Input.eventWorker[i].threadId); pthread_cancel(CORE.Input.eventWorker[i].threadId);
close(CORE.Input.eventWorker[i].fd); close(CORE.Input.eventWorker[i].fd);
} }
@ -5043,7 +5043,7 @@ static void *EventThread(void *arg)
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true;
TraceLog(LOG_DEBUG, "KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode); TRACELOGD("KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode);
} }
} }
} }
@ -5106,7 +5106,7 @@ static void InitGamepad(void)
if ((CORE.Input.Gamepad.streamId[i] = open(gamepadDev, O_RDONLY|O_NONBLOCK)) < 0) if ((CORE.Input.Gamepad.streamId[i] = open(gamepadDev, O_RDONLY|O_NONBLOCK)) < 0)
{ {
// NOTE: Only show message for first gamepad // NOTE: Only show message for first gamepad
if (i == 0) TraceLog(LOG_WARNING, "Gamepad device could not be opened, no gamepad available"); if (i == 0) TRACELOG(LOG_WARNING, "Gamepad device could not be opened, no gamepad available");
} }
else else
{ {
@ -5117,8 +5117,8 @@ static void InitGamepad(void)
{ {
int error = pthread_create(&CORE.Input.Gamepad.threadId, NULL, &GamepadThread, NULL); int error = pthread_create(&CORE.Input.Gamepad.threadId, NULL, &GamepadThread, NULL);
if (error != 0) TraceLog(LOG_WARNING, "Error creating gamepad input event thread"); if (error != 0) TRACELOG(LOG_WARNING, "Error creating gamepad input event thread");
else TraceLog(LOG_INFO, "Gamepad device initialized successfully"); else TRACELOG(LOG_INFO, "Gamepad device initialized successfully");
} }
} }
} }
@ -5152,7 +5152,7 @@ static void *GamepadThread(void *arg)
// Process gamepad events by type // Process gamepad events by type
if (gamepadEvent.type == JS_EVENT_BUTTON) if (gamepadEvent.type == JS_EVENT_BUTTON)
{ {
TraceLog(LOG_DEBUG, "Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value); TRACELOGD("Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS) if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS)
{ {
@ -5165,7 +5165,7 @@ static void *GamepadThread(void *arg)
} }
else if (gamepadEvent.type == JS_EVENT_AXIS) else if (gamepadEvent.type == JS_EVENT_AXIS)
{ {
TraceLog(LOG_DEBUG, "Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value); TRACELOGD("Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_AXIS) if (gamepadEvent.number < MAX_GAMEPAD_AXIS)
{ {

View file

@ -667,10 +667,10 @@ Model LoadModel(const char *fileName)
model.meshCount = 1; model.meshCount = 1;
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh)); model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
#if defined(SUPPORT_MESH_GENERATION) #if defined(SUPPORT_MESH_GENERATION)
TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName); TRACELOG(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName);
model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f); model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f);
#else #else
TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, and can't create a default mesh. The raylib mesh generation is not supported (SUPPORT_MESH_GENERATION).", fileName); TRACELOG(LOG_WARNING, "[%s] No meshes can be loaded, and can't create a default mesh. The raylib mesh generation is not supported (SUPPORT_MESH_GENERATION).", fileName);
#endif #endif
} }
else else
@ -681,7 +681,7 @@ Model LoadModel(const char *fileName)
if (model.materialCount == 0) if (model.materialCount == 0)
{ {
TraceLog(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName); TRACELOG(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName);
model.materialCount = 1; model.materialCount = 1;
model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material)); model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material));
@ -735,7 +735,7 @@ void UnloadModel(Model model)
RL_FREE(model.bones); RL_FREE(model.bones);
RL_FREE(model.bindPose); RL_FREE(model.bindPose);
TraceLog(LOG_INFO, "Unloaded model data from RAM and VRAM"); TRACELOG(LOG_INFO, "Unloaded model data from RAM and VRAM");
} }
// Load meshes from model file // Load meshes from model file
@ -809,8 +809,8 @@ void ExportMesh(Mesh mesh, const char *fileName)
} }
else if (IsFileExtension(fileName, ".raw")) { } // TODO: Support additional file formats to export mesh vertex data else if (IsFileExtension(fileName, ".raw")) { } // TODO: Support additional file formats to export mesh vertex data
if (success) TraceLog(LOG_INFO, "Mesh exported successfully: %s", fileName); if (success) TRACELOG(LOG_INFO, "Mesh exported successfully: %s", fileName);
else TraceLog(LOG_WARNING, "Mesh could not be exported."); else TRACELOG(LOG_WARNING, "Mesh could not be exported.");
} }
// Load materials from model file // Load materials from model file
@ -828,7 +828,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
int result = tinyobj_parse_mtl_file(&mats, &count, fileName); int result = tinyobj_parse_mtl_file(&mats, &count, fileName);
if (result != TINYOBJ_SUCCESS) { if (result != TINYOBJ_SUCCESS) {
TraceLog(LOG_WARNING, "[%s] Could not parse Materials file", fileName); TRACELOG(LOG_WARNING, "[%s] Could not parse Materials file", fileName);
} }
// TODO: Process materials to return // TODO: Process materials to return
@ -836,7 +836,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
tinyobj_materials_free(mats, count); tinyobj_materials_free(mats, count);
} }
#else #else
TraceLog(LOG_WARNING, "[%s] Materials file not supported", fileName); TRACELOG(LOG_WARNING, "[%s] Materials file not supported", fileName);
#endif #endif
// Set materials shader to default (DIFFUSE, SPECULAR, NORMAL) // Set materials shader to default (DIFFUSE, SPECULAR, NORMAL)
@ -888,8 +888,8 @@ void SetMaterialTexture(Material *material, int mapType, Texture2D texture)
// Set the material for a mesh // Set the material for a mesh
void SetModelMeshMaterial(Model *model, int meshId, int materialId) void SetModelMeshMaterial(Model *model, int meshId, int materialId)
{ {
if (meshId >= model->meshCount) TraceLog(LOG_WARNING, "Mesh id greater than mesh count"); if (meshId >= model->meshCount) TRACELOG(LOG_WARNING, "Mesh id greater than mesh count");
else if (materialId >= model->materialCount) TraceLog(LOG_WARNING,"Material id greater than material count"); else if (materialId >= model->materialCount) TRACELOG(LOG_WARNING,"Material id greater than material count");
else model->meshMaterial[meshId] = materialId; else model->meshMaterial[meshId] = materialId;
} }
@ -937,7 +937,7 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
if (!iqmFile) if (!iqmFile)
{ {
TraceLog(LOG_ERROR, "[%s] Unable to open file", filename); TRACELOG(LOG_ERROR, "[%s] Unable to open file", filename);
} }
// Read IQM header // Read IQM header
@ -945,7 +945,7 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC))) if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC)))
{ {
TraceLog(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic); TRACELOG(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic);
fclose(iqmFile); fclose(iqmFile);
return NULL; return NULL;
@ -953,7 +953,7 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
if (iqm.version != IQM_VERSION) if (iqm.version != IQM_VERSION)
{ {
TraceLog(LOG_ERROR, "IQM version %i is incorrect.", iqm.version); TRACELOG(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
fclose(iqmFile); fclose(iqmFile);
return NULL; return NULL;
@ -2292,7 +2292,7 @@ BoundingBox MeshBoundingBox(Mesh mesh)
void MeshTangents(Mesh *mesh) void MeshTangents(Mesh *mesh)
{ {
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float)); if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
else TraceLog(LOG_WARNING, "Mesh tangents already exist"); else TRACELOG(LOG_WARNING, "Mesh tangents already exist");
Vector3 *tan1 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3)); Vector3 *tan1 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
Vector3 *tan2 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3)); Vector3 *tan2 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
@ -2365,7 +2365,7 @@ void MeshTangents(Mesh *mesh)
// Load a new tangent attributes buffer // Load a new tangent attributes buffer
mesh->vboId[LOC_VERTEX_TANGENT] = rlLoadAttribBuffer(mesh->vaoId, LOC_VERTEX_TANGENT, mesh->tangents, mesh->vertexCount*4*sizeof(float), false); mesh->vboId[LOC_VERTEX_TANGENT] = rlLoadAttribBuffer(mesh->vaoId, LOC_VERTEX_TANGENT, mesh->tangents, mesh->vertexCount*4*sizeof(float), false);
TraceLog(LOG_INFO, "Tangents computed for mesh"); TRACELOG(LOG_INFO, "Tangents computed for mesh");
} }
// Compute mesh binormals (aka bitangent) // Compute mesh binormals (aka bitangent)
@ -2817,8 +2817,8 @@ static Model LoadOBJ(const char *fileName)
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE; unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, data, dataLength, flags); int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, data, dataLength, flags);
if (ret != TINYOBJ_SUCCESS) TraceLog(LOG_WARNING, "[%s] Model data could not be loaded", fileName); if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "[%s] Model data could not be loaded", fileName);
else TraceLog(LOG_INFO, "[%s] Model data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount); else TRACELOG(LOG_INFO, "[%s] Model data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);
// Init model meshes array // Init model meshes array
// TODO: Support multiple meshes... in the meantime, only one mesh is returned // TODO: Support multiple meshes... in the meantime, only one mesh is returned
@ -2868,7 +2868,7 @@ static Model LoadOBJ(const char *fileName)
tinyobj_vertex_index_t idx1 = attrib.faces[3*f + 1]; tinyobj_vertex_index_t idx1 = attrib.faces[3*f + 1];
tinyobj_vertex_index_t idx2 = attrib.faces[3*f + 2]; tinyobj_vertex_index_t idx2 = attrib.faces[3*f + 2];
// TraceLog(LOG_DEBUG, "Face %i index: v %i/%i/%i . vt %i/%i/%i . vn %i/%i/%i\n", f, idx0.v_idx, idx1.v_idx, idx2.v_idx, idx0.vt_idx, idx1.vt_idx, idx2.vt_idx, idx0.vn_idx, idx1.vn_idx, idx2.vn_idx); // TRACELOGD("Face %i index: v %i/%i/%i . vt %i/%i/%i . vn %i/%i/%i\n", f, idx0.v_idx, idx1.v_idx, idx2.v_idx, idx0.vt_idx, idx1.vt_idx, idx2.vt_idx, idx0.vn_idx, idx1.vn_idx, idx2.vn_idx);
// Fill vertices buffer (float) using vertex index of the face // Fill vertices buffer (float) using vertex index of the face
for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx0.v_idx*3 + v]; } vCount +=3; for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx0.v_idx*3 + v]; } vCount +=3;
@ -2960,7 +2960,7 @@ static Model LoadOBJ(const char *fileName)
} }
// NOTE: At this point we have all model data loaded // NOTE: At this point we have all model data loaded
TraceLog(LOG_INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName); TRACELOG(LOG_INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName);
return model; return model;
} }
@ -3079,7 +3079,7 @@ static Model LoadIQM(const char *fileName)
if (iqmFile == NULL) if (iqmFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] IQM file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] IQM file could not be opened", fileName);
return model; return model;
} }
@ -3087,14 +3087,14 @@ static Model LoadIQM(const char *fileName)
if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC))) if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC)))
{ {
TraceLog(LOG_WARNING, "[%s] IQM file does not seem to be valid", fileName); TRACELOG(LOG_WARNING, "[%s] IQM file does not seem to be valid", fileName);
fclose(iqmFile); fclose(iqmFile);
return model; return model;
} }
if (iqm.version != IQM_VERSION) if (iqm.version != IQM_VERSION)
{ {
TraceLog(LOG_WARNING, "[%s] IQM file version is not supported (%i).", fileName, iqm.version); TRACELOG(LOG_WARNING, "[%s] IQM file version is not supported (%i).", fileName, iqm.version);
fclose(iqmFile); fclose(iqmFile);
return model; return model;
} }
@ -3396,7 +3396,7 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
int i = 0; int i = 0;
while ((image->uri[i] != ',') && (image->uri[i] != 0)) i++; while ((image->uri[i] != ',') && (image->uri[i] != 0)) i++;
if (image->uri[i] == 0) TraceLog(LOG_WARNING, "CGLTF Image: Invalid data URI"); if (image->uri[i] == 0) TRACELOG(LOG_WARNING, "CGLTF Image: Invalid data URI");
else else
{ {
int size; int size;
@ -3498,7 +3498,7 @@ static Model LoadGLTF(const char *fileName)
if (gltfFile == NULL) if (gltfFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] glTF file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] glTF file could not be opened", fileName);
return model; return model;
} }
@ -3518,11 +3518,11 @@ static Model LoadGLTF(const char *fileName)
if (result == cgltf_result_success) if (result == cgltf_result_success)
{ {
TraceLog(LOG_INFO, "[%s][%s] Model meshes/materials: %i/%i", fileName, (data->file_type == 2)? "glb" : "gltf", data->meshes_count, data->materials_count); TRACELOG(LOG_INFO, "[%s][%s] Model meshes/materials: %i/%i", fileName, (data->file_type == 2)? "glb" : "gltf", data->meshes_count, data->materials_count);
// Read data buffers // Read data buffers
result = cgltf_load_buffers(&options, data, fileName); result = cgltf_load_buffers(&options, data, fileName);
if (result != cgltf_result_success) TraceLog(LOG_INFO, "[%s][%s] Error loading mesh/material buffers", fileName, (data->file_type == 2)? "glb" : "gltf"); if (result != cgltf_result_success) TRACELOG(LOG_INFO, "[%s][%s] Error loading mesh/material buffers", fileName, (data->file_type == 2)? "glb" : "gltf");
int primitivesCount = 0; int primitivesCount = 0;
@ -3625,7 +3625,7 @@ static Model LoadGLTF(const char *fileName)
else else
{ {
// TODO: Support normalized unsigned byte/unsigned short texture coordinates // TODO: Support normalized unsigned byte/unsigned short texture coordinates
TraceLog(LOG_WARNING, "[%s] Texture coordinates must be float", fileName); TRACELOG(LOG_WARNING, "[%s] Texture coordinates must be float", fileName);
} }
} }
} }
@ -3643,7 +3643,7 @@ static Model LoadGLTF(const char *fileName)
else else
{ {
// TODO: Support unsigned byte/unsigned int // TODO: Support unsigned byte/unsigned int
TraceLog(LOG_WARNING, "[%s] Indices must be unsigned short", fileName); TRACELOG(LOG_WARNING, "[%s] Indices must be unsigned short", fileName);
} }
} }
else else
@ -3668,7 +3668,7 @@ static Model LoadGLTF(const char *fileName)
cgltf_free(data); cgltf_free(data);
} }
else TraceLog(LOG_WARNING, "[%s] glTF data could not be loaded", fileName); else TRACELOG(LOG_WARNING, "[%s] glTF data could not be loaded", fileName);
RL_FREE(buffer); RL_FREE(buffer);

View file

@ -247,7 +247,7 @@ static Wave LoadMP3(const char *fileName); // Load MP3 file
#if defined(RAUDIO_STANDALONE) #if defined(RAUDIO_STANDALONE)
bool IsFileExtension(const char *fileName, const char *ext);// Check file extension bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) void TRACELOG(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -282,7 +282,7 @@ void InitAudioDevice(void)
ma_result result = ma_context_init(NULL, 0, &ctxConfig, &AUDIO.System.context); ma_result result = ma_context_init(NULL, 0, &ctxConfig, &AUDIO.System.context);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
TraceLog(LOG_ERROR, "Failed to initialize audio context"); TRACELOG(LOG_ERROR, "Failed to initialize audio context");
return; return;
} }
@ -302,7 +302,7 @@ void InitAudioDevice(void)
result = ma_device_init(&AUDIO.System.context, &config, &AUDIO.System.device); result = ma_device_init(&AUDIO.System.context, &config, &AUDIO.System.device);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
TraceLog(LOG_ERROR, "Failed to initialize audio playback AUDIO.System.device"); TRACELOG(LOG_ERROR, "Failed to initialize audio playback AUDIO.System.device");
ma_context_uninit(&AUDIO.System.context); ma_context_uninit(&AUDIO.System.context);
return; return;
} }
@ -312,7 +312,7 @@ void InitAudioDevice(void)
result = ma_device_start(&AUDIO.System.device); result = ma_device_start(&AUDIO.System.device);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
TraceLog(LOG_ERROR, "Failed to start audio playback AUDIO.System.device"); TRACELOG(LOG_ERROR, "Failed to start audio playback AUDIO.System.device");
ma_device_uninit(&AUDIO.System.device); ma_device_uninit(&AUDIO.System.device);
ma_context_uninit(&AUDIO.System.context); ma_context_uninit(&AUDIO.System.context);
return; return;
@ -322,21 +322,21 @@ void InitAudioDevice(void)
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary. // want to look at something a bit smarter later on to keep everything real-time, if that's necessary.
if (ma_mutex_init(&AUDIO.System.context, &AUDIO.System.lock) != MA_SUCCESS) if (ma_mutex_init(&AUDIO.System.context, &AUDIO.System.lock) != MA_SUCCESS)
{ {
TraceLog(LOG_ERROR, "Failed to create mutex for audio mixing"); TRACELOG(LOG_ERROR, "Failed to create mutex for audio mixing");
ma_device_uninit(&AUDIO.System.device); ma_device_uninit(&AUDIO.System.device);
ma_context_uninit(&AUDIO.System.context); ma_context_uninit(&AUDIO.System.context);
return; return;
} }
TraceLog(LOG_INFO, "Audio device initialized successfully"); TRACELOG(LOG_INFO, "Audio device initialized successfully");
TraceLog(LOG_INFO, "Audio backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend)); TRACELOG(LOG_INFO, "Audio backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend));
TraceLog(LOG_INFO, "Audio format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat)); TRACELOG(LOG_INFO, "Audio format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat));
TraceLog(LOG_INFO, "Audio channels: %d -> %d", AUDIO.System.device.playback.channels, AUDIO.System.device.playback.internalChannels); TRACELOG(LOG_INFO, "Audio channels: %d -> %d", AUDIO.System.device.playback.channels, AUDIO.System.device.playback.internalChannels);
TraceLog(LOG_INFO, "Audio sample rate: %d -> %d", AUDIO.System.device.sampleRate, AUDIO.System.device.playback.internalSampleRate); TRACELOG(LOG_INFO, "Audio sample rate: %d -> %d", AUDIO.System.device.sampleRate, AUDIO.System.device.playback.internalSampleRate);
TraceLog(LOG_INFO, "Audio buffer size: %d", AUDIO.System.device.playback.internalBufferSizeInFrames); TRACELOG(LOG_INFO, "Audio buffer size: %d", AUDIO.System.device.playback.internalBufferSizeInFrames);
InitAudioBufferPool(); InitAudioBufferPool();
TraceLog(LOG_INFO, "Audio multichannel pool size: %i", MAX_AUDIO_BUFFER_POOL_CHANNELS); TRACELOG(LOG_INFO, "Audio multichannel pool size: %i", MAX_AUDIO_BUFFER_POOL_CHANNELS);
AUDIO.System.isReady = true; AUDIO.System.isReady = true;
} }
@ -352,9 +352,9 @@ void CloseAudioDevice(void)
CloseAudioBufferPool(); CloseAudioBufferPool();
TraceLog(LOG_INFO, "Audio AUDIO.System.device closed successfully"); TRACELOG(LOG_INFO, "Audio AUDIO.System.device closed successfully");
} }
else TraceLog(LOG_WARNING, "Could not close audio AUDIO.System.device because it is not currently initialized"); else TRACELOG(LOG_WARNING, "Could not close audio AUDIO.System.device because it is not currently initialized");
} }
// Check if device has been initialized successfully // Check if device has been initialized successfully
@ -383,7 +383,7 @@ AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam
if (audioBuffer == NULL) if (audioBuffer == NULL)
{ {
TraceLog(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer"); TRACELOG(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer");
return NULL; return NULL;
} }
@ -406,7 +406,7 @@ AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
TraceLog(LOG_ERROR, "InitAudioBuffer() : Failed to create data conversion pipeline"); TRACELOG(LOG_ERROR, "InitAudioBuffer() : Failed to create data conversion pipeline");
RL_FREE(audioBuffer); RL_FREE(audioBuffer);
return NULL; return NULL;
} }
@ -441,7 +441,7 @@ void CloseAudioBuffer(AudioBuffer *buffer)
RL_FREE(buffer->data); RL_FREE(buffer->data);
RL_FREE(buffer); RL_FREE(buffer);
} }
else TraceLog(LOG_ERROR, "CloseAudioBuffer() : No audio buffer"); else TRACELOG(LOG_ERROR, "CloseAudioBuffer() : No audio buffer");
} }
// Check if an audio buffer is playing // Check if an audio buffer is playing
@ -450,7 +450,7 @@ bool IsAudioBufferPlaying(AudioBuffer *buffer)
bool result = false; bool result = false;
if (buffer != NULL) result = (buffer->playing && !buffer->paused); if (buffer != NULL) result = (buffer->playing && !buffer->paused);
else TraceLog(LOG_WARNING, "IsAudioBufferPlaying() : No audio buffer"); else TRACELOG(LOG_WARNING, "IsAudioBufferPlaying() : No audio buffer");
return result; return result;
} }
@ -466,7 +466,7 @@ void PlayAudioBuffer(AudioBuffer *buffer)
buffer->paused = false; buffer->paused = false;
buffer->frameCursorPos = 0; buffer->frameCursorPos = 0;
} }
else TraceLog(LOG_ERROR, "PlayAudioBuffer() : No audio buffer"); else TRACELOG(LOG_ERROR, "PlayAudioBuffer() : No audio buffer");
} }
// Stop an audio buffer // Stop an audio buffer
@ -484,28 +484,28 @@ void StopAudioBuffer(AudioBuffer *buffer)
buffer->isSubBufferProcessed[1] = true; buffer->isSubBufferProcessed[1] = true;
} }
} }
else TraceLog(LOG_ERROR, "StopAudioBuffer() : No audio buffer"); else TRACELOG(LOG_ERROR, "StopAudioBuffer() : No audio buffer");
} }
// Pause an audio buffer // Pause an audio buffer
void PauseAudioBuffer(AudioBuffer *buffer) void PauseAudioBuffer(AudioBuffer *buffer)
{ {
if (buffer != NULL) buffer->paused = true; if (buffer != NULL) buffer->paused = true;
else TraceLog(LOG_ERROR, "PauseAudioBuffer() : No audio buffer"); else TRACELOG(LOG_ERROR, "PauseAudioBuffer() : No audio buffer");
} }
// Resume an audio buffer // Resume an audio buffer
void ResumeAudioBuffer(AudioBuffer *buffer) void ResumeAudioBuffer(AudioBuffer *buffer)
{ {
if (buffer != NULL) buffer->paused = false; if (buffer != NULL) buffer->paused = false;
else TraceLog(LOG_ERROR, "ResumeAudioBuffer() : No audio buffer"); else TRACELOG(LOG_ERROR, "ResumeAudioBuffer() : No audio buffer");
} }
// Set volume for an audio buffer // Set volume for an audio buffer
void SetAudioBufferVolume(AudioBuffer *buffer, float volume) void SetAudioBufferVolume(AudioBuffer *buffer, float volume)
{ {
if (buffer != NULL) buffer->volume = volume; if (buffer != NULL) buffer->volume = volume;
else TraceLog(LOG_WARNING, "SetAudioBufferVolume() : No audio buffer"); else TRACELOG(LOG_WARNING, "SetAudioBufferVolume() : No audio buffer");
} }
// Set pitch for an audio buffer // Set pitch for an audio buffer
@ -524,7 +524,7 @@ void SetAudioBufferPitch(AudioBuffer *buffer, float pitch)
ma_pcm_converter_set_output_sample_rate(&buffer->dsp, newOutputSampleRate); ma_pcm_converter_set_output_sample_rate(&buffer->dsp, newOutputSampleRate);
} }
else TraceLog(LOG_WARNING, "SetAudioBufferPitch() : No audio buffer"); else TRACELOG(LOG_WARNING, "SetAudioBufferPitch() : No audio buffer");
} }
// Track audio buffer to linked list next position // Track audio buffer to linked list next position
@ -583,7 +583,7 @@ Wave LoadWave(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_MP3) #if defined(SUPPORT_FILEFORMAT_MP3)
else if (IsFileExtension(fileName, ".mp3")) wave = LoadMP3(fileName); else if (IsFileExtension(fileName, ".mp3")) wave = LoadMP3(fileName);
#endif #endif
else TraceLog(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName); else TRACELOG(LOG_WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
return wave; return wave;
} }
@ -622,13 +622,13 @@ Sound LoadSoundFromWave(Wave wave)
ma_uint32 frameCountIn = wave.sampleCount/wave.channels; ma_uint32 frameCountIn = wave.sampleCount/wave.channels;
ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn); ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn);
if (frameCount == 0) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Failed to get frame count for format conversion"); if (frameCount == 0) TRACELOG(LOG_WARNING, "LoadSoundFromWave() : Failed to get frame count for format conversion");
AudioBuffer *audioBuffer = InitAudioBuffer(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, frameCount, AUDIO_BUFFER_USAGE_STATIC); AudioBuffer *audioBuffer = InitAudioBuffer(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, frameCount, AUDIO_BUFFER_USAGE_STATIC);
if (audioBuffer == NULL) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Failed to create audio buffer"); if (audioBuffer == NULL) TRACELOG(LOG_WARNING, "LoadSoundFromWave() : Failed to create audio buffer");
frameCount = (ma_uint32)ma_convert_frames(audioBuffer->data, audioBuffer->dsp.formatConverterIn.config.formatIn, audioBuffer->dsp.formatConverterIn.config.channels, audioBuffer->dsp.src.config.sampleRateIn, wave.data, formatIn, wave.channels, wave.sampleRate, frameCountIn); frameCount = (ma_uint32)ma_convert_frames(audioBuffer->data, audioBuffer->dsp.formatConverterIn.config.formatIn, audioBuffer->dsp.formatConverterIn.config.channels, audioBuffer->dsp.src.config.sampleRateIn, wave.data, formatIn, wave.channels, wave.sampleRate, frameCountIn);
if (frameCount == 0) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Format conversion failed"); if (frameCount == 0) TRACELOG(LOG_WARNING, "LoadSoundFromWave() : Format conversion failed");
sound.sampleCount = frameCount*DEVICE_CHANNELS; sound.sampleCount = frameCount*DEVICE_CHANNELS;
sound.stream.sampleRate = DEVICE_SAMPLE_RATE; sound.stream.sampleRate = DEVICE_SAMPLE_RATE;
@ -645,7 +645,7 @@ void UnloadWave(Wave wave)
{ {
if (wave.data != NULL) RL_FREE(wave.data); if (wave.data != NULL) RL_FREE(wave.data);
TraceLog(LOG_INFO, "Unloaded wave data from RAM"); TRACELOG(LOG_INFO, "Unloaded wave data from RAM");
} }
// Unload sound // Unload sound
@ -653,7 +653,7 @@ void UnloadSound(Sound sound)
{ {
CloseAudioBuffer(sound.stream.buffer); CloseAudioBuffer(sound.stream.buffer);
TraceLog(LOG_INFO, "Unloaded sound data from RAM"); TRACELOG(LOG_INFO, "Unloaded sound data from RAM");
} }
// Update sound buffer with new data // Update sound buffer with new data
@ -668,7 +668,7 @@ void UpdateSound(Sound sound, const void *data, int samplesCount)
// TODO: May want to lock/unlock this since this data buffer is read at mixing time // TODO: May want to lock/unlock this since this data buffer is read at mixing time
memcpy(audioBuffer->data, data, samplesCount*audioBuffer->dsp.formatConverterIn.config.channels*ma_get_bytes_per_sample(audioBuffer->dsp.formatConverterIn.config.formatIn)); memcpy(audioBuffer->data, data, samplesCount*audioBuffer->dsp.formatConverterIn.config.channels*ma_get_bytes_per_sample(audioBuffer->dsp.formatConverterIn.config.formatIn));
} }
else TraceLog(LOG_ERROR, "UpdateSound() : Invalid sound - no audio buffer"); else TRACELOG(LOG_ERROR, "UpdateSound() : Invalid sound - no audio buffer");
} }
// Export wave data to file // Export wave data to file
@ -689,8 +689,8 @@ void ExportWave(Wave wave, const char *fileName)
fclose(rawFile); fclose(rawFile);
} }
if (success) TraceLog(LOG_INFO, "Wave exported successfully: %s", fileName); if (success) TRACELOG(LOG_INFO, "Wave exported successfully: %s", fileName);
else TraceLog(LOG_WARNING, "Wave could not be exported."); else TRACELOG(LOG_WARNING, "Wave could not be exported.");
} }
// Export wave sample data to code (.h) // Export wave sample data to code (.h)
@ -771,12 +771,12 @@ void PlaySoundMulti(Sound sound)
// If no none playing pool members can be index choose the oldest // If no none playing pool members can be index choose the oldest
if (index == -1) if (index == -1)
{ {
TraceLog(LOG_WARNING,"pool age %i ended a sound early no room in buffer pool", AUDIO.MultiChannel.poolCounter); TRACELOG(LOG_WARNING,"pool age %i ended a sound early no room in buffer pool", AUDIO.MultiChannel.poolCounter);
if (oldIndex == -1) if (oldIndex == -1)
{ {
// Shouldn't be able to get here... but just in case something odd happens! // Shouldn't be able to get here... but just in case something odd happens!
TraceLog(LOG_ERROR,"sound buffer pool couldn't determine oldest buffer not playing sound"); TRACELOG(LOG_ERROR,"sound buffer pool couldn't determine oldest buffer not playing sound");
return; return;
} }
@ -872,7 +872,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, formatOut, channels, sampleRate, NULL, formatIn, wave->channels, wave->sampleRate, frameCountIn); ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, formatOut, channels, sampleRate, NULL, formatIn, wave->channels, wave->sampleRate, frameCountIn);
if (frameCount == 0) if (frameCount == 0)
{ {
TraceLog(LOG_ERROR, "WaveFormat() : Failed to get frame count for format conversion."); TRACELOG(LOG_ERROR, "WaveFormat() : Failed to get frame count for format conversion.");
return; return;
} }
@ -881,7 +881,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
frameCount = (ma_uint32)ma_convert_frames(data, formatOut, channels, sampleRate, wave->data, formatIn, wave->channels, wave->sampleRate, frameCountIn); frameCount = (ma_uint32)ma_convert_frames(data, formatOut, channels, sampleRate, wave->data, formatIn, wave->channels, wave->sampleRate, frameCountIn);
if (frameCount == 0) if (frameCount == 0)
{ {
TraceLog(LOG_ERROR, "WaveFormat() : Format conversion failed."); TRACELOG(LOG_ERROR, "WaveFormat() : Format conversion failed.");
return; return;
} }
@ -930,7 +930,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample)
RL_FREE(wave->data); RL_FREE(wave->data);
wave->data = data; wave->data = data;
} }
else TraceLog(LOG_WARNING, "Wave crop range out of bounds"); else TRACELOG(LOG_WARNING, "Wave crop range out of bounds");
} }
// Get samples data from wave as a floats array // Get samples data from wave as a floats array
@ -1082,16 +1082,16 @@ Music LoadMusicStream(const char *fileName)
else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); } else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
#endif #endif
TraceLog(LOG_WARNING, "[%s] Music file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] Music file could not be opened", fileName);
} }
else else
{ {
// Show some music stream info // Show some music stream info
TraceLog(LOG_INFO, "[%s] Music file successfully loaded:", fileName); TRACELOG(LOG_INFO, "[%s] Music file successfully loaded:", fileName);
TraceLog(LOG_INFO, " Total samples: %i", music.sampleCount); TRACELOG(LOG_INFO, " Total samples: %i", music.sampleCount);
TraceLog(LOG_INFO, " Sample rate: %i Hz", music.stream.sampleRate); TRACELOG(LOG_INFO, " Sample rate: %i Hz", music.stream.sampleRate);
TraceLog(LOG_INFO, " Sample size: %i bits", music.stream.sampleSize); TRACELOG(LOG_INFO, " Sample size: %i bits", music.stream.sampleSize);
TraceLog(LOG_INFO, " Channels: %i (%s)", music.stream.channels, (music.stream.channels == 1)? "Mono" : (music.stream.channels == 2)? "Stereo" : "Multi"); TRACELOG(LOG_INFO, " Channels: %i (%s)", music.stream.channels, (music.stream.channels == 1)? "Mono" : (music.stream.channels == 2)? "Stereo" : "Multi");
} }
return music; return music;
@ -1135,7 +1135,7 @@ void PlayMusicStream(Music music)
PlayAudioStream(music.stream); // WARNING: This resets the cursor position. PlayAudioStream(music.stream); // WARNING: This resets the cursor position.
audioBuffer->frameCursorPos = frameCursorPos; audioBuffer->frameCursorPos = frameCursorPos;
} }
else TraceLog(LOG_ERROR, "PlayMusicStream() : No audio buffer"); else TRACELOG(LOG_ERROR, "PlayMusicStream() : No audio buffer");
} }
@ -1350,9 +1350,9 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
if (stream.buffer != NULL) if (stream.buffer != NULL)
{ {
stream.buffer->looping = true; // Always loop for streaming buffers stream.buffer->looping = true; // Always loop for streaming buffers
TraceLog(LOG_INFO, "Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.sampleRate, stream.sampleSize, (stream.channels == 1)? "Mono" : "Stereo"); TRACELOG(LOG_INFO, "Audio stream loaded successfully (%i Hz, %i bit, %s)", stream.sampleRate, stream.sampleSize, (stream.channels == 1)? "Mono" : "Stereo");
} }
else TraceLog(LOG_ERROR, "InitAudioStream() : Failed to create audio buffer"); else TRACELOG(LOG_ERROR, "InitAudioStream() : Failed to create audio buffer");
return stream; return stream;
} }
@ -1362,7 +1362,7 @@ void CloseAudioStream(AudioStream stream)
{ {
CloseAudioBuffer(stream.buffer); CloseAudioBuffer(stream.buffer);
TraceLog(LOG_INFO, "Unloaded audio stream data"); TRACELOG(LOG_INFO, "Unloaded audio stream data");
} }
// Update audio stream buffers with data // Update audio stream buffers with data
@ -1415,11 +1415,11 @@ void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
audioBuffer->isSubBufferProcessed[subBufferToUpdate] = false; audioBuffer->isSubBufferProcessed[subBufferToUpdate] = false;
} }
else TraceLog(LOG_ERROR, "UpdateAudioStream() : Attempting to write too many frames to buffer"); else TRACELOG(LOG_ERROR, "UpdateAudioStream() : Attempting to write too many frames to buffer");
} }
else TraceLog(LOG_ERROR, "UpdateAudioStream() : Audio buffer not available for updating"); else TRACELOG(LOG_ERROR, "UpdateAudioStream() : Audio buffer not available for updating");
} }
else TraceLog(LOG_ERROR, "UpdateAudioStream() : No audio buffer"); else TRACELOG(LOG_ERROR, "UpdateAudioStream() : No audio buffer");
} }
// Check if any audio stream buffers requires refill // Check if any audio stream buffers requires refill
@ -1427,7 +1427,7 @@ bool IsAudioStreamProcessed(AudioStream stream)
{ {
if (stream.buffer == NULL) if (stream.buffer == NULL)
{ {
TraceLog(LOG_ERROR, "IsAudioStreamProcessed() : No audio buffer"); TRACELOG(LOG_ERROR, "IsAudioStreamProcessed() : No audio buffer");
return false; return false;
} }
@ -1484,7 +1484,7 @@ static void OnLog(ma_context *pContext, ma_device *pDevice, ma_uint32 logLevel,
(void)pContext; (void)pContext;
(void)pDevice; (void)pDevice;
TraceLog(LOG_ERROR, message); // All log messages from miniaudio are errors TRACELOG(LOG_ERROR, message); // All log messages from miniaudio are errors
} }
// Sending audio data to device callback function // Sending audio data to device callback function
@ -1511,7 +1511,7 @@ static void OnSendAudioDataToDevice(ma_device *pDevice, void *pFramesOut, const
{ {
if (framesRead > frameCount) if (framesRead > frameCount)
{ {
TraceLog(LOG_DEBUG, "Mixed too many frames from audio buffer"); TRACELOGD("Mixed too many frames from audio buffer");
break; break;
} }
@ -1586,7 +1586,7 @@ static ma_uint32 OnAudioBufferDSPRead(ma_pcm_converter *pDSP, void *pFramesOut,
if (currentSubBufferIndex > 1) if (currentSubBufferIndex > 1)
{ {
TraceLog(LOG_DEBUG, "Frame cursor position moved too far forward in audio stream"); TRACELOGD("Frame cursor position moved too far forward in audio stream");
return 0; return 0;
} }
@ -1742,7 +1742,7 @@ static Wave LoadWAV(const char *fileName)
if (wavFile == NULL) if (wavFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] WAV file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] WAV file could not be opened", fileName);
wave.data = NULL; wave.data = NULL;
} }
else else
@ -1754,7 +1754,7 @@ static Wave LoadWAV(const char *fileName)
if (strncmp(wavRiffHeader.chunkID, "RIFF", 4) || if (strncmp(wavRiffHeader.chunkID, "RIFF", 4) ||
strncmp(wavRiffHeader.format, "WAVE", 4)) strncmp(wavRiffHeader.format, "WAVE", 4))
{ {
TraceLog(LOG_WARNING, "[%s] Invalid RIFF or WAVE Header", fileName); TRACELOG(LOG_WARNING, "[%s] Invalid RIFF or WAVE Header", fileName);
} }
else else
{ {
@ -1765,7 +1765,7 @@ static Wave LoadWAV(const char *fileName)
if ((wavFormat.subChunkID[0] != 'f') || (wavFormat.subChunkID[1] != 'm') || if ((wavFormat.subChunkID[0] != 'f') || (wavFormat.subChunkID[1] != 'm') ||
(wavFormat.subChunkID[2] != 't') || (wavFormat.subChunkID[3] != ' ')) (wavFormat.subChunkID[2] != 't') || (wavFormat.subChunkID[3] != ' '))
{ {
TraceLog(LOG_WARNING, "[%s] Invalid Wave format", fileName); TRACELOG(LOG_WARNING, "[%s] Invalid Wave format", fileName);
} }
else else
{ {
@ -1779,7 +1779,7 @@ static Wave LoadWAV(const char *fileName)
if ((wavData.subChunkID[0] != 'd') || (wavData.subChunkID[1] != 'a') || if ((wavData.subChunkID[0] != 'd') || (wavData.subChunkID[1] != 'a') ||
(wavData.subChunkID[2] != 't') || (wavData.subChunkID[3] != 'a')) (wavData.subChunkID[2] != 't') || (wavData.subChunkID[3] != 'a'))
{ {
TraceLog(LOG_WARNING, "[%s] Invalid data header", fileName); TRACELOG(LOG_WARNING, "[%s] Invalid data header", fileName);
} }
else else
{ {
@ -1797,7 +1797,7 @@ static Wave LoadWAV(const char *fileName)
// NOTE: Only support 8 bit, 16 bit and 32 bit sample sizes // NOTE: Only support 8 bit, 16 bit and 32 bit sample sizes
if ((wave.sampleSize != 8) && (wave.sampleSize != 16) && (wave.sampleSize != 32)) if ((wave.sampleSize != 8) && (wave.sampleSize != 16) && (wave.sampleSize != 32))
{ {
TraceLog(LOG_WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize); TRACELOG(LOG_WARNING, "[%s] WAV sample size (%ibit) not supported, converted to 16bit", fileName, wave.sampleSize);
WaveFormat(&wave, wave.sampleRate, 16, wave.channels); WaveFormat(&wave, wave.sampleRate, 16, wave.channels);
} }
@ -1805,13 +1805,13 @@ static Wave LoadWAV(const char *fileName)
if (wave.channels > 2) if (wave.channels > 2)
{ {
WaveFormat(&wave, wave.sampleRate, wave.sampleSize, 2); WaveFormat(&wave, wave.sampleRate, wave.sampleSize, 2);
TraceLog(LOG_WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels); TRACELOG(LOG_WARNING, "[%s] WAV channels number (%i) not supported, converted to 2 channels", fileName, wave.channels);
} }
// NOTE: subChunkSize comes in bytes, we need to translate it to number of samples // NOTE: subChunkSize comes in bytes, we need to translate it to number of samples
wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels; wave.sampleCount = (wavData.subChunkSize/(wave.sampleSize/8))/wave.channels;
TraceLog(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo"); TRACELOG(LOG_INFO, "[%s] WAV file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
} }
} }
} }
@ -1853,7 +1853,7 @@ static int SaveWAV(Wave wave, const char *fileName)
FILE *wavFile = fopen(fileName, "wb"); FILE *wavFile = fopen(fileName, "wb");
if (wavFile == NULL) TraceLog(LOG_WARNING, "[%s] WAV audio file could not be created", fileName); if (wavFile == NULL) TRACELOG(LOG_WARNING, "[%s] WAV audio file could not be created", fileName);
else else
{ {
RiffHeader riffHeader; RiffHeader riffHeader;
@ -1912,7 +1912,7 @@ static Wave LoadOGG(const char *fileName)
stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL); stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL);
if (oggFile == NULL) TraceLog(LOG_WARNING, "[%s] OGG file could not be opened", fileName); if (oggFile == NULL) TRACELOG(LOG_WARNING, "[%s] OGG file could not be opened", fileName);
else else
{ {
stb_vorbis_info info = stb_vorbis_get_info(oggFile); stb_vorbis_info info = stb_vorbis_get_info(oggFile);
@ -1923,16 +1923,16 @@ static Wave LoadOGG(const char *fileName)
wave.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggFile)*info.channels; // Independent by channel wave.sampleCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggFile)*info.channels; // Independent by channel
float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile);
if (totalSeconds > 10) TraceLog(LOG_WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); if (totalSeconds > 10) TRACELOG(LOG_WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
wave.data = (short *)RL_MALLOC(wave.sampleCount*wave.channels*sizeof(short)); wave.data = (short *)RL_MALLOC(wave.sampleCount*wave.channels*sizeof(short));
// NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!) // NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!)
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels); int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels);
TraceLog(LOG_DEBUG, "[%s] Samples obtained: %i", fileName, numSamplesOgg); TRACELOGD("[%s] Samples obtained: %i", fileName, numSamplesOgg);
TraceLog(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo"); TRACELOG(LOG_INFO, "[%s] OGG file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
stb_vorbis_close(oggFile); stb_vorbis_close(oggFile);
} }
@ -1956,10 +1956,10 @@ static Wave LoadFLAC(const char *fileName)
wave.sampleSize = 16; wave.sampleSize = 16;
// NOTE: Only support up to 2 channels (mono, stereo) // NOTE: Only support up to 2 channels (mono, stereo)
if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels); if (wave.channels > 2) TRACELOG(LOG_WARNING, "[%s] FLAC channels number (%i) not supported", fileName, wave.channels);
if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] FLAC data could not be loaded", fileName); if (wave.data == NULL) TRACELOG(LOG_WARNING, "[%s] FLAC data could not be loaded", fileName);
else TraceLog(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo"); else TRACELOG(LOG_INFO, "[%s] FLAC file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
return wave; return wave;
} }
@ -1983,10 +1983,10 @@ static Wave LoadMP3(const char *fileName)
wave.sampleSize = 32; wave.sampleSize = 32;
// NOTE: Only support up to 2 channels (mono, stereo) // NOTE: Only support up to 2 channels (mono, stereo)
if (wave.channels > 2) TraceLog(LOG_WARNING, "[%s] MP3 channels number (%i) not supported", fileName, wave.channels); if (wave.channels > 2) TRACELOG(LOG_WARNING, "[%s] MP3 channels number (%i) not supported", fileName, wave.channels);
if (wave.data == NULL) TraceLog(LOG_WARNING, "[%s] MP3 data could not be loaded", fileName); if (wave.data == NULL) TRACELOG(LOG_WARNING, "[%s] MP3 data could not be loaded", fileName);
else TraceLog(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo"); else TRACELOG(LOG_INFO, "[%s] MP3 file loaded successfully (%i Hz, %i bit, %s)", fileName, wave.sampleRate, wave.sampleSize, (wave.channels == 1)? "Mono" : "Stereo");
return wave; return wave;
} }
@ -2009,7 +2009,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
} }
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...) void TRACELOG(int msgType, const char *text, ...)
{ {
va_list args; va_list args;
va_start(args, text); va_start(args, text);

View file

@ -74,6 +74,20 @@
#define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#endif #endif
#endif #endif
// Support TRACELOG macros
#if defined(SUPPORT_TRACELOG)
#define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#if defined(SUPPORT_TRACELOG_DEBUG)
#define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__)
#else
#define TRACELOGD(...) void(0)
#endif
#else
#define TRACELOG(level, ...) void(0)
#define TRACELOGD(...) void(0)
#endif
// Allow custom memory allocators // Allow custom memory allocators
#ifndef RL_MALLOC #ifndef RL_MALLOC
@ -89,7 +103,7 @@
#define RL_FREE(p) free(p) #define RL_FREE(p) free(p)
#endif #endif
#else #else
#include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog() #include "raylib.h" // Required for: Model, Shader, Texture2D, TRACELOG()
#endif #endif
#include "raymath.h" // Required for: Vector3, Matrix #include "raymath.h" // Required for: Vector3, Matrix
@ -582,7 +596,7 @@ RLAPI void ToggleVrMode(void); // Enable/Disable VR exp
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
RLAPI void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) RLAPI void TRACELOG(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
RLAPI int GetPixelDataSize(int width, int height, int format);// Get pixel data size in bytes (image or texture) RLAPI int GetPixelDataSize(int width, int height, int format);// Get pixel data size in bytes (image or texture)
#endif #endif
@ -663,7 +677,7 @@ RLAPI int GetPixelDataSize(int width, int height, int format);// Get pixel data
#endif #endif
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()] #include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TRACELOG()]
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -941,7 +955,7 @@ void rlMatrixMode(int mode)
// Push the current matrix into RLGL.State.stack // Push the current matrix into RLGL.State.stack
void rlPushMatrix(void) void rlPushMatrix(void)
{ {
if (RLGL.State.stackCounter >= MAX_MATRIX_STACK_SIZE) TraceLog(LOG_ERROR, "Matrix RLGL.State.stack overflow"); if (RLGL.State.stackCounter >= MAX_MATRIX_STACK_SIZE) TRACELOG(LOG_ERROR, "Matrix RLGL.State.stack overflow");
if (RLGL.State.currentMatrixMode == RL_MODELVIEW) if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
{ {
@ -1183,7 +1197,7 @@ void rlVertex3f(float x, float y, float z)
RLGL.State.draws[RLGL.State.drawsCounter - 1].vertexCount++; RLGL.State.draws[RLGL.State.drawsCounter - 1].vertexCount++;
} }
else TraceLog(LOG_ERROR, "MAX_BATCH_ELEMENTS overflow"); else TRACELOG(LOG_ERROR, "MAX_BATCH_ELEMENTS overflow");
} }
// Define one vertex (position) // Define one vertex (position)
@ -1311,7 +1325,7 @@ void rlTextureParameters(unsigned int id, int param, int value)
{ {
#if !defined(GRAPHICS_API_OPENGL_11) #if !defined(GRAPHICS_API_OPENGL_11)
if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value); if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value);
else TraceLog(LOG_WARNING, "Clamp mirror wrap mode not supported"); else TRACELOG(LOG_WARNING, "Clamp mirror wrap mode not supported");
#endif #endif
} }
else glTexParameteri(GL_TEXTURE_2D, param, value); else glTexParameteri(GL_TEXTURE_2D, param, value);
@ -1325,10 +1339,10 @@ void rlTextureParameters(unsigned int id, int param, int value)
if (value <= RLGL.ExtSupported.maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); if (value <= RLGL.ExtSupported.maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
else if (RLGL.ExtSupported.maxAnisotropicLevel > 0.0f) else if (RLGL.ExtSupported.maxAnisotropicLevel > 0.0f)
{ {
TraceLog(LOG_WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, RLGL.ExtSupported.maxAnisotropicLevel); TRACELOG(LOG_WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, RLGL.ExtSupported.maxAnisotropicLevel);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
} }
else TraceLog(LOG_WARNING, "Anisotropic filtering not supported"); else TRACELOG(LOG_WARNING, "Anisotropic filtering not supported");
#endif #endif
} break; } break;
default: break; default: break;
@ -1417,7 +1431,7 @@ void rlDeleteRenderTextures(RenderTexture2D target)
if (target.id > 0) glDeleteFramebuffers(1, &target.id); if (target.id > 0) glDeleteFramebuffers(1, &target.id);
TraceLog(LOG_INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id); TRACELOG(LOG_INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id);
#endif #endif
} }
@ -1436,7 +1450,7 @@ void rlDeleteVertexArrays(unsigned int id)
if (RLGL.ExtSupported.vao) if (RLGL.ExtSupported.vao)
{ {
if (id != 0) glDeleteVertexArrays(1, &id); if (id != 0) glDeleteVertexArrays(1, &id);
TraceLog(LOG_INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id); TRACELOG(LOG_INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id);
} }
#endif #endif
} }
@ -1448,7 +1462,7 @@ void rlDeleteBuffers(unsigned int id)
if (id != 0) if (id != 0)
{ {
glDeleteBuffers(1, &id); glDeleteBuffers(1, &id);
if (!RLGL.ExtSupported.vao) TraceLog(LOG_INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id); if (!RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id);
} }
#endif #endif
} }
@ -1492,28 +1506,28 @@ void rlglInit(int width, int height)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Print current OpenGL and GLSL version // Print current OpenGL and GLSL version
TraceLog(LOG_INFO, "GPU: Vendor: %s", glGetString(GL_VENDOR)); TRACELOG(LOG_INFO, "GPU: Vendor: %s", glGetString(GL_VENDOR));
TraceLog(LOG_INFO, "GPU: Renderer: %s", glGetString(GL_RENDERER)); TRACELOG(LOG_INFO, "GPU: Renderer: %s", glGetString(GL_RENDERER));
TraceLog(LOG_INFO, "GPU: Version: %s", glGetString(GL_VERSION)); TRACELOG(LOG_INFO, "GPU: Version: %s", glGetString(GL_VERSION));
TraceLog(LOG_INFO, "GPU: GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); TRACELOG(LOG_INFO, "GPU: GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
// NOTE: We can get a bunch of extra information about GPU capabilities (glGet*) // NOTE: We can get a bunch of extra information about GPU capabilities (glGet*)
//int maxTexSize; //int maxTexSize;
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
//TraceLog(LOG_INFO, "GL_MAX_TEXTURE_SIZE: %i", maxTexSize); //TRACELOG(LOG_INFO, "GL_MAX_TEXTURE_SIZE: %i", maxTexSize);
//GL_MAX_TEXTURE_IMAGE_UNITS //GL_MAX_TEXTURE_IMAGE_UNITS
//GL_MAX_VIEWPORT_DIMS //GL_MAX_VIEWPORT_DIMS
//int numAuxBuffers; //int numAuxBuffers;
//glGetIntegerv(GL_AUX_BUFFERS, &numAuxBuffers); //glGetIntegerv(GL_AUX_BUFFERS, &numAuxBuffers);
//TraceLog(LOG_INFO, "GL_AUX_BUFFERS: %i", numAuxBuffers); //TRACELOG(LOG_INFO, "GL_AUX_BUFFERS: %i", numAuxBuffers);
//GLint numComp = 0; //GLint numComp = 0;
//GLint format[32] = { 0 }; //GLint format[32] = { 0 };
//glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numComp); //glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numComp);
//glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, format); //glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, format);
//for (int i = 0; i < numComp; i++) TraceLog(LOG_INFO, "Supported compressed format: 0x%x", format[i]); //for (int i = 0; i < numComp; i++) TRACELOG(LOG_INFO, "Supported compressed format: 0x%x", format[i]);
// NOTE: We don't need that much data on screen... right now... // NOTE: We don't need that much data on screen... right now...
@ -1571,10 +1585,10 @@ void rlglInit(int width, int height)
// NOTE: Duplicated string (extensionsDup) must be deallocated // NOTE: Duplicated string (extensionsDup) must be deallocated
#endif #endif
TraceLog(LOG_INFO, "Number of supported extensions: %i", numExt); TRACELOG(LOG_INFO, "Number of supported extensions: %i", numExt);
// Show supported extensions // Show supported extensions
//for (int i = 0; i < numExt; i++) TraceLog(LOG_INFO, "Supported extension: %s", extList[i]); //for (int i = 0; i < numExt; i++) TRACELOG(LOG_INFO, "Supported extension: %s", extList[i]);
// Check required extensions // Check required extensions
for (int i = 0; i < numExt; i++) for (int i = 0; i < numExt; i++)
@ -1646,23 +1660,23 @@ void rlglInit(int width, int height)
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
RL_FREE(extensionsDup); // Duplicated string must be deallocated RL_FREE(extensionsDup); // Duplicated string must be deallocated
if (RLGL.ExtSupported.vao) TraceLog(LOG_INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully"); if (RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully");
else TraceLog(LOG_WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported"); else TRACELOG(LOG_WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported");
if (RLGL.ExtSupported.texNPOT) TraceLog(LOG_INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported"); if (RLGL.ExtSupported.texNPOT) TRACELOG(LOG_INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported");
else TraceLog(LOG_WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)"); else TRACELOG(LOG_WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)");
#endif #endif
if (RLGL.ExtSupported.texCompDXT) TraceLog(LOG_INFO, "[EXTENSION] DXT compressed textures supported"); if (RLGL.ExtSupported.texCompDXT) TRACELOG(LOG_INFO, "[EXTENSION] DXT compressed textures supported");
if (RLGL.ExtSupported.texCompETC1) TraceLog(LOG_INFO, "[EXTENSION] ETC1 compressed textures supported"); if (RLGL.ExtSupported.texCompETC1) TRACELOG(LOG_INFO, "[EXTENSION] ETC1 compressed textures supported");
if (RLGL.ExtSupported.texCompETC2) TraceLog(LOG_INFO, "[EXTENSION] ETC2/EAC compressed textures supported"); if (RLGL.ExtSupported.texCompETC2) TRACELOG(LOG_INFO, "[EXTENSION] ETC2/EAC compressed textures supported");
if (RLGL.ExtSupported.texCompPVRT) TraceLog(LOG_INFO, "[EXTENSION] PVRT compressed textures supported"); if (RLGL.ExtSupported.texCompPVRT) TRACELOG(LOG_INFO, "[EXTENSION] PVRT compressed textures supported");
if (RLGL.ExtSupported.texCompASTC) TraceLog(LOG_INFO, "[EXTENSION] ASTC compressed textures supported"); if (RLGL.ExtSupported.texCompASTC) TRACELOG(LOG_INFO, "[EXTENSION] ASTC compressed textures supported");
if (RLGL.ExtSupported.texAnisoFilter) TraceLog(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", RLGL.ExtSupported.maxAnisotropicLevel); if (RLGL.ExtSupported.texAnisoFilter) TRACELOG(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", RLGL.ExtSupported.maxAnisotropicLevel);
if (RLGL.ExtSupported.texMirrorClamp) TraceLog(LOG_INFO, "[EXTENSION] Mirror clamp wrap texture mode supported"); if (RLGL.ExtSupported.texMirrorClamp) TRACELOG(LOG_INFO, "[EXTENSION] Mirror clamp wrap texture mode supported");
if (RLGL.ExtSupported.debugMarker) TraceLog(LOG_INFO, "[EXTENSION] Debug Marker supported"); if (RLGL.ExtSupported.debugMarker) TRACELOG(LOG_INFO, "[EXTENSION] Debug Marker supported");
// Initialize buffers, default shaders and default textures // Initialize buffers, default shaders and default textures
//---------------------------------------------------------- //----------------------------------------------------------
@ -1670,8 +1684,8 @@ void rlglInit(int width, int height)
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1); RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1);
if (RLGL.State.defaultTextureId != 0) TraceLog(LOG_INFO, "[TEX ID %i] Base white texture loaded successfully", RLGL.State.defaultTextureId); if (RLGL.State.defaultTextureId != 0) TRACELOG(LOG_INFO, "[TEX ID %i] Base white texture loaded successfully", RLGL.State.defaultTextureId);
else TraceLog(LOG_WARNING, "Base white texture could not be loaded"); else TRACELOG(LOG_WARNING, "Base white texture could not be loaded");
// Init default Shader (customized for GL 3.3 and ES2) // Init default Shader (customized for GL 3.3 and ES2)
RLGL.State.defaultShader = LoadShaderDefault(); RLGL.State.defaultShader = LoadShaderDefault();
@ -1744,7 +1758,7 @@ void rlglInit(int width, int height)
RLGL.State.shapesTexture = GetTextureDefault(); RLGL.State.shapesTexture = GetTextureDefault();
RLGL.State.shapesTextureRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f }; RLGL.State.shapesTextureRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f };
TraceLog(LOG_INFO, "OpenGL default states initialized successfully"); TRACELOG(LOG_INFO, "OpenGL default states initialized successfully");
} }
// Vertex Buffer Object deinitialization (memory free) // Vertex Buffer Object deinitialization (memory free)
@ -1755,7 +1769,7 @@ void rlglClose(void)
UnloadBuffersDefault(); // Unload default buffers UnloadBuffersDefault(); // Unload default buffers
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", RLGL.State.defaultTextureId); TRACELOG(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", RLGL.State.defaultTextureId);
RL_FREE(RLGL.State.draws); RL_FREE(RLGL.State.draws);
#endif #endif
@ -1817,14 +1831,14 @@ void rlLoadExtensions(void *loader)
#if defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_33)
// NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions)
#if !defined(__APPLE__) #if !defined(__APPLE__)
if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(LOG_WARNING, "GLAD: Cannot load OpenGL extensions"); if (!gladLoadGLLoader((GLADloadproc)loader)) TRACELOG(LOG_WARNING, "GLAD: Cannot load OpenGL extensions");
else TraceLog(LOG_INFO, "GLAD: OpenGL extensions loaded successfully"); else TRACELOG(LOG_INFO, "GLAD: OpenGL extensions loaded successfully");
#if defined(GRAPHICS_API_OPENGL_21) #if defined(GRAPHICS_API_OPENGL_21)
if (GLAD_GL_VERSION_2_1) TraceLog(LOG_INFO, "OpenGL 2.1 profile supported"); if (GLAD_GL_VERSION_2_1) TRACELOG(LOG_INFO, "OpenGL 2.1 profile supported");
#elif defined(GRAPHICS_API_OPENGL_33) #elif defined(GRAPHICS_API_OPENGL_33)
if (GLAD_GL_VERSION_3_3) TraceLog(LOG_INFO, "OpenGL 3.3 Core profile supported"); if (GLAD_GL_VERSION_3_3) TRACELOG(LOG_INFO, "OpenGL 3.3 Core profile supported");
else TraceLog(LOG_ERROR, "OpenGL 3.3 Core profile not supported"); else TRACELOG(LOG_ERROR, "OpenGL 3.3 Core profile not supported");
#endif #endif
#endif #endif
@ -1867,38 +1881,38 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
if (format >= COMPRESSED_DXT1_RGB) if (format >= COMPRESSED_DXT1_RGB)
{ {
TraceLog(LOG_WARNING, "OpenGL 1.1 does not support GPU compressed texture formats"); TRACELOG(LOG_WARNING, "OpenGL 1.1 does not support GPU compressed texture formats");
return id; return id;
} }
#else #else
if ((!RLGL.ExtSupported.texCompDXT) && ((format == COMPRESSED_DXT1_RGB) || (format == COMPRESSED_DXT1_RGBA) || if ((!RLGL.ExtSupported.texCompDXT) && ((format == COMPRESSED_DXT1_RGB) || (format == COMPRESSED_DXT1_RGBA) ||
(format == COMPRESSED_DXT3_RGBA) || (format == COMPRESSED_DXT5_RGBA))) (format == COMPRESSED_DXT3_RGBA) || (format == COMPRESSED_DXT5_RGBA)))
{ {
TraceLog(LOG_WARNING, "DXT compressed texture format not supported"); TRACELOG(LOG_WARNING, "DXT compressed texture format not supported");
return id; return id;
} }
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if ((!RLGL.ExtSupported.texCompETC1) && (format == COMPRESSED_ETC1_RGB)) if ((!RLGL.ExtSupported.texCompETC1) && (format == COMPRESSED_ETC1_RGB))
{ {
TraceLog(LOG_WARNING, "ETC1 compressed texture format not supported"); TRACELOG(LOG_WARNING, "ETC1 compressed texture format not supported");
return id; return id;
} }
if ((!RLGL.ExtSupported.texCompETC2) && ((format == COMPRESSED_ETC2_RGB) || (format == COMPRESSED_ETC2_EAC_RGBA))) if ((!RLGL.ExtSupported.texCompETC2) && ((format == COMPRESSED_ETC2_RGB) || (format == COMPRESSED_ETC2_EAC_RGBA)))
{ {
TraceLog(LOG_WARNING, "ETC2 compressed texture format not supported"); TRACELOG(LOG_WARNING, "ETC2 compressed texture format not supported");
return id; return id;
} }
if ((!RLGL.ExtSupported.texCompPVRT) && ((format == COMPRESSED_PVRT_RGB) || (format == COMPRESSED_PVRT_RGBA))) if ((!RLGL.ExtSupported.texCompPVRT) && ((format == COMPRESSED_PVRT_RGB) || (format == COMPRESSED_PVRT_RGBA)))
{ {
TraceLog(LOG_WARNING, "PVRT compressed texture format not supported"); TRACELOG(LOG_WARNING, "PVRT compressed texture format not supported");
return id; return id;
} }
if ((!RLGL.ExtSupported.texCompASTC) && ((format == COMPRESSED_ASTC_4x4_RGBA) || (format == COMPRESSED_ASTC_8x8_RGBA))) if ((!RLGL.ExtSupported.texCompASTC) && ((format == COMPRESSED_ASTC_4x4_RGBA) || (format == COMPRESSED_ASTC_8x8_RGBA)))
{ {
TraceLog(LOG_WARNING, "ASTC compressed texture format not supported"); TRACELOG(LOG_WARNING, "ASTC compressed texture format not supported");
return id; return id;
} }
#endif #endif
@ -1918,7 +1932,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
int mipHeight = height; int mipHeight = height;
int mipOffset = 0; // Mipmap data offset int mipOffset = 0; // Mipmap data offset
TraceLog(LOG_DEBUG, "Load texture from data memory address: 0x%x", data); TRACELOGD("Load texture from data memory address: 0x%x", data);
// Load the different mipmap levels // Load the different mipmap levels
for (int i = 0; i < mipmapCount; i++) for (int i = 0; i < mipmapCount; i++)
@ -1928,7 +1942,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
unsigned int glInternalFormat, glFormat, glType; unsigned int glInternalFormat, glFormat, glType;
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
TraceLog(LOG_DEBUG, "Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset); TRACELOGD("Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset);
if (glInternalFormat != -1) if (glInternalFormat != -1)
{ {
@ -2004,8 +2018,8 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
// Unbind current texture // Unbind current texture
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
if (id > 0) TraceLog(LOG_INFO, "[TEX ID %i] Texture created successfully (%ix%i - %i mipmaps)", id, width, height, mipmapCount); if (id > 0) TRACELOG(LOG_INFO, "[TEX ID %i] Texture created successfully (%ix%i - %i mipmaps)", id, width, height, mipmapCount);
else TraceLog(LOG_WARNING, "Texture could not be created"); else TRACELOG(LOG_WARNING, "Texture could not be created");
return id; return id;
} }
@ -2138,7 +2152,7 @@ void rlUpdateTexture(unsigned int id, int width, int height, int format, const v
{ {
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glFormat, glType, (unsigned char *)data); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glFormat, glType, (unsigned char *)data);
} }
else TraceLog(LOG_WARNING, "Texture format updating not supported"); else TRACELOG(LOG_WARNING, "Texture format updating not supported");
} }
// Get OpenGL internal formats and data type from raylib PixelFormat // Get OpenGL internal formats and data type from raylib PixelFormat
@ -2189,7 +2203,7 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned
case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3
#endif #endif
default: TraceLog(LOG_WARNING, "Texture format not supported"); break; default: TRACELOG(LOG_WARNING, "Texture format not supported"); break;
} }
} }
@ -2245,7 +2259,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth
// Check if fbo is complete with attachments (valid) // Check if fbo is complete with attachments (valid)
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
if (rlRenderTextureComplete(target)) TraceLog(LOG_INFO, "[FBO ID %i] Framebuffer object created successfully", target.id); if (rlRenderTextureComplete(target)) TRACELOG(LOG_INFO, "[FBO ID %i] Framebuffer object created successfully", target.id);
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -2286,12 +2300,12 @@ bool rlRenderTextureComplete(RenderTexture target)
{ {
switch (status) switch (status)
{ {
case GL_FRAMEBUFFER_UNSUPPORTED: TraceLog(LOG_WARNING, "Framebuffer is unsupported"); break; case GL_FRAMEBUFFER_UNSUPPORTED: TRACELOG(LOG_WARNING, "Framebuffer is unsupported"); break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TraceLog(LOG_WARNING, "Framebuffer has incomplete attachment"); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TRACELOG(LOG_WARNING, "Framebuffer has incomplete attachment"); break;
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TraceLog(LOG_WARNING, "Framebuffer has incomplete dimensions"); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TRACELOG(LOG_WARNING, "Framebuffer has incomplete dimensions"); break;
#endif #endif
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TraceLog(LOG_WARNING, "Framebuffer has a missing attachment"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TRACELOG(LOG_WARNING, "Framebuffer has a missing attachment"); break;
default: break; default: break;
} }
} }
@ -2349,16 +2363,16 @@ void rlGenerateMipmaps(Texture2D *texture)
texture->mipmaps = mipmapCount + 1; texture->mipmaps = mipmapCount + 1;
RL_FREE(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data RL_FREE(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data
TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps [%i] generated manually on CPU side", texture->id, texture->mipmaps); TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps [%i] generated manually on CPU side", texture->id, texture->mipmaps);
} }
else TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps could not be generated for texture format", texture->id); else TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps could not be generated for texture format", texture->id);
} }
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) if ((texIsPOT) || (RLGL.ExtSupported.texNPOT))
{ {
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically
TraceLog(LOG_INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id); TRACELOG(LOG_INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps
@ -2369,7 +2383,7 @@ void rlGenerateMipmaps(Texture2D *texture)
texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2)); texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2));
} }
#endif #endif
else TraceLog(LOG_WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id); else TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
@ -2380,7 +2394,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
if (mesh->vaoId > 0) if (mesh->vaoId > 0)
{ {
// Check if mesh has already been loaded in GPU // Check if mesh has already been loaded in GPU
TraceLog(LOG_WARNING, "Trying to re-load an already loaded mesh"); TRACELOG(LOG_WARNING, "Trying to re-load an already loaded mesh");
return; return;
} }
@ -2493,12 +2507,12 @@ void rlLoadMesh(Mesh *mesh, bool dynamic)
if (RLGL.ExtSupported.vao) if (RLGL.ExtSupported.vao)
{ {
if (mesh->vaoId > 0) TraceLog(LOG_INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId); if (mesh->vaoId > 0) TRACELOG(LOG_INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId);
else TraceLog(LOG_WARNING, "Mesh could not be uploaded to VRAM (GPU)"); else TRACELOG(LOG_WARNING, "Mesh could not be uploaded to VRAM (GPU)");
} }
else else
{ {
TraceLog(LOG_INFO, "[VBOs] Mesh uploaded successfully to VRAM (GPU)"); TRACELOG(LOG_INFO, "[VBOs] Mesh uploaded successfully to VRAM (GPU)");
} }
#endif #endif
} }
@ -2896,7 +2910,7 @@ void *rlReadTexturePixels(Texture2D texture)
pixels = (unsigned char *)RL_MALLOC(size); pixels = (unsigned char *)RL_MALLOC(size);
glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels); glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels);
} }
else TraceLog(LOG_WARNING, "Texture data retrieval not suported for pixel format"); else TRACELOG(LOG_WARNING, "Texture data retrieval not suported for pixel format");
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
#endif #endif
@ -3009,7 +3023,7 @@ char *LoadText(const char *fileName)
fclose(textFile); fclose(textFile);
} }
else TraceLog(LOG_WARNING, "[%s] Text file could not be opened", fileName); else TRACELOG(LOG_WARNING, "[%s] Text file could not be opened", fileName);
} }
return text; return text;
@ -3064,7 +3078,7 @@ Shader LoadShaderCode(const char *vsCode, const char *fsCode)
if (shader.id == 0) if (shader.id == 0)
{ {
TraceLog(LOG_WARNING, "Custom shader could not be loaded"); TRACELOG(LOG_WARNING, "Custom shader could not be loaded");
shader = RLGL.State.defaultShader; shader = RLGL.State.defaultShader;
} }
@ -3090,10 +3104,7 @@ Shader LoadShaderCode(const char *vsCode, const char *fsCode)
name[namelen] = 0; name[namelen] = 0;
// Get the location of the named uniform TRACELOGD("[SHDR ID %i] Active uniform [%s] set at location: %i", shader.id, name, glGetUniformLocation(shader.id, name));
unsigned int location = glGetUniformLocation(shader.id, name);
TraceLog(LOG_DEBUG, "[SHDR ID %i] Active uniform [%s] set at location: %i", shader.id, name, location);
} }
#endif #endif
@ -3106,7 +3117,7 @@ void UnloadShader(Shader shader)
if (shader.id > 0) if (shader.id > 0)
{ {
rlDeleteShader(shader.id); rlDeleteShader(shader.id);
TraceLog(LOG_INFO, "[SHDR ID %i] Unloaded shader program data", shader.id); TRACELOG(LOG_INFO, "[SHDR ID %i] Unloaded shader program data", shader.id);
} }
RL_FREE(shader.locs); RL_FREE(shader.locs);
@ -3139,8 +3150,8 @@ int GetShaderLocation(Shader shader, const char *uniformName)
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
location = glGetUniformLocation(shader.id, uniformName); location = glGetUniformLocation(shader.id, uniformName);
if (location == -1) TraceLog(LOG_WARNING, "[SHDR ID %i][%s] Shader uniform could not be found", shader.id, uniformName); if (location == -1) TRACELOG(LOG_WARNING, "[SHDR ID %i][%s] Shader uniform could not be found", shader.id, uniformName);
else TraceLog(LOG_INFO, "[SHDR ID %i][%s] Shader uniform set at location: %i", shader.id, uniformName, location); else TRACELOG(LOG_INFO, "[SHDR ID %i][%s] Shader uniform set at location: %i", shader.id, uniformName, location);
#endif #endif
return location; return location;
} }
@ -3168,7 +3179,7 @@ void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int unifo
case UNIFORM_IVEC3: glUniform3iv(uniformLoc, count, (int *)value); break; case UNIFORM_IVEC3: glUniform3iv(uniformLoc, count, (int *)value); break;
case UNIFORM_IVEC4: glUniform4iv(uniformLoc, count, (int *)value); break; case UNIFORM_IVEC4: glUniform4iv(uniformLoc, count, (int *)value); break;
case UNIFORM_SAMPLER2D: glUniform1iv(uniformLoc, count, (int *)value); break; case UNIFORM_SAMPLER2D: glUniform1iv(uniformLoc, count, (int *)value); break;
default: TraceLog(LOG_WARNING, "Shader uniform could not be set data type not recognized"); default: TRACELOG(LOG_WARNING, "Shader uniform could not be set data type not recognized");
} }
//glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set //glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set
@ -3612,7 +3623,7 @@ void InitVrSimulator(void)
RLGL.Vr.simulatorReady = true; RLGL.Vr.simulatorReady = true;
#else #else
TraceLog(LOG_WARNING, "VR Simulator not supported on OpenGL 1.1"); TRACELOG(LOG_WARNING, "VR Simulator not supported on OpenGL 1.1");
#endif #endif
} }
@ -3660,17 +3671,17 @@ void SetVrConfiguration(VrDeviceInfo hmd, Shader distortion)
hmd.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq + hmd.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq +
hmd.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq; hmd.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq;
TraceLog(LOG_DEBUG, "VR: Distortion Scale: %f", distortionScale); TRACELOGD("VR: Distortion Scale: %f", distortionScale);
float normScreenWidth = 0.5f; float normScreenWidth = 0.5f;
float normScreenHeight = 1.0f; float normScreenHeight = 1.0f;
float scaleIn[2] = { 2.0f/normScreenWidth, 2.0f/normScreenHeight/aspect }; float scaleIn[2] = { 2.0f/normScreenWidth, 2.0f/normScreenHeight/aspect };
float scale[2] = { normScreenWidth*0.5f/distortionScale, normScreenHeight*0.5f*aspect/distortionScale }; float scale[2] = { normScreenWidth*0.5f/distortionScale, normScreenHeight*0.5f*aspect/distortionScale };
TraceLog(LOG_DEBUG, "VR: Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]); TRACELOGD("VR: Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]); TRACELOGD("VR: Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]); TRACELOGD("VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]);
TraceLog(LOG_DEBUG, "VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]); TRACELOGD("VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]);
// Fovy is normally computed with: 2*atan2(hmd.vScreenSize, 2*hmd.eyeToScreenDistance) // Fovy is normally computed with: 2*atan2(hmd.vScreenSize, 2*hmd.eyeToScreenDistance)
// ...but with lens distortion it is increased (see Oculus SDK Documentation) // ...but with lens distortion it is increased (see Oculus SDK Documentation)
@ -3849,7 +3860,7 @@ static unsigned int CompileShader(const char *shaderStr, int type)
if (success != GL_TRUE) if (success != GL_TRUE)
{ {
TraceLog(LOG_WARNING, "[SHDR ID %i] Failed to compile shader...", shader); TRACELOG(LOG_WARNING, "[SHDR ID %i] Failed to compile shader...", shader);
int maxLength = 0; int maxLength = 0;
int length; int length;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
@ -3861,13 +3872,13 @@ static unsigned int CompileShader(const char *shaderStr, int type)
#endif #endif
glGetShaderInfoLog(shader, maxLength, &length, log); glGetShaderInfoLog(shader, maxLength, &length, log);
TraceLog(LOG_INFO, "%s", log); TRACELOG(LOG_INFO, "%s", log);
#if defined(_MSC_VER) #if defined(_MSC_VER)
RL_FREE(log); RL_FREE(log);
#endif #endif
} }
else TraceLog(LOG_INFO, "[SHDR ID %i] Shader compiled successfully", shader); else TRACELOG(LOG_INFO, "[SHDR ID %i] Shader compiled successfully", shader);
return shader; return shader;
} }
@ -3903,7 +3914,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
if (success == GL_FALSE) if (success == GL_FALSE)
{ {
TraceLog(LOG_WARNING, "[SHDR ID %i] Failed to link shader program...", program); TRACELOG(LOG_WARNING, "[SHDR ID %i] Failed to link shader program...", program);
int maxLength = 0; int maxLength = 0;
int length; int length;
@ -3917,7 +3928,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
#endif #endif
glGetProgramInfoLog(program, maxLength, &length, log); glGetProgramInfoLog(program, maxLength, &length, log);
TraceLog(LOG_INFO, "%s", log); TRACELOG(LOG_INFO, "%s", log);
#if defined(_MSC_VER) #if defined(_MSC_VER)
RL_FREE(log); RL_FREE(log);
@ -3926,7 +3937,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad
program = 0; program = 0;
} }
else TraceLog(LOG_INFO, "[SHDR ID %i] Shader program loaded successfully", program); else TRACELOG(LOG_INFO, "[SHDR ID %i] Shader program loaded successfully", program);
#endif #endif
return program; return program;
} }
@ -4009,7 +4020,7 @@ static Shader LoadShaderDefault(void)
if (shader.id > 0) if (shader.id > 0)
{ {
TraceLog(LOG_INFO, "[SHDR ID %i] Default shader loaded successfully", shader.id); TRACELOG(LOG_INFO, "[SHDR ID %i] Default shader loaded successfully", shader.id);
// Set default shader locations: attributes locations // Set default shader locations: attributes locations
shader.locs[LOC_VERTEX_POSITION] = glGetAttribLocation(shader.id, "vertexPosition"); shader.locs[LOC_VERTEX_POSITION] = glGetAttribLocation(shader.id, "vertexPosition");
@ -4025,7 +4036,7 @@ static Shader LoadShaderDefault(void)
// changed for external custom shaders, we just use direct bindings above // changed for external custom shaders, we just use direct bindings above
//SetShaderDefaultLocations(&shader); //SetShaderDefaultLocations(&shader);
} }
else TraceLog(LOG_WARNING, "[SHDR ID %i] Default shader could not be loaded", shader.id); else TRACELOG(LOG_WARNING, "[SHDR ID %i] Default shader could not be loaded", shader.id);
return shader; return shader;
} }
@ -4115,7 +4126,7 @@ static void LoadBuffersDefault(void)
RLGL.State.vertexData[i].cCounter = 0; RLGL.State.vertexData[i].cCounter = 0;
} }
TraceLog(LOG_INFO, "Internal buffers initialized successfully (CPU)"); TRACELOG(LOG_INFO, "Internal buffers initialized successfully (CPU)");
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs // Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs
@ -4161,7 +4172,7 @@ static void LoadBuffersDefault(void)
#endif #endif
} }
TraceLog(LOG_INFO, "Internal buffers uploaded successfully (GPU)"); TRACELOG(LOG_INFO, "Internal buffers uploaded successfully (GPU)");
// Unbind the current VAO // Unbind the current VAO
if (RLGL.ExtSupported.vao) glBindVertexArray(0); if (RLGL.ExtSupported.vao) glBindVertexArray(0);
@ -4521,20 +4532,20 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
if (width != 1) width /= 2; if (width != 1) width /= 2;
if (height != 1) height /= 2; if (height != 1) height /= 2;
TraceLog(LOG_DEBUG, "Next mipmap size: %i x %i", width, height); TRACELOGD("Next mipmap size: %i x %i", width, height);
mipmapCount++; mipmapCount++;
size += (width*height*4); // Add mipmap size (in bytes) size += (width*height*4); // Add mipmap size (in bytes)
} }
TraceLog(LOG_DEBUG, "Total mipmaps required: %i", mipmapCount); TRACELOGD("Total mipmaps required: %i", mipmapCount);
TraceLog(LOG_DEBUG, "Total size of data required: %i", size); TRACELOGD("Total size of data required: %i", size);
unsigned char *temp = RL_REALLOC(data, size); unsigned char *temp = RL_REALLOC(data, size);
if (temp != NULL) data = temp; if (temp != NULL) data = temp;
else TraceLog(LOG_WARNING, "Mipmaps required memory could not be allocated"); else TRACELOG(LOG_WARNING, "Mipmaps required memory could not be allocated");
width = baseWidth; width = baseWidth;
height = baseHeight; height = baseHeight;
@ -4556,7 +4567,7 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight)
j++; j++;
} }
TraceLog(LOG_DEBUG, "Mipmap base (%ix%i)", width, height); TRACELOGD("Mipmap base (%ix%i)", width, height);
for (int mip = 1; mip < mipmapCount; mip++) for (int mip = 1; mip < mipmapCount; mip++)
{ {
@ -4627,7 +4638,7 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight)
} }
} }
TraceLog(LOG_DEBUG, "Mipmap generated successfully (%ix%i)", width, height); TRACELOGD("Mipmap generated successfully (%ix%i)", width, height);
return mipmap; return mipmap;
} }
@ -4635,7 +4646,7 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight)
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int msgType, const char *text, ...) void TRACELOG(int msgType, const char *text, ...)
{ {
va_list args; va_list args;
va_start(args, text); va_start(args, text);

View file

@ -268,7 +268,7 @@ extern void LoadFontDefault(void)
defaultFont.baseSize = (int)defaultFont.recs[0].height; defaultFont.baseSize = (int)defaultFont.recs[0].height;
TraceLog(LOG_INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id); TRACELOG(LOG_INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
} }
// Unload raylib default font // Unload raylib default font
@ -318,7 +318,7 @@ Font LoadFont(const char *fileName)
if (font.texture.id == 0) if (font.texture.id == 0)
{ {
TraceLog(LOG_WARNING, "[%s] Font could not be loaded, using default font", fileName); TRACELOG(LOG_WARNING, "[%s] Font could not be loaded, using default font", fileName);
font = GetFontDefault(); font = GetFontDefault();
} }
else SetTextureFilter(font.texture, FILTER_POINT); // By default we set point filter (best performance) else SetTextureFilter(font.texture, FILTER_POINT); // By default we set point filter (best performance)
@ -435,7 +435,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
xPosToRead = charSpacing; xPosToRead = charSpacing;
} }
TraceLog(LOG_DEBUG, "Font data parsed correctly from image"); TRACELOGD("Font data parsed correctly from image");
// NOTE: We need to remove key color borders from image to avoid weird // NOTE: We need to remove key color borders from image to avoid weird
// artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR // artifacts on texture scaling when using FILTER_BILINEAR or FILTER_TRILINEAR
@ -477,7 +477,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
font.baseSize = (int)font.recs[0].height; font.baseSize = (int)font.recs[0].height;
TraceLog(LOG_INFO, "Image file loaded correctly as Font"); TRACELOG(LOG_INFO, "Image file loaded correctly as Font");
return font; return font;
} }
@ -515,7 +515,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
// Init font for data reading // Init font for data reading
stbtt_fontinfo fontInfo; stbtt_fontinfo fontInfo;
if (!stbtt_InitFont(&fontInfo, fontBuffer, 0)) TraceLog(LOG_WARNING, "Failed to init font!"); if (!stbtt_InitFont(&fontInfo, fontBuffer, 0)) TRACELOG(LOG_WARNING, "Failed to init font!");
// Calculate font scale factor // Calculate font scale factor
float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, (float)fontSize); float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, (float)fontSize);
@ -590,17 +590,17 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
int chX1, chY1, chX2, chY2; int chX1, chY1, chX2, chY2;
stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2); stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2);
TraceLog(LOG_DEBUG, "Character box measures: %i, %i, %i, %i", chX1, chY1, chX2 - chX1, chY2 - chY1); TRACELOGD("Character box measures: %i, %i, %i, %i", chX1, chY1, chX2 - chX1, chY2 - chY1);
TraceLog(LOG_DEBUG, "Character offsetY: %i", (int)((float)ascent*scaleFactor) + chY1); TRACELOGD("Character offsetY: %i", (int)((float)ascent*scaleFactor) + chY1);
*/ */
} }
RL_FREE(fontBuffer); RL_FREE(fontBuffer);
if (genFontChars) RL_FREE(fontChars); if (genFontChars) RL_FREE(fontChars);
} }
else TraceLog(LOG_WARNING, "[%s] TTF file could not be opened", fileName); else TRACELOG(LOG_WARNING, "[%s] TTF file could not be opened", fileName);
#else #else
TraceLog(LOG_WARNING, "[%s] TTF support is disabled", fileName); TRACELOG(LOG_WARNING, "[%s] TTF support is disabled", fileName);
#endif #endif
return chars; return chars;
@ -680,7 +680,7 @@ Image GenImageFontAtlas(const CharInfo *chars, Rectangle **charRecs, int charsCo
} }
else if (packMethod == 1) // Use Skyline rect packing algorythm (stb_pack_rect) else if (packMethod == 1) // Use Skyline rect packing algorythm (stb_pack_rect)
{ {
TraceLog(LOG_DEBUG, "Using Skyline packing algorythm!"); TRACELOGD("Using Skyline packing algorythm!");
stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context)); stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context));
stbrp_node *nodes = (stbrp_node *)RL_MALLOC(charsCount*sizeof(*nodes)); stbrp_node *nodes = (stbrp_node *)RL_MALLOC(charsCount*sizeof(*nodes));
@ -718,7 +718,7 @@ Image GenImageFontAtlas(const CharInfo *chars, Rectangle **charRecs, int charsCo
} }
} }
} }
else TraceLog(LOG_WARNING, "Character could not be packed: %i", i); else TRACELOG(LOG_WARNING, "Character could not be packed: %i", i);
} }
RL_FREE(rects); RL_FREE(rects);
@ -760,7 +760,7 @@ void UnloadFont(Font font)
RL_FREE(font.chars); RL_FREE(font.chars);
RL_FREE(font.recs); RL_FREE(font.recs);
TraceLog(LOG_DEBUG, "Unloaded sprite font data"); TRACELOGD("Unloaded sprite font data");
} }
} }
@ -1682,7 +1682,7 @@ static Font LoadBMFont(const char *fileName)
if (fntFile == NULL) if (fntFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] FNT file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] FNT file could not be opened", fileName);
return font; return font;
} }
@ -1695,20 +1695,20 @@ static Font LoadBMFont(const char *fileName)
searchPoint = strstr(buffer, "lineHeight"); searchPoint = strstr(buffer, "lineHeight");
sscanf(searchPoint, "lineHeight=%i base=%i scaleW=%i scaleH=%i", &fontSize, &base, &texWidth, &texHeight); sscanf(searchPoint, "lineHeight=%i base=%i scaleW=%i scaleH=%i", &fontSize, &base, &texWidth, &texHeight);
TraceLog(LOG_DEBUG, "[%s] Font size: %i", fileName, fontSize); TRACELOGD("[%s] Font size: %i", fileName, fontSize);
TraceLog(LOG_DEBUG, "[%s] Font texture scale: %ix%i", fileName, texWidth, texHeight); TRACELOGD("[%s] Font texture scale: %ix%i", fileName, texWidth, texHeight);
fgets(buffer, MAX_BUFFER_SIZE, fntFile); fgets(buffer, MAX_BUFFER_SIZE, fntFile);
searchPoint = strstr(buffer, "file"); searchPoint = strstr(buffer, "file");
sscanf(searchPoint, "file=\"%128[^\"]\"", texFileName); sscanf(searchPoint, "file=\"%128[^\"]\"", texFileName);
TraceLog(LOG_DEBUG, "[%s] Font texture filename: %s", fileName, texFileName); TRACELOGD("[%s] Font texture filename: %s", fileName, texFileName);
fgets(buffer, MAX_BUFFER_SIZE, fntFile); fgets(buffer, MAX_BUFFER_SIZE, fntFile);
searchPoint = strstr(buffer, "count"); searchPoint = strstr(buffer, "count");
sscanf(searchPoint, "count=%i", &charsCount); sscanf(searchPoint, "count=%i", &charsCount);
TraceLog(LOG_DEBUG, "[%s] Font num chars: %i", fileName, charsCount); TRACELOGD("[%s] Font num chars: %i", fileName, charsCount);
// Compose correct path using route of .fnt file (fileName) and texFileName // Compose correct path using route of .fnt file (fileName) and texFileName
char *texPath = NULL; char *texPath = NULL;
@ -1728,7 +1728,7 @@ static Font LoadBMFont(const char *fileName)
strncat(texPath, fileName, strlen(fileName) - strlen(lastSlash) + 1); strncat(texPath, fileName, strlen(fileName) - strlen(lastSlash) + 1);
strncat(texPath, texFileName, strlen(texFileName)); strncat(texPath, texFileName, strlen(texFileName));
TraceLog(LOG_DEBUG, "[%s] Font texture loading path: %s", fileName, texPath); TRACELOGD("[%s] Font texture loading path: %s", fileName, texPath);
Image imFont = LoadImage(texPath); Image imFont = LoadImage(texPath);
@ -1779,7 +1779,7 @@ static Font LoadBMFont(const char *fileName)
UnloadFont(font); UnloadFont(font);
font = GetFontDefault(); font = GetFontDefault();
} }
else TraceLog(LOG_INFO, "[%s] Font loaded successfully", fileName); else TRACELOG(LOG_INFO, "[%s] Font loaded successfully", fileName);
return font; return font;
} }

View file

@ -269,7 +269,7 @@ Image LoadImage(const char *fileName)
else if (imgBpp == 4) image.format = UNCOMPRESSED_R32G32B32A32; else if (imgBpp == 4) image.format = UNCOMPRESSED_R32G32B32A32;
else else
{ {
TraceLog(LOG_WARNING, "[%s] Image fileformat not supported", fileName); TRACELOG(LOG_WARNING, "[%s] Image fileformat not supported", fileName);
UnloadImage(image); UnloadImage(image);
} }
} }
@ -289,10 +289,10 @@ Image LoadImage(const char *fileName)
#if defined(SUPPORT_FILEFORMAT_ASTC) #if defined(SUPPORT_FILEFORMAT_ASTC)
else if (IsFileExtension(fileName, ".astc")) image = LoadASTC(fileName); else if (IsFileExtension(fileName, ".astc")) image = LoadASTC(fileName);
#endif #endif
else TraceLog(LOG_WARNING, "[%s] Image fileformat not supported", fileName); else TRACELOG(LOG_WARNING, "[%s] Image fileformat not supported", fileName);
if (image.data != NULL) TraceLog(LOG_INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height); if (image.data != NULL) TRACELOG(LOG_INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
else TraceLog(LOG_WARNING, "[%s] Image could not be loaded", fileName); else TRACELOG(LOG_WARNING, "[%s] Image could not be loaded", fileName);
return image; return image;
} }
@ -350,7 +350,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
if (rawFile == NULL) if (rawFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] RAW image file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] RAW image file could not be opened", fileName);
} }
else else
{ {
@ -367,7 +367,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
// Check if data has been read successfully // Check if data has been read successfully
if (bytes < size) if (bytes < size)
{ {
TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName); TRACELOG(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
RL_FREE(image.data); RL_FREE(image.data);
} }
@ -397,7 +397,7 @@ Texture2D LoadTexture(const char *fileName)
texture = LoadTextureFromImage(image); texture = LoadTextureFromImage(image);
UnloadImage(image); UnloadImage(image);
} }
else TraceLog(LOG_WARNING, "Texture could not be created"); else TRACELOG(LOG_WARNING, "Texture could not be created");
return texture; return texture;
} }
@ -412,7 +412,7 @@ Texture2D LoadTextureFromImage(Image image)
{ {
texture.id = rlLoadTexture(image.data, image.width, image.height, image.format, image.mipmaps); texture.id = rlLoadTexture(image.data, image.width, image.height, image.format, image.mipmaps);
} }
else TraceLog(LOG_WARNING, "Texture could not be loaded from Image"); else TRACELOG(LOG_WARNING, "Texture could not be loaded from Image");
texture.width = image.width; texture.width = image.width;
texture.height = image.height; texture.height = image.height;
@ -444,7 +444,7 @@ void UnloadTexture(Texture2D texture)
{ {
rlDeleteTextures(texture.id); rlDeleteTextures(texture.id);
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data from VRAM (GPU)", texture.id); TRACELOG(LOG_INFO, "[TEX ID %i] Unloaded texture data from VRAM (GPU)", texture.id);
} }
} }
@ -461,12 +461,12 @@ Color *GetImageData(Image image)
Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color)); Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color));
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); if (image.format >= COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
else else
{ {
if ((image.format == UNCOMPRESSED_R32) || if ((image.format == UNCOMPRESSED_R32) ||
(image.format == UNCOMPRESSED_R32G32B32) || (image.format == UNCOMPRESSED_R32G32B32) ||
(image.format == UNCOMPRESSED_R32G32B32A32)) TraceLog(LOG_WARNING, "32bit pixel format converted to 8bit per channel"); (image.format == UNCOMPRESSED_R32G32B32A32)) TRACELOG(LOG_WARNING, "32bit pixel format converted to 8bit per channel");
for (int i = 0, k = 0; i < image.width*image.height; i++) for (int i = 0, k = 0; i < image.width*image.height; i++)
{ {
@ -576,7 +576,7 @@ Vector4 *GetImageDataNormalized(Image image)
{ {
Vector4 *pixels = (Vector4 *)RL_MALLOC(image.width*image.height*sizeof(Vector4)); Vector4 *pixels = (Vector4 *)RL_MALLOC(image.width*image.height*sizeof(Vector4));
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); if (image.format >= COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
else else
{ {
for (int i = 0, k = 0; i < image.width*image.height; i++) for (int i = 0, k = 0; i < image.width*image.height; i++)
@ -783,11 +783,11 @@ Image GetTextureData(Texture2D texture)
// original texture format is retrieved on RPI... // original texture format is retrieved on RPI...
image.format = UNCOMPRESSED_R8G8B8A8; image.format = UNCOMPRESSED_R8G8B8A8;
#endif #endif
TraceLog(LOG_INFO, "Texture pixel data obtained successfully"); TRACELOG(LOG_INFO, "Texture pixel data obtained successfully");
} }
else TraceLog(LOG_WARNING, "Texture pixel data could not be obtained"); else TRACELOG(LOG_WARNING, "Texture pixel data could not be obtained");
} }
else TraceLog(LOG_WARNING, "Compressed texture data could not be obtained"); else TRACELOG(LOG_WARNING, "Compressed texture data could not be obtained");
return image; return image;
} }
@ -852,8 +852,8 @@ void ExportImage(Image image, const char *fileName)
RL_FREE(imgData); RL_FREE(imgData);
#endif #endif
if (success != 0) TraceLog(LOG_INFO, "Image exported successfully: %s", fileName); if (success != 0) TRACELOG(LOG_INFO, "Image exported successfully: %s", fileName);
else TraceLog(LOG_WARNING, "Image could not be exported."); else TRACELOG(LOG_WARNING, "Image could not be exported.");
} }
// Export image as code file (.h) defining an array of bytes // Export image as code file (.h) defining an array of bytes
@ -977,7 +977,7 @@ void ImageToPOT(Image *image, Color fillColor)
} }
} }
TraceLog(LOG_WARNING, "Image converted to POT: (%ix%i) -> (%ix%i)", image->width, image->height, potWidth, potHeight); TRACELOG(LOG_WARNING, "Image converted to POT: (%ix%i) -> (%ix%i)", image->width, image->height, potWidth, potHeight);
RL_FREE(pixels); // Free pixels data RL_FREE(pixels); // Free pixels data
RL_FREE(image->data); // Free old image data RL_FREE(image->data); // Free old image data
@ -1167,7 +1167,7 @@ void ImageFormat(Image *image, int newFormat)
#endif #endif
} }
} }
else TraceLog(LOG_WARNING, "Image data format is compressed, can not be converted"); else TRACELOG(LOG_WARNING, "Image data format is compressed, can not be converted");
} }
} }
@ -1178,11 +1178,11 @@ void ImageAlphaMask(Image *image, Image alphaMask)
{ {
if ((image->width != alphaMask.width) || (image->height != alphaMask.height)) if ((image->width != alphaMask.width) || (image->height != alphaMask.height))
{ {
TraceLog(LOG_WARNING, "Alpha mask must be same size as image"); TRACELOG(LOG_WARNING, "Alpha mask must be same size as image");
} }
else if (image->format >= COMPRESSED_DXT1_RGB) else if (image->format >= COMPRESSED_DXT1_RGB)
{ {
TraceLog(LOG_WARNING, "Alpha mask can not be applied to compressed data formats"); TRACELOG(LOG_WARNING, "Alpha mask can not be applied to compressed data formats");
} }
else else
{ {
@ -1340,11 +1340,11 @@ TextureCubemap LoadTextureCubemap(Image image, int layoutType)
for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, size*i, size, size }, WHITE); for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, size*i, size, size }, WHITE);
cubemap.id = rlLoadTextureCubemap(faces.data, size, faces.format); cubemap.id = rlLoadTextureCubemap(faces.data, size, faces.format);
if (cubemap.id == 0) TraceLog(LOG_WARNING, "Cubemap image could not be loaded."); if (cubemap.id == 0) TRACELOG(LOG_WARNING, "Cubemap image could not be loaded.");
UnloadImage(faces); UnloadImage(faces);
} }
else TraceLog(LOG_WARNING, "Cubemap image layout can not be detected."); else TRACELOG(LOG_WARNING, "Cubemap image layout can not be detected.");
return cubemap; return cubemap;
} }
@ -1389,7 +1389,7 @@ void ImageCrop(Image *image, Rectangle crop)
// Reformat 32bit RGBA image to original format // Reformat 32bit RGBA image to original format
ImageFormat(image, format); ImageFormat(image, format);
} }
else TraceLog(LOG_WARNING, "Image can not be cropped, crop rectangle out of bounds"); else TRACELOG(LOG_WARNING, "Image can not be cropped, crop rectangle out of bounds");
} }
// Crop image depending on alpha value // Crop image depending on alpha value
@ -1592,15 +1592,15 @@ void ImageMipmaps(Image *image)
if (mipWidth < 1) mipWidth = 1; if (mipWidth < 1) mipWidth = 1;
if (mipHeight < 1) mipHeight = 1; if (mipHeight < 1) mipHeight = 1;
TraceLog(LOG_DEBUG, "Next mipmap level: %i x %i - current size %i", mipWidth, mipHeight, mipSize); TRACELOGD("Next mipmap level: %i x %i - current size %i", mipWidth, mipHeight, mipSize);
mipCount++; mipCount++;
mipSize += GetPixelDataSize(mipWidth, mipHeight, image->format); // Add mipmap size (in bytes) mipSize += GetPixelDataSize(mipWidth, mipHeight, image->format); // Add mipmap size (in bytes)
} }
TraceLog(LOG_DEBUG, "Mipmaps available: %i - Mipmaps required: %i", image->mipmaps, mipCount); TRACELOGD("Mipmaps available: %i - Mipmaps required: %i", image->mipmaps, mipCount);
TraceLog(LOG_DEBUG, "Mipmaps total size required: %i", mipSize); TRACELOGD("Mipmaps total size required: %i", mipSize);
TraceLog(LOG_DEBUG, "Image data memory start address: 0x%x", image->data); TRACELOGD("Image data memory start address: 0x%x", image->data);
if (image->mipmaps < mipCount) if (image->mipmaps < mipCount)
{ {
@ -1609,9 +1609,9 @@ void ImageMipmaps(Image *image)
if (temp != NULL) if (temp != NULL)
{ {
image->data = temp; // Assign new pointer (new size) to store mipmaps data image->data = temp; // Assign new pointer (new size) to store mipmaps data
TraceLog(LOG_DEBUG, "Image data memory point reallocated: 0x%x", temp); TRACELOGD("Image data memory point reallocated: 0x%x", temp);
} }
else TraceLog(LOG_WARNING, "Mipmaps required memory could not be allocated"); else TRACELOG(LOG_WARNING, "Mipmaps required memory could not be allocated");
// Pointer to allocated memory point where store next mipmap level data // Pointer to allocated memory point where store next mipmap level data
unsigned char *nextmip = (unsigned char *)image->data + GetPixelDataSize(image->width, image->height, image->format); unsigned char *nextmip = (unsigned char *)image->data + GetPixelDataSize(image->width, image->height, image->format);
@ -1623,7 +1623,7 @@ void ImageMipmaps(Image *image)
for (int i = 1; i < mipCount; i++) for (int i = 1; i < mipCount; i++)
{ {
TraceLog(LOG_DEBUG, "Gen mipmap level: %i (%i x %i) - size: %i - offset: 0x%x", i, mipWidth, mipHeight, mipSize, nextmip); TRACELOGD("Gen mipmap level: %i (%i x %i) - size: %i - offset: 0x%x", i, mipWidth, mipHeight, mipSize, nextmip);
ImageResize(&imCopy, mipWidth, mipHeight); // Uses internally Mitchell cubic downscale filter ImageResize(&imCopy, mipWidth, mipHeight); // Uses internally Mitchell cubic downscale filter
@ -1643,7 +1643,7 @@ void ImageMipmaps(Image *image)
UnloadImage(imCopy); UnloadImage(imCopy);
} }
else TraceLog(LOG_WARNING, "Image mipmaps already available"); else TRACELOG(LOG_WARNING, "Image mipmaps already available");
} }
// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
@ -1656,13 +1656,13 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
if (image->format >= COMPRESSED_DXT1_RGB) if (image->format >= COMPRESSED_DXT1_RGB)
{ {
TraceLog(LOG_WARNING, "Compressed data formats can not be dithered"); TRACELOG(LOG_WARNING, "Compressed data formats can not be dithered");
return; return;
} }
if ((rBpp + gBpp + bBpp + aBpp) > 16) if ((rBpp + gBpp + bBpp + aBpp) > 16)
{ {
TraceLog(LOG_WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp)); TRACELOG(LOG_WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
} }
else else
{ {
@ -1672,7 +1672,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8)) if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8))
{ {
TraceLog(LOG_WARNING, "Image format is already 16bpp or lower, dithering could have no effect"); TRACELOG(LOG_WARNING, "Image format is already 16bpp or lower, dithering could have no effect");
} }
// Define new image format, check if desired bpp match internal known format // Define new image format, check if desired bpp match internal known format
@ -1682,7 +1682,7 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
else else
{ {
image->format = 0; image->format = 0;
TraceLog(LOG_WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp); TRACELOG(LOG_WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
} }
// NOTE: We will store the dithered data as unsigned short (16bpp) // NOTE: We will store the dithered data as unsigned short (16bpp)
@ -1796,7 +1796,7 @@ Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount)
if (palCount >= maxPaletteSize) if (palCount >= maxPaletteSize)
{ {
i = image.width*image.height; // Finish palette get i = image.width*image.height; // Finish palette get
TraceLog(LOG_WARNING, "Image palette is greater than %i colors!", maxPaletteSize); TRACELOG(LOG_WARNING, "Image palette is greater than %i colors!", maxPaletteSize);
} }
} }
} }
@ -1825,13 +1825,13 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
if ((srcRec.x + srcRec.width) > src.width) if ((srcRec.x + srcRec.width) > src.width)
{ {
srcRec.width = src.width - srcRec.x; srcRec.width = src.width - srcRec.x;
TraceLog(LOG_WARNING, "Source rectangle width out of bounds, rescaled width: %i", srcRec.width); TRACELOG(LOG_WARNING, "Source rectangle width out of bounds, rescaled width: %i", srcRec.width);
} }
if ((srcRec.y + srcRec.height) > src.height) if ((srcRec.y + srcRec.height) > src.height)
{ {
srcRec.height = src.height - srcRec.y; srcRec.height = src.height - srcRec.y;
TraceLog(LOG_WARNING, "Source rectangle height out of bounds, rescaled height: %i", srcRec.height); TRACELOG(LOG_WARNING, "Source rectangle height out of bounds, rescaled height: %i", srcRec.height);
} }
Image srcCopy = ImageCopy(src); // Make a copy of source image to work with it Image srcCopy = ImageCopy(src); // Make a copy of source image to work with it
@ -1987,7 +1987,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
if (fontSize > imSize.y) if (fontSize > imSize.y)
{ {
float scaleFactor = fontSize/imSize.y; float scaleFactor = fontSize/imSize.y;
TraceLog(LOG_INFO, "Image text scaled by factor: %f", scaleFactor); TRACELOG(LOG_INFO, "Image text scaled by factor: %f", scaleFactor);
// Using nearest-neighbor scaling algorithm for default font // Using nearest-neighbor scaling algorithm for default font
if (font.texture.id == GetFontDefault().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor)); if (font.texture.id == GetFontDefault().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor));
@ -2635,7 +2635,7 @@ void SetTextureFilter(Texture2D texture, int filterMode)
} }
else else
{ {
TraceLog(LOG_WARNING, "[TEX ID %i] No mipmaps available for TRILINEAR texture filtering", texture.id); TRACELOG(LOG_WARNING, "[TEX ID %i] No mipmaps available for TRILINEAR texture filtering", texture.id);
// RL_FILTER_LINEAR - tex filter: BILINEAR, no mipmaps // RL_FILTER_LINEAR - tex filter: BILINEAR, no mipmaps
rlTextureParameters(texture.id, RL_TEXTURE_MIN_FILTER, RL_FILTER_LINEAR); rlTextureParameters(texture.id, RL_TEXTURE_MIN_FILTER, RL_FILTER_LINEAR);
@ -2986,7 +2986,7 @@ static Image LoadAnimatedGIF(const char *fileName, int *frames, int **delays)
if (gifFile == NULL) if (gifFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] Animated GIF file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] Animated GIF file could not be opened", fileName);
} }
else else
{ {
@ -3065,7 +3065,7 @@ static Image LoadDDS(const char *fileName)
if (ddsFile == NULL) if (ddsFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] DDS file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] DDS file could not be opened", fileName);
} }
else else
{ {
@ -3076,7 +3076,7 @@ static Image LoadDDS(const char *fileName)
if ((ddsHeaderId[0] != 'D') || (ddsHeaderId[1] != 'D') || (ddsHeaderId[2] != 'S') || (ddsHeaderId[3] != ' ')) if ((ddsHeaderId[0] != 'D') || (ddsHeaderId[1] != 'D') || (ddsHeaderId[2] != 'S') || (ddsHeaderId[3] != ' '))
{ {
TraceLog(LOG_WARNING, "[%s] DDS file does not seem to be a valid image", fileName); TRACELOG(LOG_WARNING, "[%s] DDS file does not seem to be a valid image", fileName);
} }
else else
{ {
@ -3085,11 +3085,11 @@ static Image LoadDDS(const char *fileName)
// Get the image header // Get the image header
fread(&ddsHeader, sizeof(DDSHeader), 1, ddsFile); fread(&ddsHeader, sizeof(DDSHeader), 1, ddsFile);
TraceLog(LOG_DEBUG, "[%s] DDS file header size: %i", fileName, sizeof(DDSHeader)); TRACELOGD("[%s] DDS file header size: %i", fileName, sizeof(DDSHeader));
TraceLog(LOG_DEBUG, "[%s] DDS file pixel format size: %i", fileName, ddsHeader.ddspf.size); TRACELOGD("[%s] DDS file pixel format size: %i", fileName, ddsHeader.ddspf.size);
TraceLog(LOG_DEBUG, "[%s] DDS file pixel format flags: 0x%x", fileName, ddsHeader.ddspf.flags); TRACELOGD("[%s] DDS file pixel format flags: 0x%x", fileName, ddsHeader.ddspf.flags);
TraceLog(LOG_DEBUG, "[%s] DDS file format: 0x%x", fileName, ddsHeader.ddspf.fourCC); TRACELOGD("[%s] DDS file format: 0x%x", fileName, ddsHeader.ddspf.fourCC);
TraceLog(LOG_DEBUG, "[%s] DDS file bit count: 0x%x", fileName, ddsHeader.ddspf.rgbBitCount); TRACELOGD("[%s] DDS file bit count: 0x%x", fileName, ddsHeader.ddspf.rgbBitCount);
image.width = ddsHeader.width; image.width = ddsHeader.width;
image.height = ddsHeader.height; image.height = ddsHeader.height;
@ -3179,7 +3179,7 @@ static Image LoadDDS(const char *fileName)
if (ddsHeader.mipmapCount > 1) size = ddsHeader.pitchOrLinearSize*2; if (ddsHeader.mipmapCount > 1) size = ddsHeader.pitchOrLinearSize*2;
else size = ddsHeader.pitchOrLinearSize; else size = ddsHeader.pitchOrLinearSize;
TraceLog(LOG_DEBUG, "Pitch or linear size: %i", ddsHeader.pitchOrLinearSize); TRACELOGD("Pitch or linear size: %i", ddsHeader.pitchOrLinearSize);
image.data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char)); image.data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char));
@ -3245,7 +3245,7 @@ static Image LoadPKM(const char *fileName)
if (pkmFile == NULL) if (pkmFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] PKM file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] PKM file could not be opened", fileName);
} }
else else
{ {
@ -3256,7 +3256,7 @@ static Image LoadPKM(const char *fileName)
if ((pkmHeader.id[0] != 'P') || (pkmHeader.id[1] != 'K') || (pkmHeader.id[2] != 'M') || (pkmHeader.id[3] != ' ')) if ((pkmHeader.id[0] != 'P') || (pkmHeader.id[1] != 'K') || (pkmHeader.id[2] != 'M') || (pkmHeader.id[3] != ' '))
{ {
TraceLog(LOG_WARNING, "[%s] PKM file does not seem to be a valid image", fileName); TRACELOG(LOG_WARNING, "[%s] PKM file does not seem to be a valid image", fileName);
} }
else else
{ {
@ -3265,9 +3265,9 @@ static Image LoadPKM(const char *fileName)
pkmHeader.width = ((pkmHeader.width & 0x00FF) << 8) | ((pkmHeader.width & 0xFF00) >> 8); pkmHeader.width = ((pkmHeader.width & 0x00FF) << 8) | ((pkmHeader.width & 0xFF00) >> 8);
pkmHeader.height = ((pkmHeader.height & 0x00FF) << 8) | ((pkmHeader.height & 0xFF00) >> 8); pkmHeader.height = ((pkmHeader.height & 0x00FF) << 8) | ((pkmHeader.height & 0xFF00) >> 8);
TraceLog(LOG_DEBUG, "PKM (ETC) image width: %i", pkmHeader.width); TRACELOGD("PKM (ETC) image width: %i", pkmHeader.width);
TraceLog(LOG_DEBUG, "PKM (ETC) image height: %i", pkmHeader.height); TRACELOGD("PKM (ETC) image height: %i", pkmHeader.height);
TraceLog(LOG_DEBUG, "PKM (ETC) image format: %i", pkmHeader.format); TRACELOGD("PKM (ETC) image format: %i", pkmHeader.format);
image.width = pkmHeader.width; image.width = pkmHeader.width;
image.height = pkmHeader.height; image.height = pkmHeader.height;
@ -3338,7 +3338,7 @@ static Image LoadKTX(const char *fileName)
if (ktxFile == NULL) if (ktxFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] KTX image file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] KTX image file could not be opened", fileName);
} }
else else
{ {
@ -3350,7 +3350,7 @@ static Image LoadKTX(const char *fileName)
if ((ktxHeader.id[1] != 'K') || (ktxHeader.id[2] != 'T') || (ktxHeader.id[3] != 'X') || if ((ktxHeader.id[1] != 'K') || (ktxHeader.id[2] != 'T') || (ktxHeader.id[3] != 'X') ||
(ktxHeader.id[4] != ' ') || (ktxHeader.id[5] != '1') || (ktxHeader.id[6] != '1')) (ktxHeader.id[4] != ' ') || (ktxHeader.id[5] != '1') || (ktxHeader.id[6] != '1'))
{ {
TraceLog(LOG_WARNING, "[%s] KTX file does not seem to be a valid file", fileName); TRACELOG(LOG_WARNING, "[%s] KTX file does not seem to be a valid file", fileName);
} }
else else
{ {
@ -3358,9 +3358,9 @@ static Image LoadKTX(const char *fileName)
image.height = ktxHeader.height; image.height = ktxHeader.height;
image.mipmaps = ktxHeader.mipmapLevels; image.mipmaps = ktxHeader.mipmapLevels;
TraceLog(LOG_DEBUG, "KTX (ETC) image width: %i", ktxHeader.width); TRACELOGD("KTX (ETC) image width: %i", ktxHeader.width);
TraceLog(LOG_DEBUG, "KTX (ETC) image height: %i", ktxHeader.height); TRACELOGD("KTX (ETC) image height: %i", ktxHeader.height);
TraceLog(LOG_DEBUG, "KTX (ETC) image format: 0x%x", ktxHeader.glInternalFormat); TRACELOGD("KTX (ETC) image format: 0x%x", ktxHeader.glInternalFormat);
unsigned char unused; unsigned char unused;
@ -3420,7 +3420,7 @@ static int SaveKTX(Image image, const char *fileName)
FILE *ktxFile = fopen(fileName, "wb"); FILE *ktxFile = fopen(fileName, "wb");
if (ktxFile == NULL) TraceLog(LOG_WARNING, "[%s] KTX image file could not be created", fileName); if (ktxFile == NULL) TRACELOG(LOG_WARNING, "[%s] KTX image file could not be created", fileName);
else else
{ {
KTXHeader ktxHeader; KTXHeader ktxHeader;
@ -3452,7 +3452,7 @@ static int SaveKTX(Image image, const char *fileName)
// NOTE: We can save into a .ktx all PixelFormats supported by raylib, including compressed formats like DXT, ETC or ASTC // NOTE: We can save into a .ktx all PixelFormats supported by raylib, including compressed formats like DXT, ETC or ASTC
if (ktxHeader.glFormat == -1) TraceLog(LOG_WARNING, "Image format not supported for KTX export."); if (ktxHeader.glFormat == -1) TRACELOG(LOG_WARNING, "Image format not supported for KTX export.");
else else
{ {
success = fwrite(&ktxHeader, sizeof(KTXHeader), 1, ktxFile); success = fwrite(&ktxHeader, sizeof(KTXHeader), 1, ktxFile);
@ -3547,7 +3547,7 @@ static Image LoadPVR(const char *fileName)
if (pvrFile == NULL) if (pvrFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] PVR file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] PVR file could not be opened", fileName);
} }
else else
{ {
@ -3566,7 +3566,7 @@ static Image LoadPVR(const char *fileName)
if ((pvrHeader.id[0] != 'P') || (pvrHeader.id[1] != 'V') || (pvrHeader.id[2] != 'R') || (pvrHeader.id[3] != 3)) if ((pvrHeader.id[0] != 'P') || (pvrHeader.id[1] != 'V') || (pvrHeader.id[2] != 'R') || (pvrHeader.id[3] != 3))
{ {
TraceLog(LOG_WARNING, "[%s] PVR file does not seem to be a valid image", fileName); TRACELOG(LOG_WARNING, "[%s] PVR file does not seem to be a valid image", fileName);
} }
else else
{ {
@ -3627,7 +3627,7 @@ static Image LoadPVR(const char *fileName)
fread(image.data, dataSize, 1, pvrFile); fread(image.data, dataSize, 1, pvrFile);
} }
} }
else if (pvrVersion == 52) TraceLog(LOG_INFO, "PVR v2 not supported, update your files to PVR v3"); else if (pvrVersion == 52) TRACELOG(LOG_INFO, "PVR v2 not supported, update your files to PVR v3");
fclose(pvrFile); // Close file pointer fclose(pvrFile); // Close file pointer
} }
@ -3665,7 +3665,7 @@ static Image LoadASTC(const char *fileName)
if (astcFile == NULL) if (astcFile == NULL)
{ {
TraceLog(LOG_WARNING, "[%s] ASTC file could not be opened", fileName); TRACELOG(LOG_WARNING, "[%s] ASTC file could not be opened", fileName);
} }
else else
{ {
@ -3676,7 +3676,7 @@ static Image LoadASTC(const char *fileName)
if ((astcHeader.id[3] != 0x5c) || (astcHeader.id[2] != 0xa1) || (astcHeader.id[1] != 0xab) || (astcHeader.id[0] != 0x13)) if ((astcHeader.id[3] != 0x5c) || (astcHeader.id[2] != 0xa1) || (astcHeader.id[1] != 0xab) || (astcHeader.id[0] != 0x13))
{ {
TraceLog(LOG_WARNING, "[%s] ASTC file does not seem to be a valid image", fileName); TRACELOG(LOG_WARNING, "[%s] ASTC file does not seem to be a valid image", fileName);
} }
else else
{ {
@ -3684,9 +3684,9 @@ static Image LoadASTC(const char *fileName)
image.width = 0x00000000 | ((int)astcHeader.width[2] << 16) | ((int)astcHeader.width[1] << 8) | ((int)astcHeader.width[0]); image.width = 0x00000000 | ((int)astcHeader.width[2] << 16) | ((int)astcHeader.width[1] << 8) | ((int)astcHeader.width[0]);
image.height = 0x00000000 | ((int)astcHeader.height[2] << 16) | ((int)astcHeader.height[1] << 8) | ((int)astcHeader.height[0]); image.height = 0x00000000 | ((int)astcHeader.height[2] << 16) | ((int)astcHeader.height[1] << 8) | ((int)astcHeader.height[0]);
TraceLog(LOG_DEBUG, "ASTC image width: %i", image.width); TRACELOGD("ASTC image width: %i", image.width);
TraceLog(LOG_DEBUG, "ASTC image height: %i", image.height); TRACELOGD("ASTC image height: %i", image.height);
TraceLog(LOG_DEBUG, "ASTC image blocks: %ix%i", astcHeader.blockX, astcHeader.blockY); TRACELOGD("ASTC image blocks: %ix%i", astcHeader.blockX, astcHeader.blockY);
image.mipmaps = 1; // NOTE: ASTC format only contains one mipmap level image.mipmaps = 1; // NOTE: ASTC format only contains one mipmap level
@ -3704,7 +3704,7 @@ static Image LoadASTC(const char *fileName)
if (bpp == 8) image.format = COMPRESSED_ASTC_4x4_RGBA; if (bpp == 8) image.format = COMPRESSED_ASTC_4x4_RGBA;
else if (bpp == 2) image.format = COMPRESSED_ASTC_8x8_RGBA; else if (bpp == 2) image.format = COMPRESSED_ASTC_8x8_RGBA;
} }
else TraceLog(LOG_WARNING, "[%s] ASTC block size configuration not supported", fileName); else TRACELOG(LOG_WARNING, "[%s] ASTC block size configuration not supported", fileName);
} }
fclose(astcFile); fclose(astcFile);

View file

@ -195,7 +195,7 @@ static int android_read(void *cookie, char *buf, int size)
static int android_write(void *cookie, const char *buf, int size) static int android_write(void *cookie, const char *buf, int size)
{ {
TraceLog(LOG_ERROR, "Can't provide write access to the APK"); TRACELOG(LOG_ERROR, "Can't provide write access to the APK");
return EACCES; return EACCES;
} }
@ -252,7 +252,7 @@ void UWPSendMessage(UWPMessage *msg)
UWPInMessageId++; UWPInMessageId++;
UWPInMessages[UWPInMessageId] = msg; UWPInMessages[UWPInMessageId] = msg;
} }
else TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP inbound Message."); else TRACELOG(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP inbound Message.");
} }
void SendMessageToUWP(UWPMessage *msg) void SendMessageToUWP(UWPMessage *msg)
@ -262,7 +262,7 @@ void SendMessageToUWP(UWPMessage *msg)
UWPOutMessageId++; UWPOutMessageId++;
UWPOutMessages[UWPOutMessageId] = msg; UWPOutMessages[UWPOutMessageId] = msg;
} }
else TraceLog(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP outward Message."); else TRACELOG(LOG_WARNING, "[UWP Messaging] Not enough array space to register new UWP outward Message.");
} }
bool HasMessageFromUWP(void) bool HasMessageFromUWP(void)

View file

@ -38,10 +38,11 @@
#if defined(SUPPORT_TRACELOG_DEBUG) #if defined(SUPPORT_TRACELOG_DEBUG)
#define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__) #define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__)
#else #else
#define TRACELOGD(...) void(0) #define TRACELOGD(...) (void)0
#endif #endif
#else #else
#define TRACELOG(level, ...) void(0) #define TRACELOG(level, ...) (void)0
#define TRACELOGD(...) (void)0
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------