The Problem

This is what happens when I draw switching from the black texture to the lime green one in a simple for loop

Here's a simplified version of how my renderer works

  1. Init(): Create my VAO and attrib pointers and generate element buffer and indicies
  2. Begin(): Bind my vertex buffer and map the buffer pointer
  3. Draw(): Submit a renderable to draw which gets 4 vertecies in the vertex buffer each get a position, color, texCoords, and a Texture Slot
  4. End(): I delete the buffer pointer, bind my VAO, IBO, and textures to their active texture slots and draw the elements.

I do this every frame. What I don't understand is if I draw PER TEXTURE, only having one active then this doesn't happen. It's when I have multiple active textures and they are bound.

Here's my fragment shader

#version 330 core
out vec4 FragColor;

in vec4 ourColor;
in vec2 ourTexCoord;
in float ourTid;

uniform sampler2D textures[32];

void main()
    vec4 texColor = ourColor;
    if(ourTid > 0.0) 
        int tid = int(ourTid - 0.5);
        texColor = ourColor * texture(textures[tid], ourTexCoord);
    FragColor = texColor;

I appreciate any help, let me know if you need to see more code


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.