mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- Took more functions out of GLSceneDrawer
This commit is contained in:
parent
469c9241eb
commit
f229b05675
5 changed files with 51 additions and 61 deletions
|
@ -322,10 +322,8 @@ sector_t *FGLRenderer::RenderView(player_t* player)
|
|||
fovratio = ratio;
|
||||
}
|
||||
|
||||
GLSceneDrawer drawer;
|
||||
|
||||
mShadowMap.Update();
|
||||
retsec = drawer.RenderViewpoint(r_viewpoint, player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true);
|
||||
retsec = RenderViewpoint(r_viewpoint, player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true);
|
||||
}
|
||||
All.Unclock();
|
||||
return retsec;
|
||||
|
@ -352,9 +350,8 @@ void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, doub
|
|||
bounds.width = FHardwareTexture::GetTexDimension(gltex->GetWidth());
|
||||
bounds.height = FHardwareTexture::GetTexDimension(gltex->GetHeight());
|
||||
|
||||
GLSceneDrawer drawer;
|
||||
FRenderViewpoint texvp;
|
||||
drawer.RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
|
||||
EndOffscreen();
|
||||
|
||||
|
@ -387,9 +384,8 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
|
|||
mLights->Clear();
|
||||
|
||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
||||
GLSceneDrawer drawer;
|
||||
FRenderViewpoint savevp;
|
||||
sector_t *viewsector = drawer.RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||
sector_t *viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
gl_RenderState.SetSoftLightLevel(-1);
|
||||
CopyToBackbuffer(&bounds, false);
|
||||
|
|
|
@ -110,7 +110,6 @@ public:
|
|||
FLightBuffer *mLights;
|
||||
SWSceneDrawer *swdrawer = nullptr;
|
||||
|
||||
bool mDrawingScene2D = false;
|
||||
bool buffersActive = false;
|
||||
|
||||
float mSceneClearColor[3];
|
||||
|
@ -148,6 +147,10 @@ public:
|
|||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
||||
sector_t *RenderView(player_t *player);
|
||||
void BeginFrame();
|
||||
|
||||
void Set3DViewport(bool mainview);
|
||||
sector_t *RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||
|
||||
|
||||
bool StartOffscreen();
|
||||
void EndOffscreen();
|
||||
|
|
|
@ -72,43 +72,6 @@ EXTERN_CVAR (Bool, r_deathcamera)
|
|||
EXTERN_CVAR (Float, r_visibility)
|
||||
EXTERN_CVAR (Bool, r_drawvoxels)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// sets 3D viewport and initial state
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GLSceneDrawer::Set3DViewport(bool mainview)
|
||||
{
|
||||
if (mainview && GLRenderer->buffersActive)
|
||||
{
|
||||
bool useSSAO = (gl_ssao != 0);
|
||||
GLRenderer->mBuffers->BindSceneFB(useSSAO);
|
||||
gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
||||
gl_RenderState.Apply();
|
||||
}
|
||||
|
||||
// Always clear all buffers with scissor test disabled.
|
||||
// This is faster on newer hardware because it allows the GPU to skip
|
||||
// reading from slower memory where the full buffers are stored.
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearColor(GLRenderer->mSceneClearColor[0], GLRenderer->mSceneClearColor[1], GLRenderer->mSceneClearColor[2], 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
const auto &bounds = screen->mSceneViewport;
|
||||
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_ALWAYS,0,~0); // default stencil
|
||||
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// SetProjection
|
||||
|
@ -116,7 +79,7 @@ void GLSceneDrawer::Set3DViewport(bool mainview)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GLSceneDrawer::SetProjection(VSMatrix matrix)
|
||||
void SetProjection(VSMatrix matrix)
|
||||
{
|
||||
gl_RenderState.mProjectionMatrix.loadIdentity();
|
||||
gl_RenderState.mProjectionMatrix.multMatrix(matrix);
|
||||
|
@ -128,7 +91,7 @@ void GLSceneDrawer::SetProjection(VSMatrix matrix)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GLSceneDrawer::SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||
void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||
{
|
||||
float mult = mirror? -1:1;
|
||||
float planemult = planemirror? -level.info->pixelstretch : level.info->pixelstretch;
|
||||
|
@ -488,17 +451,54 @@ void FDrawInfo::ProcessScene(bool toscreen)
|
|||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// sets 3D viewport and initial state
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::Set3DViewport(bool mainview)
|
||||
{
|
||||
if (mainview && buffersActive)
|
||||
{
|
||||
bool useSSAO = (gl_ssao != 0);
|
||||
mBuffers->BindSceneFB(useSSAO);
|
||||
gl_RenderState.SetPassType(useSSAO ? GBUFFER_PASS : NORMAL_PASS);
|
||||
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
||||
gl_RenderState.Apply();
|
||||
}
|
||||
|
||||
// Always clear all buffers with scissor test disabled.
|
||||
// This is faster on newer hardware because it allows the GPU to skip
|
||||
// reading from slower memory where the full buffers are stored.
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearColor(mSceneClearColor[0], mSceneClearColor[1], mSceneClearColor[2], 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
const auto &bounds = screen->mSceneViewport;
|
||||
glViewport(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
glScissor(bounds.left, bounds.top, bounds.width, bounds.height);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_ALWAYS,0,~0); // default stencil
|
||||
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Renders one viewpoint in a scene
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
||||
sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen)
|
||||
{
|
||||
R_SetupFrame (mainvp, r_viewwindow, camera);
|
||||
|
||||
GLRenderer->mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility);
|
||||
mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility);
|
||||
|
||||
// Render (potentially) multiple views for stereo 3d
|
||||
float viewShift[3];
|
||||
|
@ -510,9 +510,8 @@ sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * ca
|
|||
eye->SetUp();
|
||||
screen->SetViewportRects(bounds);
|
||||
Set3DViewport(mainview);
|
||||
GLRenderer->mDrawingScene2D = true;
|
||||
|
||||
FDrawInfo *di = FDrawInfo::StartDrawInfo(this, mainvp);
|
||||
FDrawInfo *di = FDrawInfo::StartDrawInfo(nullptr, mainvp);
|
||||
auto vp = di->Viewpoint;
|
||||
di->SetViewArea();
|
||||
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
|
||||
|
@ -520,7 +519,6 @@ sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * ca
|
|||
|
||||
// Stereo mode specific perspective projection
|
||||
SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
||||
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||
vp.SetViewAngle(r_viewwindow);
|
||||
// Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos
|
||||
eye->GetViewShift(vp.HWAngles.Yaw.Degrees, viewShift);
|
||||
|
@ -533,12 +531,11 @@ sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * ca
|
|||
if (mainview)
|
||||
{
|
||||
if (toscreen) di->EndDrawScene(mainvp.sector); // do not call this for camera textures.
|
||||
GLRenderer->PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector); });
|
||||
PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector); });
|
||||
}
|
||||
di->EndDrawInfo();
|
||||
GLRenderer->mDrawingScene2D = false;
|
||||
if (!stereo3dMode.IsMono())
|
||||
GLRenderer->mBuffers->BlitToEyeTexture(eye_ix);
|
||||
mBuffers->BlitToEyeTexture(eye_ix);
|
||||
}
|
||||
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
|
|
@ -19,12 +19,7 @@ public:
|
|||
GLPortal::drawer = this;
|
||||
}
|
||||
|
||||
void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror);
|
||||
void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
|
||||
void SetProjection(VSMatrix matrix);
|
||||
void Set3DViewport(bool mainview);
|
||||
|
||||
sector_t *RenderViewpoint(FRenderViewpoint &mainvp, AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||
sector_t *RenderView(player_t *player);
|
||||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
||||
};
|
||||
|
|
|
@ -36,7 +36,6 @@ VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float fovRatio) co
|
|||
{
|
||||
VSMatrix result;
|
||||
|
||||
// Lifted from gl_scene.cpp FGLRenderer::SetProjection()
|
||||
float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)));
|
||||
result.perspective(fovy, aspectRatio, FGLRenderer::GetZNear(), FGLRenderer::GetZFar());
|
||||
|
||||
|
|
Loading…
Reference in a new issue