-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
55 lines (47 loc) · 1.26 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include "SDL2_gfxPrimitives.h"
#define WIDTH 640
#define HEIGHT 480
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO))
{
printf ("SDL_Init Error: %s", SDL_GetError());
return 1;
}
SDL_Window *window = SDL_CreateWindow("SDL2_gfx test", 100, 100, WIDTH, HEIGHT, SDL_WINDOW_OPENGL);
if (window == NULL)
{
printf ("SDL_CreateWindow Error: %s", SDL_GetError());
SDL_Quit();
return 2;
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == NULL)
{
SDL_DestroyWindow(window);
printf ("SDL_CreateRenderer Error: %s", SDL_GetError());
SDL_Quit();
return 3;
}
SDL_Event e;
int quit = 0;
while (!quit)
{
if (SDL_PollEvent(&e))
{
if (e.type == SDL_QUIT)
quit = 1;
}
SDL_SetRenderDrawColor(renderer, 0, 0, 0xFF, 0xFF);
SDL_RenderClear(renderer);
thickLineColor(renderer, 0, 0, WIDTH, HEIGHT, 20, 0xFF00FFFF) ;
thickLineColor(renderer, 0, HEIGHT, WIDTH, 0, 20, 0xFF00FFFF) ;
SDL_RenderPresent(renderer);
SDL_Delay(10);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}