Stop caching the GL viewport since OSX changes it when making a context current.

This commit is contained in:
Leonardo Zide
2017-01-29 19:31:30 -08:00
parent 32f2f3fac7
commit e7fe26d2a4
6 changed files with 9 additions and 34 deletions
-13
View File
@@ -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)
-15
View File
@@ -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;
+4 -3
View File
@@ -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));
+3 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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();