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

glfw always on top

This commit is contained in:
Alexander Medvednikov
2019-07-15 18:33:11 +02:00
parent f27777af56
commit b36a9f7e55
3 changed files with 34 additions and 8 deletions

View File

@ -27,17 +27,18 @@ fn main() {
height := 300
mut game := &Game{
vg: 0
dx: 3
dy: 3
dx: 1
dy: 1
height: height
width: width
}
mut window := glfw.create_window(glfw.WinCfg {
width: width,
height: height,
borderless: false,
width: width
height: height
borderless: false
title: 'Hot code reloading demo'
ptr: game
always_on_top: true
})
//window.onkeydown(key_down)
game.main_wnd = window
@ -60,13 +61,14 @@ fn main() {
}
}
const (
W = 50
)
[live]
fn (ctx &Game) draw() {
ctx.vg.draw_rect(ctx.x, ctx.y, W, W, gx.rgb(0, 0, 255))
ctx.vg.draw_rect(ctx.x, ctx.y, W, W, gx.rgb(255, 0, 0))
}
fn (ctx mut Game) run() {
@ -80,9 +82,27 @@ fn (ctx mut Game) run() {
ctx.dx = - ctx.dx
}
// Refresh
time.sleep_ms(30)
time.sleep_ms(17)
glfw.post_empty_event()
}
}
//sdfsd