Mac OpenGL fixes

This commit is contained in:
Jack Andersen 2019-05-27 11:25:00 -10:00
parent c4cc4b8657
commit acd925ffaa
7 changed files with 23 additions and 8 deletions

View File

@ -10,6 +10,8 @@ include(cmake/generate_product_version.cmake)
if(MSVC)
add_compile_options(/WX /wd4267 /wd4100 /wd4101 /wd4189)
elseif(APPLE)
add_compile_definitions(GL_SILENCE_DEPRECATION)
endif()
# Set where the binary files will be built. The program will not execute from

View File

@ -16,4 +16,4 @@ void main()
{
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
gl_Position = vec4(Position, 1) * MVP;
};
}

View File

@ -66,4 +66,4 @@ void main()
Illum += (Atten * DiffuseAtten * Lights[iLight].Color);
}
COLOR0A0 = COLOR0_Mat * (Illum + COLOR0_Amb);
};
}

View File

@ -21,4 +21,4 @@ void main()
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
gl_Position = vec4(Position, 1) * MVP;
TexCoord = Tex0;
};
}

View File

@ -187,6 +187,12 @@ GLuint CShader::GetUniformBlockIndex(const char* pkUniformBlock)
return glGetUniformBlockIndex(mProgram, pkUniformBlock);
}
void CShader::UniformBlockBinding(GLuint BlockIndex, GLuint BlockBinding)
{
if (BlockIndex != GL_INVALID_INDEX)
glUniformBlockBinding(mProgram, BlockIndex, BlockBinding);
}
void CShader::SetTextureUniforms(uint32 NumTextures)
{
for (uint32 iTex = 0; iTex < NumTextures; iTex++)
@ -205,11 +211,11 @@ void CShader::SetCurrent()
glUseProgram(mProgram);
spCurrentShader = this;
glUniformBlockBinding(mProgram, mMVPBlockIndex, CGraphics::MVPBlockBindingPoint());
glUniformBlockBinding(mProgram, mVertexBlockIndex, CGraphics::VertexBlockBindingPoint());
glUniformBlockBinding(mProgram, mPixelBlockIndex, CGraphics::PixelBlockBindingPoint());
glUniformBlockBinding(mProgram, mLightBlockIndex, CGraphics::LightBlockBindingPoint());
glUniformBlockBinding(mProgram, mBoneTransformBlockIndex, CGraphics::BoneTransformBlockBindingPoint());
UniformBlockBinding(mMVPBlockIndex, CGraphics::MVPBlockBindingPoint());
UniformBlockBinding(mVertexBlockIndex, CGraphics::VertexBlockBindingPoint());
UniformBlockBinding(mPixelBlockIndex, CGraphics::PixelBlockBindingPoint());
UniformBlockBinding(mLightBlockIndex, CGraphics::LightBlockBindingPoint());
UniformBlockBinding(mBoneTransformBlockIndex, CGraphics::BoneTransformBlockBindingPoint());
}
}

View File

@ -37,6 +37,7 @@ public:
GLuint GetProgramID();
GLuint GetUniformLocation(const char* pkUniform);
GLuint GetUniformBlockIndex(const char* pkUniformBlock);
void UniformBlockBinding(GLuint BlockIndex, GLuint BlockBinding);
void SetTextureUniforms(uint32 NumTextures);
void SetNumLights(uint32 NumLights);
void SetCurrent();

View File

@ -107,6 +107,12 @@ public:
MacOSSetDarkAppearance();
#endif
// Default OpenGL format
QSurfaceFormat glFormat;
glFormat.setVersion(3, 3);
glFormat.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(glFormat);
// Init log
bool Initialized = NLog::InitLog(LocateLogPath());
if (!Initialized) UICommon::ErrorMsg(0, "Couldn't open log file. Logging will not work for this session.");