package Ġcom . so y wiz . k orge . render Ċ Ċ import Ġcom . so y wiz . kor ag . log .* Ċ import Ġkotlin . test .* Ċ Ċ class ĠBatch Builder Test Ġ{ Ċ ĉ val Ġag Ġ= ĠLog AG ( 1 6 , Ġ 1 6 ) Ċ ĉ val Ġbb Ġ= ĠBatch Builder 2 D ( Render Context ( ag )) ĊĊ ĉ @ Test Ċ ĉ fun Ġsimple Batch () Ġ{ Ċĉ ĉ val Ġtex Ġ= ĠTexture ( ag . create Texture (), Ġ 1 0 0 , Ġ 1 0 0 ) Ċĉ ĉ bb . draw Quad ( tex , Ġ 0 f , Ġ 0 f ) Ċĉ ĉ bb . flush () ĊĊĉ ĉ assertEquals ( Ċĉĉ ĉ """ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Buffer ( VERTEX ): 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Buffer ( INDEX ): 1 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Texture (): 0 ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBuffer [ 0 ]. after Set Mem ( mem [ 3 9 3 2 1 6 ]) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBuffer [ 1 ]. after Set Mem ( mem [ 4 9 1 5 2 ]) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdraw ( vertices = Buffer [ 0 ], Ġindices = Buffer [ 1 ], Ġprogram = Program ( name = Batch Builder 2 D . Pre multiplied . Tint ed , Ġattributes =[ a _ Tex , Ġa _ Col , Ġa _ Col 2 , Ġa _ Pos ], Ġuniform s =[ u _ Proj Mat , Ġu _ View Mat , Ġu _ Tex ]), Ġtype = TRI ANG LES , Ġvertex Layout = Vertex Layout [ a _ Pos , Ġa _ Tex , Ġa _ Col , Ġa _ Col 2 ], Ġvertex Count = 6 , Ġoffset = 0 , Ġbl ending = Bl ending ( src RGB = SOURCE _ ALPHA , Ġdst RGB = ONE _ MINUS _ SOURCE _ ALPHA , Ġsrc A = ONE , Ġdst A = ONE _ MINUS _ SOURCE _ ALPHA , Ġeq RGB = ADD , Ġeq A = ADD ), Ġuniform s ={ Uniform ( u _ Proj Mat )= Matrix 3 D ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 . 0 1 5 6 2 5 , Ġ 0 , Ġ 0 , Ġ- 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ- 0 . 0 1 5 6 2 5 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ- 1 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĠUniform ( u _ View Mat )= Matrix 3 D ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 1 , Ġ 0 , Ġ 0 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 1 , Ġ 0 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 1 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĠUniform ( u _ Tex )= Texture Unit ( texture = Texture [ 0 ], Ġlinear = true )}, Ġstencil = Stencil State ( enabled = false , Ġtriangle Face = FRONT _ AND _ BACK , Ġcompare Mode = ALWAYS , Ġaction On Both Pass = KEEP , Ġaction On Depth Fail = KEEP , Ġaction On Depth Pass Stencil Fail = KEEP , Ġreference Value = 0 , Ġread Mask = 2 5 5 , Ġwrite Mask = 2 5 5 ), Ġcolor Mask = Color Mask State ( red = true , Ġgreen = true , Ġblue = true , Ġalpha = true )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . indices =[ 0 , Ġ 1 , Ġ 2 , Ġ 3 , Ġ 0 , Ġ 2 ] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 0 ]: Ġa _ Pos [ vec 2 ( 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 1 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 2 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 3 ]: Ġa _ Pos [ vec 2 ( 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] Ċĉĉ ĉ """. trim Indent (), Ċĉĉ ĉ ag . getLog AsString () Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġbatch 2 () Ġ{ Ċĉ ĉ val Ġtex Ġ= ĠTexture ( ag . create Texture (), Ġ 1 0 0 , Ġ 1 0 0 ) Ċĉ ĉ bb . draw Quad ( tex , Ġ 0 f , Ġ 0 f ) Ċĉ ĉ bb . draw Quad ( tex , Ġ 1 0 0 f , Ġ 0 f ) Ċĉ ĉ bb . flush () ĊĊĉ ĉ assertEquals ( Ċĉĉ ĉ """ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Buffer ( VERTEX ): 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Buffer ( INDEX ): 1 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Texture (): 0 ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBuffer [ 0 ]. after Set Mem ( mem [ 3 9 3 2 1 6 ]) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBuffer [ 1 ]. after Set Mem ( mem [ 4 9 1 5 2 ]) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdraw ( vertices = Buffer [ 0 ], Ġindices = Buffer [ 1 ], Ġprogram = Program ( name = Batch Builder 2 D . Pre multiplied . Tint ed , Ġattributes =[ a _ Tex , Ġa _ Col , Ġa _ Col 2 , Ġa _ Pos ], Ġuniform s =[ u _ Proj Mat , Ġu _ View Mat , Ġu _ Tex ]), Ġtype = TRI ANG LES , Ġvertex Layout = Vertex Layout [ a _ Pos , Ġa _ Tex , Ġa _ Col , Ġa _ Col 2 ], Ġvertex Count = 1 2 , Ġoffset = 0 , Ġbl ending = Bl ending ( src RGB = SOURCE _ ALPHA , Ġdst RGB = ONE _ MINUS _ SOURCE _ ALPHA , Ġsrc A = ONE , Ġdst A = ONE _ MINUS _ SOURCE _ ALPHA , Ġeq RGB = ADD , Ġeq A = ADD ), Ġuniform s ={ Uniform ( u _ Proj Mat )= Matrix 3 D ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 . 0 1 5 6 2 5 , Ġ 0 , Ġ 0 , Ġ- 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ- 0 . 0 1 5 6 2 5 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ- 1 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĠUniform ( u _ View Mat )= Matrix 3 D ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 1 , Ġ 0 , Ġ 0 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 1 , Ġ 0 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 1 , Ġ 0 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ[ Ġ 0 , Ġ 0 , Ġ 0 , Ġ 1 Ġ], ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĠUniform ( u _ Tex )= Texture Unit ( texture = Texture [ 0 ], Ġlinear = true )}, Ġstencil = Stencil State ( enabled = false , Ġtriangle Face = FRONT _ AND _ BACK , Ġcompare Mode = ALWAYS , Ġaction On Both Pass = KEEP , Ġaction On Depth Fail = KEEP , Ġaction On Depth Pass Stencil Fail = KEEP , Ġreference Value = 0 , Ġread Mask = 2 5 5 , Ġwrite Mask = 2 5 5 ), Ġcolor Mask = Color Mask State ( red = true , Ġgreen = true , Ġblue = true , Ġalpha = true )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . indices =[ 0 , Ġ 1 , Ġ 2 , Ġ 3 , Ġ 0 , Ġ 2 , Ġ 4 , Ġ 5 , Ġ 6 , Ġ 7 , Ġ 4 , Ġ 6 ] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 0 ]: Ġa _ Pos [ vec 2 ( 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 1 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 2 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 3 ]: Ġa _ Pos [ vec 2 ( 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 4 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 5 ]: Ġa _ Pos [ vec 2 ( 2 0 0 . 0 , 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 0 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 6 ]: Ġa _ Pos [ vec 2 ( 2 0 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 1 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ:: draw . vertex [ 7 ]: Ġa _ Pos [ vec 2 ( 1 0 0 . 0 , 1 0 0 . 0 )], Ġa _ Tex [ vec 2 ( 0 . 0 , 1 . 0 )], Ġa _ Col [ byte 4 (- 1 )], Ġa _ Col 2 [ byte 4 ( 2 1 3 9 0 6 2 1 4 3 )] Ċĉĉ ĉ """. trim Indent (), Ċĉĉ ĉ ag . getLog AsString () Ċĉ ĉ ) Ċ ĉ } Ċ } Ċ