glfw always on top
							parent
							
								
									f27777af56
								
							
						
					
					
						commit
						b36a9f7e55
					
				|  | @ -400,7 +400,7 @@ void reload_so() { | ||||||
| 			last = now;  | 			last = now;  | ||||||
| 			load_so("$so_name");  | 			load_so("$so_name");  | ||||||
| 		} | 		} | ||||||
| 		time__sleep_ms(500);  | 		time__sleep_ms(400);  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| ' )  | ' )  | ||||||
|  |  | ||||||
|  | @ -27,17 +27,18 @@ fn main() { | ||||||
| 	height := 300 | 	height := 300 | ||||||
| 	mut game := &Game{ | 	mut game := &Game{ | ||||||
| 		vg: 0  | 		vg: 0  | ||||||
| 		dx: 3  | 		dx: 1  | ||||||
| 		dy: 3  | 		dy: 1  | ||||||
| 		height: height  | 		height: height  | ||||||
| 		width: width  | 		width: width  | ||||||
| 	} | 	} | ||||||
| 	mut window := glfw.create_window(glfw.WinCfg { | 	mut window := glfw.create_window(glfw.WinCfg { | ||||||
| 		width: width, | 		width: width  | ||||||
| 		height: height, | 		height: height  | ||||||
| 		borderless: false, | 		borderless: false  | ||||||
| 		title: 'Hot code reloading demo' | 		title: 'Hot code reloading demo' | ||||||
| 		ptr: game  | 		ptr: game  | ||||||
|  | 		always_on_top: true  | ||||||
| 	})  | 	})  | ||||||
| 	//window.onkeydown(key_down)
 | 	//window.onkeydown(key_down)
 | ||||||
| 	game.main_wnd = window  | 	game.main_wnd = window  | ||||||
|  | @ -60,13 +61,14 @@ fn main() { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| const ( | const ( | ||||||
| 	W = 50 | 	W = 50 | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| [live] | [live] | ||||||
| fn (ctx &Game) draw() { | 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() { | fn (ctx mut Game) run() { | ||||||
|  | @ -80,9 +82,27 @@ fn (ctx mut Game) run() { | ||||||
| 			ctx.dx = - ctx.dx | 			ctx.dx = - ctx.dx | ||||||
| 		} | 		} | ||||||
| 		// Refresh
 | 		// Refresh
 | ||||||
| 		time.sleep_ms(30) | 		time.sleep_ms(17) | ||||||
| 		glfw.post_empty_event() | 		glfw.post_empty_event() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //sdfsd 
 | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ const ( | ||||||
| import const ( | import const ( | ||||||
| 	GLFW_RESIZABLE | 	GLFW_RESIZABLE | ||||||
| 	GLFW_DECORATED | 	GLFW_DECORATED | ||||||
|  | 	GLFW_FLOATING  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| import const ( | import const ( | ||||||
|  | @ -102,6 +103,7 @@ struct WinCfg { | ||||||
| 	is_modal   int | 	is_modal   int | ||||||
| 	is_browser bool | 	is_browser bool | ||||||
| 	url        string | 	url        string | ||||||
|  | 	always_on_top     bool  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // data  *C.GLFWwindow
 | // data  *C.GLFWwindow
 | ||||||
|  | @ -161,6 +163,10 @@ pub fn create_window(c WinCfg) *Window { | ||||||
| 		window_hint(GLFW_RESIZABLE, 0) | 		window_hint(GLFW_RESIZABLE, 0) | ||||||
| 		window_hint(GLFW_DECORATED, 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) | 	cwindow := C.glfwCreateWindow(c.width, c.height, c.title.str, 0, 0) | ||||||
| 	# if (!cwindow) | 	# if (!cwindow) | ||||||
| 	// if cwindow == 0
 | 	// if cwindow == 0
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue