WINTERMUTE: Store fov in member variable during 3d setup

This commit is contained in:
Gunnar Birke 2020-06-09 01:11:50 +02:00 committed by Paweł Kołodziejski
parent 6e8d7d8517
commit bb126c18ba
2 changed files with 6 additions and 4 deletions

View file

@ -175,12 +175,12 @@ bool BaseRenderOpenGL3D::drawRect(int x1, int y1, int x2, int y2, uint32 color,
return true; return true;
} }
bool BaseRenderOpenGL3D::setProjection(float fov) { bool BaseRenderOpenGL3D::setProjection() {
// is the viewport already set here? // is the viewport already set here?
float viewportWidth = _viewportRect.right - _viewportRect.left; float viewportWidth = _viewportRect.right - _viewportRect.left;
float viewportHeight = _viewportRect.bottom - _viewportRect.top; float viewportHeight = _viewportRect.bottom - _viewportRect.top;
float verticalViewAngle = fov; float verticalViewAngle = _fov;
float aspectRatio = float(viewportWidth) / float(viewportHeight); float aspectRatio = float(viewportWidth) / float(viewportHeight);
float nearPlane = 1.0f; float nearPlane = 1.0f;
float farPlane = 10000.0f; float farPlane = 10000.0f;
@ -313,7 +313,8 @@ bool BaseRenderOpenGL3D::setup3D(Camera3D* camera, bool force) {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glAlphaFunc(GL_GEQUAL, 0x08); glAlphaFunc(GL_GEQUAL, 0x08);
setProjection(camera->_fov); _fov = camera->_fov;
setProjection();
Math::Matrix4 viewMatrix; Math::Matrix4 viewMatrix;
camera->getViewMatrix(&viewMatrix); camera->getViewMatrix(&viewMatrix);

View file

@ -78,7 +78,7 @@ public:
bool drawLine(int x1, int y1, int x2, int y2, uint32 color) override; // Unused outside indicator-display bool drawLine(int x1, int y1, int x2, int y2, uint32 color) override; // Unused outside indicator-display
bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1) override; // Unused outside indicator-display bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1) override; // Unused outside indicator-display
bool setProjection(float fov); bool setProjection();
bool setProjection2D(); bool setProjection2D();
void resetModelViewTransform(); void resetModelViewTransform();
void pushWorldTransform(const Math::Matrix4 &transform); void pushWorldTransform(const Math::Matrix4 &transform);
@ -168,6 +168,7 @@ public:
private: private:
Math::Matrix4 _lastProjectionMatrix; Math::Matrix4 _lastProjectionMatrix;
Math::Matrix4 _lastViewMatrix; Math::Matrix4 _lastViewMatrix;
float _fov;
bool _spriteBatchMode; bool _spriteBatchMode;
bool _state3D; bool _state3D;
}; };