You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two problems existed in the source managin the debug draw of texts
and lines, cube etc… :
- The text were draft directly when Render2DText was called.
But this suppose that the OpenGL state have to be changed before the
text render and have to be restored after the render.
The same appeared for the 2d box render.
- The debug shapes were stored in a private subclass of RAS_IRasterizer
per scene, so every push of a debug lines needed to pass the scene
pointer and the rasterizer needed to find the proper debug shape
list. This can cost a lot when the push could share a statement.
To fix these issue the first step was to create a special independant
class managing only the debug shapes, this class is named RAS_DebugDraw.
Its goal is to store the debug shapes but also to draw them using an
interface named RAS_OpenGLDebugDraw for all the OpenGL calls.
The rasterizer contains a list of all the debug drawer per scene, they
are get through the function GetDebugDraw. Once this, the push of
shapes is made as before but in the debug drawer instead of the rasterizer.
The 2D texts and boxes are now stored into the debug drawer to do one
OpenGL state switch before render them all and share the viewport settings.
To do this the functions RenderText2D and RenderBox2D are moved in RAS_DebugDraw.
In the same time the shadow is generalized by removing the "mode" argument
and using BLF_SHADOW mode for the text draw.
The flush function is a bit modified, it is renamed FlushDebugDraw and
need a canvas to be passed, this canvas is used to compute the viewport and
camera projection for 2D texts and boxes.
This refactor optimized the text render time of 31% (previous 0.81ms, now 0.56ms).
0 commit comments