From e3568b7d97b429f2673c406318fbe2b645d3fc6c Mon Sep 17 00:00:00 2001
From: maberet <marcberet1@gmail.com>
Date: Mon, 20 Jun 2022 17:14:00 +0200
Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20fen=C3=AAtre=20+=20renderer=20S?=
 =?UTF-8?q?nakes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 travail_individuel/Beret/snakes/main.c | 56 ++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/travail_individuel/Beret/snakes/main.c b/travail_individuel/Beret/snakes/main.c
index e69de29..ecb1565 100644
--- a/travail_individuel/Beret/snakes/main.c
+++ b/travail_individuel/Beret/snakes/main.c
@@ -0,0 +1,56 @@
+#include <SDL2/SDL.h>
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+    (void)argc;
+    (void)argv;
+
+    SDL_Window 
+       *window_1 = NULL;
+    SDL_Renderer
+        *renderer = NULL;
+
+    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
+    SDL_Log("Error : SDL initialisation - %s\n", 
+             SDL_GetError());                // l'initialisation de la SDL a échoué 
+    exit(EXIT_FAILURE);}
+
+    SDL_DisplayMode DM;
+    SDL_GetCurrentDisplayMode(0, &DM);
+
+    /* Création de la fenêtre de gauche */
+    window_1 = SDL_CreateWindow("Premier dessin",
+                            SDL_WINDOWPOS_CENTERED,
+                            SDL_WINDOWPOS_CENTERED, DM.w * 0.66,
+                            DM.h * 0.66,
+                            SDL_WINDOW_OPENGL);              
+
+    if (window_1 == NULL) {
+        SDL_Log("Error : SDL window 1 creation - %s\n", 
+                SDL_GetError());                 // échec de la création de la fenêtre
+        SDL_Quit();                              // On referme la SDL       
+        exit(EXIT_FAILURE);
+    }
+
+    renderer = SDL_CreateRenderer(window_1, -1,
+                                SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
+    if (renderer == NULL) {SDL_DestroyRenderer(renderer);                                  // Attention : on suppose que les NULL sont maintenus !!
+    renderer = NULL;
+
+    SDL_DestroyWindow(window_1);
+    window_1 = NULL;};
+
+    //draw(renderer);                                       
+    SDL_RenderPresent(renderer);
+    SDL_Delay(2000); 
+    SDL_DestroyRenderer(renderer);                                  // Attention : on suppose que les NULL sont maintenus !!
+    renderer = NULL;
+
+    SDL_DestroyWindow(window_1);
+    window_1 = NULL;
+    SDL_Quit();                                
+
+    return 0;
+}
-- 
GitLab