very minor tidying

This commit is contained in:
Edward R. Gonzalez 2024-03-19 08:36:58 -04:00
parent 36bf6840e4
commit d29a1e20e7
16 changed files with 101 additions and 100 deletions

View File

@ -9,6 +9,7 @@
"autoHide.autoHideSideBar": false,
"files.associations": {
"*.rmd": "markdown",
"type_traits": "cpp"
"type_traits": "cpp",
"utf8proc.c": "cpp"
}
}

View File

@ -11,7 +11,6 @@ The things to explore:
* Making AST editing as versatile as text editing.
* High-performance generating a large amount of UI widget boxes with proper auto-layout & no perceptible rendering-lag or input lag for interactions (framtimes stable).
The project is so far in a "codebase boostrapping" phase.
The project's is organized into 2 modules sectr_host & sectr.
@ -40,5 +39,3 @@ Even so the notatble groups are:
* Will most likely be the bulk of this prototype.
* PIMGUI (Persistent Immediate Mode User Interface);
* Auto-layout with heavy procedural generation of box widgets

View File

@ -28,7 +28,7 @@ ModuleAPI :: struct {
}
@export
startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem, files_buffer_mem : ^VArena, host_logger : ^ Logger )
startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem, files_buffer_mem : ^VArena, host_logger : ^Logger )
{
spall.SCOPED_EVENT( & prof.ctx, & prof.buffer, #procedure )
Memory_App.profiler = prof
@ -127,7 +127,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
refresh_rate = 0
cam_min_zoom = 0.25
cam_max_zoom = 10.0
cam_max_zoom = 30.0
cam_zoom_mode = .Smooth
cam_zoom_smooth_snappiness = 4.0
cam_zoom_sensitivity_digital = 0.2
@ -143,33 +143,34 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
Desired_OS_Scheduler_MS :: 1
sleep_is_granular = set__scheduler_granularity( Desired_OS_Scheduler_MS )
// rl.Odin_SetMalloc( RL_MALLOC )
rl.SetConfigFlags( {
rl.ConfigFlag.WINDOW_RESIZABLE,
// rl.ConfigFlag.WINDOW_TOPMOST,
})
// Rough setup of window with rl stuff
window_width : i32 = 1000
window_height : i32 = 600
win_title : cstring = "Sectr Prototype"
rl.InitWindow( window_width, window_height, win_title )
log( "Raylib initialized and window opened" )
{
// rl.Odin_SetMalloc( RL_MALLOC )
window := & state.app_window
window.extent.x = f32(window_width) * 0.5
window.extent.y = f32(window_height) * 0.5
rl.SetConfigFlags( {
rl.ConfigFlag.WINDOW_RESIZABLE,
// rl.ConfigFlag.WINDOW_TOPMOST,
})
// We do not support non-uniform DPI.
window.dpi_scale = rl.GetWindowScaleDPI().x
window.ppcm = os_default_ppcm * window.dpi_scale
window_width : i32 = 1000
window_height : i32 = 600
win_title : cstring = "Sectr Prototype"
rl.InitWindow( window_width, window_height, win_title )
log( "Raylib initialized and window opened" )
// Determining current monitor and setting the target frametime based on it..
monitor_id = rl.GetCurrentMonitor()
monitor_refresh_hz = rl.GetMonitorRefreshRate( monitor_id )
rl.SetTargetFPS( 60 * 24 )
log( str_fmt_tmp( "Set target FPS to: %v", monitor_refresh_hz ) )
window := & state.app_window
window.extent.x = f32(window_width) * 0.5
window.extent.y = f32(window_height) * 0.5
// We do not support non-uniform DPI.
window.dpi_scale = rl.GetWindowScaleDPI().x
window.ppcm = os_default_ppcm * window.dpi_scale
// Determining current monitor and setting the target frametime based on it..
monitor_id = rl.GetCurrentMonitor()
monitor_refresh_hz = rl.GetMonitorRefreshRate( monitor_id )
log( str_fmt_tmp( "Set target FPS to: %v", monitor_refresh_hz ) )
}
// Basic Font Setup
{
@ -196,7 +197,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
using project.workspace
cam = {
target = { 0, 0 },
offset = transmute(Vec2) window.extent,
offset = transmute(Vec2) app_window.extent,
rotation = 0,
zoom = 1.0,
}
@ -290,10 +291,7 @@ reload :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem,
log("Module reloaded")
}
// TODO(Ed) : This lang really not have a fucking swap?
swap :: proc( a, b : ^ $Type ) -> ( ^ Type, ^ Type ) {
return b, a
}
@export
tick :: proc( host_delta_time : f64, host_delta_ns : Duration ) -> b32

View File

@ -1,3 +1,5 @@
// Goal is for any Position or 'Shape' intersections used by the prototype to be defined here for centeralization
package sectr
import "core:math/linalg"

View File

@ -26,9 +26,6 @@ Font_Atlas_Packing_Method :: enum u32 {
Skyeline_Rect = 1, // stb_pack_rect
}
// TODO(Ed) : These are currently i32, I wanted them to be string ids for debug ease of use.
// There is an issue with the hash map type preventing me from doing so. Its allocator reference breaks.
// FontID :: distinct string
FontID :: struct {
key : u64,
label : string,
@ -184,20 +181,6 @@ to_rl_Font :: proc( id : FontID, size := Font_Use_Default_Size ) -> rl.Font
id := (size / Font_Size_Interval) + (size % Font_Size_Interval)
px_render := & def.size_table[ id - 1 ]
// This is free for now perf wise... may have to move this out to on a setting change later.
if id <= 8 {
rl.SetTextureFilter( px_render.texture, rl.TextureFilter.POINT )
}
else if id <= 14 {
rl.SetTextureFilter( px_render.texture, rl.TextureFilter.POINT )
}
else if id <= 48 {
rl.SetTextureFilter( px_render.texture, rl.TextureFilter.POINT )
}
else if id > 48 {
rl.SetTextureFilter( px_render.texture, rl.TextureFilter.POINT )
}
rl_font : rl.Font
rl_font.baseSize = px_render.size
rl_font.glyphCount = px_render.count

View File

@ -86,6 +86,10 @@ import "core:unicode/utf8"
OS_Type :: type_of(ODIN_OS)
swap :: proc( a, b : ^ $Type ) -> ( ^ Type, ^ Type ) {
return b, a
}
// Proc Name Overloads Alias table
// This has to be done on a per-module basis.
@ -118,6 +122,17 @@ is_power_of_two :: proc {
is_power_of_two_uintptr,
}
pixels_to_cm :: proc {
f32_pixels_to_cm,
vec2_pixels_to_cm,
range2_pixels_to_cm,
}
points_to_pixels :: proc {
f32_points_to_pixels,
vec2_points_to_pixels,
}
pop :: proc {
stack_pop,
stack_allocator_pop,
@ -149,17 +164,6 @@ to_string :: proc {
str_builder_to_string,
}
pixels_to_cm :: proc {
f32_pixels_to_cm,
vec2_pixels_to_cm,
range2_pixels_to_cm,
}
points_to_pixels :: proc {
f32_points_to_pixels,
vec2_points_to_pixels,
}
ui_set_layout :: proc {
ui_style_set_layout,
ui_style_theme_set_layout,

View File

@ -17,7 +17,6 @@ profile_begin :: #force_inline proc "contextless" ( name : string, loc := #calle
spall._buffer_begin( & Memory_App.profiler.ctx, & Memory_App.profiler.buffer, name, "", loc )
}
profile_end :: #force_inline proc "contextless" ()
{
profile_end :: #force_inline proc "contextless" () {
spall._buffer_end( & Memory_App.profiler.ctx, & Memory_App.profiler.buffer)
}

View File

@ -15,12 +15,16 @@ import "core:mem"
import "core:slice"
import "core:strings"
// Should this just store the key instead?
StringKey :: distinct u64
RunesCached :: []rune
// TODO(Ed): Should this just track the key instead? (by default)
StringCached :: struct {
str : string,
runes : []rune,
}
StringCache :: struct {
slab : Slab,
table : HMapZPL(StringCached),

View File

@ -1,5 +1,28 @@
package sectr
rune16 :: distinct u16
// Exposing the alloc_error
@(require_results)
string_to_runes :: proc ( content : string, allocator := context.allocator) -> (runes : []rune, alloc_error : AllocatorError) {
num := str_rune_count(content)
runes, alloc_error = make([]rune, num, allocator)
if runes == nil || alloc_error != AllocatorError.None {
return
}
idx := 0
for codepoint in content {
runes[idx] = codepoint
idx += 1
}
return
}
string_to_runes_array :: proc( content : string, allocator := context.allocator ) -> ( []rune, AllocatorError )
{
num := cast(u64) str_rune_count(content)
@ -18,21 +41,3 @@ string_to_runes_array :: proc( content : string, allocator := context.allocator
}
return runes, alloc_error
}
// Exposing the alloc_error
@(require_results)
string_to_runes :: proc "odin" ( content : string, allocator := context.allocator) -> (runes : []rune, alloc_error : AllocatorError) {
num := str_rune_count(content)
runes, alloc_error = make([]rune, num, allocator)
if runes == nil || alloc_error != AllocatorError.None {
return
}
idx := 0
for codepoint in content {
runes[idx] = codepoint
idx += 1
}
return
}

View File

@ -1,3 +1,5 @@
// General mathematical constructions used for the prototype
package sectr
Axis2 :: enum i32 {

View File

@ -0,0 +1,3 @@
package sectr

View File

@ -1,10 +1,16 @@
/* Space
Provides various definitions for converting from one standard of measurement to another.
Ultimately the user's window ppcm (pixels-per-centimeter) determins how all virtual metric conventions are handled.
*/
package sectr
import rl "vendor:raylib"
// The points to pixels and pixels to points are our only reference to accurately converting
// an object from world space to screen-space.
// This prototype engine will have all its spacial unit base for distances in pixels.
// This prototype engine will have all its spacial unit base for distances in virtual pixels.
Inches_To_CM :: cast(f32) 2.54
Points_Per_CM :: cast(f32) 28.3465

View File

@ -278,7 +278,7 @@ render_mode_2d :: proc()
// profile_end()
if len(current.text.str) > 0 {
draw_text_string_cached( current.text, world_to_screen_pos(computed.text_pos), style.font_size, style.text_color )
draw_text( current.text, world_to_screen_pos(computed.text_pos), style.font_size, style.text_color )
}
}
}

View File

@ -157,23 +157,20 @@ update :: proc( delta_time : f64 ) -> b32
workspace.zoom_target = cam.zoom
}
config.cam_max_zoom = 30.0
config.cam_zoom_smooth_snappiness = 10.0
config.cam_zoom_mode = .Smooth
switch config.cam_zoom_mode
{
case .Smooth:
zoom_delta := input.mouse.vertical_wheel * config.cam_zoom_sensitivity_smooth
workspace.zoom_target *= 1 + zoom_delta * f32(delta_time)
workspace.zoom_target = clamp(workspace.zoom_target, 0.05, config.cam_max_zoom)
workspace.zoom_target = clamp(workspace.zoom_target, config.cam_min_zoom, config.cam_max_zoom)
// Linearly interpolate cam.zoom towards zoom_target
lerp_factor := config.cam_zoom_smooth_snappiness // Adjust this value to control the interpolation speed
cam.zoom += (workspace.zoom_target - cam.zoom) * lerp_factor * f32(delta_time)
cam.zoom = clamp(cam.zoom, 0.05, config.cam_max_zoom) // Ensure cam.zoom stays within bounds
cam.zoom = clamp(cam.zoom, config.cam_min_zoom, config.cam_max_zoom) // Ensure cam.zoom stays within bounds
case .Digital:
zoom_delta := input.mouse.vertical_wheel * config.cam_zoom_sensitivity_digital
workspace.zoom_target = clamp(workspace.zoom_target + zoom_delta, 0.05, config.cam_max_zoom)
workspace.zoom_target = clamp(workspace.zoom_target + zoom_delta, config.cam_min_zoom, config.cam_max_zoom)
cam.zoom = workspace.zoom_target
}

View File

@ -161,8 +161,8 @@ push-location $path_root
$build_args += $flag_build_mode_dll
$build_args += $flag_output_path + $module_dll
# $build_args += ($flag_collection + $pkg_collection_thirdparty)
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
$build_args += $flag_micro_architecture_native
$build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
@ -232,16 +232,16 @@ push-location $path_root
write-host 'Building Host Module'
$linker_args = ""
$linker_args += ( $flag_msvc_link_disable_dynamic_base + ' ' )
$linker_args += ( $flag_msvc_link_stack_size + ' ')
# $linker_args += ( $flag_msvc_link_disable_dynamic_base + ' ' )
# $linker_args += ( $flag_msvc_link_stack_size + ' ')
$build_args = @()
$build_args += $command_build
$build_args += './host'
$build_args += $flag_output_path + $executable
# $build_args += ($flag_collection + $pkg_collection_thirdparty)
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
$build_args += $flag_micro_architecture_native
$build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
# $build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
@ -253,8 +253,8 @@ push-location $path_root
# $build_args += ($flag_extra_linker_flags + $linker_args )
$build_args += $flag_show_timings
# $build_args += $flag_show_system_call
# $build_args += $flag_no_bounds_check
# $build_args += $flag_no_thread_checker
$build_args += $flag_no_bounds_check
$build_args += $flag_no_thread_checker
$build_args += $flag_default_allocator_nil
$build_args += ($flag_max_error_count + '10')
# $build_args += $flag_sanitize_address

2
thirdparty/ols vendored

@ -1 +1 @@
Subproject commit bdaa093fb4494a9c963451ae9e80d20702dd230c
Subproject commit 04a7dbee44c86efbd27101bf7d68a934e444c1a0