Browse code

Wait for textures and size before default zoom

neauoire authored on 22/09/2021 17:42:17
Showing 1 changed files
... ...
@@ -245,9 +245,8 @@ quit(void)
245 245
 }
246 246
 
247 247
 static int
248
-init(Uxn *u)
248
+init(void)
249 249
 {
250
-	SDL_DisplayMode DM;
251 250
 	SDL_AudioSpec as;
252 251
 	SDL_zero(as);
253 252
 	as.freq = SAMPLE_FREQUENCY;
... ...
@@ -276,8 +275,6 @@ init(Uxn *u)
276 275
 	SDL_CreateThread(stdin_handler, "stdin", NULL);
277 276
 	SDL_StartTextInput();
278 277
 	SDL_ShowCursor(SDL_DISABLE);
279
-	SDL_GetCurrentDisplayMode(0, &DM);
280
-	set_zoom(u, DM.w / 1000);
281 278
 	return 1;
282 279
 }
283 280
 
... ...
@@ -574,6 +571,7 @@ load(Uxn *u, char *filepath)
574 571
 int
575 572
 main(int argc, char **argv)
576 573
 {
574
+	SDL_DisplayMode DM;
577 575
 	Uxn u;
578 576
 	int i;
579 577
 
... ...
@@ -601,11 +599,14 @@ main(int argc, char **argv)
601 599
 	/* unused   */ uxn_port(&u, 0xe, nil_talk);
602 600
 	/* unused   */ uxn_port(&u, 0xf, nil_talk);
603 601
 
604
-	if(!init(&u))
602
+	if(!init())
605 603
 		return error("Init", "Failed to initialize emulator.");
606 604
 	if(!set_size(WIDTH, HEIGHT, 0))
607 605
 		return error("Window", "Failed to set window size.");
608
-
606
+	/* default zoom */
607
+	SDL_GetCurrentDisplayMode(0, &DM);
608
+	set_zoom(&u, DM.w / 1000);
609
+	/* zoom from flags */
609 610
 	for(i = 1; i < argc - 1; i++) {
610 611
 		if(strcmp(argv[i], "-s") == 0) {
611 612
 			if((i + 1) < argc - 1)