Render draw_line to gui (SOLVED)

FINALLY, i STARTED TO MAKE My game!

I tried to search before, but nothing.

For debugging purpouses i need to draw a line from on_update of my gui script, wich starts from a node to another gui node.
But if i send a msg.post("@render:", … ) it follows the world coordinates (affected by camera)

How can i render in gui coordinates?

Thanks you!!!

1 Like

Create a custom render script and change it so that the line:

render.draw_debug3d()

is called with the same view and projection as the GUI. Easiest is to move the line down a bit:

-- render GUI
--
render.set_view(vmath.matrix4())
render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))

render.enable_state(render.STATE_STENCIL_TEST)
render.draw(self.gui_pred)
render.draw(self.text_pred)
render.disable_state(render.STATE_STENCIL_TEST)
render.set_depth_mask(false)

-- draw debug lines in GUI space...
render.draw_debug3d()
...
6 Likes

Thank you, it works!

3 Likes