snipplets.dev/~/SDL/DrawRect/draw_rect.c

27 lines
587 B
C
Raw Normal View History

2023-04-09 12:25:11 +03:00
SDL_Rect box = { 10, 10, 50, 10 };
while (!quit) {
if (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
quit = true;
break;
}
}
// clear render
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
SDL_RenderClear(renderer);
box.w += 1;
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0);
SDL_RenderFillRect(renderer, &box);
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 0);
SDL_RenderDrawRect(renderer, &box);
// render
SDL_RenderPresent(renderer);
SDL_Delay(10);
}