summaryrefslogtreecommitdiff
path: root/applications/goldman/source/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'applications/goldman/source/main.cpp')
-rw-r--r--applications/goldman/source/main.cpp84
1 files changed, 21 insertions, 63 deletions
diff --git a/applications/goldman/source/main.cpp b/applications/goldman/source/main.cpp
index d74eaad..475129f 100644
--- a/applications/goldman/source/main.cpp
+++ b/applications/goldman/source/main.cpp
@@ -1,79 +1,37 @@
#include <daguerre/framebuffer.hpp>
#include <daguerre/ppm.hpp>
+#include "renderer.hpp"
+#include "socket.hpp"
+#include "input.hpp"
+#include "main.hpp"
-daguerre::hilbert_color trans_color;
+//TODO: handle errors
-void convert_pointer(
- daguerre::hilbert_color &dest, const daguerre::hilbert_color &src) {
- if (src != trans_color)
- dest = src;
-}
+renderer *r;
int main(int, char **) {
- trans_color = euler::syscall::encode_color(0xff, 0x00, 0xff);
-
- daguerre::image<daguerre::hilbert_color> framebuffer =
- daguerre::get_hilbert_framebuffer();
-
- int fw = framebuffer.width;
- int fh = framebuffer.height;
-
- daguerre::image<daguerre::hilbert_color> double_buffer(fw, fh);
+ euler::syscall::listener_handle listener;
+ euler::syscall::create_socket_listener("hilbert.compositor", listener);
- std::optional<daguerre::image<daguerre::hilbert_color>>
- background_original = daguerre::try_load_ppm("/assets/background.ppm");
-
- daguerre::image<daguerre::hilbert_color> background;
-
- if (background_original.has_value())
- background = background_original->stretch(fw, fh);
- else {
- background = daguerre::image<daguerre::hilbert_color>(fw, fh);
- background.fill(euler::syscall::encode_color(0, 0, 0));
- }
+ r = new renderer(
+ daguerre::get_hilbert_framebuffer(),
+ *daguerre::try_load_ppm("/assets/background.ppm"),
+ euler::syscall::encode_color(0x00, 0x00, 0x00),
+ *daguerre::try_load_ppm("/assets/pointer.ppm"),
+ euler::syscall::encode_color(0xff, 0x00, 0xff));
- std::optional<daguerre::image<daguerre::hilbert_color>>
- pointer_original = daguerre::try_load_ppm("/assets/pointer.ppm");
+ euler::syscall::start_thread([]() { r->render_thread_main(); });
+ euler::syscall::start_thread(input_thread_main);
- if (!pointer_original.has_value())
- //TODO
- while (1)
- ;
+ r->dispatch_render();
- daguerre::image<daguerre::hilbert_color>
- pointer = std::move(*pointer_original);
-
- int mouse_x = fw / 2;
- int mouse_y = fh / 2;
+ euler::syscall::set_thread_name("socket listener thread");
while (true) {
-
- double_buffer.copy_from(background, 0, 0);
- double_buffer.convert_from(pointer, mouse_x, mouse_y, 0, 0,
- std::min(pointer. width, double_buffer. width - mouse_x),
- std::min(pointer.height, double_buffer.height - mouse_y),
- &convert_pointer);
-
- framebuffer.copy_from(double_buffer, 0, 0);
-
- auto result = euler::syscall::get_input_packet();
- if (std::holds_alternative<euler::syscall::mouse_packet>(result)) {
- const auto &packet = std::get<euler::syscall::mouse_packet>(result);
- mouse_x += packet.x_changed;
- mouse_y += packet.y_changed;
- if (mouse_x < 0)
- mouse_x = 0;
- else if (mouse_x >= fw)
- mouse_x = fw - 1;
- if (mouse_y < 0)
- mouse_y = 0;
- else if (mouse_y >= fh)
- mouse_y = fh - 1;
- }
-
+ euler::syscall::stream_handle socket;
+ euler::syscall::accept_socket_connection(listener, socket);
+ euler::syscall::start_thread(socket_thread_main, socket);
}
- return 0;
-
}