Deferred showing window until after the first frame has rendered

Fixes #97
This commit is contained in:
rxi 2020-05-14 22:28:22 +01:00
parent b8d2805502
commit 5102088aca
2 changed files with 8 additions and 2 deletions

View File

@ -89,8 +89,8 @@ int main(int argc, char **argv) {
SDL_GetCurrentDisplayMode(0, &dm); SDL_GetCurrentDisplayMode(0, &dm);
window = SDL_CreateWindow( window = SDL_CreateWindow(
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, "", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8,
dm.w * 0.8, dm.h * 0.8, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
init_window_icon(); init_window_icon();
ren_init(window); ren_init(window);

View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include "lib/stb/stb_truetype.h" #include "lib/stb/stb_truetype.h"
@ -65,6 +66,11 @@ void ren_init(SDL_Window *win) {
void ren_update_rects(RenRect *rects, int count) { void ren_update_rects(RenRect *rects, int count) {
SDL_UpdateWindowSurfaceRects(window, (SDL_Rect*) rects, count); SDL_UpdateWindowSurfaceRects(window, (SDL_Rect*) rects, count);
static bool initial_frame = true;
if (initial_frame) {
SDL_ShowWindow(window);
initial_frame = false;
}
} }