BootSplash viewer thing
This commit is contained in:
@@ -0,0 +1,101 @@
|
|||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
printf("Troposphere boot splash app thing");
|
||||||
|
if (argc < 2){
|
||||||
|
printf("Add path to Boot splash png");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* image_path = argv[1];
|
||||||
|
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) < 0){
|
||||||
|
|
||||||
|
fprintf(stderr, "SDL_Init error %s\n", SDL_GetError());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IMG_Init(IMG_INIT_PNG) && IMG_INIT_PNG){
|
||||||
|
|
||||||
|
fprintf(stderr,"SDL IMG_INIT_PNG Failed to ... well init", IMG_GetError);
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDL_Window* AppWindow = SDL_CreateWindow("Fullscreen Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,0,0,SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN);
|
||||||
|
|
||||||
|
|
||||||
|
if (!AppWindow){
|
||||||
|
fprintf(stderr,"App window init Crashed %s\n", SDL_GetError());
|
||||||
|
IMG_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
|
||||||
|
SDL_Renderer* renderer = SDL_CreateRenderer(AppWindow,-1,SDL_RENDERER_ACCELERATED);
|
||||||
|
|
||||||
|
SDL_Texture* BootSplash_Texture = IMG_LoadTexture(renderer, image_path);
|
||||||
|
|
||||||
|
if(!BootSplash_Texture){
|
||||||
|
fprintf(stderr, "Failed to load texture %s\n", IMG_GetError());
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(AppWindow);
|
||||||
|
|
||||||
|
IMG_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int running = 1 ;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
|
||||||
|
while(SDL_PollEvent(&event)){
|
||||||
|
if (event.type == SDL_QUIT){
|
||||||
|
running =0;
|
||||||
|
} else if (event.type == SDL_KEYDOWN){
|
||||||
|
if (event.key.keysym.sym == SDLK_ESCAPE ||event.key.keysym.sym == SDLK_q ){
|
||||||
|
running =0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0,0,0,255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
SDL_RenderCopy(renderer,BootSplash_Texture,NULL,NULL);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDL_DestroyTexture(BootSplash_Texture);
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(AppWindow);
|
||||||
|
IMG_Quit();
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# Compiler and Flags
|
||||||
|
CC := gcc
|
||||||
|
CFLAGS := -Wall -Wextra -O2
|
||||||
|
|
||||||
|
# Query static compiler flags and libraries using pkg-config
|
||||||
|
PKG_CFLAGS := $(shell pkg-config --static --cflags sdl2 SDL2_image)
|
||||||
|
PKG_LIBS := $(shell pkg-config --static --libs sdl2 SDL2_image)
|
||||||
|
|
||||||
|
# Additional low-level system libraries required for static SDL2/PNG linking
|
||||||
|
EXTRA_LIBS := -lpng -lz -lm -lpthread -ldl
|
||||||
|
|
||||||
|
# Combine all libraries
|
||||||
|
LIBS := $(PKG_LIBS) $(EXTRA_LIBS)
|
||||||
|
|
||||||
|
# Target executable name
|
||||||
|
TARGET := viewer
|
||||||
|
SRC := main.c
|
||||||
|
|
||||||
|
.PHONY: all clean check
|
||||||
|
|
||||||
|
# Default target
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
# Compile and statically link the binary
|
||||||
|
$(TARGET): $(SRC)
|
||||||
|
$(CC) $(CFLAGS) $(PKG_CFLAGS) $< -o $@ $(LIBS)
|
||||||
|
|
||||||
|
# Check if the generated executable is truly statically linked
|
||||||
|
check: $(TARGET)
|
||||||
|
@file $(TARGET)
|
||||||
|
@echo "--- Dynamic Library Dependencies (should show 'not a dynamic executable') ---"
|
||||||
|
@-ldd $(TARGET) || true
|
||||||
|
|
||||||
|
# Clean up built artifacts
|
||||||
|
clean:
|
||||||
|
rm -f $(TARGET)
|
||||||
Reference in New Issue
Block a user