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

@ -400,7 +400,7 @@ void reload_so() {
last = now;
load_so("$so_name");
}
time__sleep_ms(500);
time__sleep_ms(400);
}
}
' )

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

View File

@ -26,6 +26,7 @@ const (
import const (
GLFW_RESIZABLE
GLFW_DECORATED
GLFW_FLOATING
)
import const (
@ -102,6 +103,7 @@ struct WinCfg {
is_modal int
is_browser bool
url string
always_on_top bool
}
// data *C.GLFWwindow
@ -161,6 +163,10 @@ pub fn create_window(c WinCfg) *Window {
window_hint(GLFW_RESIZABLE, 0)
window_hint(GLFW_DECORATED, 0)
}
if c.always_on_top {
window_hint(GLFW_FLOATING, 1)
}
cwindow := C.glfwCreateWindow(c.width, c.height, c.title.str, 0, 0)
# if (!cwindow)
// if cwindow == 0