summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/sdl.c22
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);