1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg: move code using C types to c.v files, add js.v files (#12873)

This commit is contained in:
playX
2021-12-17 16:22:09 +03:00
committed by GitHub
parent 66070ec63e
commit b482da74e9
9 changed files with 1173 additions and 930 deletions

41
vlib/gg/recorder.c.v Normal file
View File

@@ -0,0 +1,41 @@
module gg
import sokol.sapp
import os
[if gg_record ?]
pub fn (mut ctx Context) record_frame() {
if ctx.frame in gg.recorder_settings.screenshot_frames {
screenshot_file_path := '$gg.recorder_settings.screenshot_prefix${ctx.frame}.png'
$if gg_record_trace ? {
eprintln('>>> screenshoting $screenshot_file_path')
}
sapp.screenshot_png(screenshot_file_path) or { panic(err) }
}
if ctx.frame == gg.recorder_settings.stop_at_frame {
$if gg_record_trace ? {
eprintln('>>> exiting at frame $ctx.frame')
}
exit(0)
}
}
fn new_gg_recorder_settings() &SSRecorderSettings {
$if gg_record ? {
stop_frame := os.getenv_opt('VGG_STOP_AT_FRAME') or { '-1' }.i64()
frames := os.getenv('VGG_SCREENSHOT_FRAMES').split_any(',').map(it.u64())
folder := os.getenv('VGG_SCREENSHOT_FOLDER')
prefix := os.join_path_single(folder, os.file_name(os.executable()).all_before('.') + '_')
return &SSRecorderSettings{
stop_at_frame: stop_frame
screenshot_frames: frames
screenshot_folder: folder
screenshot_prefix: prefix
}
} $else {
return &SSRecorderSettings{}
}
}
const recorder_settings = new_gg_recorder_settings()