From a38778deb1a69964b52386ee8bbbdfda8db267ce Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Tue, 14 Sep 2010 23:02:50 +0000 Subject: [PATCH] map preview is scree resolution resistant --- .../menu/menu_state_connected_game.cpp | 7 ++++--- .../glest_game/menu/menu_state_custom_game.cpp | 8 +++++--- .../include/graphics/gl/base_renderer.h | 2 +- .../include/graphics/graphics_interface.h | 2 +- .../sources/graphics/gl/base_renderer.cpp | 17 ++++++++--------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 6f912c512..48d1250e8 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -567,8 +567,6 @@ void MenuStateConnectedGame::render() { if(program != NULL) program->renderProgramMsgBox(); - renderer.renderChatManager(&chatManager); - renderer.renderConsole(&console,showFullConsole,true); if(mapPreview.hasFileLoaded() == true) { @@ -578,8 +576,11 @@ void MenuStateConnectedGame::render() { renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim); bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 1); - renderer.renderMapPreview(&mapPreview, 0, 0, renderAll, 10, 350); + renderer.renderMapPreview(&mapPreview, renderAll, 10, 350,128,128); } + renderer.renderChatManager(&chatManager); + renderer.renderConsole(&console,showFullConsole,true); + } catch(const std::exception &ex) { char szBuf[1024]=""; diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index fdf3fcaa1..d40dc2282 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1076,8 +1076,6 @@ void MenuStateCustomGame::render() { renderer.renderListBox(&listBoxTechTree); renderer.renderListBox(&listBoxAdvanced); - renderer.renderChatManager(&chatManager); - renderer.renderConsole(&console,showFullConsole,true); if(listBoxPublishServer.getEditable()) { @@ -1107,8 +1105,12 @@ void MenuStateCustomGame::render() { renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim); bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 1); - renderer.renderMapPreview(&mapPreview, 0, 0, renderAll, 10, 350); + const Metrics &metrics= Metrics::getInstance(); + renderer.renderMapPreview(&mapPreview, renderAll, 10, 350,metrics.getVirtualW(),metrics.getVirtualH()); } + + renderer.renderChatManager(&chatManager); + renderer.renderConsole(&console,showFullConsole,true); } catch(const std::exception &ex) { char szBuf[1024]=""; diff --git a/source/shared_lib/include/graphics/gl/base_renderer.h b/source/shared_lib/include/graphics/gl/base_renderer.h index f07f7dc34..b0836e144 100644 --- a/source/shared_lib/include/graphics/gl/base_renderer.h +++ b/source/shared_lib/include/graphics/gl/base_renderer.h @@ -28,7 +28,7 @@ public: virtual void initMapSurface(int clientW, int clientH); virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize); - virtual void renderMapPreview(const MapPreview *map, int x, int y,bool renderAll, int screenX, int screenY); + virtual void renderMapPreview(const MapPreview *map, bool renderAll, int screenX, int screenY, int sizeW, int sizeH); }; }} // end namespace diff --git a/source/shared_lib/include/graphics/graphics_interface.h b/source/shared_lib/include/graphics/graphics_interface.h index 144c3092b..712fc9489 100644 --- a/source/shared_lib/include/graphics/graphics_interface.h +++ b/source/shared_lib/include/graphics/graphics_interface.h @@ -42,7 +42,7 @@ class RendererMapInterface { public: virtual void initMapSurface(int clientW, int clientH) = 0; virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize) = 0; - virtual void renderMapPreview(const MapPreview *map, int x, int y,bool renderAll, int screenX, int screenY) = 0; + virtual void renderMapPreview(const MapPreview *map, bool renderAll, int screenX, int screenY, int sizeW, int sizeH) = 0; }; // ===================================================== diff --git a/source/shared_lib/sources/graphics/gl/base_renderer.cpp b/source/shared_lib/sources/graphics/gl/base_renderer.cpp index 152dd1b1a..63345ad08 100644 --- a/source/shared_lib/sources/graphics/gl/base_renderer.cpp +++ b/source/shared_lib/sources/graphics/gl/base_renderer.cpp @@ -190,12 +190,12 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y, assertGl(); } -void BaseRenderer::renderMapPreview( const MapPreview *map, int x, int y, - bool renderAll, int screenX, int screenY) { +void BaseRenderer::renderMapPreview( const MapPreview *map, bool renderAll, + int screenX, int screenY, int sizeW, int sizeH) { float alt=0; float showWater=0; - int renderMapHeight=128; - int renderMapWidth=128; + int renderMapHeight=64; + int renderMapWidth=64; float clientW=256; float clientH=256; float cellSize=2; @@ -218,11 +218,10 @@ void BaseRenderer::renderMapPreview( const MapPreview *map, int x, int y, glLoadIdentity(); - glViewport(screenX, screenY, renderMapWidth,renderMapHeight); - //glViewport(1, 1, renderMapWidth*4,renderMapHeight*4); - glOrtho(0, clientW, 0, clientH, -1, 1); - //glOrtho(-clientW, clientW, -clientH, clientH, -1000, 1000); - + // glViewport(screenX, screenY, sizeH,sizeW); + // glOrtho(0, clientW, 0, clientH, -1, 1); + glOrtho(0, sizeW, 0, sizeH, 0, 1); + //glMatrixMode(GL_MODELVIEW); glPushMatrix();