Windowing changes
This commit is contained in:
parent
2bc13cd7d8
commit
34101d2e8c
|
@ -1,5 +1,7 @@
|
|||
stn := @use("../../stn/src/lib.hb");
|
||||
.{string, memory, buffer} := stn
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
|
||||
input := @use("../../intouch/src/lib.hb")
|
||||
|
||||
|
@ -12,20 +14,34 @@ WindowID := struct {
|
|||
|
||||
VoidWindowID := WindowID.(0, 0)
|
||||
|
||||
create_window := fn(channel: int): WindowID {
|
||||
create_window := fn(channel: int): ^render.Surface {
|
||||
// get the horizon buffer
|
||||
// request a new window and provide the callback buffer
|
||||
// wait to recieve a message
|
||||
|
||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||
mem_buf := memory.request_page(1)
|
||||
|
||||
if windowing_system_buffer == 0 {
|
||||
return VoidWindowID
|
||||
return 0
|
||||
} else {
|
||||
msg := "\{01}\0"
|
||||
msg_length := 2
|
||||
// msg := "\{01}\0"
|
||||
// msg_length := 2
|
||||
|
||||
@as(void, @eca(3, windowing_system_buffer, msg, msg_length))
|
||||
return WindowID.(1, 0)
|
||||
// @as(void, @eca(3, windowing_system_buffer, msg, msg_length))
|
||||
|
||||
x := 0
|
||||
loop if x > 1000 break else x += 1
|
||||
|
||||
ret := buffer.recv(windowing_system_buffer, mem_buf, 4096)
|
||||
if ret == 0 {
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
||||
if *mem_buf == 0 {
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, random} := stn;
|
||||
.{string, memory, buffer, random, log} := stn;
|
||||
.{Vec2} := stn.math
|
||||
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
||||
|
@ -16,7 +16,7 @@ Window := struct {
|
|||
}
|
||||
|
||||
main := fn(): int {
|
||||
a := buffer.create("XHorizon\0")
|
||||
win_buff := buffer.create("XHorizon\0")
|
||||
|
||||
// BUG: Backbuffering is disabled
|
||||
screen := render.init(true)
|
||||
|
@ -26,24 +26,60 @@ main := fn(): int {
|
|||
|
||||
window := render.new_surface(screen.width / 3, screen.height / 3)
|
||||
|
||||
pos := Vec2(int).(100, 100)
|
||||
x := 10
|
||||
|
||||
mem_buf := memory.request_page(1)
|
||||
color := random.range(render.Color, render.black, render.white)
|
||||
side := window.width / 8
|
||||
|
||||
vel_inner := Vec2(int).(1, 1)
|
||||
pos_inner := Vec2(int).((window.width - side) / 2, (window.height - side) / 2)
|
||||
|
||||
loop {
|
||||
// Clear the screen
|
||||
render.clear(screen, render.black)
|
||||
|
||||
// TODO: Read the window buffer here
|
||||
{
|
||||
ret := buffer.recv(win_buff, mem_buf, 4096)
|
||||
if ret == 0 {
|
||||
log.info("No messages\0")
|
||||
}
|
||||
}
|
||||
|
||||
if pos_inner.x == 0 | pos_inner.x == window.width - side {
|
||||
vel_inner.x = -vel_inner.x
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
if pos_inner.y == 0 | pos_inner.y == window.height - side {
|
||||
vel_inner.y = -vel_inner.y
|
||||
color = random.range(render.Color, render.black, render.white)
|
||||
}
|
||||
|
||||
// TODO: Get windows out of a collection and iter through
|
||||
//
|
||||
window_count := 0
|
||||
loop {
|
||||
render.clear(window, render.black)
|
||||
|
||||
// Draw the decorators
|
||||
{
|
||||
render.clear(window, color)
|
||||
render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white)
|
||||
// render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white)
|
||||
}
|
||||
render.put_filled_rect(window, pos_inner, .(side, side), color)
|
||||
|
||||
// Apply the image to the screen
|
||||
pos := Vec2(int).(x, 100)
|
||||
|
||||
render.put_surface(screen, window, pos)
|
||||
if window_count >= 1 {
|
||||
x = 10
|
||||
break
|
||||
}
|
||||
window_count += 1
|
||||
x += 400
|
||||
}
|
||||
pos_inner += vel_inner
|
||||
|
||||
// Sync the screen
|
||||
render.sync(screen)
|
||||
|
|
|
@ -9,12 +9,12 @@ ignim := @use("../../../libraries/ignim/src/lib.hb");
|
|||
|
||||
main := fn(): int {
|
||||
x := 0
|
||||
loop if x > 1000000 break else x += 1
|
||||
// loop if x > 10000 break else x += 1
|
||||
|
||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||
// TODO: get WindowID
|
||||
create_window(windowing_system_buffer)
|
||||
|
||||
wid := create_window(windowing_system_buffer)
|
||||
if false {
|
||||
program_name := "Horizon Testing Program\0"
|
||||
program_version := ignim.version.make_version(0, 1, 0)
|
||||
engine_name := "None\0"
|
||||
|
@ -30,8 +30,11 @@ main := fn(): int {
|
|||
// // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
|
||||
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
||||
if ret == errors.IncompatibleDriver {
|
||||
// log.error("Driver Incompatible with Vulkan\0")
|
||||
log.error("Driver Incompatible with Vulkan\0")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: get window from the window system and draw to the surface
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Reference in a new issue