GlslWriter: Handle OpenGL ES precision qualifier

This commit is contained in:
Jérôme Leclercq 2020-07-08 22:52:33 +02:00
parent b076a517c6
commit cd01facd01
2 changed files with 11 additions and 2 deletions

View File

@ -35,8 +35,7 @@ namespace Nz
const auto& contextParams = context.GetParams(); const auto& contextParams = context.GetParams();
GlslWriter::Environment env; GlslWriter::Environment env;
env.glES = false; env.glES = (contextParams.type == GL::ContextType::OpenGL_ES);
//env.glES = (contextParams.type == GL::ContextType::OpenGL_ES);
env.glMajorVersion = contextParams.glMajorVersion; env.glMajorVersion = contextParams.glMajorVersion;
env.glMinorVersion = contextParams.glMinorVersion; env.glMinorVersion = contextParams.glMinorVersion;
env.extCallback = [&](const std::string_view& ext) env.extCallback = [&](const std::string_view& ext)

View File

@ -98,6 +98,16 @@ namespace Nz
AppendLine(); AppendLine();
} }
if (m_environment.glES)
{
AppendLine("#if GL_FRAGMENT_PRECISION_HIGH");
AppendLine("precision highp float;");
AppendLine("#else");
AppendLine("precision mediump float;");
AppendLine("#endif");
AppendLine();
}
// Global variables (uniforms, input and outputs) // Global variables (uniforms, input and outputs)
const char* inKeyword = (glslVersion >= 130) ? "in" : "varying"; const char* inKeyword = (glslVersion >= 130) ? "in" : "varying";
const char* outKeyword = (glslVersion >= 130) ? "out" : "varying"; const char* outKeyword = (glslVersion >= 130) ? "out" : "varying";