You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gg, examples: add optional update_fn: fn (dt f32, ctx &gg.Context) to gg.Context and gg.Config . Pass consistently the current GG context to *all* callback functions, instead of nil.
Previously, when the user_data field: was not set explicitly in the gg.new_context() call,
it was still passed to *some* of the callbacks, which was harder to understand, and hindered simple GG apps.
Now, when the user_data field is not set explicitly, all gg callbacks will receive a pointer to the current gg context, instead of nil.
Copy file name to clipboardExpand all lines: vlib/gg/gg.c.v
+30-19Lines changed: 30 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,8 @@ pub:
101
101
cleanup_fn FNCb=unsafe { nil } // Called once, after Sokol determines that the application is finished/closed. Put your app specific cleanup/free actions here.
102
102
fail_fn FNFail=unsafe { nil } // Called once per Sokol error/log message. TODO: currently it does nothing with latest Sokol, reimplement using Sokol's new sapp_logger APIs.
103
103
104
+
update_fn FNUpdate=unsafe { nil } // Called once at the start of each frame, so usually ~60 times a second. The first argument is the delta `dt` time passed, since the *previous* update call (in seconds).
105
+
104
106
event_fn FNEvent=unsafe { nil } // Called once per each user initiated event, received by Sokol/GG.
105
107
on_event FNEvent2=unsafe { nil } // Called once per each user initiated event, received by Sokol/GG. Same as event_fn, just the parameter order is different. TODO: deprecate this, in favor of event_fn
106
108
quit_fn FNEvent=unsafe { nil } // Called when the user closes the app window.
@@ -202,7 +204,10 @@ pub mut:
202
204
font_inited bool
203
205
ui_mode bool// do not redraw everything 60 times/second, but only when the user requests
204
206
frame u64// the current frame counted from the start of the application; always increasing
205
-
timer time.StopWatch
207
+
//
208
+
timer time.StopWatch // starts right after new_context, and can be controlled/stopped/restarted in whatever way the user wants.
209
+
update_timer time.StopWatch // measures how much time has passed since the start of the frame.
210
+
// Note: when there is an update_fn, this timer is reset by GG itself, at the start of each frame.
206
211
207
212
mbtn_mask u8
208
213
mouse_buttons MouseButtons // typed version of mbtn_mask; easier to use for user programs
0 commit comments