diff --git a/window/window.c b/window/window.c new file mode 100644 index 0000000000000000000000000000000000000000..531a11837d61ee674c310bb0914c131f2b3a62e5 --- /dev/null +++ b/window/window.c @@ -0,0 +1,32 @@ +#include "window.h" +#include <SDL2/SDL.h> +#include <stdio.h> +#include <stdlib.h> + +SDL_Window * initWindow(int width, int height,int x_pos, int y_pos, char * window_name) +{ + SDL_Window * window; + + if (SDL_Init(SDL_INIT_VIDEO)) + { + SDL_Log("Error : SDL initialisation - %s\n", SDL_GetError()); // l'initialisation de la SDL a échoué + exit(EXIT_FAILURE); + } + + window = SDL_CreateWindow( + window_name, // window title + x_pos, // initial x position + y_pos, // initial y position + 640, // width, in pixels + 480, // height, in pixels + SDL_WINDOW_OPENGL + ); + + if (window == NULL) { + printf("Error : Window initialisation - %s\n", SDL_GetError()); + window = NULL; + } + + return window; + +} \ No newline at end of file diff --git a/window/window.h b/window/window.h new file mode 100644 index 0000000000000000000000000000000000000000..189e100bc6a17a54f123b52fcf7a1349b3517dce --- /dev/null +++ b/window/window.h @@ -0,0 +1,10 @@ +#ifndef __WINDOW_H__ +#define __WINDOW_H__ + +#include <SDL2/SDL.h> +#include <stdio.h> +#include <stdlib.h> + +SDL_Window * initWindow(int , int, int, int, char *); + +#endif \ No newline at end of file