Skip to content

Commit

Permalink
Merge branch 'fix_alloc_fn_arg' of https://github.com/Barinzaya/sokol…
Browse files Browse the repository at this point in the history
…-odin into Barinzaya-fix_alloc_fn_arg
  • Loading branch information
floooh committed Nov 20, 2024
2 parents 83efa84 + c1ca579 commit 04e41f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/instancing/main.odin
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package main

import "base:runtime"
import "core:c"
import slog "../../sokol/log"
import sg "../../sokol/gfx"
import sapp "../../sokol/app"
Expand Down Expand Up @@ -123,7 +124,7 @@ frame :: proc "c" () {
// update instance data
sg.update_buffer(state.bind.vertex_buffers[1], {
ptr = &state.pos,
size = u64(state.cur_num_particles * size_of(m.vec3)),
size = c.size_t(state.cur_num_particles * size_of(m.vec3)),
})

// vertex shader uniform data with model-view-projection matrix
Expand Down
5 changes: 3 additions & 2 deletions sokol/helpers/allocator.odin
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package sokol_helpers
import sapp "../app"
import sg "../gfx"
import "base:runtime"
import "core:c"

Allocator :: struct {
alloc_fn: proc "c" (size: u64, user_data: rawptr) -> rawptr,
alloc_fn: proc "c" (size: c.size_t, user_data: rawptr) -> rawptr,
free_fn: proc "c" (ptr: rawptr, user_data: rawptr),
user_data: rawptr,
}
Expand All @@ -22,7 +23,7 @@ allocator :: proc(context_ptr: ^runtime.Context) -> Allocator {
}
}

allocator_alloc_proc :: proc "c" (size: u64, user_data: rawptr) -> rawptr {
allocator_alloc_proc :: proc "c" (size: c.size_t, user_data: rawptr) -> rawptr {
context = (cast(^runtime.Context)user_data)^
bytes, err := runtime.mem_alloc(size = int(size))
if err != nil {
Expand Down

0 comments on commit 04e41f0

Please sign in to comment.