diff --git a/init.c b/init.c new file mode 100644 index 0000000000000000000000000000000000000000..0567513b2f808779c0c90f8bdd87483945e9eb7f --- /dev/null +++ b/init.c @@ -0,0 +1,42 @@ +#include <SDL.h> +#include <SDL_video.h> +#include <stdbool.h> + +enum screen_size { + SCREEN_WIDTH = 640, + SCREEN_HEIGHT = 480, +}; + +int main(int argc, char **argv) { + // Ggf. noch andere Subsyteme + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + SDL_Log("Initialisierung fehlgeschlagen! SDL_Error: %s\n", SDL_GetError()); + return -1; + } + + SDL_Window *window = SDL_CreateWindow("Fenster", SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, + SCREEN_HEIGHT, SDL_WINDOW_SHOWN); + if (window == NULL) { + SDL_Log("Fenster nicht erstellt! SDL_Error: %s\n", SDL_GetError()); + return -1; + } + + /* Magie */ + SDL_GetWindowSurface(window); + SDL_UpdateWindowSurface(window); + + SDL_Event e; + bool quit = false; + while (quit == false) { + while (SDL_PollEvent(&e)) { + if (e.type == SDL_QUIT) + quit = true; + } + } + /* Magie Ende */ + + SDL_DestroyWindow(window); + SDL_Quit(); + return 0; +}