Skip to content

Commit fbb682a

Browse files
authored
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.
1 parent 06b776a commit fbb682a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/libprojectM/Renderer/StaticGlShaders.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class StaticGlShaders {
1616

1717
static std::shared_ptr<StaticGlShaders> instance(
1818
new StaticGlShaders(use_gles));
19-
2019
return instance;
2120
}
2221

@@ -44,15 +43,18 @@ class StaticGlShaders {
4443
int major, minor;
4544
};
4645

47-
// Constructs a StaticGlShaders, overriding the version to GLES3 if
48-
// `use_gles` is true.
49-
StaticGlShaders(bool use_gles);
50-
5146
// Queries the system GLSL version using
5247
// `glGetString(GL_SHADING_LANGUAGE_VERSION)` and returns the major and
5348
// minor numbers.
5449
GlslVersion QueryGlslVersion();
5550

51+
// Constructs a StaticGlShaders, overriding the version to GLES3 if
52+
// `use_gles` is true.
53+
// Note - this happens after GlslVersion is called, because it uses the
54+
// version to determine things.
55+
StaticGlShaders(bool use_gles);
56+
57+
5658
// Prepends a string of the form "#version <number>\n" to the provided
5759
// shader text, where <number> is derived from the queried GLSL version (or
5860
// overridden when the manager was constructed with `use_gles` = true).

src/libprojectM/Renderer/hlslparser/src/GLSLGenerator.cpp

100755100644
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ GLSLGenerator::GLSLGenerator() :
114114
m_tree = NULL;
115115
m_entryName = NULL;
116116
m_target = Target_VertexShader;
117+
#ifdef USE_GLES
118+
m_version = Version_300_ES;
119+
#else
117120
m_version = Version_330;
121+
#endif
122+
118123
m_versionLegacy = false;
119124
m_inAttribPrefix = NULL;
120125
m_outAttribPrefix = NULL;
@@ -233,7 +238,7 @@ bool GLSLGenerator::Generate(HLSLTree* tree, Target target, Version version, con
233238
m_writer.WriteLine(0, "precision highp float;");
234239
}
235240
else if (m_version == Version_300_ES)
236-
{
241+
{
237242
m_writer.WriteLine(0, "#version 300 es");
238243
m_writer.WriteLine(0, "precision highp float;");
239244
m_writer.WriteLine(0, "precision highp sampler3D;");

0 commit comments

Comments
 (0)