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