@@ -318,7 +318,7 @@ bool AabbAabbIntersects(r_aabb_s& a, r_aabb_s& b)
318318
319319struct Vertex {
320320 float x, y;
321- float u, v;
321+ float u, v, w ;
322322 float r, g, b, a;
323323 float viewX, viewY, viewW, viewH;
324324 float texId;
@@ -390,7 +390,7 @@ void Batch::Execute(GLuint sharedVbo, size_t vertexBase)
390390 auto dataSize = vertices.size () * sizeof (Vertex);
391391 glBufferSubData (GL_ARRAY_BUFFER , dataOff, dataSize, dataPtr);
392392 glVertexAttribPointer (xyAttr, 2 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, x));
393- glVertexAttribPointer (uvAttr, 2 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, u));
393+ glVertexAttribPointer (uvAttr, 3 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, u));
394394 glVertexAttribPointer (tintAttr, 4 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, r));
395395 glVertexAttribPointer (texIdAttr, 1 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, texId));
396396 glVertexAttribPointer (viewportAttr, 4 , GL_FLOAT , GL_FALSE , sizeof (Vertex), (void const *)offsetof (Vertex, viewX));
@@ -528,7 +528,7 @@ struct AdjacentMergeStrategy : RenderStrategy {
528528 texSlot = std::distance (textures.begin (), texI);
529529 }
530530
531- Vertex quad[4 ];
531+ Vertex quad[4 ]{} ;
532532 for (int v = 0 ; v < 4 ; v++) {
533533 auto & q = quad[v];
534534 auto & vp = nextViewport_;
@@ -622,7 +622,7 @@ struct AdjacentMergeStrategy : RenderStrategy {
622622 }
623623 }
624624 else {
625- glBindTexture (GL_TEXTURE_2D , 0 );
625+ glBindTexture (GL_TEXTURE_2D_ARRAY , 0 );
626626 }
627627 }
628628 glActiveTexture (GL_TEXTURE0 );
@@ -776,21 +776,21 @@ static std::string GetProgramInfoLog(GLuint id)
776776 return std::string (msg.data (), msg.data () + len);
777777}
778778
779- static char const * s_tintedTextureVertexSource = R"( #version 100
779+ static char const * s_tintedTextureVertexSource = R"( #version 300 es
780780
781781uniform mat4 mvp_matrix;
782782
783- attribute vec2 a_vertex;
784- attribute vec2 a_texcoord;
785- attribute vec4 a_tint;
786- attribute float a_texId;
787- attribute vec4 a_viewport;
783+ in vec2 a_vertex;
784+ in vec3 a_texcoord;
785+ in vec4 a_tint;
786+ in float a_texId;
787+ in vec4 a_viewport;
788788
789- varying vec2 v_screenPos;
790- varying vec2 v_texcoord;
791- varying vec4 v_tint;
792- varying float v_texId;
793- varying vec4 v_viewport;
789+ out vec2 v_screenPos;
790+ out vec3 v_texcoord;
791+ out vec4 v_tint;
792+ out float v_texId;
793+ out vec4 v_viewport;
794794
795795void main(void)
796796{
@@ -808,17 +808,19 @@ void main(void)
808808}
809809)" ;
810810
811- static char const * s_tintedTextureFragmentTemplate = R"( #version 100
811+ static char const * s_tintedTextureFragmentTemplate = R"( #version 300 es
812812precision mediump float;
813813
814- uniform sampler2D s_tex[{SG_TEXTURE_COUNT}];
814+ uniform highp sampler2DArray s_tex[{SG_TEXTURE_COUNT}];
815815uniform vec4 i_tint;
816816
817- varying vec2 v_screenPos;
818- varying vec2 v_texcoord;
819- varying vec4 v_tint;
820- varying float v_texId;
821- varying vec4 v_viewport; // x0, y0, x1, y1
817+ in vec2 v_screenPos;
818+ in vec3 v_texcoord;
819+ in vec4 v_tint;
820+ in float v_texId;
821+ in vec4 v_viewport; // x0, y0, x1, y1
822+
823+ out vec4 f_fragColor;
822824
823825void main(void)
824826{{
@@ -831,32 +833,34 @@ void main(void)
831833 }}
832834 vec4 color;
833835 {SG_TEXTURE_SWITCH}
834- gl_FragColor = color * v_tint;
836+ f_fragColor = color * v_tint;
835837}}
836838)" ;
837839
838- std::string const s_scaleVsSource = R"( #version 100
839- attribute vec4 a_position;
840- attribute vec2 a_texcoord;
840+ std::string const s_scaleVsSource = R"( #version 300 es
841+ in vec4 a_position;
842+ in vec2 a_texcoord;
841843
842- varying vec2 v_texcoord;
844+ out vec2 v_texcoord;
843845
844846void main(void) {
845847 gl_Position = a_position;
846848 v_texcoord = a_texcoord;
847849}
848850)" ;
849851
850- std::string const s_scaleFsSource = R"( #version 100
852+ std::string const s_scaleFsSource = R"( #version 300 es
851853precision mediump float;
852854
853- uniform sampler2D s_tex;
855+ uniform highp sampler2D s_tex;
856+
857+ in vec2 v_texcoord;
854858
855- varying vec2 v_texcoord ;
859+ out vec4 f_fragColor ;
856860
857861void main(void) {
858- vec3 color = texture2D (s_tex, v_texcoord).rgb;
859- gl_FragColor = vec4(color, 1.0);
862+ vec3 color = texture (s_tex, v_texcoord).rgb;
863+ f_fragColor = vec4(color, 1.0);
860864}
861865)" ;
862866
@@ -961,7 +965,7 @@ void r_renderer_c::Init(r_featureFlag_e features)
961965 else {
962966 fmt::format_to (fmt::appender (buf), " else if (v_texId < {}.5)" , i);
963967 }
964- fmt::format_to (fmt::appender (buf), " color = texture2D (s_tex[{}], v_texcoord);\n " , i);
968+ fmt::format_to (fmt::appender (buf), " color = texture (s_tex[{}], v_texcoord);\n " , i);
965969 }
966970 textureSwitch = to_string (buf);
967971 }
0 commit comments