Strange clip behaviour

I expect I’m just doing something wrong here …

I wanted to try out the new clip stuff so created a simple project to do that. When it didn’t work, I fired up an old project and discovered that the clip from the test project was still in effect! Does anyone else get the same?

Here’s the test code

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end

-- This function gets called once every frame
function draw()
    -- This sets the background color to black
    background(0, 0, 0)
    --translate(WIDTH/2,HEIGHT/2)
    clip(0,0,100,100)
    --noClip()
    fill(255, 0, 0, 255)
    stroke(0, 3, 255, 255)
    rect(0,0,600,600)
    line(0,0,WIDTH,HEIGHT)
    -- Do your drawing here
end

It’s an OpenGL state bug - the clip() state should be reset when you start the viewer. Will have to fix that.

Or we can reset clip() at the start of the draw function, what do you think?

Either way, your code can be fixed like this. Because your background(0, 0, 0) call will continue to be clipped after the first frame is drawn.


-- This function gets called once every frame
function draw()
    -- This sets the background color to black
    background(0, 0, 0)
    --translate(WIDTH/2,HEIGHT/2)
    clip(0,0,100,100)
    --noClip()
    fill(255, 0, 0, 255)
    stroke(0, 3, 255, 255)
    rect(0,0,600,600)
    line(0,0,WIDTH,HEIGHT)
    -- Do your drawing here

    noClip()
end

I’ve reset it at the start of draw() now. This will probably be in a 1.2.6 update submitted soon.