From c4bd214cf07c68476c4ce972766c24ee54a982f6 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 5 Feb 2017 03:00:35 +0100 Subject: [PATCH] Added function SetWindowIcon() Only DESKTOP platforms (Windows, Linus, OSX) --- src/core.c | 21 ++++++++++++++++++++- src/raylib.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 4ce32a057..04dd0540f 100644 --- a/src/core.c +++ b/src/core.c @@ -524,7 +524,7 @@ bool IsWindowMinimized(void) #endif } -// Fullscreen toggle +// Fullscreen toggle (only PLATFORM_DESKTOP) void ToggleFullscreen(void) { #if defined(PLATFORM_DESKTOP) @@ -540,6 +540,25 @@ void ToggleFullscreen(void) #endif } +// Set icon for window (only PLATFORM_DESKTOP) +void SetWindowIcon(Image image) +{ +#if defined(PLATFORM_DESKTOP) + ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); + + GLFWimage icon[1]; + + icon[0].width = image.width; + icon[0].height = image.height; + icon[0].pixels = (unsigned char *)image.data; + + // NOTE: We only support one image icon + glfwSetWindowIcon(window, 1, icon); + + // TODO: Support multi-image icons --> image.mipmaps +#endif +} + // Get current screen width int GetScreenWidth(void) { diff --git a/src/raylib.h b/src/raylib.h index f5b908db7..5a1304fce 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -638,6 +638,7 @@ RLAPI void CloseWindow(void); // Close Windo RLAPI bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed RLAPI bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus) RLAPI void ToggleFullscreen(void); // Fullscreen toggle (only PLATFORM_DESKTOP) +RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height