Name: gfx_debug_draw
Owner: PistonDevelopers
Description: Simple debug renderer (lines, text, etc) for gfx
Created: 2015-02-23 21:26:39.0
Updated: 2016-11-02 18:47:27.0
Pushed: 2018-02-22 01:41:25.0
Homepage: null
Size: 132
Language: Rust
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Library for batched renderering of lines and text in 3D space, using gfx-rs.
nitializing...
reate gfx_text::Renderer to be used by the DebugRenderer
text_renderer = {
let factory = piston_window.device.borrow_mut().spawn_factory(); // gfx::Factory
gfx_text::new(factory).unwrap() // can optionally configure text renderer here (font, color)
mut debug_renderer = DebugRenderer::new(
piston_window.device.borrow_mut().spawn_factory(), // gfx::Factory
text_renderer,
64, // Initial size of vertex buffers
().unwrap();
n render loop...
raw red line from origin along x-axis
g_renderer.draw_line(
[0.0, 0.0, 0.0], // Start position
[5.0, 0.0, 0.0], // End position
[1.0, 0.0, 0.0, 1.0], // Line color
raw an 'X' on the x-axis, at the end of the line drawn above.
g_renderer.draw_text_at_position(
"X", // String to draw
[6.0, 0.0, 0.0], // World-space position to draw at
[1.0, 0.0, 0.0, 1.0], // Text color
raw salmoney-colored text 10 pixels down and right from the top left corner of the screen
g_renderer.draw_text_on_screen(
"Hello World!", // Text to draw
[10, 10], // Pixel coordinates relative to top-left corner of screen
[1.0, 0.4, 0.4, 0.7] // Text color
raw a yellow position marker
g_renderer.draw_marker(
[1.0, 2.0, 3.0], // Position
0.5, // Size
[1.0, 1.0, 0.0, 1.0] // Color
ender the final batch of all lines and text currently present in the vertex/index buffers
g_renderer.render(
stream, // &mut gfx::Stream
camera_projection, // Current camera projection matrix
Draw commands can also be queued up with static methods, which is useful when you want to debug something in a context where you have no access to the DebugRenderer instance.
oobar() {
..
et x: Vector3<f32> = some_expression;
/ Visually debug the value of `x` with a red position marker:
fx_debug_draw::draw_marker(x, 1.0, [1.0, 0.0, 0.0, 1.0]);
..