From a87019ea5afb904dd337f38802f2ebfbcd9a268a Mon Sep 17 00:00:00 2001 From: historic_bruno Date: Fri, 22 Feb 2013 07:32:22 +0000 Subject: [PATCH] Render initial game view during loading screen, to begin loading assets and eliminate ugly terrain blending artifacts. Refs #1663 This was SVN commit r13181. --- source/ps/Game.cpp | 21 +++++++++++++-------- source/ps/GameSetup/GameSetup.cpp | 6 ------ source/renderer/Renderer.cpp | 8 +++++++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index 48ffe2587a..a23c2adce5 100644 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2013 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -199,6 +199,18 @@ PSRETURN CGame::ReallyStartGame() m_Simulation2->InitGame(settings); } + // We need to do an initial Interpolate call to set up all the models etc, + // because Update might never interpolate (e.g. if the game starts paused) + // and we could end up rendering before having set up any models (so they'd + // all be invisible) + Interpolate(0, 0); + + m_GameStarted=true; + + // Render a frame to begin loading assets + if (CRenderer::IsInitialised()) + Render(); + // Call the reallyStartGame GUI function, but only if it exists if (g_GUI && g_GUI->HasPages()) { @@ -212,14 +224,7 @@ PSRETURN CGame::ReallyStartGame() if (g_NetClient) g_NetClient->LoadFinished(); - // We need to do an initial Interpolate call to set up all the models etc, - // because Update might never interpolate (e.g. if the game starts paused) - // and we could end up rendering before having set up any models (so they'd - // all be invisible) - Interpolate(0, 0); - debug_printf(L"GAME STARTED, ALL INIT COMPLETE\n"); - m_GameStarted=true; // The call tree we've built for pregame probably isn't useful in-game. if (CProfileManager::IsInitialised()) diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index b14184b6be..fcf883a31f 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -201,12 +201,6 @@ void Render() ogl_WarnIfError(); - CStr skystring = "255 0 255"; - CFG_GET_VAL("skycolor", String, skystring); - CColor skycol; - GUI::ParseString(skystring.FromUTF8(), skycol); - g_Renderer.SetClearColor(skycol.AsSColor4ub()); - // prepare before starting the renderer frame if (g_Game && g_Game->IsGameStarted()) g_Game->GetView()->BeginFrame(); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index e889386fc6..4cff27e98f 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2013 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -451,6 +451,12 @@ CRenderer::CRenderer() CFG_GET_VAL("smoothlos", Bool, m_Options.m_SmoothLOS); CFG_GET_VAL("postproc", Bool, m_Options.m_Postproc); + CStr skystring = "0 0 0"; + CColor skycolor; + CFG_GET_VAL("skycolor", String, skystring); + if (skycolor.ParseString(skystring, 255.f)) + SetClearColor(skycolor.AsSColor4ub()); + #if CONFIG2_GLES // Override config option since GLES only supports GLSL m_Options.m_PreferGLSL = true;