This work fixes a problem where GL 3.30 was being chosen for (#493)

GLES 2.0 mode. GLES needs Version 3.00 ES.

This was done by switching the order of how a StaticGl Shader is constructed,
And there is additional code that properly sets up the GLSLGenerator for GLES mode.
This commit is contained in:
Hib Engler
2021-05-27 23:13:48 -07:00
committed by GitHub
parent 06b776ad7e
commit fbb682a649
2 changed files with 13 additions and 6 deletions

View File

@ -16,7 +16,6 @@ class StaticGlShaders {
static std::shared_ptr<StaticGlShaders> instance(
new StaticGlShaders(use_gles));
return instance;
}
@ -44,15 +43,18 @@ class StaticGlShaders {
int major, minor;
};
// Constructs a StaticGlShaders, overriding the version to GLES3 if
// `use_gles` is true.
StaticGlShaders(bool use_gles);
// Queries the system GLSL version using
// `glGetString(GL_SHADING_LANGUAGE_VERSION)` and returns the major and
// minor numbers.
GlslVersion QueryGlslVersion();
// Constructs a StaticGlShaders, overriding the version to GLES3 if
// `use_gles` is true.
// Note - this happens after GlslVersion is called, because it uses the
// version to determine things.
StaticGlShaders(bool use_gles);
// Prepends a string of the form "#version <number>\n" to the provided
// shader text, where <number> is derived from the queried GLSL version (or
// overridden when the manager was constructed with `use_gles` = true).

View File

@ -114,7 +114,12 @@ GLSLGenerator::GLSLGenerator() :
m_tree = NULL;
m_entryName = NULL;
m_target = Target_VertexShader;
#ifdef USE_GLES
m_version = Version_300_ES;
#else
m_version = Version_330;
#endif
m_versionLegacy = false;
m_inAttribPrefix = NULL;
m_outAttribPrefix = NULL;
@ -233,7 +238,7 @@ bool GLSLGenerator::Generate(HLSLTree* tree, Target target, Version version, con
m_writer.WriteLine(0, "precision highp float;");
}
else if (m_version == Version_300_ES)
{
{
m_writer.WriteLine(0, "#version 300 es");
m_writer.WriteLine(0, "precision highp float;");
m_writer.WriteLine(0, "precision highp sampler3D;");