Use two functions for renderer drawing instead of several, fix alignment with Zoom Window border

This commit is contained in:
Simon Robertshaw 2012-07-19 16:37:56 +01:00
parent dd0e6e7f4d
commit 2b4ec99894
5 changed files with 54 additions and 26 deletions

View File

@ -1133,13 +1133,7 @@ void GameView::OnDraw()
if(ren) if(ren)
{ {
ren->clearScreen(1.0f); ren->clearScreen(1.0f);
ren->draw_air(); ren->RenderBegin();
ren->render_parts();
ren->render_fire();
ren->draw_grav();
ren->DrawWalls();
ren->DrawSigns();
ren->FinaliseParts();
if(activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES) if(activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES)
{ {
ui::Point finalCurrentMouse = c->PointTranslate(currentMouse); ui::Point finalCurrentMouse = c->PointTranslate(currentMouse);
@ -1169,7 +1163,7 @@ void GameView::OnDraw()
activeBrush->RenderPoint(g, finalCurrentMouse); activeBrush->RenderPoint(g, finalCurrentMouse);
} }
} }
ren->RenderZoom(); ren->RenderEnd();
if(selectMode!=SelectNone) if(selectMode!=SelectNone)
{ {

View File

@ -35,6 +35,29 @@ extern "C"
#define drawrect(args) g->drawrect(args) #define drawrect(args) g->drawrect(args)
#endif #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) void Renderer::clearScreen(float alpha)
{ {
#ifdef OGLR #ifdef OGLR
@ -245,7 +268,7 @@ void Renderer::FinaliseParts()
} }
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
#else #elif defined(OGLI)
g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255); g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255);
#endif #endif
} }
@ -254,7 +277,7 @@ void Renderer::RenderZoom()
{ {
if(!zoomEnabled) if(!zoomEnabled)
return; return;
#ifdef OGLR #if defined(OGLR)
int sdl_scale = 1; int sdl_scale = 1;
int origBlendSrc, origBlendDst; int origBlendSrc, origBlendDst;
float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor, i; //X-Factor is shit, btw 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; int x, y, i, j;
pixel pix; pixel pix;
pixel * img = vid; pixel * img = vid;
drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+2, zoomScopeSize*ZFACTOR+2, 192, 192, 192, 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, zoomScopeSize*ZFACTOR, 0, 0, 0, 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); clearrect(zoomWindowPosition.X, zoomWindowPosition.Y, zoomScopeSize*ZFACTOR, zoomScopeSize*ZFACTOR);
for (j=0; j<zoomScopeSize; j++) for (j=0; j<zoomScopeSize; j++)
for (i=0; i<zoomScopeSize; i++) for (i=0; i<zoomScopeSize; i++)
@ -2103,10 +2126,16 @@ void Renderer::CompileRenderMode()
//If firemode is removed, clear the fire display //If firemode is removed, clear the fire display
if(!(render_mode & FIREMODE) && (old_render_mode & FIREMODE)) if(!(render_mode & FIREMODE) && (old_render_mode & FIREMODE))
{ {
ClearAccumulation();
}
}
void Renderer::ClearAccumulation()
{
//Fire
std::fill(fire_r[0]+0, fire_r[(YRES/CELL)-1]+((XRES/CELL)-1), 0); std::fill(fire_r[0]+0, fire_r[(YRES/CELL)-1]+((XRES/CELL)-1), 0);
std::fill(fire_g[0]+0, fire_g[(YRES/CELL)-1]+((XRES/CELL)-1), 0); std::fill(fire_g[0]+0, fire_g[(YRES/CELL)-1]+((XRES/CELL)-1), 0);
std::fill(fire_b[0]+0, fire_b[(YRES/CELL)-1]+((XRES/CELL)-1), 0); std::fill(fire_b[0]+0, fire_b[(YRES/CELL)-1]+((XRES/CELL)-1), 0);
}
} }
void Renderer::AddRenderMode(unsigned int mode) void Renderer::AddRenderMode(unsigned int mode)

View File

@ -55,6 +55,9 @@ public:
int ZFACTOR; int ZFACTOR;
//Renderers //Renderers
void RenderBegin();
void RenderEnd();
void RenderZoom(); void RenderZoom();
void DrawWalls(); void DrawWalls();
void DrawSigns(); void DrawSigns();
@ -67,6 +70,8 @@ public:
void draw_grav(); void draw_grav();
void draw_other(); void draw_other();
void FinaliseParts(); void FinaliseParts();
void ClearAccumulation();
void clearScreen(float alpha); void clearScreen(float alpha);
//class SolidsRenderer; //class SolidsRenderer;

View File

@ -240,13 +240,8 @@ void RenderView::OnDraw()
if(ren) if(ren)
{ {
ren->clearScreen(1.0f); ren->clearScreen(1.0f);
ren->draw_air(); ren->RenderBegin();
ren->render_parts(); ren->RenderEnd();
ren->render_fire();
ren->draw_grav();
ren->DrawWalls();
ren->DrawSigns();
ren->FinaliseParts();
} }
g->draw_line(0, YRES, XRES-1, YRES, 255, 255, 255, XRES+BARSIZE); 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); g->draw_line(180, YRES, 180, YRES+MENUSIZE, 200, 200, 200, XRES+BARSIZE);

View File

@ -55,9 +55,12 @@ Thumbnail * SaveRenderer::Render(GameSave * save)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ren->clearScreen(1.0f); ren->clearScreen(1.0f);
ren->render_parts(); ren->ClearAccumulation();
ren->FinaliseParts(); ren->RenderBegin();
ren->RenderEnd();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glTranslated(0, -MENUSIZE, 0); glTranslated(0, -MENUSIZE, 0);
@ -90,8 +93,10 @@ Thumbnail * SaveRenderer::Render(GameSave * save)
pixel * pData = NULL; pixel * pData = NULL;
pixel * dst; pixel * dst;
pixel * src = g->vid; pixel * src = g->vid;
ren->render_parts();
ren->FinaliseParts(); ren->ClearAccumulation();
ren->RenderBegin();
ren->RenderEnd();
pData = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL))); pData = (pixel *)malloc(PIXELSIZE * ((width*CELL)*(height*CELL)));
dst = pData; dst = pData;