diff options
author | zlago | 2024-09-01 12:57:22 +0200 |
---|---|---|
committer | zlago | 2024-09-01 12:57:22 +0200 |
commit | eb0194ee748ab3707ade5318e8d336bbbed81594 (patch) | |
tree | 88240dcfdac719a1737af243fb6dd59dad3b4b8c /src | |
parent | aa2a4457dfba11792253937e1ec8e937152b5510 (diff) |
dummy renderer
Diffstat (limited to 'src')
-rw-r--r-- | src/sdl.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/sdl.c b/src/sdl.c index 18ab7d0..d99fc34 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -41,12 +41,25 @@ int main(void) { SDL_StopTextInput(); - if ((window = SDL_CreateWindow("mu-sdl", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_RESIZABLE)) == NULL) { + if ((window = SDL_CreateWindow("mu-sdl", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN)) == NULL) { eprintf("failed to create a window: %s\n"); SDL_Quit(); return EXIT_FAILURE; } + SDL_Renderer *renderer; + if ((renderer = SDL_CreateRenderer(window, -1, 0)) == NULL) { + eprintf("failed to create a renderer: %s\n"); + SDL_DestroyWindow(window); + SDL_Quit(); + return EXIT_FAILURE; + } + + SDL_ShowWindow(window); + SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + SDL_AudioSpec desired = { .freq = 48000, .format = AUDIO_F32SYS, @@ -64,6 +77,11 @@ int main(void) { switch (evt.type) { case SDL_QUIT: goto done; + + case SDL_WINDOWEVENT: + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + break; case SDL_KEYDOWN: // ^Q @@ -97,6 +115,8 @@ int main(void) { } done: + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); SDL_CloseAudioDevice(audio); |