- updated GL renderer.
This commit is contained in:
parent
348c384bb6
commit
af78937a15
22 changed files with 238 additions and 306 deletions
|
|
@ -131,18 +131,18 @@ angle_t FGLRenderer::FrustumAngle()
|
|||
void FGLRenderer::SetViewArea()
|
||||
{
|
||||
// The render_sector is better suited to represent the current position in GL
|
||||
viewsector = R_PointInSubsector(viewx, viewy)->render_sector;
|
||||
viewsector = R_PointInSubsector(ViewPos)->render_sector;
|
||||
|
||||
// Get the heightsec state from the render sector, not the current one!
|
||||
if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
{
|
||||
in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below :
|
||||
(viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) &&
|
||||
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal;
|
||||
in_area = ViewPos.Z <= viewsector->heightsec->floorplane.ZatPoint(ViewPos) ? area_below :
|
||||
(ViewPos.Z > viewsector->heightsec->ceilingplane.ZatPoint(ViewPos) &&
|
||||
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above : area_normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_area=area_default; // depends on exposed lower sectors
|
||||
in_area = area_default; // depends on exposed lower sectors
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,12 +218,12 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::SetViewAngle(angle_t viewangle)
|
||||
void FGLRenderer::SetViewAngle(DAngle viewangle)
|
||||
{
|
||||
float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES;
|
||||
|
||||
mAngles.Yaw = 270.0f-fviewangle;
|
||||
mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle)));
|
||||
mAngles.Yaw = float(270.0-viewangle.Degrees);
|
||||
DVector2 v = ViewAngle.ToVector();
|
||||
mViewVector.X = v.X;
|
||||
mViewVector.Y = v.Y;
|
||||
|
||||
R_SetViewAngle();
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ void FGLRenderer::SetProjection(VSMatrix matrix)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror)
|
||||
void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||
{
|
||||
float mult = mirror? -1:1;
|
||||
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch;
|
||||
|
|
@ -267,7 +267,7 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo
|
|||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
|
||||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f);
|
||||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f);
|
||||
gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy));
|
||||
gl_RenderState.mViewMatrix.translate(vx * mult, -vz * planemult , -vy);
|
||||
gl_RenderState.mViewMatrix.scale(-mult, planemult, 1);
|
||||
}
|
||||
|
||||
|
|
@ -278,10 +278,10 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo
|
|||
// Setup the view rotation matrix for the given viewpoint
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror)
|
||||
void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
||||
{
|
||||
SetViewAngle(viewangle);
|
||||
SetViewMatrix(viewx, viewy, viewz, mirror, planemirror);
|
||||
SetViewAngle(va);
|
||||
SetViewMatrix(vx, vy, vz, mirror, planemirror);
|
||||
gl_RenderState.ApplyMatrices();
|
||||
}
|
||||
|
||||
|
|
@ -305,6 +305,7 @@ void FGLRenderer::CreateScene()
|
|||
for(unsigned i=0;i<portals.Size(); i++) portals[i]->glportal = NULL;
|
||||
gl_spriteindex=0;
|
||||
Bsp.Clock();
|
||||
R_SetView();
|
||||
gl_RenderBSPNode (nodes + numnodes - 1);
|
||||
Bsp.Unclock();
|
||||
|
||||
|
|
@ -333,7 +334,7 @@ void FGLRenderer::RenderScene(int recursion)
|
|||
glDepthMask(true);
|
||||
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion);
|
||||
|
||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
|
||||
|
||||
gl_RenderState.EnableFog(true);
|
||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||
|
|
@ -455,7 +456,7 @@ void FGLRenderer::RenderTranslucent()
|
|||
RenderAll.Clock();
|
||||
|
||||
glDepthMask(false);
|
||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
|
||||
|
||||
// final pass: translucent stuff
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||
|
|
@ -567,13 +568,13 @@ void FGLRenderer::DrawBlend(sector_t * viewsector)
|
|||
|
||||
for (unsigned int i = 0; i < lightlist.Size(); i++)
|
||||
{
|
||||
fixed_t lightbottom;
|
||||
double lightbottom;
|
||||
if (i < lightlist.Size() - 1)
|
||||
lightbottom = lightlist[i + 1].plane.ZatPoint(viewx, viewy);
|
||||
lightbottom = lightlist[i + 1].plane.ZatPoint(ViewPos);
|
||||
else
|
||||
lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy);
|
||||
lightbottom = viewsector->floorplane.ZatPoint(ViewPos);
|
||||
|
||||
if (lightbottom < viewz && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS)))
|
||||
if (lightbottom < ViewPos.Z && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS)))
|
||||
{
|
||||
// 3d floor 'fog' is rendered as a blending value
|
||||
blendv = lightlist[i].blend;
|
||||
|
|
@ -706,7 +707,7 @@ void FGLRenderer::ProcessScene(bool toscreen)
|
|||
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
|
||||
GLPortal::BeginScene();
|
||||
|
||||
int mapsection = R_PointInSubsector(viewx, viewy)->mapsection;
|
||||
int mapsection = R_PointInSubsector(ViewPos)->mapsection;
|
||||
memset(¤tmapsection[0], 0, currentmapsection.Size());
|
||||
currentmapsection[mapsection>>3] |= 1 << (mapsection & 7);
|
||||
DrawScene(toscreen);
|
||||
|
|
@ -771,10 +772,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
SetViewArea();
|
||||
|
||||
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
|
||||
double radPitch = (viewpitch)* M_PI / 0x80000000;
|
||||
if (radPitch > PI) radPitch -= 2 * PI;
|
||||
radPitch = clamp(radPitch, -PI / 2, PI / 2);
|
||||
|
||||
double radPitch = clamp(ViewPitch.Normalized180().Radians(), -PI / 2, PI / 2);
|
||||
double angx = cos(radPitch);
|
||||
double angy = sin(radPitch) * glset.pixelstretch;
|
||||
double alen = sqrt(angx*angx + angy*angy);
|
||||
|
|
@ -815,16 +813,16 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
// Stereo mode specific perspective projection
|
||||
SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
||||
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||
SetViewAngle(viewangle);
|
||||
SetViewAngle(ViewAngle);
|
||||
// Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz
|
||||
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
|
||||
s3d::ScopedViewShifter viewShifter(viewShift);
|
||||
SetViewMatrix(viewx, viewy, viewz, false, false);
|
||||
SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false);
|
||||
gl_RenderState.ApplyMatrices();
|
||||
|
||||
clipper.Clear();
|
||||
angle_t a1 = FrustumAngle();
|
||||
clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1);
|
||||
clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1);
|
||||
|
||||
ProcessScene(toscreen);
|
||||
if (mainview) EndDrawScene(retval); // do not call this for camera textures.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue