Ticket #14530: sdl_repro.c

File sdl_repro.c, 1011 bytes (added by PushmePullyu, 8 months ago)
Line 
1#include <stdio.h>
2
3#define SDL_MAIN_HANDLED
4#include "SDL.h"
5
6// gcc -o sdl_repro sdl_repro.c $(sdl2-config --cflags) $(sdl2-config --libs)
7// = gcc -o sdl_repro sdl_repro.c -I/usr/include/SDL2 -D_REENTRANT -lSDL2
8// SDL_RENDER_DRIVER="software" ./sdl_repro
9
10void fail() {
11 printf("error: %s\n", SDL_GetError());
12 exit(1);
13}
14
15int main() {
16 SDL_Init(SDL_INIT_EVERYTHING);
17
18 SDL_Window *window = NULL;
19 SDL_Renderer *renderer = NULL;
20
21 // Create window
22 window = SDL_CreateWindow("myWindow", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
23 if (!window)
24 fail();
25
26 // Create renderer
27 printf("Creating renderer\n");
28 renderer = SDL_CreateRenderer(window, -1, 0);
29 if (!renderer)
30 fail();
31
32 // Destroy renderer
33 printf("Destroying renderer\n");
34 SDL_DestroyRenderer(renderer);
35 if (SDL_GetRenderer(window))
36 fail();
37
38 // Recreate renderer
39 printf("Recreating renderer\n");
40 renderer = SDL_CreateRenderer(window, -1, 0);
41 if (!renderer)
42 fail();
43
44 printf("Quitting\n");
45 SDL_Quit();
46 return 0;
47}