draw rect
This commit is contained in:
parent
dc97f5aa81
commit
4039a67a8b
26
~/SDL/DrawRect/draw_rect.c
Normal file
26
~/SDL/DrawRect/draw_rect.c
Normal file
@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user