The-Powder-Toy/src/WindowIcon.cpp
Tamás Bálint Misius 1ef78c019a
Migrate embedded files to custom targets
Meson generators seem to be a dying feature, evidenced by the fact that they have been in a state of isolation from the rest of the language for several years at this point:

 - very few things accept generator outputs as inputs, not even generators themselves do
 - unlike configured files, their outputs aren't guaranteed to be always synthesized, and yet they can't be passed as dependencies to other targets
 - they accept strictly one input and can't depend on other files

This makes them really hard to work with in a context that would require either a project resource or a target. Custom targets don't have any of these shortcomings, so this commit migrates embedded files over to those. A real shame, considering that generators can be used anywhere and are generally less messy than custom targets.
2024-12-17 16:15:27 +01:00

16 lines
462 B
C++

#include "Format.h"
#include "graphics/VideoBuffer.h"
#include "WindowIcon.h"
#include "icon_exe_png.h"
void WindowIcon(SDL_Window *window)
{
if (auto image = format::PixelsFromPNG(icon_exe_png.AsCharSpan()))
{
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(image->data(), image->Size().X, image->Size().Y, 32, image->Size().Y * sizeof(pixel), 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
SDL_SetWindowIcon(window, icon);
SDL_FreeSurface(icon);
}
}