Open simsaens opened 2 months ago
Thanks for the PR and sorry for the delayed reply.
Unfortunately I cannot merge this PR atm because I feel this should be a feature implemented in a different way. Regarding your questions:
In other words, I'd implement it similar to how the scissor rect is currently handled.
May I ask how depth order can help with the "text on top of UI widget" case? Is your whole UI a single layer (background + text)? If it has multiple layers (e.g. overlapping windows), do you plan to increase the depth order for every UI layer?
My approach to this would be a bit different (and a bit more complicated). IMO the API should be something like:
vg::beginLayer(1)
// Draw shapes to layer 1 here
vg::endLayer() // Automatically revert to layer 0
// Draw shapes to layer 0 here
vg::beginLayer(2)
// Draw shapes to layer 2 here
vg::endLayer()
AFAIR, I tried implementing something like that in the layers branch but I never finished it. Unfortunately I don't remember the details.
Having said all that, I don't currently use this version of the library in my own projects. I use a stripped down version based on c99 branch. AFAIK @bkaradzic plans on integrating vg-renderer into bgfx at some point so it might be better if you tried porting your changes to his branch once it's ready.
We use vg-renderer extensively in our project and have found the need to specify a depth order (which gets passed through to
bgfx::submit
asdepth
). This is used to, for example, render text on top of UI components or just layer different shapes in a specified orderingThis PR attempts to add a public API to vg-renderer to specify the depth ordering state of the renderer. I'm unsure about some things:
depthOrder
orsetDepthOrder
(I went with the former, opting for brevity)DrawCommand
, or is it sufficient to keep the depth order inState
? Again, I went with the formerDrawCommand
, then do we need tom_ForceNewDrawCommand
whenctxPopState
runs if the depth order is different?State
, then is it OK togetState(ctx)
from theend(...)
function in order to read the depthOrder forbgfx::submit
?I am happy to change anything (naming, etc) to match convention here