Skip to content

Commit

Permalink
[debug_print_text] add README
Browse files Browse the repository at this point in the history
  • Loading branch information
tgfrerer committed Oct 23, 2024
1 parent 8b6622f commit 9e5da2f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 12 deletions.
50 changes: 50 additions & 0 deletions modules/le_debug_print_text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Debug Print Text

## A stateful debug printer for debug messages

The simplest way to print to screen is to use the Global Printer
Singleton -- it is available to any file that includes this header.

You can print like this:

```cpp
le::DebugPrint("I'm printing %04d", 1);
```
The debug printer supports `printf` formatting.
To see the messages rendered on top of a specific renderpass,
you must do this:
```cpp
le::DebugPrint::drawAllMessages(main_renderpass);
```

Otherwise, all messages are rendered into the last renderpass that is
part of [the](the.md) rendergraph, assuming that this renderpass is
going to the screen.

`drawAllMessages()` clears the message state and resets the debug
message printer.

Note that there is no implicit synchronisation - this printer is
unaware that other threads might be using it.

The cursor moves with text that has been printed, and there is support
for multi-line text: If a newline `\n` character is detected, the
cursor moves to the next line.

You can set colour style information; Style info is on a stack to which
you can push / pop. Yes, this is stateful. It is also concise and
relatively simple (assuming a single-threaded environment) we might
want to reconsider this architecture if we get into trouble with
threading.

On draw, all the text that has accumulated through the frame gets
printed in one go, and the accumulated print instructions reset.

# Acknowledgements

* Pixel font data based on the free
[Tamsyn](http://www.fial.com/~scott/tamsyn-font/) bitmap font

40 changes: 28 additions & 12 deletions modules/le_debug_print_text/le_debug_print_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,55 @@ struct le_renderpass_o;

/*
----------------------------------------------------------------------
A stateful debug printer for debug messages
----------------------------------------------------------------------
# Debug Print Text
## A stateful debug printer for debug messages
The simplest way to print to screen is to use the Global Printer
Singleton -- it is available to any file that includes this header.
You can print like this:
le::DebugPrint::printf("I'm printing %04d", 1);
```cpp
le::DebugPrint("I'm printing %04d", 1);
```
The debug printer supports `printf` formatting.
To see the messages rendered on top of a renderpass, you must do this:
To see the messages rendered on top of a specific renderpass,
you must do this:
le::DebugPrint::drawAllMessages(main_renderpass);
```cpp
le::DebugPrint::drawAllMessages(main_renderpass);
```
Drawing the messages into a renderpass clears the message state and
resets the debug message printer.
Otherwise, all messages are rendered into the last renderpass that is
part of [the](the.md) rendergraph, assuming that this renderpass is
going to the screen.
`drawAllMessages()` clears the message state and resets the debug
message printer.
Note that there is no implicit synchronisation - this printer is
unaware that other threads might be using it.
Cursor moves with text that has been printed.
The cursor moves with text that has been printed, and there is support
for multi-line text: If a newline `\n` character is detected, the
cursor moves to the next line.
You can set color style information; style info is on a stack to which
You can set colour style information; Style info is on a stack to which
you can push / pop. Yes, this is stateful. It is also concise and
relatively simple (assuming a single-threaded environment) we might
want to reconsider this architecture if we get into trouble with
threading.
On draw, all the text that has accumulated through the frame gets
printed in one go. and the accumulated print instructions reset.
printed in one go, and the accumulated print instructions reset.
# Acknowledgements
----------------------------------------------------------------------
* Pixel font data based on the free
[Tamsyn](http://www.fial.com/~scott/tamsyn-font/) bitmap font
*/

Expand Down

0 comments on commit 9e5da2f

Please sign in to comment.