I am trying to use SDL2 in C language compiled with GCC but the events don't work, for example, I can't close the window with SDL_QUIT. Is anything wrong on the code, please ?
#include <stdlib.h>
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc, char** argv)
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stdout,"Échec\n", SDL_GetError());
return -1;
}
SDL_Window* windowImg = NULL;
SDL_Renderer* renderImg = NULL;
int quit = 0;
SDL_Event e;
windowImg = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 400, 400, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
renderImg = SDL_CreateRenderer(windowImg, -1, SDL_RENDERER_ACCELERATED);
while (!quit) {
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
quit = 1;
break;
}
}
}
SDL_DestroyWindow(windowImg);
SDL_Quit();
return 0;
}
Okay, I forgot to link libraries in the build options > linker options : -lSDL2main -lSDL2