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

Function loop

deps/SDL2/test/testwm2.c:50–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void
51loop()
52{
53 int i;
54 SDL_Event event;
55 /* Check for events */
56 while (SDL_PollEvent(&event)) {
57 SDLTest_CommonEvent(state, &event, &done);
58
59 if (event.type == SDL_WINDOWEVENT) {
60 if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
61 SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
62 if (window) {
63 SDL_Log("Window %d resized to %dx%d\n",
64 event.window.windowID,
65 event.window.data1,
66 event.window.data2);
67 }
68 }
69 if (event.window.event == SDL_WINDOWEVENT_MOVED) {
70 SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
71 if (window) {
72 SDL_Log("Window %d moved to %d,%d (display %s)\n",
73 event.window.windowID,
74 event.window.data1,
75 event.window.data2,
76 SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
77 }
78 }
79 }
80 if (event.type == SDL_KEYUP) {
81 SDL_bool updateCursor = SDL_FALSE;
82
83 if (event.key.keysym.sym == SDLK_LEFT) {
84 --system_cursor;
85 if (system_cursor < 0) {
86 system_cursor = SDL_NUM_SYSTEM_CURSORS - 1;
87 }
88 updateCursor = SDL_TRUE;
89 } else if (event.key.keysym.sym == SDLK_RIGHT) {
90 ++system_cursor;
91 if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) {
92 system_cursor = 0;
93 }
94 updateCursor = SDL_TRUE;
95 }
96 if (updateCursor) {
97 SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]);
98 SDL_FreeCursor(cursor);
99 cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor);
100 SDL_SetCursor(cursor);
101 }
102 }
103 }
104
105 for (i = 0; i < state->num_windows; ++i) {
106 SDL_Renderer *renderer = state->renderers[i];
107 SDL_RenderClear(renderer);

Callers 1

mainFunction · 0.70

Calls 11

SDL_PollEventFunction · 0.85
SDLTest_CommonEventFunction · 0.85
SDL_GetWindowFromIDFunction · 0.85
SDL_LogFunction · 0.85
SDL_GetDisplayNameFunction · 0.85
SDL_FreeCursorFunction · 0.85
SDL_CreateSystemCursorFunction · 0.85
SDL_SetCursorFunction · 0.85
SDL_RenderClearFunction · 0.85
SDL_RenderPresentFunction · 0.85

Tested by

no test coverage detected