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

34
main.c
View file

@ -4,7 +4,6 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> // only include this one in the source file with main()!
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
@ -36,44 +35,27 @@ int main( int argc, char* argv[] )
panic("SDL_CreateWindow");
}
renderer = SDL_CreateRenderer(window, 0);
renderer = SDL_CreateRenderer(window, "opengl");
if (!renderer)
{
panic("SDL_CreateRenderer");
}
SDL_SetRenderDrawColor(renderer, 255, 64, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
int orange = 0;
while (!loopShouldStop)
{
SDL_Event e;
SDL_zero(e);
while (SDL_PollEvent(&e))
{
switch (e.type)
{
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:
if (e.type == SDL_EVENT_KEY_DOWN && e.key.mod == SDL_KMOD_LCTRL && e.key.key == SDLK_Q)
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_DestroyWindow(window);