Closed LaylBongers closed 9 years ago
Looks interesting. Is it a blocker for someone?
It is for Phosphorus
@LaylConway first off, you are calling draw_end
after each draw
. I don't think it's meant to be used this way. draw_end
should only be used once, I believe, but it's up to @Kagami to decide.
What's happening is - draw commands are queued but the vertex buffer gets rewritten multiple times before even the first command executes. The reason gfx-rs doesn't complain is this only "easy" bug - https://github.com/gfx-rs/gfx-rs/issues/139. Also, we are exploring better ways to make this kind of use case working in https://github.com/gfx-rs/gfx-rs/issues/730
The problem could be solved in one of the following ways:
draw_end
to only be called once per frame somehowI'm going to implement way-2 as the least restrictive one now in a PR.
Calling draw_end
only once in a frame is not an option when I need to do complex layering with text. It would mean I need a new text object for every single piece of text I need do draw. Trying this tanked the framerate way too bad.
Edit: To clarify, there's a reason I'm calling draw_end
more often, it's just not shown in this quick example.
@LaylConway why would you need a new text object?
@kvark If I can only call draw_end once on a text renderer object per frame, I would need multiple of them to draw multiple times per frame right?
@LaylConway no, you can call draw
multiple times before calling draw_end
. For example, remove all draw_end
but the last in the code you posted - it works.
But I assume draw_end does the actual drawing. This means that if I want to draw text, a square on top of it, then more text, I can't call draw_end at the end of it all.
I see what you mean. Fix is coming, hold on ;)
I'm calling it a day for now, I'll tomorrow check on a fix, I'll have to merge it up with the changes I'm using to allow usage of a stream.
I don't think it's meant to be used this way. draw_end should only be used once, I believe
Yes, it meant to be used that way: one draw_end
for one text instance on each frame. But your fix is also nice.
The following example code:
Will give the following result:
This causes problems in applications where multiple calls to
draw_end
are done for layering.