diff --git a/src/swrenderer/drawers/r_draw.cpp b/src/swrenderer/drawers/r_draw.cpp index d7a6ddd410..8db9d3be8d 100644 --- a/src/swrenderer/drawers/r_draw.cpp +++ b/src/swrenderer/drawers/r_draw.cpp @@ -225,6 +225,7 @@ namespace swrenderer if (rendertarget->IsBgra()) { uint32_t *destorg = (uint32_t*)rendertarget->GetBuffer(); + destorg += viewwindowx + viewwindowy * rendertarget->GetPitch(); uint32_t *dest = (uint32_t*)args.Dest(); int offset = (int)(ptrdiff_t)(dest - destorg); x = offset % rendertarget->GetPitch(); @@ -233,6 +234,7 @@ namespace swrenderer else { uint8_t *destorg = rendertarget->GetBuffer(); + destorg += viewwindowx + viewwindowy * rendertarget->GetPitch(); uint8_t *dest = (uint8_t*)args.Dest(); int offset = (int)(ptrdiff_t)(dest - destorg); x = offset % rendertarget->GetPitch(); @@ -247,6 +249,7 @@ namespace swrenderer if (rendertarget->IsBgra()) { uint32_t *destorg = (uint32_t*)rendertarget->GetBuffer(); + destorg += viewwindowx + viewwindowy * rendertarget->GetPitch(); uint32_t *dest = (uint32_t*)args.Dest(); int offset = (int)(ptrdiff_t)(dest - destorg); x = offset % rendertarget->GetPitch(); @@ -255,6 +258,7 @@ namespace swrenderer else { uint8_t *destorg = rendertarget->GetBuffer(); + destorg += viewwindowx + viewwindowy * rendertarget->GetPitch(); uint8_t *dest = (uint8_t*)args.Dest(); int offset = (int)(ptrdiff_t)(dest - destorg); x = offset % rendertarget->GetPitch(); diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index d582aaf48c..8d01205599 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -178,7 +178,8 @@ namespace swrenderer double curyfrac = baseyfrac + ystepscale * (x1 - minx); double distance = viewport->PlaneDepth(y, planeheight); - float zbufferdepth = 1.0f / (distance * Thread->Viewport->viewwindow.FocalTangent); + + float zbufferdepth = (float)(1.0 / fabs(planeheight / Thread->Viewport->ScreenToViewY(y, 1.0))); drawerargs.SetTextureUStep(distance * xstepscale / drawerargs.TextureWidth()); drawerargs.SetTextureUPos((distance * curxfrac + pviewx) / drawerargs.TextureWidth());