From fb7ca56d8775e6cf76cf60e218a650ab3a011136 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 4 Jun 2020 19:57:13 +0200 Subject: [PATCH] gg: minor fixes --- cmd/tools/modules/testing/common.v | 4 +--- examples/tetris/tetris.v | 2 ++ thirdparty/sokol/sokol_app.h | 2 +- thirdparty/sokol/sokol_gfx.h | 2 +- vlib/gg/gg.v | 8 +++++++- vlib/sokol/sapp/sapp_structs.v | 4 ++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index ff43695649..5a7cb363ba 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -88,9 +88,7 @@ pub fn (mut ts TestSession) test() { } ts.files = remaining_files ts.benchmark.set_total_expected_steps(remaining_files.len) - // QTODO - //mut pool_of_test_runners := sync.new_pool_processor({ - mut pool_of_test_runners := sync.new_pool_processor(sync.PoolProcessorConfig{ + mut pool_of_test_runners := sync.new_pool_processor({ callback: worker_trunner }) // for handling messages across threads diff --git a/examples/tetris/tetris.v b/examples/tetris/tetris.v index 36f1b067bb..47b957aeae 100644 --- a/examples/tetris/tetris.v +++ b/examples/tetris/tetris.v @@ -185,6 +185,7 @@ fn main() { frame_fn: frame event_fn: on_event scale: 2 + //wait_events: true ) game.init_game() go game.run() // Run the game loop in a new thread @@ -396,6 +397,7 @@ fn parse_binary_tetro(t_ int) []Block { } fn on_event(e &sapp.Event, mut game Game) { + //println('code=$e.char_code') if e.typ == .key_down { game.key_down(e.key_code) } diff --git a/thirdparty/sokol/sokol_app.h b/thirdparty/sokol/sokol_app.h index 01632d645d..b9133b04ca 100755 --- a/thirdparty/sokol/sokol_app.h +++ b/thirdparty/sokol/sokol_app.h @@ -1337,7 +1337,7 @@ _SOKOL_PRIVATE void _sapp_macos_init_keytable(void) { } _SOKOL_PRIVATE void _sapp_run(const sapp_desc* desc) { - puts("RUN"); + //puts("Sokol run()"); _sapp_init_state(desc); _sapp_macos_init_keytable(); [NSApplication sharedApplication]; diff --git a/thirdparty/sokol/sokol_gfx.h b/thirdparty/sokol/sokol_gfx.h index de3c4f3b42..6a89094dfb 100755 --- a/thirdparty/sokol/sokol_gfx.h +++ b/thirdparty/sokol/sokol_gfx.h @@ -8477,7 +8477,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_caps(void) { /*-- main Metal backend state and functions ----------------------------------*/ _SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) { - puts("METAL"); + puts("Sokol backend: Metal"); /* assume already zero-initialized */ SOKOL_ASSERT(desc); SOKOL_ASSERT(desc->mtl_device); diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index c969d98086..2a59db918b 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -9,6 +9,7 @@ import sokol import sokol.sapp import sokol.sgl import sokol.gfx +import gg.ft type FNvoidptr1 fn(voidptr) type FNvoidptr2 fn(voidptr,voidptr) @@ -26,6 +27,7 @@ pub: create_window bool // window_user_ptr voidptr window_title string + borderless_window bool always_on_top bool scale f32 = 1.0 bg_color gx.Color @@ -34,7 +36,8 @@ pub: event_fn FNvoidptr2 = voidptr(0) cleanup_fn FNvoidptr1 = voidptr(0) fail_fn FNFail = voidptr(0) - wait_events bool = false // set this to true for UIs, to save power + wait_events bool // set this to true for UIs, to save power + font_path string } pub struct GG { @@ -47,6 +50,8 @@ pub mut: config Config } +pub struct Size { pub: width int height int } + fn gg_init_sokol_window(user_data voidptr) { mut g := &GG(user_data) desc := C.sg_desc{ @@ -186,6 +191,7 @@ pub fn (gg &GG) end() { gfx.end_pass() gfx.commit() if gg.config.wait_events { + //println('gg: waiting') wait_events() } } diff --git a/vlib/sokol/sapp/sapp_structs.v b/vlib/sokol/sapp/sapp_structs.v index 7d65a41445..c9bfa35462 100644 --- a/vlib/sokol/sapp/sapp_structs.v +++ b/vlib/sokol/sapp/sapp_structs.v @@ -2,13 +2,13 @@ module sapp pub struct C.sapp_desc { pub: - init_cb fn() /* these are the user-provided callbacks without user data */ + init_cb fn() // these are the user-provided callbacks without user data frame_cb fn() cleanup_cb fn() event_cb fn(&C.sapp_event) //&sapp_event) fail_cb fn(byteptr) - user_data voidptr /* these are the user-provided callbacks with user data */ + user_data voidptr // these are the user-provided callbacks with user data init_userdata_cb fn(voidptr) frame_userdata_cb fn(voidptr) cleanup_userdata_cb fn(voidptr)