mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2024-11-16 19:09:15 +01:00
Add Linux taskbar icon (#6)
This commit is contained in:
parent
a6e34bb49b
commit
25a3837b37
BIN
icons/512.png
Normal file
BIN
icons/512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@ -30,6 +30,9 @@
|
||||
#include "SDL_syswm.h"
|
||||
#endif
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "../../lib/rt64/src/contrib/stb/stb_image.h"
|
||||
|
||||
extern "C" void init();
|
||||
/*extern "C"*/ void start(ultramodern::WindowHandle window_handle, const ultramodern::audio_callbacks_t* audio_callbacks, const ultramodern::input_callbacks_t* input_callbacks);
|
||||
|
||||
@ -55,10 +58,60 @@ ultramodern::gfx_callbacks_t::gfx_data_t create_gfx() {
|
||||
return {};
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
bool SetImageAsIcon(const char* filename, SDL_Window* window)
|
||||
{
|
||||
// Read data
|
||||
int width, height, bytesPerPixel;
|
||||
void* data = stbi_load(filename, &width, &height, &bytesPerPixel, 4);
|
||||
|
||||
// Calculate pitch
|
||||
int pitch;
|
||||
pitch = width * 4;
|
||||
pitch = (pitch + 3) & ~3;
|
||||
|
||||
// Setup relevance bitmask
|
||||
int Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
Rmask = 0x000000FF;
|
||||
Gmask = 0x0000FF00;
|
||||
Bmask = 0x00FF0000;
|
||||
Amask = 0xFF000000;
|
||||
#else
|
||||
Rmask = 0xFF000000;
|
||||
Gmask = 0x00FF0000;
|
||||
Bmask = 0x0000FF00;
|
||||
Amask = 0x000000FF;
|
||||
#endif
|
||||
|
||||
SDL_Surface* surface;
|
||||
if (data != NULL) {
|
||||
surface = SDL_CreateRGBSurfaceFrom(data, width, height, 32, pitch, Rmask, Gmask,
|
||||
Bmask, Amask);
|
||||
}
|
||||
|
||||
if (surface == NULL) {
|
||||
if (data != NULL) {
|
||||
stbi_image_free(data);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
SDL_SetWindowIcon(window,surface);
|
||||
SDL_FreeSurface(surface);
|
||||
stbi_image_free(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_Window* window;
|
||||
|
||||
ultramodern::WindowHandle create_window(ultramodern::gfx_callbacks_t::gfx_data_t) {
|
||||
window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, SDL_WINDOW_RESIZABLE );
|
||||
#if defined(__linux__)
|
||||
SetImageAsIcon("icons/512.png",window);
|
||||
#endif
|
||||
|
||||
if (window == nullptr) {
|
||||
exit_error("Failed to create window: %s\n", SDL_GetError());
|
||||
|
Loading…
Reference in New Issue
Block a user