From ff785332c9d770322e6d4b3988e56f2ada20dc02 Mon Sep 17 00:00:00 2001 From: Seb James Date: Wed, 27 May 2026 15:33:54 +0100 Subject: [PATCH 1/2] Changes to make GLSL compatible with OpenGL ES --- mplot/VisualDefaultShaders.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mplot/VisualDefaultShaders.h b/mplot/VisualDefaultShaders.h index 5d2fff3d..71ed7acf 100644 --- a/mplot/VisualDefaultShaders.h +++ b/mplot/VisualDefaultShaders.h @@ -16,9 +16,9 @@ namespace mplot "uniform float alpha;\n"; const char* defaultVtxShader_instance_uniforms = "uniform mat4 s_matrix;\n" // scaling matrix - "uniform int instance_count = 0;\n" - "uniform int instance_start = -1;\n" - "uniform int instparam_count = 0;\n"; + "uniform int instance_count;\n" + "uniform int instance_start;\n" + "uniform int instparam_count;\n"; const char* defaultVtxShader_part1b = "layout(location = 0) in vec4 position;\n" "layout(location = 1) in vec4 normalin;\n" @@ -50,7 +50,11 @@ namespace mplot "{\n" " if (instance_count > 0) {\n" " int ipos_i = instance_start * 3 + gl_InstanceID * 3;\n" - " vec4 iposv = { ipos[ipos_i], ipos[ipos_i + 1], ipos[ipos_i + 2], 0 };\n" + " vec4 iposv;\n" + " iposv[0] = ipos[ipos_i];\n" + " iposv[1] = ipos[ipos_i + 1];\n" + " iposv[2] = ipos[ipos_i + 2];\n" + " iposv[3] = 0.0;\n" " if (instparam_count > 0) {\n" " int idx = gl_InstanceID % instparam_count;\n" " int ippos_i = instance_start * 5;\n" From bac74fe5e0ffb9bb1e3db41c09dfc8e9c0a4b047 Mon Sep 17 00:00:00 2001 From: Seb James Date: Tue, 2 Jun 2026 12:04:59 +0100 Subject: [PATCH 2/2] Reflect the changes in generated GLSL from ff78533 in the in-source glsl copies --- shaders/Visual_instancing.vert.glsl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shaders/Visual_instancing.vert.glsl b/shaders/Visual_instancing.vert.glsl index e11e5e8d..6aed531a 100644 --- a/shaders/Visual_instancing.vert.glsl +++ b/shaders/Visual_instancing.vert.glsl @@ -3,9 +3,9 @@ uniform mat4 m_matrix; uniform mat4 v_matrix; uniform mat4 p_matrix; uniform float alpha; -uniform int instance_count = 0; -uniform int instance_start = -1; -uniform int instparam_count = 0; +uniform int instance_count; +uniform int instance_start; +uniform int instparam_count; layout(location = 0) in vec4 position; layout(location = 1) in vec4 normalin; layout(location = 2) in vec3 color; @@ -21,7 +21,11 @@ void main() { if (instance_count > 0) { int ipos_i = instance_start * 3 + gl_InstanceID * 3; - vec4 iposv = { ipos[ipos_i], ipos[ipos_i + 1], ipos[ipos_i + 2], 0 }; + vec4 iposv; + iposv[0] = ipos[ipos_i]; + iposv[1] = ipos[ipos_i + 1]; + iposv[2] = ipos[ipos_i + 2]; + iposv[3] = 0.0; if (instparam_count > 0) { int idx = gl_InstanceID % instparam_count; int ippos_i = instance_start * 5;