Is there a way to batch render textures in Qt?

108 views Asked by At

I have been trying to batch render two different pictures. I have 2 different QOpenGLTexture objects I want to draw in a single draw call with batch rendering but am struggling. Both texture objects have id's but only the last texture objects image is drawn. I believe my problem is with setting up the or frag shader.


//..............Setting up uniform...............//
const GLuint vals[] = {m_texture1->textureId(), m_texture2->textureId()};
m_program->setUniformValueArray("u_TextureID", vals, 2);

//..............frag Shader.....................//
#version 330 core
out vec4 color;
in vec2 v_textCoord;               // Texture coordinate
in float v_index;                  // (0, 1) Vertex for which image to draw.  
                                   // 0 would draw the image of the first texture object
uniform sampler2D u_Texture[2];

void main()
{
    int index = int(v_index);
    color = texture(u_Texture[index], v_textCoord);
};

I've tried experimenting with the index value in the frag shader but it only draws the last texture image or blacks out. I tried implementing it how you would with openGL but have had no luck.

0

There are 0 answers