fn dpi_scale() f32
fn high_dpi() bool
fn new_context(cfg Config) &Context
fn screen_size() Size
fn system_font_path() string
fn window_size() Size
window_size returns the Size
of the active window
fn window_size_real_pixels() Size
window_size_real_pixels returns the Size
of the active window without scale
type FNCb = fn (x voidptr)
import time
type FNChar = fn (c u32, x voidptr)
type FNEvent = fn (e &Event, x voidptr)
type FNFail = fn (msg string, x voidptr)
type FNKeyDown = fn (c KeyCode, m Modifier, x voidptr)
type FNMove = fn (x f32, y f32, z voidptr)
fn (ft &FT) flush()
enum KeyCode {
invalid = 0
space = 32
apostrophe = 39
comma = 44
minus = 45
period = 46
slash = 47
_0 = 48
_1 = 49
_2 = 50
_3 = 51
_4 = 52
_5 = 53
_6 = 54
_7 = 55
_8 = 56
_9 = 57
semicolon = 59
equal = 61
a = 65
b = 66
c = 67
d = 68
e = 69
f = 70
g = 71
h = 72
i = 73
j = 74
k = 75
l = 76
m = 77
n = 78
o = 79
p = 80
q = 81
r = 82
s = 83
t = 84
u = 85
v = 86
w = 87
x = 88
y = 89
z = 90
left_bracket = 91
backslash = 92
right_bracket = 93
grave_accent = 96
world_1 = 161
world_2 = 162
escape = 256
enter = 257
tab = 258
backspace = 259
insert = 260
delete = 261
right = 262
left = 263
down = 264
up = 265
page_up = 266
page_down = 267
home = 268
end = 269
caps_lock = 280
scroll_lock = 281
num_lock = 282
print_screen = 283
pause = 284
f1 = 290
f2 = 291
f3 = 292
f4 = 293
f5 = 294
f6 = 295
f7 = 296
f8 = 297
f9 = 298
f10 = 299
f11 = 300
f12 = 301
f13 = 302
f14 = 303
f15 = 304
f16 = 305
f17 = 306
f18 = 307
f19 = 308
f20 = 309
f21 = 310
f22 = 311
f23 = 312
f24 = 313
f25 = 314
kp_0 = 320
kp_1 = 321
kp_2 = 322
kp_3 = 323
kp_4 = 324
kp_5 = 325
kp_6 = 326
kp_7 = 327
kp_8 = 328
kp_9 = 329
kp_decimal = 330
kp_divide = 331
kp_multiply = 332
kp_subtract = 333
kp_add = 334
kp_enter = 335
kp_equal = 336
left_shift = 340
left_control = 341
left_alt = 342
left_super = 343
right_shift = 344
right_control = 345
right_alt = 346
right_super = 347
menu = 348
}
enum Modifier {
shift = 1
ctrl = 2
alt = 4
super = 8
}
struct Config {
pub:
width int
height int
use_ortho bool
retina bool
resizable bool
user_data voidptr
font_size int
create_window bool
window_title string
borderless_window bool
always_on_top bool
bg_color gx.Color
init_fn FNCb = voidptr(0)
frame_fn FNCb = voidptr(0)
native_frame_fn FNCb = voidptr(0)
cleanup_fn FNCb = voidptr(0)
fail_fn FNFail = voidptr(0)
event_fn FNEvent = voidptr(0)
keydown_fn FNKeyDown = voidptr(0)
char_fn FNChar = voidptr(0)
move_fn FNMove = voidptr(0)
click_fn FNMove = voidptr(0)
fullscreen bool
scale f32 = 1.0
sample_count int
font_path string
custom_bold_font_path string
ui_mode bool
font_bytes_normal []byte
font_bytes_bold []byte
font_bytes_mono []byte
font_bytes_italic []byte
native_rendering bool
}
struct Context {
render_text bool
mut:
image_cache []Image
needs_refresh bool = true
ticks int
pub:
native_rendering bool
pub mut:
scale f32 = 1.0
width int
height int
clear_pass C.sg_pass_action
window C.sapp_desc
timage_pip C.sgl_pipeline
config Config
ft &FT
font_inited bool
ui_mode bool
mbtn_mask byte
}
fn (gg &Context) begin()
fn (mut ctx Context) create_image(file string) Image
fn (mut ctx Context) create_image_from_byte_array(b []byte) Image
fn (mut ctx Context) create_image_from_memory(buf &byte, bufsize int) Image
fn (mut ctx Context) create_image_with_size(file string, width int, height int) Image
TODO copypasta
fn (ctx &Context) draw_arc(x f32, y f32, r int, start_angle f32, arc_angle f32, segments int, c gx.Color)
fn (ctx &Context) draw_arc_line(x f32, y f32, r int, start_angle f32, arc_angle f32, segments int, c gx.Color)
fn (ctx &Context) draw_circle(x f32, y f32, r f32, c gx.Color)
fn (ctx &Context) draw_circle_line(x f32, y f32, r int, segments int, c gx.Color)
fn (ctx &Context) draw_circle_with_segments(x f32, y f32, r f32, segments int, c gx.Color)
fn (ctx &Context) draw_convex_poly(points []f32, c gx.Color)
draw_convex_poly draws a convex polygon, given an array of points, and a color. Note that the points must be given in clockwise order.
fn (ctx &Context) draw_empty_poly(points []f32, c gx.Color)
draw_empty_poly - draws the borders of a polygon, given an array of points, and a color. Note that the points must be given in clockwise order.
fn (ctx &Context) draw_empty_rect(x f32, y f32, w f32, h f32, c gx.Color)
fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius f32, border_color gx.Color)
fn (ctx &Context) draw_empty_square(x f32, y f32, s f32, c gx.Color)
fn (ctx &Context) draw_image(x f32, y f32, width f32, height f32, img_ &Image)
fn (ctx &Context) draw_image_3d(x f32, y f32, z f32, width f32, height f32, img_ &Image)
fn (ctx &Context) draw_image_by_id(x f32, y f32, width f32, height f32, id int)
fn (ctx &Context) draw_image_flipped(x f32, y f32, width f32, height f32, img_ &Image)
TODO remove copy pasta, merge the functions
fn (ctx &Context) draw_image_part(img_rect Rect, part_rect Rect, img_ &Image)
Draw part of an image using uv coordinates img_rect is the size and position (in pixels on screen) of the displayed rectangle (ie the draw_image args) part_rect is the size and position (in absolute pixels in the image) of the wanted part eg. On a 600600 context, to display only the first 400400 pixels of a 2000*2000 image on the entire context surface, call : draw_image_part(Rect{0, 0, 600, 600}, Rect{0, 0, 400, 400}, img)
fn (ctx &Context) draw_line(x f32, y f32, x2 f32, y2 f32, c gx.Color)
fn (ctx &Context) draw_rect(x f32, y f32, w f32, h f32, c gx.Color)
TODO: Fix alpha
fn (ctx &Context) draw_rounded_rect(x f32, y f32, w f32, h f32, radius f32, color gx.Color)
fn (ctx &Context) draw_square(x f32, y f32, s f32, c gx.Color)
fn (ctx &Context) draw_text(x int, y int, text_ string, cfg gx.TextCfg)
fn (ctx &Context) draw_text_def(x int, y int, text string)
fn (ctx &Context) draw_triangle(x f32, y f32, x2 f32, y2 f32, x3 f32, y3 f32, c gx.Color)
fn (gg &Context) end()
fn (mut ctx Context) refresh_ui()
fn (mut ctx Context) resize(width int, height int)
fn (gg &Context) run()
fn (mut ctx Context) set_bg_color(c gx.Color)
fn (ctx &Context) set_cfg(cfg gx.TextCfg)
fn (ctx &Context) set_pixel(x f32, y f32, c gx.Color)
fn (ctx &Context) text_height(s string) int
fn (ctx &Context) text_size(s string) (int, int)
fn (ctx &Context) text_width(s string) int
struct Event {
pub mut:
frame_count u64
typ sapp.EventType
key_code KeyCode
char_code u32
key_repeat bool
modifiers u32
mouse_button sapp.MouseButton
mouse_x f32
mouse_y f32
mouse_dx f32
mouse_dy f32
scroll_x f32
scroll_y f32
num_touches int
touches [8]C.sapp_touchpoint
window_width int
window_height int
framebuffer_width int
framebuffer_height int
}
struct Image {
pub mut:
id int
width int
height int
nr_channels int
ok bool
data voidptr
ext string
simg_ok bool
simg C.sg_image
path string
}
fn (mut img Image) init_sokol_image() &Image
struct Rect {
pub:
x f32
y f32
width f32
height f32
}
struct Size {
pub:
width int
height int
}