- Joined
- Jul 31, 2017
- Messages
- 500
Hi there
I made a modification to mojo2.graphics / DrawList: I added a DrawPrimitives and a DrawIndexedPrimitives that both take an additional array for individual vertex colours. For the curious, you can find it on GitHub. But the ugly things are, that
So far they look like this:
I think the name shouldn't be a problem. But I don't know where to put them - as functions into mojo2.graphics directly or as methods/functions into one of the classes of mojo2, and if, into which.
What would you prefer? I'm almost (say 51%) satisfied having them as separate functions.
I made a modification to mojo2.graphics / DrawList: I added a DrawPrimitives and a DrawIndexedPrimitives that both take an additional array for individual vertex colours. For the curious, you can find it on GitHub. But the ugly things are, that
- vertex colours have to be pre-multiplied
- vertex colours are stored in abgr instead of argb
So far they look like this:
Code:
' Converts pColor from ARGB to ABGR and premultiplies RGB
' Returns ABGR color
' PM stands for pre-multiplied
Function Argb2AbgrPM:Int(pColor:Int)
Local a:Int, r:Int, g:Int, b:Int
Local fa:Float
' extract color components
a = (pColor Shr 24) & $ff
r = (pColor Shr 16) & $ff
g = (pColor Shr 08) & $ff
b = (pColor ) & $ff
' premultiply
fa = Float(a) / 255.0
r *= fa
g *= fa
b *= fa
' reorder
Return (a Shl 24) | (b Shl 16) | (g Shl 08) | r
End
' Converts all colors in pColors from ARGB to ABGR and premultiplies RGB
' PM stans for pre-multiplied
Function Argb2AbgrPM:Void(pColors:Int[])
For Local i:Int = 0 Until pColors.Length
pColors[i] = Argb2AbgrPM( pColors[i] )
Next
End
I think the name shouldn't be a problem. But I don't know where to put them - as functions into mojo2.graphics directly or as methods/functions into one of the classes of mojo2, and if, into which.
What would you prefer? I'm almost (say 51%) satisfied having them as separate functions.