ADDED: SetWindowIcons()
to set multiple icon image sizes
This commit is contained in:
parent
d26a56d4e1
commit
1347a15539
2 changed files with 60 additions and 13 deletions
|
@ -941,7 +941,8 @@ RLAPI void ToggleFullscreen(void); // Toggle wind
|
|||
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
||||
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
||||
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
|
||||
|
|
48
src/rcore.c
48
src/rcore.c
|
@ -1554,10 +1554,18 @@ void ClearWindowState(unsigned int flags)
|
|||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if (image.data == NULL)
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
GLFWimage icon[1] = { 0 };
|
||||
|
@ -1571,6 +1579,44 @@ void SetWindowIcon(Image image)
|
|||
glfwSetWindowIcon(CORE.Window.handle, 1, icon);
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if ((images == NULL) || (count <= 0))
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
int valid = 0;
|
||||
GLFWimage *icons = RL_CALLOC(count, sizeof(GLFWimage));
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (images[i].format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
icons[valid].width = images[i].width;
|
||||
icons[valid].height = images[i].height;
|
||||
icons[valid].pixels = (unsigned char *)images[i].data;
|
||||
|
||||
valid++;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
// NOTE: Images data is copied internally before this function returns
|
||||
glfwSetWindowIcon(CORE.Window.handle, valid, icons);
|
||||
|
||||
RL_FREE(icons);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue