From 93166fa150a35e57128f52c7e7ea4d7d46062ef7 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 1 Feb 2017 21:42:08 +0100 Subject: [PATCH] Remove r_swtruecolor variable as it is redundant --- src/polyrenderer/drawers/poly_draw_args.cpp | 4 ++-- src/polyrenderer/poly_renderer.cpp | 10 +-------- src/polyrenderer/scene/poly_decal.cpp | 2 +- src/polyrenderer/scene/poly_particle.cpp | 2 +- src/polyrenderer/scene/poly_sky.cpp | 2 +- src/polyrenderer/scene/poly_sprite.cpp | 2 +- src/swrenderer/drawers/r_drawerargs.cpp | 24 ++++++++++----------- src/swrenderer/line/r_walldraw.cpp | 8 +++---- src/swrenderer/plane/r_flatplane.cpp | 2 +- src/swrenderer/r_swrenderer.cpp | 7 +++--- src/swrenderer/scene/r_light.cpp | 2 +- src/swrenderer/scene/r_portal.cpp | 4 ++-- src/swrenderer/scene/r_scene.cpp | 18 +++------------- src/swrenderer/scene/r_viewport.cpp | 2 +- src/swrenderer/scene/r_viewport.h | 1 - src/swrenderer/things/r_particle.cpp | 2 +- src/swrenderer/things/r_voxel.cpp | 16 ++++++++------ src/v_draw.cpp | 10 ++++----- 18 files changed, 49 insertions(+), 69 deletions(-) diff --git a/src/polyrenderer/drawers/poly_draw_args.cpp b/src/polyrenderer/drawers/poly_draw_args.cpp index 81ca52a1bc..5e197da710 100644 --- a/src/polyrenderer/drawers/poly_draw_args.cpp +++ b/src/polyrenderer/drawers/poly_draw_args.cpp @@ -49,7 +49,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture) textureWidth = texture->GetWidth(); textureHeight = texture->GetHeight(); auto viewport = swrenderer::RenderViewport::Instance(); - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) texturePixels = (const uint8_t *)texture->GetPixelsBgra(); else texturePixels = texture->GetPixels(); @@ -63,7 +63,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, bool fo FRemapTable *table = TranslationToTable(translationID); if (table != nullptr && !table->Inactive) { - if (swrenderer::RenderViewport::Instance()->r_swtruecolor) + if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra()) translation = (uint8_t*)table->Palette; else translation = table->Remap; diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 9d5475dccc..0b3c060f14 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -58,9 +58,6 @@ void PolyRenderer::RenderView(player_t *player) viewport->RenderTarget = screen; - bool saved_swtruecolor = viewport->r_swtruecolor; - viewport->r_swtruecolor = screen->IsBgra(); - int width = SCREENWIDTH; int height = SCREENHEIGHT; int stHeight = gST_Y; @@ -72,14 +69,12 @@ void PolyRenderer::RenderView(player_t *player) // Apply special colormap if the target cannot do it CameraLight *cameraLight = CameraLight::Instance(); - if (cameraLight->realfixedcolormap && viewport->r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + if (cameraLight->realfixedcolormap && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D)) { R_BeginDrawerCommands(); DrawerCommandQueue::QueueCommand(cameraLight->realfixedcolormap, screen); R_EndDrawerCommands(); } - - viewport->r_swtruecolor = saved_swtruecolor; } void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) @@ -87,7 +82,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int auto viewport = swrenderer::RenderViewport::Instance(); const bool savedviewactive = viewactive; - const bool savedoutputformat = viewport->r_swtruecolor; viewwidth = width; viewport->RenderTarget = canvas; @@ -97,7 +91,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int viewwindowx = x; viewwindowy = y; viewactive = true; - viewport->r_swtruecolor = canvas->IsBgra(); canvas->Lock(true); @@ -112,7 +105,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int ActiveRatio(width, height, &trueratio); viewport->SetViewport(width, height, WidescreenRatio); viewactive = savedviewactive; - viewport->r_swtruecolor = savedoutputformat; } void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines) diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index c658a76fa5..024a2dd25f 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -151,7 +151,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan } args.uniforms.subsectorDepth = subsectorDepth; - if (swrenderer::RenderViewport::Instance()->r_swtruecolor) + if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra()) { args.uniforms.color = 0xff000000 | decal->AlphaColor; } diff --git a/src/polyrenderer/scene/poly_particle.cpp b/src/polyrenderer/scene/poly_particle.cpp index e9a80dc436..d83ac3cc4b 100644 --- a/src/polyrenderer/scene/poly_particle.cpp +++ b/src/polyrenderer/scene/poly_particle.cpp @@ -90,7 +90,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP uint32_t alpha = (uint32_t)clamp(particle->alpha * 255.0f + 0.5f, 0.0f, 255.0f); - if (swrenderer::RenderViewport::Instance()->r_swtruecolor) + if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra()) { args.uniforms.color = (alpha << 24) | (particle->color & 0xffffff); } diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index d4ebc57967..af24364fe9 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -94,7 +94,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor) void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) { uint32_t solid = skytex->GetSkyCapColor(bottomCap); - if (!swrenderer::RenderViewport::Instance()->r_swtruecolor) + if (!swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra()) solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)]; args.vinput = &mVertices[mPrimStart[row]]; diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 43ec99d90b..3149f68a6b 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -250,7 +250,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla args.SetTexture(tex, thing->Translation, true); } - if (!swrenderer::RenderViewport::Instance()->r_swtruecolor) + if (!swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra()) { uint32_t r = (args.uniforms.color >> 16) & 0xff; uint32_t g = (args.uniforms.color >> 8) & 0xff; diff --git a/src/swrenderer/drawers/r_drawerargs.cpp b/src/swrenderer/drawers/r_drawerargs.cpp index 8da9e3d848..e29c127c0a 100644 --- a/src/swrenderer/drawers/r_drawerargs.cpp +++ b/src/swrenderer/drawers/r_drawerargs.cpp @@ -41,7 +41,7 @@ namespace swrenderer { SWPixelFormatDrawers *DrawerArgs::Drawers() { - if (RenderViewport::Instance()->r_swtruecolor) + if (RenderViewport::Instance()->RenderTarget->IsBgra()) { static SWTruecolorDrawers tc_drawers; return &tc_drawers; @@ -80,7 +80,7 @@ namespace swrenderer { if (mBaseColormap) { - if (RenderViewport::Instance()->r_swtruecolor) + if (RenderViewport::Instance()->RenderTarget->IsBgra()) return mBaseColormap->Maps; else return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT); @@ -138,7 +138,7 @@ namespace swrenderer } auto viewport = RenderViewport::Instance(); - ds_source = viewport->r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); + ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; } @@ -147,7 +147,7 @@ namespace swrenderer auto viewport = RenderViewport::Instance(); // Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom. - if (viewport->r_swtruecolor && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba + if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba { DrawMaskedColumnBgra(x, iscale, tex, col, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, unmasked); return; @@ -159,7 +159,7 @@ namespace swrenderer const FTexture::Span *span; const BYTE *column; - if (viewport->r_swtruecolor && !drawer_needs_pal_input) + if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input) column = (const BYTE *)tex->GetColumnBgra(col >> FRACBITS, &span); else column = tex->GetColumn(col >> FRACBITS, &span); @@ -174,7 +174,7 @@ namespace swrenderer unmaskedSpan[1].Length = 0; } - int pixelsize = viewport->r_swtruecolor ? 4 : 1; + int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; while (span->Length != 0) { @@ -514,7 +514,7 @@ namespace swrenderer FRemapTable *table = TranslationToTable(translation); if (table != NULL && !table->Inactive) { - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) SetTranslationMap((uint8_t*)table->Palette); else SetTranslationMap(table->Remap); @@ -591,7 +591,7 @@ namespace swrenderer void WallDrawerArgs::SetDest(int x, int y) { auto viewport = RenderViewport::Instance(); - int pixelsize = viewport->r_swtruecolor ? 4 : 1; + int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize; dc_dest_y = y; } @@ -726,14 +726,14 @@ namespace swrenderer void SkyDrawerArgs::SetDest(int x, int y) { auto viewport = RenderViewport::Instance(); - int pixelsize = viewport->r_swtruecolor ? 4 : 1; + int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize; dc_dest_y = y; } void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column) { - if (RenderViewport::Instance()->r_swtruecolor) + if (RenderViewport::Instance()->RenderTarget->IsBgra()) { dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr); dc_sourceheight = texture->GetHeight(); @@ -752,7 +752,7 @@ namespace swrenderer dc_source2 = nullptr; dc_sourceheight2 = 1; } - else if (RenderViewport::Instance()->r_swtruecolor) + else if (RenderViewport::Instance()->RenderTarget->IsBgra()) { dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr); dc_sourceheight2 = texture->GetHeight(); @@ -772,7 +772,7 @@ namespace swrenderer void SpriteDrawerArgs::SetDest(int x, int y) { auto viewport = RenderViewport::Instance(); - int pixelsize = viewport->r_swtruecolor ? 4 : 1; + int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize; dc_dest_y = y; } diff --git a/src/swrenderer/line/r_walldraw.cpp b/src/swrenderer/line/r_walldraw.cpp index e8dedc6e18..2f3fc04e09 100644 --- a/src/swrenderer/line/r_walldraw.cpp +++ b/src/swrenderer/line/r_walldraw.cpp @@ -49,7 +49,7 @@ namespace swrenderer xoffset += FLOAT2FIXED(xmagnitude * 0.5); - if (!viewport->r_swtruecolor) + if (!viewport->RenderTarget->IsBgra()) { height = texture->GetHeight(); @@ -88,7 +88,7 @@ namespace swrenderer col = width + (col % width); } - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) source = (const uint8_t *)texture->GetColumnBgra(col, nullptr); else source = texture->GetColumn(col, nullptr); @@ -240,7 +240,7 @@ namespace swrenderer drawerargs.dc_num_lights = 0; } - if (RenderViewport::Instance()->r_swtruecolor) + if (RenderViewport::Instance()->RenderTarget->IsBgra()) { int count = y2 - y1; @@ -324,7 +324,7 @@ namespace swrenderer texturemid = 0; } - drawerargs.dc_wall_fracbits = RenderViewport::Instance()->r_swtruecolor ? FRACBITS : fracbits; + drawerargs.dc_wall_fracbits = RenderViewport::Instance()->RenderTarget->IsBgra() ? FRACBITS : fracbits; CameraLight *cameraLight = CameraLight::Instance(); bool fixed = (cameraLight->fixedcolormap != NULL || cameraLight->fixedlightlev >= 0); diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index cccac6d9d6..8c7c2704f9 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -175,7 +175,7 @@ namespace swrenderer auto viewport = RenderViewport::Instance(); - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) { double distance2 = planeheight * yslope[(y + 1 < viewheight) ? y + 1 : y - 1]; double xmagnitude = fabs(ystepscale * (distance2 - distance) * viewport->FocalLengthX); diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index ab71584717..a83289006f 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -89,7 +89,6 @@ void FSoftwareRenderer::Init() { gl_ParseDefs(); - RenderViewport::Instance()->r_swtruecolor = screen->IsBgra(); RenderScene::Instance()->Init(); } @@ -251,8 +250,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin { auto viewport = RenderViewport::Instance(); - BYTE *Pixels = viewport->r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels(); - DSimpleCanvas *Canvas = viewport->r_swtruecolor ? tex->GetCanvasBgra() : tex->GetCanvas(); + BYTE *Pixels = viewport->RenderTarget->IsBgra() ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels(); + DSimpleCanvas *Canvas = viewport->RenderTarget->IsBgra() ? tex->GetCanvasBgra() : tex->GetCanvas(); // curse Doom's overuse of global variables in the renderer. // These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette. @@ -291,7 +290,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin } } - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) { // True color render still sometimes uses palette textures (for sprites, mostly). // We need to make sure that both pixel buffers contain data: diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index 2b0f860921..076f8c9b00 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -60,7 +60,7 @@ namespace swrenderer { realfixedcolormap = &SpecialColormaps[player->fixedcolormap]; auto viewport = RenderViewport::Instance(); - if (viewport->RenderTarget == screen && (viewport->r_swtruecolor || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps))) + if (viewport->RenderTarget == screen && (viewport->RenderTarget->IsBgra() || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps))) { // Render everything fullbright. The copy to video memory will // apply the special colormap, so it won't be restricted to the diff --git a/src/swrenderer/scene/r_portal.cpp b/src/swrenderer/scene/r_portal.cpp index be45c1a015..b74337bf04 100644 --- a/src/swrenderer/scene/r_portal.cpp +++ b/src/swrenderer/scene/r_portal.cpp @@ -304,7 +304,7 @@ namespace swrenderer int Ytop = pds->ceilingclip[x - pds->x1]; int Ybottom = pds->floorclip[x - pds->x1]; - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) { uint32_t *dest = (uint32_t*)viewport->RenderTarget->GetBuffer() + x + Ytop * spacing; @@ -487,7 +487,7 @@ namespace swrenderer auto viewport = RenderViewport::Instance(); - if (viewport->r_swtruecolor) // Assuming this is just a debug function + if (viewport->RenderTarget->IsBgra()) // Assuming this is just a debug function return; BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255); diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 63c3147078..df44d9f16a 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -77,14 +77,9 @@ namespace swrenderer ActiveRatio(width, height, &trueratio); viewport->SetViewport(width, height, trueratio); - if (viewport->r_swtruecolor != screen->IsBgra()) - { - viewport->r_swtruecolor = screen->IsBgra(); - } - if (r_clearbuffer != 0) { - if (!viewport->r_swtruecolor) + if (!viewport->RenderTarget->IsBgra()) { memset(viewport->RenderTarget->GetBuffer(), clearcolor, viewport->RenderTarget->GetPitch() * viewport->RenderTarget->GetHeight()); } @@ -103,7 +98,7 @@ namespace swrenderer RenderActorView(player->mo); // Apply special colormap if the target cannot do it - if (CameraLight::Instance()->realfixedcolormap && viewport->r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + if (CameraLight::Instance()->realfixedcolormap && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D)) { DrawerCommandQueue::QueueCommand(CameraLight::Instance()->realfixedcolormap, screen); } @@ -188,7 +183,7 @@ namespace swrenderer // If we don't want shadered colormaps, NULL it now so that the // copy to the screen does not use a special colormap shader. - if (!r_shadercolormaps && !RenderViewport::Instance()->r_swtruecolor) + if (!r_shadercolormaps && !RenderViewport::Instance()->RenderTarget->IsBgra()) { CameraLight::Instance()->realfixedcolormap = NULL; } @@ -199,12 +194,6 @@ namespace swrenderer auto viewport = RenderViewport::Instance(); const bool savedviewactive = viewactive; - const bool savedoutputformat = viewport->r_swtruecolor; - - if (viewport->r_swtruecolor != canvas->IsBgra()) - { - viewport->r_swtruecolor = canvas->IsBgra(); - } R_BeginDrawerCommands(); @@ -233,7 +222,6 @@ namespace swrenderer screen->Unlock(); viewactive = savedviewactive; - viewport->r_swtruecolor = savedoutputformat; } void RenderScene::ScreenResized() diff --git a/src/swrenderer/scene/r_viewport.cpp b/src/swrenderer/scene/r_viewport.cpp index c2d50839e9..677332bd82 100644 --- a/src/swrenderer/scene/r_viewport.cpp +++ b/src/swrenderer/scene/r_viewport.cpp @@ -129,7 +129,7 @@ namespace swrenderer static BYTE *lastbuff = NULL; int pitch = RenderTarget->GetPitch(); - int pixelsize = r_swtruecolor ? 4 : 1; + int pixelsize = RenderTarget->IsBgra() ? 4 : 1; BYTE *lineptr = RenderTarget->GetBuffer() + (viewwindowy*pitch + viewwindowx) * pixelsize; if (dc_pitch != pitch || lineptr != lastbuff) diff --git a/src/swrenderer/scene/r_viewport.h b/src/swrenderer/scene/r_viewport.h index f3d945bbbe..44f28b6aa0 100644 --- a/src/swrenderer/scene/r_viewport.h +++ b/src/swrenderer/scene/r_viewport.h @@ -37,7 +37,6 @@ namespace swrenderer double CenterY = 0.0; double YaspectMul = 0.0; double IYaspectMul = 0.0; - bool r_swtruecolor = false; double globaluclip = 0.0; double globaldclip = 0.0; diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp index 72d3ce617c..6d47fc1645 100644 --- a/src/swrenderer/things/r_particle.cpp +++ b/src/swrenderer/things/r_particle.cpp @@ -239,7 +239,7 @@ namespace swrenderer RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance(); - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) { for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) { diff --git a/src/swrenderer/things/r_voxel.cpp b/src/swrenderer/things/r_voxel.cpp index f513b59ee7..6da831163a 100644 --- a/src/swrenderer/things/r_voxel.cpp +++ b/src/swrenderer/things/r_voxel.cpp @@ -251,17 +251,19 @@ namespace swrenderer double dy = (view_origin.Y - sprite_origin.Y) / sprite_xscale; int backX = (int)(dx * spriteCos - dy * spriteSin + mip.Pivot.X); int backY = (int)(dy * spriteCos + dx * spriteSin + mip.Pivot.Y); - int endX = clamp(backX, 0, mip.SizeX - 1); - int endY = clamp(backY, 0, mip.SizeY - 1); - + //int endX = clamp(backX, 0, mip.SizeX - 1); + //int endY = clamp(backY, 0, mip.SizeY - 1); + int endX = mip.SizeX - 1;// clamp(backX, 0, mip.SizeX - 1); + int endY = mip.SizeY - 1;// clamp(backY, 0, mip.SizeY - 1); + // Draw the voxel cube: - for (int index = 0; index < 4; index++) + for (int index = 0; index < 1; index++) { - if ((stepX[index] < 0 && endX >= startX[index]) || + /*if ((stepX[index] < 0 && endX >= startX[index]) || (stepX[index] > 0 && endX <= startX[index]) || (stepY[index] < 0 && endY >= startY[index]) || - (stepY[index] > 0 && endY <= startY[index])) continue; + (stepY[index] > 0 && endY <= startY[index])) continue;*/ for (int x = startX[index]; x != endX; x += stepX[index]) { @@ -346,7 +348,7 @@ namespace swrenderer int y1 = MAX((int)(screenY - screenExtentY), 0); int y2 = MIN((int)(screenY + screenExtentY + 0.5f), viewheight - 1); - int pixelsize = viewport->r_swtruecolor ? 4 : 1; + int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; if (y1 < y2) { diff --git a/src/v_draw.cpp b/src/v_draw.cpp index f190d2cc26..bf3d402227 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -149,7 +149,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) auto viewport = RenderViewport::Instance(); - viewport->r_swtruecolor = IsBgra(); + viewport->RenderTarget = screen; if (APART(parms.colorOverlay) != 0) { @@ -167,7 +167,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor(); } // Note that this overrides DTA_Translation in software, but not in hardware. - if (!viewport->r_swtruecolor) + if (!viewport->RenderTarget->IsBgra()) { FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255), parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0); @@ -176,7 +176,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } else if (parms.remap != NULL) { - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) translation = (const BYTE*)parms.remap->Palette; else translation = parms.remap->Remap; @@ -190,7 +190,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } else { - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) drawerargs.SetTranslationMap(nullptr); else drawerargs.SetTranslationMap(identitymap); @@ -198,7 +198,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) bool visible; FDynamicColormap *basecolormap = nullptr; - if (viewport->r_swtruecolor) + if (viewport->RenderTarget->IsBgra()) visible = drawerargs.SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap); else visible = drawerargs.SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor, basecolormap);