Issue #1227 resolved

shader:sendColor drops the last color

Don Miguel
created an issue

when you send a table of colors into a shader the last color is dropped. Probably the count of the elements is broken.

It worked as it should with love2d 0.10.1 and stopped working with v0.10.2

the top right corner

old love 0.10.1 sends the colors in the shader fine it works

Here is a simple test script

--Love2d 0.10.2 sendColor bug:
-- the last color value in the table is missing

function love.load()
    myShader = [[
extern vec4 colors[3];
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
     if(screen_coords.x < 300)
          return colors[0];
     else if(screen_coords.x > 600)
      return colors[2];
   return colors[1];
}
]]
    shader = love.graphics.newShader(myShader)
    shader:sendColor("colors", { 255, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 0, 255, 255 })

    shader2 = love.graphics.newShader(myShader)
    shader2:sendColor("colors", { 255, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 0, 255, 255 },
        { 1, 1, 1, 1 })
end

function love.draw()
    love.graphics.clear()
    love.graphics.print("Send 3 colors into the shader. Get the 3rd wrong", 10, 0)
    love.graphics.print("We send 4 colors as a workaround. It works", 10, 190)

    love.graphics.setShader(shader) --draw something here
    love.graphics.rectangle("fill", 10, 20, 780, 120)

    love.graphics.setShader(shader2) --draw something here
    love.graphics.rectangle("fill", 10, 210, 780, 120)
    love.graphics.setShader()

    love.graphics.print("No shader", 10, 390)
    love.graphics.rectangle("fill", 10, 410, 780, 120)
end

from the love2f forum: https://love2d.org/forums/viewtopic.php?f=3&p=205799#p205799