Created
January 21, 2016 18:56
-
-
Save jakubfijalkowski/3af8cb0f0b0291c0c8ea to your computer and use it in GitHub Desktop.
Revisions
-
jakubfijalkowski created this gist
Jan 21, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ // Version A let private renderTriangleAlways renderer ctx v1 v2 v3 c = let ymin', aes = getAEs v1 v2 v3 let mutable ymin = ymin' for ae1, ae2 in aes do let ymax = ae1.YMax for y = ymin to ymax - 1 do let minX = int (min ae1.X ae2.X) let maxX = int <| ceil (max ae1.X ae2.X) for x = minX to maxX do NativeInterop.NativePtr.set ctx.Context.Pixels (x + y * ctx.Width) c ae1.X <- ae1.X + ae1.CoeffX ae2.X <- ae2.X + ae2.CoeffX ymin <- ymax // Version B - ~2 times slower let private renderTriangleZBuffer renderer ctx v1 v2 v3 c = let ymin', aes = getAEs v1 v2 v3 let mutable ymin = ymin' for ae1, ae2 in aes do let ymax = ae1.YMax for y = ymin to ymax - 1 do let minX = int (min ae1.X ae2.X) let maxX = int <| ceil (max ae1.X ae2.X) for x = minX to maxX do let idx = y * ctx.Context.Width + x NativeInterop.NativePtr.set ctx.Context.Pixels idx c ae1.X <- ae1.X + ae1.CoeffX ae2.X <- ae2.X + ae2.CoeffX ymin <- ymax