48 lines
1.1 KiB
Zig
48 lines
1.1 KiB
Zig
|
|
const std = @import("std");
|
||
|
|
const c = @import("c");
|
||
|
|
const engine = @import("engine");
|
||
|
|
const Control = engine.Control;
|
||
|
|
|
||
|
|
pub const camera = true;
|
||
|
|
pub const mouse = true;
|
||
|
|
|
||
|
|
// later make this expandable in some way using an allocator.
|
||
|
|
|
||
|
|
pub const Display = struct {
|
||
|
|
var debug_buffer: [10][200]u8 = undefined;
|
||
|
|
|
||
|
|
pub fn reset() void {
|
||
|
|
inline for (0..debug_buffer.len) |idx| {
|
||
|
|
debug_buffer[idx][0] = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn empty_line() !usize {
|
||
|
|
for (0..debug_buffer.len) |idx| {
|
||
|
|
if (debug_buffer[idx][0] == 0) {
|
||
|
|
return idx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return error.DebugBufferOverflow;
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn add_line(comptime fmt: []const u8, args: anytype) void {
|
||
|
|
const line_idx: usize = empty_line()
|
||
|
|
catch @panic("debug buffer overflow (too many lines)");
|
||
|
|
_ = std.fmt.bufPrintZ(&debug_buffer[line_idx], fmt, args)
|
||
|
|
catch @panic("debug buffer overflow (line too long)");
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn render(renderer: *c.SDL_Renderer) void {
|
||
|
|
_ = c.SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||
|
|
const x = 10;
|
||
|
|
var y: f32 = 10;
|
||
|
|
const line_height = 10;
|
||
|
|
inline for (0..debug_buffer.len) |idx| {
|
||
|
|
_ = c.SDL_RenderDebugText(renderer, x, y, &debug_buffer[idx]);
|
||
|
|
y = y + line_height;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|