Fixed #787: IndigoShader, expose ability to add UniformBlocks#790
Conversation
|
This works, but I'm still thinking about what I've ended up doing here a bit. I've realised (as a consequence of this work, wasn't the point of the PR) that you can now use one case class to define the data structure for both the Indigo and Ultraviolet side of passing data from engine to shader. The catch is that your definition must eventually use the few UV types we support for UBOs. This means that either we allow all the types we can support (as-is, such as I'm leaning towards the latter with some extension methods to aide conversion. |
| trait IndigoShader extends GameLauncher[IndigoShaderModel, IndigoShaderModel, Unit] { | ||
|
|
||
| given [A](using toUBO: ToUniformBlock[A]): Conversion[A, UniformBlock] with | ||
| def apply(value: A): UniformBlock = toUBO.toUniformBlock(value) |
There was a problem hiding this comment.
Will be the first and only implicit conversion in Indigo. 😛
Based on the comment above uniformBlocks below, saves the user from doing:
final case class CustomData(color: RGBA, customTime: Seconds) extends FragmentEnvReference derives ToUniformBlock
def uniformBlocks: Batch[UniformBlock] = Batch(
summon[ToUniformBlock[CustomData]].toUniformBlock(CustomData(RGBA.Magenta, 0.seconds))
)
I've had a go and the implementation sucks and is quite spectacularly unfriendly to use. I think I'm going to keep it as-is and just recommend sticking with UV types in the examples. |
No description provided.