Files
Troposphere/include/shell/boot/main.c
T

102 lines
1.9 KiB
C
Raw Normal View History

2026-07-31 00:02:54 +03:00
#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;
}