diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 9466e5fd0..7d8b36a42 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -90,7 +90,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) mLightCount = 0; mAngles = FRotator(0,0,0); mViewVector = FVector2(0,0); - mCameraPos = FVector3(0,0,0); mVBO = NULL; mSkyVBO = NULL; gl_spriteindex = 0; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 0e5e99643..534745869 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -67,7 +67,6 @@ public: FRotator mAngles; FVector2 mViewVector; - FVector3 mCameraPos; FFlatVertexBuffer *mVBO; FSkyVertexBuffer *mSkyVBO; @@ -83,7 +82,7 @@ public: void SetViewport(GL_IRECT *bounds); sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); void RenderView(player_t *player); - void SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle); + void SetViewAngle(angle_t viewangle); void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror); void Initialize(); @@ -121,7 +120,7 @@ public: void Flush() {} void SetProjection(float fov, float ratio, float fovratio); - void SetViewMatrix(bool mirror, bool planemirror); + void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); void ProcessScene(bool toscreen = false); bool StartOffscreen(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 395403690..189c3acc3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -86,6 +86,7 @@ CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_aspect, 1.2f, 0) EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Bool, cl_capfps) @@ -228,13 +229,12 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds) // //----------------------------------------------------------------------------- -void FGLRenderer::SetCameraPos(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle) +void FGLRenderer::SetViewAngle(angle_t viewangle) { float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; mAngles.Yaw = 270.0f-fviewangle; mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle))); - mCameraPos = FVector3(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); R_SetViewAngle(); } @@ -261,16 +261,16 @@ void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) // //----------------------------------------------------------------------------- -void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) +void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror) { float mult = mirror? -1:1; - float planemult = planemirror? -1:1; + float planemult = planemirror? -gl_aspect:gl_aspect; gl_RenderState.mViewMatrix.loadIdentity(); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); - gl_RenderState.mViewMatrix.translate( GLRenderer->mCameraPos.X * mult, -GLRenderer->mCameraPos.Z*planemult, -GLRenderer->mCameraPos.Y); + gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy)); gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); } @@ -283,8 +283,8 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) //----------------------------------------------------------------------------- void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror) { - SetCameraPos(viewx, viewy, viewz, viewangle); - SetViewMatrix(mirror, planemirror); + SetViewAngle(viewangle); + SetViewMatrix(viewx, viewy, viewz, mirror, planemirror); gl_RenderState.ApplyMatrices(); } @@ -795,8 +795,8 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo SetViewport(bounds); mCurrentFoV = fov; SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper - SetCameraPos(viewx, viewy, viewz, viewangle); - SetViewMatrix(false, false); + SetViewAngle(viewangle); + SetViewMatrix(viewx, viewy, viewz, false, false); gl_RenderState.ApplyMatrices(); clipper.Clear(); @@ -851,16 +851,15 @@ void FGLRenderer::RenderView (player_t* player) // I stopped using BaseRatioSizes here because the information there wasn't well presented. - #define RMUL (1.6f/1.333333f) // 4:3 16:9 16:10 17:10 5:4 - static float ratios[]={RMUL*1.333333f, RMUL*1.777777f, RMUL*1.6f, RMUL*1.7f, RMUL*1.25f}; + static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f}; // now render the main view float fovratio; float ratio = ratios[WidescreenRatio]; if (!(WidescreenRatio&4)) { - fovratio = 1.6f; + fovratio = 1.333333f; } else {