Mesh and lineCapMode

Hi,
The following code snipped shows my actual problem: it seems to me as if the mesh engine does affect the settings of e.g. a line like linecapmode, smooth, … Please try that, if you can repeat that problem? Does someone has an explanation for that? Or am I simply doing something wrong? The text describes the effect which I do have.

Thanks!


-- Use this function to perform your initial setup
function setup()
    text="This small demo shows that probably the mesh engine does change the "
    text = text .."drawing settings. I have no idea how to correct that. "
    text = text .."It also seems as if the new settings are ignored ...\
"  
    
    text = text .."If you switch the flag from 0 to 1 please "
    text = text .."inspect the endpoints of the line segments. They change from a "
    text = text .."visible black gap inbetween (which is strange) to the wanted "
    text = text .."dot at each line-end. Also smooth() seems to be affected. "
    text = text .."You can see that the line itself gets blurred. \
\
"
    
    text = text .."Another thing is the Output window on left side of screen. "
    text = text .."If I open Codea the first time and run the code the text is unfocussed. "
    text = text .."This can be corrected, if I completely shrink the window size first, and then "
    text = text .."go back to the default size (using gestures)."
    print(text)
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    iparameter("flag",0,1,0)

    -- shape of line segwment changes. So sequence of commands matters ...
    if flag==0 then
        triangle(60,10,25,60,75,65)
        lineseg()
    else
        lineseg()
        triangle(60,10,25,60,75,65)
    end
    
     
end
    
function triangle(x1, y1, x2, y2, x3, y3, c1, c2)
    pushStyle()
    pushMatrix()
        local col1 = c1 or color(255, 0, 0, 255)
        local col2 = c2 or nil
        local tri = {}
        local mytriangle 
        
        tri[1]=vec2(x1, y1)
        tri[2]=vec2(x2, y2)
        tri[3]=vec2(x3, y3)
    
        mytriangle = mesh()        
        mytriangle.vertices = tri    
        mytriangle:setColors(col1)
        mytriangle:draw()
        
    popMatrix()   
    popStyle()
end

function lineseg()   
    pushStyle()
    pushMatrix()
        translate(100,100)
        smooth()
        lineCapMode(PROJECT)
        stroke(255, 168, 0, 255)
        strokeWidth(7)
        line(10,10,40,40)
        line(40,40,60,40)
        line(60,40,70,80)
        translate(-100,-100)
    popMatrix()
    popStyle()
end


Thank you for this @CrazyEd. I’ve found the bug — the mesh renderer changes the blending mode but that state is not correctly resumed when the line is next rendered. This will be fixed.

This is now fixed for the next update. (It only affects lines rendered after a certain type of mesh.)

Many many thanks @Simeon! That was really quick!