1
0
Fork 0
forked from AbleOS/ableos

Windowing changes

This commit is contained in:
Able 2024-10-15 20:30:24 -05:00
parent 2bc13cd7d8
commit 34101d2e8c
3 changed files with 83 additions and 28 deletions

View file

@ -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
}
}

View file

@ -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
//
{
render.clear(window, color)
window_count := 0
loop {
render.clear(window, render.black)
// Draw the decorators
{
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)

View file

@ -9,29 +9,32 @@ 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"
engine_version := ignim.version.make_version(0, 0, 0)
api_version := ignim.version.make_api_version(0, 1, 0, 0)
program_name := "Horizon Testing Program\0"
program_version := ignim.version.make_version(0, 1, 0)
engine_name := "None\0"
engine_version := ignim.version.make_version(0, 0, 0)
api_version := ignim.version.make_api_version(0, 1, 0, 0)
app_info := ignim.application.new_application_info(program_name, program_version, engine_name, engine_version, api_version)
app_info := ignim.application.new_application_info(program_name, program_version, engine_name, engine_version, api_version)
create_info := ignim.instance.new_create_info(&app_info)
create_info := ignim.instance.new_create_info(&app_info)
instance := ignim.instance.void_instance()
instance := ignim.instance.void_instance()
// // 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")
// // 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")
}
}
// TODO: get window from the window system and draw to the surface
return 0
}