So I followed The Cherno’s Game Engine series and now created the batch rendering system, I followed it, but the textures seem to flicker, like if OpenGL tries to mix two textures. Here is the fragment shader:
#version 330 core
layout (location = 0) out vec4 color;
in vec4 v_Color;
in vec2 v_TexCoord;
in float v_TexIndex;
uniform sampler2D u_Textures[32];
void main() {
color = texture(u_Textures[int(v_TexIndex)], v_TexCoord) * v_Color;
}
I think the issue is because of the index(ing), to solve this I should use the sampler2DArray, but here is now my question: I want to still be able to create different Textures, loading them seperately and then render them without having to create complex texture coordinates, how to achieve that with the sampler2DArray?