mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 22:51:39 +00:00
- Fix playersprite offset being wrong in softpoly
- Remove DFrameBuffer::GetCanvas as it always returned null
This commit is contained in:
parent
4a730f6dd5
commit
c4768441b4
7 changed files with 24 additions and 16 deletions
|
@ -89,7 +89,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
||||||
Threads.MainThread()->FlushDrawQueue();
|
Threads.MainThread()->FlushDrawQueue();
|
||||||
DrawerThreads::WaitForWorkers();
|
DrawerThreads::WaitForWorkers();
|
||||||
|
|
||||||
RenderTarget = screen->GetCanvas();
|
RenderTarget = nullptr;
|
||||||
RenderToCanvas = false;
|
RenderToCanvas = false;
|
||||||
R_ExecuteSetViewSize(Viewpoint, Viewwindow);
|
R_ExecuteSetViewSize(Viewpoint, Viewwindow);
|
||||||
float trueratio;
|
float trueratio;
|
||||||
|
|
|
@ -218,6 +218,11 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
const auto &viewwindow = PolyRenderer::Instance()->Viewwindow;
|
const auto &viewwindow = PolyRenderer::Instance()->Viewwindow;
|
||||||
DCanvas *renderTarget = PolyRenderer::Instance()->RenderTarget;
|
DCanvas *renderTarget = PolyRenderer::Instance()->RenderTarget;
|
||||||
|
|
||||||
|
// Force it to use software rendering.
|
||||||
|
// To do: Fix that Draw2D() is never called by SWSceneDrawer::RenderView. Make sure to adjust the similar comment in r_playersprite.cpp
|
||||||
|
bool renderToCanvas = true;
|
||||||
|
//bool renderToCanvas = PolyRenderer::Instance()->RenderToCanvas;
|
||||||
|
|
||||||
sprframe = &SpriteFrames[sprdef->spriteframes + pspr->GetFrame()];
|
sprframe = &SpriteFrames[sprdef->spriteframes + pspr->GetFrame()];
|
||||||
|
|
||||||
picnum = sprframe->Texture[0];
|
picnum = sprframe->Texture[0];
|
||||||
|
@ -288,16 +293,14 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
|
|
||||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffsetPo();
|
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffsetPo();
|
||||||
|
|
||||||
auto screencanvas = screen->GetCanvas();
|
if (viewpoint.camera->player && (renderToCanvas ||
|
||||||
|
|
||||||
if (viewpoint.camera->player && (renderTarget != screencanvas ||
|
|
||||||
viewheight == renderTarget->GetHeight() ||
|
viewheight == renderTarget->GetHeight() ||
|
||||||
(renderTarget->GetWidth() > (BASEXCENTER * 2))))
|
(renderTarget->GetWidth() > (BASEXCENTER * 2))))
|
||||||
{ // Adjust PSprite for fullscreen views
|
{ // Adjust PSprite for fullscreen views
|
||||||
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
||||||
if (weapon != nullptr && weapon->YAdjust != 0)
|
if (weapon != nullptr && weapon->YAdjust != 0)
|
||||||
{
|
{
|
||||||
if (renderTarget != screencanvas || viewheight == renderTarget->GetHeight())
|
if (renderToCanvas || viewheight == renderTarget->GetHeight())
|
||||||
{
|
{
|
||||||
vis.texturemid -= weapon->YAdjust;
|
vis.texturemid -= weapon->YAdjust;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +415,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
|
|
||||||
// Check for hardware-assisted 2D. If it's available, and this sprite is not
|
// Check for hardware-assisted 2D. If it's available, and this sprite is not
|
||||||
// fuzzy, don't draw it until after the switch to 2D mode.
|
// fuzzy, don't draw it until after the switch to 2D mode.
|
||||||
if (!noaccel && renderTarget == screencanvas)
|
if (!noaccel && !renderToCanvas)
|
||||||
{
|
{
|
||||||
FRenderStyle style = vis.RenderStyle;
|
FRenderStyle style = vis.RenderStyle;
|
||||||
style.CheckFuzz();
|
style.CheckFuzz();
|
||||||
|
@ -500,7 +503,7 @@ void PolyNoAccelPlayerSprite::Render(PolyRenderThread *thread)
|
||||||
y1 = centerY - texturemid * yscale;
|
y1 = centerY - texturemid * yscale;
|
||||||
y2 = y1 + pic->GetHeight() * yscale;
|
y2 = y1 + pic->GetHeight() * yscale;
|
||||||
}
|
}
|
||||||
args.Draw(thread, x1, x2, y1, y2, 0.0f, 1.0f, 0.0f, 1.0f);
|
args.Draw(thread, viewwindowx + x1, viewwindowx + x2, viewwindowy + y1, viewwindowy + y2, 0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -91,6 +91,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
auto viewport = MainThread()->Viewport.get();
|
auto viewport = MainThread()->Viewport.get();
|
||||||
viewport->RenderTarget = target;
|
viewport->RenderTarget = target;
|
||||||
|
viewport->RenderingToCanvas = false;
|
||||||
|
|
||||||
int width = SCREENWIDTH;
|
int width = SCREENWIDTH;
|
||||||
int height = SCREENHEIGHT;
|
int height = SCREENHEIGHT;
|
||||||
|
@ -339,6 +340,7 @@ namespace swrenderer
|
||||||
|
|
||||||
viewwidth = width;
|
viewwidth = width;
|
||||||
viewport->RenderTarget = canvas;
|
viewport->RenderTarget = canvas;
|
||||||
|
viewport->RenderingToCanvas = true;
|
||||||
|
|
||||||
R_SetWindow(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow, 12, width, height, height, true);
|
R_SetWindow(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow, 12, width, height, height, true);
|
||||||
viewwindowx = x;
|
viewwindowx = x;
|
||||||
|
@ -351,7 +353,8 @@ namespace swrenderer
|
||||||
DrawerThreads::WaitForWorkers();
|
DrawerThreads::WaitForWorkers();
|
||||||
DrawerWaitCycles.Unclock();
|
DrawerWaitCycles.Unclock();
|
||||||
|
|
||||||
viewport->RenderTarget = screen->GetCanvas();
|
viewport->RenderTarget = nullptr;
|
||||||
|
viewport->RenderingToCanvas = false;
|
||||||
|
|
||||||
R_ExecuteSetViewSize(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow);
|
R_ExecuteSetViewSize(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow);
|
||||||
float trueratio;
|
float trueratio;
|
||||||
|
|
|
@ -289,15 +289,19 @@ namespace swrenderer
|
||||||
|
|
||||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffset(0);
|
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffset(0);
|
||||||
|
|
||||||
auto screencanvas = screen->GetCanvas();
|
// Force it to use software rendering.
|
||||||
if (Thread->Viewport->viewpoint.camera->player && (viewport->RenderTarget != screencanvas ||
|
// To do: Fix that Draw2D() is never called by SWSceneDrawer::RenderView. Also make sure to adjust the similar comment in poly_playersprite.cpp
|
||||||
|
bool renderToCanvas = true;
|
||||||
|
//bool renderToCanvas = viewport->RenderingToCanvas;
|
||||||
|
|
||||||
|
if (Thread->Viewport->viewpoint.camera->player && (renderToCanvas ||
|
||||||
viewheight == viewport->RenderTarget->GetHeight() ||
|
viewheight == viewport->RenderTarget->GetHeight() ||
|
||||||
(viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2))))
|
(viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2))))
|
||||||
{ // Adjust PSprite for fullscreen views
|
{ // Adjust PSprite for fullscreen views
|
||||||
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
|
||||||
if (weapon != nullptr && weapon->YAdjust != 0)
|
if (weapon != nullptr && weapon->YAdjust != 0)
|
||||||
{
|
{
|
||||||
if (viewport->RenderTarget != screencanvas || viewheight == viewport->RenderTarget->GetHeight())
|
if (renderToCanvas || viewheight == viewport->RenderTarget->GetHeight())
|
||||||
{
|
{
|
||||||
vis.texturemid -= weapon->YAdjust;
|
vis.texturemid -= weapon->YAdjust;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +418,7 @@ namespace swrenderer
|
||||||
|
|
||||||
// Check for hardware-assisted 2D. If it's available, and this sprite is not
|
// Check for hardware-assisted 2D. If it's available, and this sprite is not
|
||||||
// fuzzy, don't draw it until after the switch to 2D mode.
|
// fuzzy, don't draw it until after the switch to 2D mode.
|
||||||
if (!noaccel && viewport->RenderTarget == screencanvas)
|
if (!noaccel && !renderToCanvas)
|
||||||
{
|
{
|
||||||
FRenderStyle style = vis.RenderStyle;
|
FRenderStyle style = vis.RenderStyle;
|
||||||
style.CheckFuzz();
|
style.CheckFuzz();
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
int virtheight, virtwidth, virtwidth2, virtheight2;
|
int virtheight, virtwidth, virtwidth2, virtheight2;
|
||||||
|
|
||||||
if (!RenderingToCanvas())
|
if (!RenderingToCanvas)
|
||||||
{ // Set r_viewsize cvar to reflect the current view size
|
{ // Set r_viewsize cvar to reflect the current view size
|
||||||
UCVarValue value;
|
UCVarValue value;
|
||||||
char temp[16];
|
char temp[16];
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace swrenderer
|
||||||
TriMatrix WorldToClip;
|
TriMatrix WorldToClip;
|
||||||
|
|
||||||
DCanvas *RenderTarget = nullptr;
|
DCanvas *RenderTarget = nullptr;
|
||||||
|
bool RenderingToCanvas = false;
|
||||||
|
|
||||||
FViewWindow viewwindow;
|
FViewWindow viewwindow;
|
||||||
FRenderViewpoint viewpoint;
|
FRenderViewpoint viewpoint;
|
||||||
|
@ -52,8 +53,6 @@ namespace swrenderer
|
||||||
|
|
||||||
uint8_t *GetDest(int x, int y);
|
uint8_t *GetDest(int x, int y);
|
||||||
|
|
||||||
bool RenderingToCanvas() const { return RenderTarget != screen->GetCanvas(); }
|
|
||||||
|
|
||||||
DVector3 PointWorldToView(const DVector3 &worldPos) const;
|
DVector3 PointWorldToView(const DVector3 &worldPos) const;
|
||||||
DVector3 PointWorldToScreen(const DVector3 &worldPos) const;
|
DVector3 PointWorldToScreen(const DVector3 &worldPos) const;
|
||||||
DVector3 PointViewToScreen(const DVector3 &viewPos) const;
|
DVector3 PointViewToScreen(const DVector3 &viewPos) const;
|
||||||
|
|
|
@ -309,7 +309,6 @@ public:
|
||||||
|
|
||||||
inline int GetWidth() const { return Width; }
|
inline int GetWidth() const { return Width; }
|
||||||
inline int GetHeight() const { return Height; }
|
inline int GetHeight() const { return Height; }
|
||||||
virtual DCanvas *GetCanvas() { return nullptr; }
|
|
||||||
|
|
||||||
// Make the surface visible.
|
// Make the surface visible.
|
||||||
virtual void Update () = 0;
|
virtual void Update () = 0;
|
||||||
|
|
Loading…
Reference in a new issue