From 2b4ec998948e022be89330a4f04880ab11fbcb94 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Thu, 19 Jul 2012 16:37:56 +0100 Subject: [PATCH] Use two functions for renderer drawing instead of several, fix alignment with Zoom Window border --- src/game/GameView.cpp | 10 ++------ src/graphics/Renderer.cpp | 43 +++++++++++++++++++++++++++------ src/graphics/Renderer.h | 5 ++++ src/render/RenderView.cpp | 9 ++----- src/simulation/SaveRenderer.cpp | 13 +++++++--- 5 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 763312d4f..08fcfe627 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1133,13 +1133,7 @@ void GameView::OnDraw() if(ren) { ren->clearScreen(1.0f); - ren->draw_air(); - ren->render_parts(); - ren->render_fire(); - ren->draw_grav(); - ren->DrawWalls(); - ren->DrawSigns(); - ren->FinaliseParts(); + ren->RenderBegin(); if(activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES) { ui::Point finalCurrentMouse = c->PointTranslate(currentMouse); @@ -1169,7 +1163,7 @@ void GameView::OnDraw() activeBrush->RenderPoint(g, finalCurrentMouse); } } - ren->RenderZoom(); + ren->RenderEnd(); if(selectMode!=SelectNone) { diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 5bf8eeff9..30f1bfdec 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -35,6 +35,29 @@ extern "C" #define drawrect(args) g->drawrect(args) #endif +void Renderer::RenderBegin() +{ + + draw_air(); + render_parts(); + render_fire(); + draw_grav(); + DrawWalls(); + DrawSigns(); +#ifndef OGLR + RenderZoom(); + FinaliseParts(); +#endif +} + +void Renderer::RenderEnd() +{ +#ifdef OGLR + RenderZoom(); + FinaliseParts(); +#endif +} + void Renderer::clearScreen(float alpha) { #ifdef OGLR @@ -245,7 +268,7 @@ void Renderer::FinaliseParts() } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable( GL_TEXTURE_2D ); -#else +#elif defined(OGLI) g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255); #endif } @@ -254,7 +277,7 @@ void Renderer::RenderZoom() { if(!zoomEnabled) return; - #ifdef OGLR + #if defined(OGLR) int sdl_scale = 1; int origBlendSrc, origBlendDst; float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor, i; //X-Factor is shit, btw @@ -344,8 +367,8 @@ void Renderer::RenderZoom() int x, y, i, j; pixel pix; pixel * img = vid; - drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+2, zoomScopeSize*ZFACTOR+2, 192, 192, 192, 255); - drawrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR, zoomScopeSize*ZFACTOR, 0, 0, 0, 255); + drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+4, zoomScopeSize*ZFACTOR+4, 192, 192, 192, 255); + drawrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+2, zoomScopeSize*ZFACTOR+2, 0, 0, 0, 255); clearrect(zoomWindowPosition.X, zoomWindowPosition.Y, zoomScopeSize*ZFACTOR, zoomScopeSize*ZFACTOR); for (j=0; jclearScreen(1.0f); - ren->draw_air(); - ren->render_parts(); - ren->render_fire(); - ren->draw_grav(); - ren->DrawWalls(); - ren->DrawSigns(); - ren->FinaliseParts(); + ren->RenderBegin(); + ren->RenderEnd(); } g->draw_line(0, YRES, XRES-1, YRES, 255, 255, 255, XRES+BARSIZE); g->draw_line(180, YRES, 180, YRES+MENUSIZE, 200, 200, 200, XRES+BARSIZE); diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index 73b486e0a..f3b419fc4 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -55,9 +55,12 @@ Thumbnail * SaveRenderer::Render(GameSave * save) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); + ren->clearScreen(1.0f); - ren->render_parts(); - ren->FinaliseParts(); + ren->ClearAccumulation(); + ren->RenderBegin(); + ren->RenderEnd(); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glTranslated(0, -MENUSIZE, 0); @@ -90,8 +93,10 @@ Thumbnail * SaveRenderer::Render(GameSave * save) pixel * pData = NULL; pixel * dst; pixel * src = g->vid; - ren->render_parts(); - ren->FinaliseParts(); + + ren->ClearAccumulation(); + ren->RenderBegin(); + ren->RenderEnd(); pData = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL))); dst = pData;