From: <geo...@us...> - 2009-12-30 07:09:15
|
Revision: 3304 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3304&view=rev Author: geoffthemedio Date: 2009-12-30 07:09:09 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Improved MapWnd::Sanitize so that hopefully old Universe's map won't appear briefly when loading or starting a new game and hopefully to avoid the hard-to-reproduce bug where the map appears over the splash intro screen. Modified Paths: -------------- trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/MapWnd.h Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2009-12-30 06:44:29 UTC (rev 3303) +++ trunk/FreeOrion/UI/MapWnd.cpp 2009-12-30 07:09:09 UTC (rev 3304) @@ -1290,35 +1290,9 @@ } } - // clear out all the old buffers - for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_star_core_quad_vertices.begin(); - it != m_star_core_quad_vertices.end(); ++it) - { - glDeleteBuffers(1, &it->second.m_name); - } - m_star_core_quad_vertices.clear(); + ClearSystemRenderingBuffers(); - for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_star_halo_quad_vertices.begin(); - it != m_star_halo_quad_vertices.end(); ++it) - { - glDeleteBuffers(1, &it->second.m_name); - } - m_star_halo_quad_vertices.clear(); - - for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_galaxy_gas_quad_vertices.begin(); - it != m_galaxy_gas_quad_vertices.end(); ++it) - { - glDeleteBuffers(1, &it->second.m_name); - } - m_galaxy_gas_quad_vertices.clear(); - - if (m_star_texture_coords.m_name) { - glDeleteBuffers(1, &m_star_texture_coords.m_name); - m_star_texture_coords.m_name = 0; - } - - // create new buffers // star cores @@ -1382,6 +1356,37 @@ Logger().debugStream() << "MapWnd::InitSystemRenderingBuffers time: " << (timer.elapsed() * 1000.0); } +void MapWnd::ClearSystemRenderingBuffers() +{ + for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_star_core_quad_vertices.begin(); + it != m_star_core_quad_vertices.end(); ++it) + { + glDeleteBuffers(1, &it->second.m_name); + } + m_star_core_quad_vertices.clear(); + + for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_star_halo_quad_vertices.begin(); + it != m_star_halo_quad_vertices.end(); ++it) + { + glDeleteBuffers(1, &it->second.m_name); + } + m_star_halo_quad_vertices.clear(); + + for (std::map<boost::shared_ptr<GG::Texture>, GLBuffer>::const_iterator it = m_galaxy_gas_quad_vertices.begin(); + it != m_galaxy_gas_quad_vertices.end(); ++it) + { + glDeleteBuffers(1, &it->second.m_name); + } + m_galaxy_gas_quad_vertices.clear(); + + if (m_star_texture_coords.m_name) { + glDeleteBuffers(1, &m_star_texture_coords.m_name); + m_star_texture_coords.m_name = 0; + } + + +} + void MapWnd::InitStarlaneRenderingBuffers() { Logger().debugStream() << "MapWnd::InitStarlaneRenderingBuffers"; @@ -1557,31 +1562,9 @@ } } - // clear old buffers - if (m_starlane_vertices.m_name) { - glDeleteBuffers(1, &m_starlane_vertices.m_name); - m_starlane_vertices.m_name = 0; - } + ClearStarlaneRenderingBuffers(); - if (m_starlane_colors.m_name) { - glDeleteBuffers(1, &m_starlane_colors.m_name); - m_starlane_colors.m_name = 0; - } - - if (m_starlane_fleet_supply_vertices.m_name) { - glDeleteBuffers(1, &m_starlane_fleet_supply_vertices.m_name); - m_starlane_fleet_supply_vertices.m_name = 0; - } - - if (m_starlane_fleet_supply_colors.m_name) { - glDeleteBuffers(1, &m_starlane_fleet_supply_colors.m_name); - m_starlane_fleet_supply_colors.m_name = 0; - } - - - - // fill new buffers if (!raw_starlane_vertices.empty()) { glGenBuffers(1, &m_starlane_vertices.m_name); @@ -1629,6 +1612,33 @@ Logger().debugStream() << "MapWnd::InitStarlaneRenderingBuffers time: " << (timer.elapsed() * 1000.0); } +void MapWnd::ClearStarlaneRenderingBuffers() +{ + if (m_starlane_vertices.m_name) { + glDeleteBuffers(1, &m_starlane_vertices.m_name); + m_starlane_vertices.m_name = 0; + } + + if (m_starlane_colors.m_name) { + glDeleteBuffers(1, &m_starlane_colors.m_name); + m_starlane_colors.m_name = 0; + } + + if (m_starlane_fleet_supply_vertices.m_name) { + glDeleteBuffers(1, &m_starlane_fleet_supply_vertices.m_name); + m_starlane_fleet_supply_vertices.m_name = 0; + } + + if (m_starlane_fleet_supply_colors.m_name) { + glDeleteBuffers(1, &m_starlane_fleet_supply_colors.m_name); + m_starlane_fleet_supply_colors.m_name = 0; + } + + + + +} + LaneEndpoints MapWnd::StarlaneEndPointsFromSystemPositions(double X1, double Y1, double X2, double Y2) { LaneEndpoints retval; @@ -1753,7 +1763,7 @@ const System* system = GetObject<System>(system_id); if (!system) system = GetEmpireKnownObject<System>(system_id, HumanClientApp::GetApp()->EmpireID()); - if (!system) { + if (!system && system_id != UniverseObject::INVALID_OBJECT_ID) { Logger().errorStream() << "MapWnd::SelectSystem couldn't find system with id " << system_id << " so is selected no system instead"; system_id = UniverseObject::INVALID_OBJECT_ID; } @@ -3399,6 +3409,11 @@ //std::cout << "MapWnd::Sanitize()" << std::endl; Cleanup(); + SelectSystem(UniverseObject::INVALID_OBJECT_ID); + + ClearSystemRenderingBuffers(); + ClearStarlaneRenderingBuffers(); + const GG::X SIDEPANEL_WIDTH = GG::X(GetOptionsDB().Get<int>("UI.sidepanel-width")); const GG::X APP_WIDTH = GG::GUI::GetGUI()->AppWidth(); const GG::Y APP_HEIGHT = GG::GUI::GetGUI()->AppHeight(); @@ -3460,6 +3475,10 @@ m_fleet_lines.clear(); m_projected_fleet_lines.clear(); + + for (std::map<int, SystemIcon*>::iterator it = m_system_icons.begin(); it != m_system_icons.end(); ++it) + delete it->second; + m_system_icons.clear(); } bool MapWnd::ReturnToMap() Modified: trunk/FreeOrion/UI/MapWnd.h =================================================================== --- trunk/FreeOrion/UI/MapWnd.h 2009-12-30 06:44:29 UTC (rev 3303) +++ trunk/FreeOrion/UI/MapWnd.h 2009-12-30 07:09:09 UTC (rev 3304) @@ -201,7 +201,10 @@ void InitTurnRendering(); //!< sets up rendering of system icons, galaxy gas, starlanes at start of turn void InitSystemRenderingBuffers(); //!< initializes or refreshes buffers for rendering of system icons and galaxy gas + void ClearSystemRenderingBuffers(); void InitStarlaneRenderingBuffers(); //!< initializes or refreshes buffers for rendering of starlanes + void ClearStarlaneRenderingBuffers(); + /* Takes X and Y coordinates of a pair of systems and moves these points inwards along the vector * between them by the radius of a system on screen (at zoom 1.0) and return result */ LaneEndpoints StarlaneEndPointsFromSystemPositions(double X1, double Y1, double X2, double Y2); |