Base input pass updated for sokol possibly done (untested)

Still need to figure out input event consumption, I don't want to do it with the event ring.

I would like to setup input binding layers and then have the push/pop input contextes with a set of bindings.
If the bindings are detected it should "consume" that binding from further use for the buffered time period.

This will be really important with how heavily model this app will be.I
This commit is contained in:
2024-06-18 01:33:50 -04:00
parent 3b395f3356
commit b698f5166b
14 changed files with 487 additions and 151 deletions

View File

@ -0,0 +1,18 @@
package grime
import "base:runtime"
reload_array :: proc( self : [dynamic]$Type, allocator : Allocator ) {
raw := transmute(runtime.Raw_Dynamic_Array) self
raw.allocator = allocator
}
reload_queue :: proc( self : Queue($Type), allocator : Allocator ) {
raw_array := transmute(runtime.Raw_Dynamic_Array) self.data
raw_array.allocator = allocator
}
reload_map :: proc( self : map [$KeyType] $EntryType, allocator : Allocator ) {
raw := transmute(runtime.Raw_Map) self
raw.allocator = allocator
}

View File

@ -29,6 +29,9 @@ import "base:runtime"
import c "core:c/libc"
mem_fmt :: c.memset
import "core:container/queue"
Queue :: queue.Queue
import "core:dynlib"
import "core:hash"
@ -143,11 +146,17 @@ is_power_of_two :: proc {
is_power_of_two_uintptr,
}
iterator :: proc {
iterator_queue,
}
make :: proc {
array_init,
hmap_chained_init,
hmap_zpl_init,
make_queue,
// Usual
make_slice,
make_dynamic_array,
@ -157,10 +166,24 @@ make :: proc {
make_multi_pointer,
}
next :: proc {
next_queue_iterator,
}
push :: proc {
stack_push,
}
space_left :: proc {
queue.space,
}
reload :: proc {
reload_array,
reload_queue,
reload_map,
}
to_runes :: proc {
string_to_runes,
}

61
code/grime/queue.odin Normal file
View File

@ -0,0 +1,61 @@
package grime
import "core:container/queue"
make_queue :: proc( $QueueType : typeid/Queue($Type), capacity := queue.DEFAULT_CAPACITY, allocator := context.allocator ) -> (result : Queue(Type), error : AllocatorError)
{
queue.init( & result, capacity, allocator )
return
}
push_back_slice_queue :: proc( self : ^$QueueType / Queue($Type), slice : []Type ) -> ( error : AllocatorError )
{
num := cast(uint) len(slice)
if uint( space_left( self^ )) < num {
error = queue._grow( self, self.len + num )
if error != .None do return
}
size := uint(len(self.data))
insert_from := (self.offset + self.len) % size
insert_to := num
if insert_from + insert_to > size {
insert_to = size - insert_from
}
copy( self.data[ insert_from : ], slice[ : insert_to ])
copy( self.data[ : insert_from ], slice[ insert_to : ])
return
}
QueueIterator :: struct( $Type : typeid ) {
data : []Type,
length : uint,
offset : uint,
index : uint,
}
iterator_queue :: proc( queue : $QueueType / Queue($Type) ) -> QueueIterator(Type)
{
iter := QueueIterator(Type) {
data = queue.data[:],
length = queue.len,
offset = queue.offset,
index = 0,
}
return iter
}
next_queue_iterator :: proc( iter : ^QueueIterator($Type) ) -> ^Type
{
using iter
front_id := (length + offset ) % len(data)
elem_id := (length + offset - index) % len(data)
if elem_id == front_id do return nil
elem := & data[ elem_id ]
index += 1
return elem
}