MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / main

Function main

deps/SDL2/Xcode-iOS/Demos/src/rectangles.c:40–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40int
41main(int argc, char *argv[])
42{
43
44 SDL_Window *window;
45 SDL_Renderer *renderer;
46 int done;
47 SDL_Event event;
48 int windowW;
49 int windowH;
50
51 /* initialize SDL */
52 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
53 fatalError("Could not initialize SDL");
54 }
55
56 /* seed random number generator */
57 srand(time(NULL));
58
59 /* create window and renderer */
60 window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
61 if (window == 0) {
62 fatalError("Could not initialize Window");
63 }
64 renderer = SDL_CreateRenderer(window, -1, 0);
65 if (!renderer) {
66 fatalError("Could not create renderer");
67 }
68
69 SDL_GetWindowSize(window, &windowW, &windowH);
70 SDL_RenderSetLogicalSize(renderer, windowW, windowH);
71
72 /* Fill screen with black */
73 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
74 SDL_RenderClear(renderer);
75
76 /* Enter render loop, waiting for user to quit */
77 done = 0;
78 while (!done) {
79 while (SDL_PollEvent(&event)) {
80 if (event.type == SDL_QUIT) {
81 done = 1;
82 }
83 }
84 render(renderer);
85 SDL_Delay(1);
86 }
87
88 /* shutdown SDL */
89 SDL_Quit();
90
91 return 0;
92}

Callers

nothing calls this directly

Calls 12

SDL_InitFunction · 0.85
fatalErrorFunction · 0.85
SDL_CreateWindowFunction · 0.85
SDL_CreateRendererFunction · 0.85
SDL_GetWindowSizeFunction · 0.85
SDL_RenderSetLogicalSizeFunction · 0.85
SDL_SetRenderDrawColorFunction · 0.85
SDL_RenderClearFunction · 0.85
SDL_PollEventFunction · 0.85
SDL_QuitFunction · 0.85
renderFunction · 0.70
SDL_DelayFunction · 0.50

Tested by

no test coverage detected