Skip to content
Snippets Groups Projects
Commit 18f5c499 authored by YANG TIANYI's avatar YANG TIANYI
Browse files

Ajoute src sdl2

parent a567f8a0
Branches
No related merge requests found
sdl2.c 0 → 100644
#include "sdl2.h"
void sdl_init() {
int const width = 1280;
int const height = 720;
context = (SDLContext){NULL, NULL, .width = 0, .height = 0};
if (SDL_Init(SDL_INIT_VIDEO)) {
return;
}
SDL_Window *window =
SDL_CreateWindow("Sokoban", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_SHOWN);
if (!window) {
return;
}
SDL_Renderer *renderer =
SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
context = (SDLContext){
.window = window, .renderer = renderer, .width = width, .height = height};
}
void sdl_quit() {
SDL_DestroyWindow(context.window);
SDL_DestroyRenderer(context.renderer);
context.window = NULL;
context.renderer = NULL;
SDL_Quit();
}
sdl2.h 0 → 100644
#pragma once
#include <SDL2/SDL.h>
typedef struct SDLContext {
SDL_Window *window;
SDL_Renderer *renderer;
int width;
int height;
} SDLContext;
/* @brief
* Initialise une variable global `context` de type SDLContext
*
* Si il y a erreur pendant l'intialisation:
* context.window = NULL
* ou
* context.renderer = NULL
*
* Les deux cas sont à testé !
*
*/
void sdl_init();
/**
* nettoie la variable global context
*/
void sdl_quit();
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment