• Draw function only working on one panel at a time
    2 replies, posted
[img]http://img192.imageshack.us/img192/263/gmconstruct0025j.jpg[/img] Why does it only work for one panel on the screen at a time? [lua] function draw.DrawStripyBox( x, y, w, h, numx, numy, col1, col2 ) local is_col1 = true local xsp = w / numx local ysp = h / numy local firstcorner = { {}, {}, {} } firstcorner[ 1 ][ "x" ] = x firstcorner[ 1 ][ "y" ] = y firstcorner[ 2 ][ "x" ] = x + xsp firstcorner[ 2 ][ "y" ] = y firstcorner[ 3 ][ "x" ] = x firstcorner[ 3 ][ "y" ] = y + ysp surface.SetDrawColor( col2 ) surface.DrawPoly( firstcorner ) for i = 1, numx - 1, 1 do local vertexdata = { {}, {}, {}, {} } vertexdata[ 1 ][ "x" ] = x + ( i * xsp ) vertexdata[ 1 ][ "y" ] = y vertexdata[ 2 ][ "x" ] = x + ( ( i + 1 ) * xsp ) vertexdata[ 2 ][ "y" ] = y vertexdata[ 3 ][ "x" ] = x vertexdata[ 3 ][ "y" ] = y + ( ( i + 1 ) * ysp ) vertexdata[ 4 ][ "x" ] = x vertexdata[ 4 ][ "y" ] = y + ( i * ysp ) surface.SetDrawColor( ( is_col1 and col1 ) or col2 ) surface.DrawPoly( vertexdata ) is_col1 = not is_col1 end for i = 1, numy - 1, 1 do local vertexdata = { {}, {}, {}, {} } vertexdata[ 1 ][ "x" ] = ( x + w ) - i * xsp vertexdata[ 1 ][ "y" ] = y + h vertexdata[ 2 ][ "x" ] = ( x + w ) - ( i + 1 ) * xsp vertexdata[ 2 ][ "y" ] = y + h vertexdata[ 3 ][ "x" ] = x + w vertexdata[ 3 ][ "y" ] = ( y + h ) - ( i + 1 ) * ysp vertexdata[ 4 ][ "x" ] = x + w vertexdata[ 4 ][ "y" ] = ( y + h ) - i * ysp surface.SetDrawColor( ( is_col1 and col1 ) or col2 ) surface.DrawPoly( vertexdata ) is_col1 = not is_col1 end local lastcorner = { {}, {}, {} } lastcorner[ 1 ][ "x" ] = x + w lastcorner[ 1 ][ "y" ] = y + h lastcorner[ 2 ][ "x" ] = x + w - xsp lastcorner[ 2 ][ "y" ] = y + h lastcorner[ 3 ][ "x" ] = x + w lastcorner[ 3 ][ "y" ] = y + h - ysp surface.SetDrawColor( col1 ) surface.DrawPoly( lastcorner ) end function test( title, x, y ) local pnl = vgui.Create( "DFrame" ) pnl:SetTitle( title ) pnl:SetSize( x, y ) pnl:Center() function pnl:Paint() surface.SetDrawColor( Color( 0, 0, 0, 155 ) ) draw.DrawStripyBox( 0, 0, self:GetWide(), self:GetTall(), x/10, y/10, Color( 0, 0, 0, 200 ), Color( 51, 58, 51, 155 ) ) surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() ) end end [/lua]
[img]http://i.imgur.com/XB3CI.png[/img] The problem was that only the DFrame that had focus drawed the pattern. From this I considered the option that a different function was called when the DFrame doesn't have focus. With a bit of testing, I was right. This line fixed it: [lua]pnl.PaintOver = pnl.Paint[/lua]
You should not use using polys for that, once DrawTexturedRectUV is fixed you should use a texture since this would be a way less resource intensive.
Sorry, you need to Log In to post a reply to this thread.