mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 16:41:22 +00:00
Create a class for the viewport
This commit is contained in:
parent
42535b17f1
commit
601ddb270d
4 changed files with 38 additions and 23 deletions
|
@ -63,7 +63,7 @@ void PolyRenderer::RenderView(player_t *player)
|
|||
int stHeight = ST_Y;
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
R_SWRSetWindow(setblocks, width, height, stHeight, trueratio);
|
||||
RenderViewport::Instance()->SetViewport(width, height, trueratio);
|
||||
|
||||
RenderActorView(player->mo, false);
|
||||
|
||||
|
@ -87,7 +87,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
|||
swrenderer::RenderTarget = canvas;
|
||||
swrenderer::bRenderingToCanvas = true;
|
||||
R_SetWindow(12, width, height, height, true);
|
||||
swrenderer::R_SWRSetWindow(12, width, height, height, WidescreenRatio);
|
||||
swrenderer::RenderViewport::Instance()->SetViewport(width, height, WidescreenRatio);
|
||||
viewwindowx = x;
|
||||
viewwindowy = y;
|
||||
viewactive = true;
|
||||
|
@ -104,7 +104,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
|||
R_ExecuteSetViewSize();
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
swrenderer::R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio);
|
||||
swrenderer::RenderViewport::Instance()->SetViewport(width, height, WidescreenRatio);
|
||||
viewactive = savedviewactive;
|
||||
swrenderer::r_swtruecolor = savedoutputformat;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
PO_LinkToSubsectors();
|
||||
R_SetupFrame(actor);
|
||||
swrenderer::R_SetupColormap(actor);
|
||||
swrenderer::R_SetupFreelook();
|
||||
swrenderer::RenderViewport::Instance()->SetupFreelook();
|
||||
|
||||
ActorRenderFlags savedflags = camera->renderflags;
|
||||
// Never draw the player unless in chasecam mode
|
||||
|
|
|
@ -72,10 +72,9 @@ namespace swrenderer
|
|||
|
||||
int width = SCREENWIDTH;
|
||||
int height = SCREENHEIGHT;
|
||||
int stHeight = ST_Y;
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
R_SWRSetWindow(setblocks, width, height, stHeight, trueratio);
|
||||
RenderViewport::Instance()->SetViewport(width, height, trueratio);
|
||||
|
||||
if (r_swtruecolor != screen->IsBgra())
|
||||
{
|
||||
|
@ -123,10 +122,9 @@ namespace swrenderer
|
|||
clip3d->Cleanup();
|
||||
clip3d->ResetClip(); // reset clips (floor/ceiling)
|
||||
|
||||
R_SetupBuffer();
|
||||
R_SetupFrame(actor);
|
||||
R_SetupColormap(actor);
|
||||
R_SetupFreelook();
|
||||
RenderViewport::Instance()->SetupFreelook();
|
||||
|
||||
RenderPortal::Instance()->CopyStackedViewParameters();
|
||||
|
||||
|
@ -191,7 +189,6 @@ namespace swrenderer
|
|||
}
|
||||
WallPortals.Clear();
|
||||
interpolator.RestoreInterpolations();
|
||||
R_SetupBuffer();
|
||||
|
||||
// If we don't want shadered colormaps, NULL it now so that the
|
||||
// copy to the screen does not use a special colormap shader.
|
||||
|
@ -219,11 +216,10 @@ namespace swrenderer
|
|||
bRenderingToCanvas = true;
|
||||
|
||||
R_SetWindow(12, width, height, height, true);
|
||||
R_SWRSetWindow(12, width, height, height, WidescreenRatio);
|
||||
|
||||
viewwindowx = x;
|
||||
viewwindowy = y;
|
||||
viewactive = true;
|
||||
RenderViewport::Instance()->SetViewport(width, height, WidescreenRatio);
|
||||
|
||||
RenderActorView(actor, dontmaplines);
|
||||
|
||||
|
@ -235,9 +231,8 @@ namespace swrenderer
|
|||
R_ExecuteSetViewSize();
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio);
|
||||
screen->Lock(true);
|
||||
R_SetupBuffer();
|
||||
RenderViewport::Instance()->SetViewport(width, height, trueratio);
|
||||
screen->Unlock();
|
||||
|
||||
viewactive = savedviewactive;
|
||||
|
@ -254,8 +249,12 @@ namespace swrenderer
|
|||
VisiblePlaneList::Instance()->Init();
|
||||
|
||||
RenderTarget = screen;
|
||||
int width = SCREENWIDTH;
|
||||
int height = SCREENHEIGHT;
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
screen->Lock(true);
|
||||
R_SetupBuffer();
|
||||
RenderViewport::Instance()->SetViewport(SCREENWIDTH, SCREENHEIGHT, trueratio);
|
||||
screen->Unlock();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,13 @@ namespace swrenderer
|
|||
// from clipangle to -clipangle.
|
||||
angle_t xtoviewangle[MAXWIDTH + 1];
|
||||
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio)
|
||||
RenderViewport *RenderViewport::Instance()
|
||||
{
|
||||
static RenderViewport instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void RenderViewport::SetViewport(int fullWidth, int fullHeight, float trueratio)
|
||||
{
|
||||
int virtheight, virtwidth, virtwidth2, virtheight2;
|
||||
|
||||
|
@ -113,13 +119,15 @@ namespace swrenderer
|
|||
// thing clipping
|
||||
fillshort(screenheightarray, viewwidth, (short)viewheight);
|
||||
|
||||
R_InitTextureMapping();
|
||||
InitTextureMapping();
|
||||
|
||||
// Reset r_*Visibility vars
|
||||
R_SetVisibility(R_GetVisibility());
|
||||
|
||||
SetupBuffer();
|
||||
}
|
||||
|
||||
void R_SetupFreelook()
|
||||
void RenderViewport::SetupFreelook()
|
||||
{
|
||||
double dy;
|
||||
|
||||
|
@ -140,7 +148,7 @@ namespace swrenderer
|
|||
RenderFlatPlane::SetupSlope();
|
||||
}
|
||||
|
||||
void R_SetupBuffer()
|
||||
void RenderViewport::SetupBuffer()
|
||||
{
|
||||
using namespace drawerargs;
|
||||
|
||||
|
@ -168,7 +176,7 @@ namespace swrenderer
|
|||
R_InitParticleTexture();
|
||||
}
|
||||
|
||||
void R_InitTextureMapping()
|
||||
void RenderViewport::InitTextureMapping()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -34,8 +34,16 @@ namespace swrenderer
|
|||
extern double globaldclip;
|
||||
extern angle_t xtoviewangle[MAXWIDTH + 1];
|
||||
|
||||
void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio);
|
||||
void R_InitTextureMapping();
|
||||
void R_SetupBuffer();
|
||||
void R_SetupFreelook();
|
||||
class RenderViewport
|
||||
{
|
||||
public:
|
||||
static RenderViewport *Instance();
|
||||
|
||||
void SetViewport(int width, int height, float trueratio);
|
||||
void SetupFreelook();
|
||||
|
||||
private:
|
||||
void InitTextureMapping();
|
||||
void SetupBuffer();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue