2024-02-10 00:40:53 -08:00
|
|
|
package sectr
|
|
|
|
|
|
|
|
import "core:fmt"
|
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
|
|
|
|
|
|
|
render :: proc()
|
|
|
|
{
|
|
|
|
state := get_state(); using state
|
|
|
|
replay := & memory.replay
|
2024-02-11 20:00:06 -08:00
|
|
|
cam := & project.workspace.cam
|
|
|
|
win_extent := state.app_window.extent
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
screen_top_left : Vec2 = {
|
|
|
|
-win_extent.x + cam.target.x,
|
|
|
|
-win_extent.y + cam.target.y,
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
|
|
|
|
rl.BeginDrawing()
|
|
|
|
rl.ClearBackground( Color_BG )
|
2024-02-11 20:00:06 -08:00
|
|
|
render_mode_2d()
|
2024-02-12 17:52:56 -08:00
|
|
|
// Render Screenspace
|
2024-02-10 00:40:53 -08:00
|
|
|
{
|
2024-02-11 20:00:06 -08:00
|
|
|
fps_msg := fmt.tprint( "FPS:", rl.GetFPS() )
|
2024-02-13 14:16:39 -08:00
|
|
|
fps_msg_width := measure_text_size( fps_msg, default_font, 16.0, 0.0 ).x
|
2024-02-11 20:00:06 -08:00
|
|
|
fps_msg_pos := screen_get_corners().top_right - { fps_msg_width, 0 }
|
2024-02-13 14:16:39 -08:00
|
|
|
debug_draw_text( fps_msg, fps_msg_pos, 16.0, color = rl.GREEN )
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
debug_text :: proc( format : string, args : ..any )
|
|
|
|
{
|
|
|
|
@static draw_text_scratch : [Kilobyte * 64]u8
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
state := get_state(); using state
|
|
|
|
if debug.draw_debug_text_y > 800 {
|
|
|
|
debug.draw_debug_text_y = 50
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
cam := & project.workspace.cam
|
|
|
|
screen_corners := screen_get_corners()
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
position := screen_corners.top_right
|
2024-02-11 21:35:22 -08:00
|
|
|
position.x -= 200
|
2024-02-11 20:00:06 -08:00
|
|
|
position.y += debug.draw_debug_text_y
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
content := fmt.bprintf( draw_text_scratch[:], format, ..args )
|
2024-02-13 14:16:39 -08:00
|
|
|
debug_draw_text( content, position, 16.0 )
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
debug.draw_debug_text_y += 16
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug Text
|
|
|
|
{
|
2024-02-11 21:35:22 -08:00
|
|
|
// debug_text( "Screen Width : %v", rl.GetScreenWidth () )
|
|
|
|
// debug_text( "Screen Height: %v", rl.GetScreenHeight() )
|
2024-02-11 20:00:06 -08:00
|
|
|
if replay.mode == ReplayMode.Record {
|
|
|
|
debug_text( "Recording Input")
|
|
|
|
}
|
|
|
|
if replay.mode == ReplayMode.Playback {
|
|
|
|
debug_text( "Replaying Input")
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
|
|
|
|
if debug.mouse_vis {
|
|
|
|
debug_text( "Position: %v", input.mouse.pos )
|
2024-02-11 21:35:22 -08:00
|
|
|
cursor_pos := transmute(Vec2) state.app_window.extent + input.mouse.pos
|
|
|
|
rl.DrawCircleV( cursor_pos, 10, Color_White_A125 )
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
|
|
|
|
debug.draw_debug_text_y = 50
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
rl.EndDrawing()
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
render_mode_2d :: proc() {
|
|
|
|
state := get_state(); using state
|
|
|
|
cam := & project.workspace.cam
|
|
|
|
win_extent := state.app_window.extent
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
rl.BeginMode2D( project.workspace.cam )
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
// debug.frame_1_on_top = true
|
|
|
|
|
|
|
|
boxes : [2]^Box2
|
|
|
|
if debug.frame_1_on_top {
|
|
|
|
boxes = { & project.workspace.frame_2, & project.workspace.frame_1 }
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
boxes = { & project.workspace.frame_1, & project.workspace.frame_2 }
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
for box in boxes {
|
2024-02-12 17:52:56 -08:00
|
|
|
screen_pos := world_to_screen_no_zoom(box.position) - vec2_cm_to_pixels( Vec2(box.extent) )
|
|
|
|
size := vec2_cm_to_pixels( transmute(Vec2) box.extent * 2.0 )
|
2024-02-11 21:35:22 -08:00
|
|
|
|
|
|
|
rect : rl.Rectangle
|
|
|
|
rect.x = screen_pos.x
|
|
|
|
rect.y = screen_pos.y
|
|
|
|
rect.width = size.x
|
|
|
|
rect.height = size.y
|
|
|
|
rl.DrawRectangleRec( rect, box.color )
|
|
|
|
}
|
|
|
|
|
2024-02-13 14:16:39 -08:00
|
|
|
debug_draw_text_world( "This is text in world space", { 0, 0 }, 16.0 )
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
if debug.mouse_vis {
|
|
|
|
// rl.DrawCircleV( screen_to_world(input.mouse.pos), 10, Color_GreyRed )
|
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
|
|
|
|
rl.EndMode2D()
|
|
|
|
}
|