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

Function DrawScreen

deps/SDL2/test/testgesture.c:127–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127static void
128DrawScreen(SDL_Window *window)
129{
130 SDL_Surface *screen = SDL_GetWindowSurface(window);
131 int i;
132
133 if (!screen) {
134 return;
135 }
136
137 SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 75, 75, 75));
138
139 /* draw Touch History */
140 for (i = eventWrite; i < eventWrite + EVENT_BUF_SIZE; ++i) {
141 const SDL_Event *event = &events[i & (EVENT_BUF_SIZE - 1)];
142 const float age = (float)(i - eventWrite) / EVENT_BUF_SIZE;
143 float x, y;
144 unsigned int c, col;
145
146 if ( (event->type == SDL_FINGERMOTION) ||
147 (event->type == SDL_FINGERDOWN) ||
148 (event->type == SDL_FINGERUP) ) {
149 x = event->tfinger.x;
150 y = event->tfinger.y;
151
152 /* draw the touch: */
153 c = colors[event->tfinger.fingerId % 7];
154 col = ((unsigned int) (c * (0.1f + 0.85f))) | (unsigned int) (0xFF * age) << 24;
155
156 if (event->type == SDL_FINGERMOTION) {
157 drawCircle(screen, x * screen->w, y * screen->h, 5, col);
158 } else if (event->type == SDL_FINGERDOWN) {
159 drawCircle(screen, x * screen->w, y * screen->h, -10, col);
160 }
161 }
162 }
163
164 if (knob.p.x > 0) {
165 drawKnob(screen, &knob);
166 }
167
168 SDL_UpdateWindowSurface(window);
169}
170
171static void
172loop(void)

Callers 1

loopFunction · 0.85

Calls 6

SDL_GetWindowSurfaceFunction · 0.85
SDL_FillRectFunction · 0.85
SDL_MapRGBFunction · 0.85
drawCircleFunction · 0.85
drawKnobFunction · 0.85
SDL_UpdateWindowSurfaceFunction · 0.85

Tested by

no test coverage detected