Fix problem with non-refresh window

Maybe it's problems was in switches's shits.

Considering that we had some problems with switch (brrr)
This commit is contained in:
CRy386i 2024-11-24 19:46:05 +02:00
parent a8df5c16fd
commit 010f6799ee
2 changed files with 13 additions and 29 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.o
mobiground

40
main.c
View file

@ -4,7 +4,6 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> // only include this one in the source file with main()! #include <SDL3/SDL_main.h> // only include this one in the source file with main()!
SDL_Window* window = NULL; SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL; SDL_Renderer* renderer = NULL;
@ -33,47 +32,30 @@ int main( int argc, char* argv[] )
window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0); window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0);
if (!window) if (!window)
{ {
panic("SDL_CreateWindow"); panic("SDL_CreateWindow");
} }
renderer = SDL_CreateRenderer(window, 0); renderer = SDL_CreateRenderer(window, "opengl");
if (!renderer) if (!renderer)
{ {
panic("SDL_CreateRenderer"); panic("SDL_CreateRenderer");
} }
SDL_SetRenderDrawColor(renderer, 255, 64, 0, 255); int orange = 0;
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
while (!loopShouldStop) while (!loopShouldStop)
{ {
SDL_Event e; SDL_Event e;
SDL_zero(e); SDL_zero(e);
while (SDL_PollEvent(&e)) while (SDL_PollEvent(&e))
{ {
switch (e.type) if (e.type == SDL_EVENT_KEY_DOWN && e.key.mod == SDL_KMOD_LCTRL && e.key.key == SDLK_Q)
{ loopShouldStop = true;
case SDL_EVENT_KEY_DOWN:
switch (e.key.mod)
{
case SDL_KMOD_LCTRL:
switch (e.key.key)
{
case SDLK_Q:
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Hello OOPS!", "OOPS!", window);
break;
}
break;
}
break;
case SDL_EVENT_QUIT:
loopShouldStop = true;
break;
default:
break;
}
} }
SDL_SetRenderDrawColor(renderer, 0, orange, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
orange = (orange + 1) % 256;
} }
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window); SDL_DestroyWindow(window);