[core] Review TRACELOG() messages, categorized

This commit is contained in:
raysan5 2020-03-27 18:06:09 +01:00
parent 70ed975b99
commit c7e9951795

View File

@ -565,7 +565,8 @@ 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, "RPI: Reconfiguring 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
@ -584,13 +585,9 @@ 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, "RPI: Failed to change keyboard mode (not a local terminal)");
}
else
{
ioctl(STDIN_FILENO, KDSKBMODE, K_XLATE);
} }
else ioctl(STDIN_FILENO, KDSKBMODE, K_XLATE);
// Register terminal restore when program finishes // Register terminal restore when program finishes
atexit(RestoreTerminal); atexit(RestoreTerminal);
@ -598,7 +595,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, "RPI: Restoring 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);
@ -634,19 +631,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, "ANDROID: Window orientation set as portrait");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TRACELOG(LOG_INFO, "LANDSCAPE window orientation"); else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TRACELOG(LOG_INFO, "ANDROID: Window orientation set as landscape");
// 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, "ANDROID: Window orientation changed to portrait");
} }
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, "ANDROID: Window orientation changed to landscape");
} }
//AConfiguration_getDensity(CORE.Android.app->config); //AConfiguration_getDensity(CORE.Android.app->config);
@ -659,7 +656,7 @@ void InitWindow(int width, int height, const char *title)
InitAssetManager(CORE.Android.app->activity->assetManager, CORE.Android.app->activity->internalDataPath); InitAssetManager(CORE.Android.app->activity->assetManager, CORE.Android.app->activity->internalDataPath);
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;
@ -895,7 +892,7 @@ void ToggleFullscreen(void)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
if (!monitor) if (!monitor)
{ {
TRACELOG(LOG_WARNING, "Failed to get monitor"); TRACELOG(LOG_WARNING, "GLFW: 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;
} }
@ -914,7 +911,7 @@ void ToggleFullscreen(void)
else EM_ASM(document.exitFullscreen();); else EM_ASM(document.exitFullscreen(););
#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, "SYSTEM: Failed to toggle to windowed mode");
#endif #endif
} }
@ -935,7 +932,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, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
#endif #endif
} }
@ -960,17 +957,17 @@ void SetWindowPosition(int x, int y)
void SetWindowMonitor(int monitor) void SetWindowMonitor(int monitor)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
int monitorCount; int monitorCount = 0;
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
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, "GLFW: 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, "GLFW: Failed to find selected monitor");
#endif #endif
} }
@ -1072,7 +1069,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, "GLFW: Failed to find selected monitor");
#endif #endif
return 0; return 0;
} }
@ -1089,7 +1086,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, "GLFW: Failed to find selected monitor");
#endif #endif
return 0; return 0;
} }
@ -1107,7 +1104,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, "GLFW: Failed to find selected monitor");
#endif #endif
return 0; return 0;
} }
@ -1125,7 +1122,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, "GLFW: Failed to find selected monitor");
#endif #endif
return 0; return 0;
} }
@ -1152,7 +1149,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, "GLFW: Failed to find selected monitor");
#endif #endif
return ""; return "";
} }
@ -1277,7 +1274,6 @@ void EndDrawing(void)
rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2)
#if defined(SUPPORT_GIF_RECORDING) #if defined(SUPPORT_GIF_RECORDING)
#define GIF_RECORD_FRAMERATE 10 #define GIF_RECORD_FRAMERATE 10
if (gifRecording) if (gifRecording)
@ -1634,7 +1630,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, "TIMER: Target time per frame: %02.03f milliseconds", (float)CORE.Time.target*1000);
} }
// Returns current FPS // Returns current FPS
@ -1884,7 +1880,8 @@ 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); // TODO: Verification required for log
TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path);
} }
// Check if the file exists // Check if the file exists
@ -2098,7 +2095,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, "FILEIO: Failed to open requested directory"); // Maybe it's a file...
dirFilesCount = counter; dirFilesCount = counter;
*fileCount = dirFilesCount; *fileCount = dirFilesCount;
@ -2263,7 +2260,7 @@ int LoadStorageValue(int position)
if (fileData != NULL) if (fileData != NULL)
{ {
if (dataSize < (position*4)) TRACELOG(LOG_WARNING, "Storage position could not be found"); if (dataSize < (position*4)) TRACELOG(LOG_WARNING, "SYSTEM: Failed to find storage position");
else else
{ {
int *dataPtr = (int *)fileData; int *dataPtr = (int *)fileData;
@ -2287,7 +2284,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, "SYSTEM: Provided URL is not valid");
} }
else else
{ {
@ -2656,7 +2653,7 @@ Vector2 GetTouchPosition(int index)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB) || defined(PLATFORM_RPI)
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, "INPUT: 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))
@ -2708,7 +2705,7 @@ static bool InitGraphicsDevice(int width, int height)
if (!glfwInit()) if (!glfwInit())
{ {
TRACELOG(LOG_WARNING, "Failed to initialize GLFW"); TRACELOG(LOG_WARNING, "GLFW: Failed to initialize GLFW");
return false; return false;
} }
@ -2718,7 +2715,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, "GLFW: Failed to get primary monitor");
return false; return false;
} }
const GLFWvidmode *mode = glfwGetVideoMode(monitor); const GLFWvidmode *mode = glfwGetVideoMode(monitor);
@ -2839,7 +2836,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, "SYSTEM: 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),
@ -2883,18 +2880,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, " > 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!
@ -2925,7 +2922,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, "DISPLAY: Trying to enable VSYNC");
} }
#endif // PLATFORM_DESKTOP || PLATFORM_WEB #endif // PLATFORM_DESKTOP || PLATFORM_WEB
@ -2953,7 +2950,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, "DISPLAY: Trying to enable MSAA x4");
} }
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] =
@ -3031,7 +3028,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, "DISPLAY: Failed to get function eglGetPlatformDisplayEXT");
return false; return false;
} }
@ -3049,7 +3046,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, "DISPLAY: Failed to initialize EGL device");
return false; return false;
} }
@ -3059,7 +3056,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, "DISPLAY: Failed to initialize EGL device");
return false; return false;
} }
@ -3069,14 +3066,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, "DISPLAY: 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, "DISPLAY: Failed to initialize EGL device");
return false; return false;
} }
} }
@ -3085,7 +3082,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, "DISPLAY: Failed to choose first EGL configuration");
return false; return false;
} }
@ -3123,14 +3120,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, "DISPLAY: 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, "DISPLAY: Failed to create EGL context");
return false; return false;
} }
@ -3145,7 +3142,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, "DISPLAY: Failed to initialize EGL device");
return false; return false;
} }
@ -3153,7 +3150,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, "DISPLAY: Failed to initialize EGL device");
return false; return false;
} }
@ -3167,7 +3164,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, "DISPLAY: Failed to create EGL context");
return false; return false;
} }
#endif #endif
@ -3237,7 +3234,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, "DISPLAY: Failed to attach EGL rendering context to EGL surface");
return false; return false;
} }
else else
@ -3246,11 +3243,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
@ -3314,7 +3311,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, "DISPLAY: 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;
@ -3344,12 +3341,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, "DISPLAY: Downscale matrix generated, content will be rendered at (%ix%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, "DISPLAY: Upscaling required: Screen size (%ix%i) smaller than display size (%ix%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;
@ -3395,7 +3392,7 @@ static void InitTimer(void)
{ {
CORE.Time.base = (unsigned long long int)now.tv_sec*1000000000LLU + (unsigned long long int)now.tv_nsec; CORE.Time.base = (unsigned long long int)now.tv_sec*1000000000LLU + (unsigned long long int)now.tv_nsec;
} }
else TRACELOG(LOG_WARNING, "No hi-resolution timer available"); else TRACELOG(LOG_WARNING, "TIMER: Hi-resolution timer not available");
#endif #endif
CORE.Time.previous = GetTime(); // Get time as double CORE.Time.previous = GetTime(); // Get time as double
@ -3839,7 +3836,7 @@ static void PollInputEvents(void)
} }
else CORE.Input.Gamepad.currentState[i][button] = 0; else CORE.Input.Gamepad.currentState[i][button] = 0;
//TRACELOGD("Gamepad %d, button %d: Digital: %d, Analog: %g", gamepadState.index, j, gamepadState.digitalButton[j], gamepadState.analogButton[j]); //TRACELOGD("INPUT: 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
@ -3905,7 +3902,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, "GLFW: Error: %i Description: %s", error, description);
} }
// GLFW3 Srolling Callback, runs on mouse wheel // GLFW3 Srolling Callback, runs on mouse wheel
@ -3939,7 +3936,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, "SYSTEM: Finish animated GIF recording");
} }
else else
{ {
@ -3959,7 +3956,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, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
} }
} }
else else
@ -4114,7 +4111,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
#endif #endif
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
// Android: Process activity lifecycle commands // ANDROID: Process activity lifecycle commands
static void AndroidCommandCallback(struct android_app *app, int32_t cmd) static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
{ {
switch (cmd) switch (cmd)
@ -4217,7 +4214,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
} }
} }
// Android: Get input events // ANDROID: Get input events
static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
{ {
// If additional inputs are required check: // If additional inputs are required check:
@ -4363,12 +4360,12 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte
if (event->isFullscreen) if (event->isFullscreen)
{ {
CORE.Window.fullscreen = true; CORE.Window.fullscreen = true;
TRACELOG(LOG_INFO, "Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight); TRACELOG(LOG_INFO, "WEB: Canvas scaled to fullscreen. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight);
} }
else else
{ {
CORE.Window.fullscreen = false; CORE.Window.fullscreen = false;
TRACELOG(LOG_INFO, "Canvas scaled to windowed. ElementSize: (%ix%i), ScreenSize(%ix%i)", event->elementWidth, event->elementHeight, event->screenWidth, event->screenHeight); TRACELOG(LOG_INFO, "WEB: 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
@ -4530,7 +4527,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, "RPI: Failed to change keyboard mode (SSH keyboard?)");
} }
else else
{ {
@ -4568,8 +4565,6 @@ 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++)
{ {
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
if (keysBuffer[i] == 0x1b) if (keysBuffer[i] == 0x1b)
@ -4637,8 +4632,6 @@ static void ProcessKeyboard(void)
} }
else else
{ {
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))
{ {
@ -4712,7 +4705,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, "RPI: Failed 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
@ -4758,7 +4751,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, "RPI: Failed to create input device thread for %s, out of worker slots", device);
return; return;
} }
@ -4766,7 +4759,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, "RPI: Failed to open input device (error: %d)", device, worker->fd);
return; return;
} }
worker->fd = fd; worker->fd = fd;
@ -4866,8 +4859,8 @@ 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 an interesting device
TRACELOG(LOG_INFO, "Opening input device [%s] (%s%s%s%s%s)", device, TRACELOG(LOG_INFO, "RPI: 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 " : "",
@ -4878,7 +4871,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, "RPI: Failed to create input device thread: %s (error: %d)", device, error);
worker->threadId = 0; worker->threadId = 0;
close(fd); close(fd);
} }
@ -4899,7 +4892,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, "RPI: Found duplicate touchscreen, 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);
} }
@ -5078,7 +5071,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;
TRACELOGD("KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode); TRACELOGD("RPI: KEY_%s ScanCode: %4i KeyCode: %4i", event.value == 0 ? "UP":"DOWN", event.code, keycode);
} }
} }
} }
@ -5141,7 +5134,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, "RPI: Failed to open Gamepad device, no gamepad available");
} }
else else
{ {
@ -5152,8 +5145,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, "RPI: Failed to create gamepad input event thread");
else TRACELOG(LOG_INFO, "Gamepad device initialized successfully"); else TRACELOG(LOG_INFO, "RPI: Gamepad device initialized successfully");
} }
} }
} }
@ -5187,7 +5180,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)
{ {
TRACELOGD("Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value); TRACELOGD("RPI: Gamepad button: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS) if (gamepadEvent.number < MAX_GAMEPAD_BUTTONS)
{ {
@ -5200,7 +5193,7 @@ static void *GamepadThread(void *arg)
} }
else if (gamepadEvent.type == JS_EVENT_AXIS) else if (gamepadEvent.type == JS_EVENT_AXIS)
{ {
TRACELOGD("Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value); TRACELOGD("RPI: Gamepad axis: %i, value: %i", gamepadEvent.number, gamepadEvent.value);
if (gamepadEvent.number < MAX_GAMEPAD_AXIS) if (gamepadEvent.number < MAX_GAMEPAD_AXIS)
{ {