I made a small program to show why I think the docs, the code or both are wrong, as I first discovered here: #157
I think docs should be corrected to say ABGR and a Color.ToABGR() added OR DrawPrimitives should be changed to take ABGR Uints.
#Import "<std>"
#Import "<mojo>"
Using std..
Using mojo..
Class MyWindow Extends Window
Field poly:= New Float[8]
Field colors:= New Uint[4]
Method New()
Local x:Float = 100
Local y:Float = 100
Local w:Float = 400
Local h:Float = 300
poly[0]=x
poly[1]=y
poly[2]=x+w
poly[3]=y
poly[4]=x+w
poly[5]=y+h
poly[6]=x
poly[7]=y+h
Local col:UInt = Color.Red.ToARGB() ' results red blue inverted when used in DrawPrimitives()
'Local col:UInt = ToABGR(Color.Red) ' need this for correct colors for DrawPrimitives()
colors[0]=col
colors[1]=col
colors[2]=col
colors[3]=col
End Method
Method OnRender( canvas:Canvas ) Override
App.RequestRender()
canvas.DrawPrimitives(4,1,poly.Data,8,Null,0,colors.Data,4,null,null )
End
End
Function ToABGR:UInt(c:Color)
Return UInt(c.a*255) Shl 24 | UInt(c.b*255) Shl 16 | UInt(c.g*255) Shl 8 | UInt(c.r*255)
End Function
Function Main()
New AppInstance
New MyWindow
App.Run()
End
Original Author: Difference
I made a small program to show why I think the docs, the code or both are wrong, as I first discovered here: #157
I think docs should be corrected to say ABGR and a Color.ToABGR() added OR DrawPrimitives should be changed to take ABGR Uints.