gg: minor fixes

pull/5211/head
Alexander Medvednikov 2020-06-04 19:57:13 +02:00
parent cf9498ef6b
commit fb7ca56d87
6 changed files with 14 additions and 8 deletions

View File

@ -88,9 +88,7 @@ pub fn (mut ts TestSession) test() {
} }
ts.files = remaining_files ts.files = remaining_files
ts.benchmark.set_total_expected_steps(remaining_files.len) 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({
mut pool_of_test_runners := sync.new_pool_processor(sync.PoolProcessorConfig{
callback: worker_trunner callback: worker_trunner
}) })
// for handling messages across threads // for handling messages across threads

View File

@ -185,6 +185,7 @@ fn main() {
frame_fn: frame frame_fn: frame
event_fn: on_event event_fn: on_event
scale: 2 scale: 2
//wait_events: true
) )
game.init_game() game.init_game()
go game.run() // Run the game loop in a new thread 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) { fn on_event(e &sapp.Event, mut game Game) {
//println('code=$e.char_code')
if e.typ == .key_down { if e.typ == .key_down {
game.key_down(e.key_code) game.key_down(e.key_code)
} }

View File

@ -1337,7 +1337,7 @@ _SOKOL_PRIVATE void _sapp_macos_init_keytable(void) {
} }
_SOKOL_PRIVATE void _sapp_run(const sapp_desc* desc) { _SOKOL_PRIVATE void _sapp_run(const sapp_desc* desc) {
puts("RUN"); //puts("Sokol run()");
_sapp_init_state(desc); _sapp_init_state(desc);
_sapp_macos_init_keytable(); _sapp_macos_init_keytable();
[NSApplication sharedApplication]; [NSApplication sharedApplication];

View File

@ -8477,7 +8477,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_caps(void) {
/*-- main Metal backend state and functions ----------------------------------*/ /*-- main Metal backend state and functions ----------------------------------*/
_SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) { _SOKOL_PRIVATE void _sg_setup_backend(const sg_desc* desc) {
puts("METAL"); puts("Sokol backend: Metal");
/* assume already zero-initialized */ /* assume already zero-initialized */
SOKOL_ASSERT(desc); SOKOL_ASSERT(desc);
SOKOL_ASSERT(desc->mtl_device); SOKOL_ASSERT(desc->mtl_device);

View File

@ -9,6 +9,7 @@ import sokol
import sokol.sapp import sokol.sapp
import sokol.sgl import sokol.sgl
import sokol.gfx import sokol.gfx
import gg.ft
type FNvoidptr1 fn(voidptr) type FNvoidptr1 fn(voidptr)
type FNvoidptr2 fn(voidptr,voidptr) type FNvoidptr2 fn(voidptr,voidptr)
@ -26,6 +27,7 @@ pub:
create_window bool create_window bool
// window_user_ptr voidptr // window_user_ptr voidptr
window_title string window_title string
borderless_window bool
always_on_top bool always_on_top bool
scale f32 = 1.0 scale f32 = 1.0
bg_color gx.Color bg_color gx.Color
@ -34,7 +36,8 @@ pub:
event_fn FNvoidptr2 = voidptr(0) event_fn FNvoidptr2 = voidptr(0)
cleanup_fn FNvoidptr1 = voidptr(0) cleanup_fn FNvoidptr1 = voidptr(0)
fail_fn FNFail = 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 { pub struct GG {
@ -47,6 +50,8 @@ pub mut:
config Config config Config
} }
pub struct Size { pub: width int height int }
fn gg_init_sokol_window(user_data voidptr) { fn gg_init_sokol_window(user_data voidptr) {
mut g := &GG(user_data) mut g := &GG(user_data)
desc := C.sg_desc{ desc := C.sg_desc{
@ -186,6 +191,7 @@ pub fn (gg &GG) end() {
gfx.end_pass() gfx.end_pass()
gfx.commit() gfx.commit()
if gg.config.wait_events { if gg.config.wait_events {
//println('gg: waiting')
wait_events() wait_events()
} }
} }

View File

@ -2,13 +2,13 @@ module sapp
pub struct C.sapp_desc { pub struct C.sapp_desc {
pub: 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() frame_cb fn()
cleanup_cb fn() cleanup_cb fn()
event_cb fn(&C.sapp_event) //&sapp_event) event_cb fn(&C.sapp_event) //&sapp_event)
fail_cb fn(byteptr) 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) init_userdata_cb fn(voidptr)
frame_userdata_cb fn(voidptr) frame_userdata_cb fn(voidptr)
cleanup_userdata_cb fn(voidptr) cleanup_userdata_cb fn(voidptr)