Added a program icon.

This commit is contained in:
2026-04-06 19:25:37 -07:00
parent 9473a05a9b
commit 0a89186e20
3 changed files with 117232 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ UFLAGS =
# hence we ignore the incompliance in our code.
# NOTE: We allow function declrations with specifying void
# (ex, void test() is allowed).
FLAGS = -ansi -pedantic -pedantic-errors -Wno-long-long \
FLAGS = -ansi -pedantic -pedantic-errors -Wno-long-long -Wno-overlength-strings \
-Wno-strict-prototypes -Wall -Wextra -fno-caret-diagnostics \
-fno-show-column -Wno-missing-field-initializers \
-Wno-unused-function -Wno-unused-parameter -Wno-unused-variable \
+117200
View File
File diff suppressed because it is too large Load Diff
+31
View File
@@ -25,6 +25,8 @@
#include <x86intrin.h>
#endif
#include "program_icon.c"
#define RESOLUTION_WIDTH 960
#define RESOLUTION_HEIGHT 540
@@ -727,12 +729,40 @@ S32 main(S32 argc, char *argv[])
if(Window) {
SDL_Renderer *Renderer;
SDL_Surface* icon;
Uint32 rmask, gmask, bmask, amask;
SDL_DisplayMode display_mode;
SDL_GetCurrentDisplayMode(0, &display_mode);
Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_PRESENTVSYNC);
SDL_SetWindowPosition(Window, (display_mode.w - RESOLUTION_WIDTH),
(display_mode.h - RESOLUTION_HEIGHT));
/* Set program icon. */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int shift = (program_icon.bytes_per_pixel == 3) ? 8 : 0;
rmask = 0xff000000 >> shift;
gmask = 0x00ff0000 >> shift;
bmask = 0x0000ff00 >> shift;
amask = 0x000000ff >> shift;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = (program_icon.bytes_per_pixel == 3) ? 0 : 0xff000000;
#endif
icon = SDL_CreateRGBSurfaceFrom(
(void *)program_icon.pixel_data,
program_icon.width, program_icon.height,
program_icon.bytes_per_pixel * 8,
program_icon.bytes_per_pixel * program_icon.width,
rmask, gmask, bmask, amask);
SDL_SetWindowIcon(Window, icon);
SDL_FreeSurface(icon);
/* "Wayland needs an event loop and rendering or it won't function."
* https://github.com/libsdl-org/SDL/issues/7699#issuecomment-1545684792 */
/* NOTE: This means that we need to readraw to even resize the
@@ -751,6 +781,7 @@ S32 main(S32 argc, char *argv[])
void *BaseAddress = (void *)(0);
#endif
GlobalRunning = TRUE;
Dimension = SDLGetWindowDimension(Window);