From e7fe26d2a4d0ca5320feb18079b5eafbe0f66cb7 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 29 Jan 2017 19:31:30 -0800 Subject: [PATCH] Stop caching the GL viewport since OSX changes it when making a context current. --- common/lc_context.cpp | 13 ------------- common/lc_context.h | 15 --------------- common/lc_model.cpp | 7 ++++--- common/lc_model.h | 4 +++- common/minifig.cpp | 2 +- common/view.cpp | 2 +- 6 files changed, 9 insertions(+), 34 deletions(-) diff --git a/common/lc_context.cpp b/common/lc_context.cpp index 2a679580..d7cb9eff 100644 --- a/common/lc_context.cpp +++ b/common/lc_context.cpp @@ -75,11 +75,6 @@ lcContext::lcContext() mFramebufferTexture = 0; mDepthRenderbufferObject = 0; - mViewportX = 0; - mViewportY = 0; - mViewportWidth = 1; - mViewportHeight = 1; - mColor = lcVector4(0.0f, 0.0f, 0.0f, 0.0f); mWorldMatrix = lcMatrix44Identity(); mViewMatrix = lcMatrix44Identity(); @@ -330,15 +325,7 @@ void lcContext::SetProgram(lcProgramType ProgramType) void lcContext::SetViewport(int x, int y, int Width, int Height) { - if (mViewportX == x && mViewportY == y && mViewportWidth == Width && mViewportHeight == Height) - return; - glViewport(x, y, Width, Height); - - mViewportX = x; - mViewportY = y; - mViewportWidth = Width; - mViewportHeight = Height; } void lcContext::SetLineWidth(float LineWidth) diff --git a/common/lc_context.h b/common/lc_context.h index 35815c05..2e0a69ae 100644 --- a/common/lc_context.h +++ b/common/lc_context.h @@ -88,16 +88,6 @@ public: lcContext(); ~lcContext(); - int GetViewportWidth() const - { - return mViewportWidth; - } - - int GetViewportHeight() const - { - return mViewportHeight; - } - static void CreateResources(); static void DestroyResources(); @@ -186,11 +176,6 @@ protected: float mLineWidth; int mMatrixMode; - int mViewportX; - int mViewportY; - int mViewportWidth; - int mViewportHeight; - lcVector4 mColor; lcMatrix44 mWorldMatrix; lcMatrix44 mViewMatrix; diff --git a/common/lc_model.cpp b/common/lc_model.cpp index d6c4e08e..f7b3c88d 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1100,7 +1100,7 @@ void lcModel::SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMat } } -void lcModel::DrawBackground(lcContext* Context) +void lcModel::DrawBackground(lcGLWidget* Widget) { if (mProperties.mBackgroundType == LC_BACKGROUND_SOLID) { @@ -1115,9 +1115,10 @@ void lcModel::DrawBackground(lcContext* Context) glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); - float ViewWidth = (float)Context->GetViewportWidth(); - float ViewHeight = (float)Context->GetViewportHeight(); + float ViewWidth = (float)Widget->mWidth; + float ViewHeight = (float)Widget->mHeight; + lcContext* Context = Widget->mContext; Context->SetWorldMatrix(lcMatrix44Identity()); Context->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0))); Context->SetProjectionMatrix(lcMatrix44Ortho(0.0f, ViewWidth, 0.0f, ViewHeight, -1.0f, 1.0f)); diff --git a/common/lc_model.h b/common/lc_model.h index b0821bd7..a43bde62 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -19,6 +19,8 @@ #define LC_SEL_CAN_ADD_CONTROL_POINT 0x0800 // Can add control points to focused piece #define LC_SEL_CAN_REMOVE_CONTROL_POINT 0x1000 // Can remove control points from focused piece +class lcGLWidget; + enum lcTransformType { LC_TRANSFORM_ABSOLUTE_TRANSLATION, @@ -212,7 +214,7 @@ public: void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface) const; void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const; - void DrawBackground(lcContext* Context); + void DrawBackground(lcGLWidget* Widget); void SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, int Width, int Height, lcStep Start, lcStep End); void RayTest(lcObjectRayTest& ObjectRayTest) const; diff --git a/common/minifig.cpp b/common/minifig.cpp index 6a71588b..bc30b0de 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -223,7 +223,7 @@ void MinifigWizard::OnDraw() float Aspect = (float)mWidth/(float)mHeight; mContext->SetViewport(0, 0, mWidth, mHeight); - lcGetActiveModel()->DrawBackground(mContext); + lcGetActiveModel()->DrawBackground(this); lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX); diff --git a/common/view.cpp b/common/view.cpp index 4d526600..eb29020d 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -562,7 +562,7 @@ void View::OnDraw() mContext->SetDefaultState(); mContext->SetViewport(0, 0, mWidth, mHeight); - mModel->DrawBackground(mContext); + mModel->DrawBackground(this); const lcPreferences& Preferences = lcGetPreferences(); const lcModelProperties& Properties = mModel->GetProperties();