2022-03-22 18:13:06 +00:00
|
|
|
|
|
|
|
internal void
|
2022-03-27 10:47:18 +00:00
|
|
|
en_init(App_State* state, App_Init_Desc desc)
|
2022-03-22 18:13:06 +00:00
|
|
|
{
|
2022-04-16 11:00:32 +00:00
|
|
|
lumenarium_env_validate();
|
|
|
|
|
2022-03-27 10:47:18 +00:00
|
|
|
state->assemblies = assembly_array_create(permanent, desc.assembly_cap);
|
2022-04-06 18:29:32 +00:00
|
|
|
|
|
|
|
Output* o = &state->output;
|
2022-04-22 18:57:52 +00:00
|
|
|
register_output_method(o, OutputData_Invalid, 0, 0, 0);
|
|
|
|
register_output_method(o, OutputData_NetworkSACN, output_network_sacn_update, output_network_sacn_build, output_network_sacn_init());
|
|
|
|
register_output_method(o, OutputData_ComUART, 0, output_network_sacn_build, output_com_uart_init());
|
2022-04-16 11:00:32 +00:00
|
|
|
|
|
|
|
lumenarium_env_validate();
|
2022-03-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
en_frame_prepare(App_State* state)
|
|
|
|
{
|
2022-04-16 11:00:32 +00:00
|
|
|
lumenarium_env_validate();
|
2022-03-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-13 14:23:53 +00:00
|
|
|
global r32 tt = 0;
|
|
|
|
|
2022-05-13 11:45:40 +00:00
|
|
|
#include "../user_space/incenter_patterns.c"
|
2022-04-23 13:55:53 +00:00
|
|
|
|
2022-03-22 18:13:06 +00:00
|
|
|
internal void
|
|
|
|
en_frame(App_State* state)
|
|
|
|
{
|
2022-04-16 11:00:32 +00:00
|
|
|
lumenarium_env_validate();
|
|
|
|
|
2022-04-13 14:23:53 +00:00
|
|
|
scratch_get(scratch);
|
|
|
|
Assembly_Array assemblies = state->assemblies;
|
|
|
|
|
2022-04-06 18:29:32 +00:00
|
|
|
///////////////////////////////////////
|
|
|
|
// Output Data
|
2022-04-22 18:57:52 +00:00
|
|
|
Output_Methods methods = state->output.methods;
|
|
|
|
|
|
|
|
// update each method that has an update method
|
|
|
|
for (u32 i = 0; i < OutputData_Count; i++)
|
|
|
|
{
|
|
|
|
if (methods.update_procs[i] == 0) continue;
|
|
|
|
methods.update_procs[i](methods.method_data[i]);
|
|
|
|
}
|
|
|
|
|
2022-04-06 18:29:32 +00:00
|
|
|
Output_Data_Queue output_queue = {};
|
2022-04-13 14:23:53 +00:00
|
|
|
output_queue.a = scratch.a;
|
2022-04-06 18:29:32 +00:00
|
|
|
|
|
|
|
// build output data buffers
|
|
|
|
for (u32 i = 0; i < assemblies.len; i++)
|
|
|
|
{
|
|
|
|
Assembly_Strip_Array strips = assemblies.strip_arrays[i];
|
2022-04-22 18:57:52 +00:00
|
|
|
Assembly_Pixel_Buffer* pixels = assemblies.pixel_buffers + i;
|
2022-04-06 18:29:32 +00:00
|
|
|
for (u32 j = 0; j < strips.len; j++)
|
|
|
|
{
|
|
|
|
Assembly_Strip* strip = strips.strips + j;
|
|
|
|
Build_Output_Data_Buffer* method_proc = methods.procs[strip->output_kind];
|
|
|
|
u8* method_data = methods.method_data[strip->output_kind];
|
|
|
|
if (method_proc == 0) continue;
|
2022-04-22 18:57:52 +00:00
|
|
|
method_proc(state, i, pixels, strip, method_data, &output_queue);
|
2022-04-06 18:29:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// output the buffers
|
|
|
|
// TODO(PS): we could sort these first if switchig between output
|
|
|
|
// types is time consuming
|
2022-04-22 18:57:52 +00:00
|
|
|
|
|
|
|
Sacn* sacn = (Sacn*)state->output.methods.method_data[OutputData_NetworkSACN];
|
2022-04-06 18:29:32 +00:00
|
|
|
for (Output_Data* at = output_queue.first; at != 0; at = at->next)
|
|
|
|
{
|
|
|
|
// NOTE(PS): we can overload each switch case as more methods come in
|
|
|
|
// ie. OutputData_NetworkSACN and OutputData_NetworkArtNet could use
|
|
|
|
// the same case since at this point they just need to push data out
|
|
|
|
// over a socket
|
|
|
|
switch (at->kind)
|
|
|
|
{
|
|
|
|
case OutputData_NetworkSACN:
|
|
|
|
{
|
2022-04-22 18:57:52 +00:00
|
|
|
os_socket_send_to(
|
|
|
|
sacn->socket,
|
|
|
|
at->network.v4_addr,
|
|
|
|
at->network.port,
|
|
|
|
at->data,
|
|
|
|
0
|
|
|
|
);
|
2022-04-06 18:29:32 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case OutputData_ComUART:
|
|
|
|
{
|
|
|
|
// TODO(PS): platform com io
|
|
|
|
} break;
|
|
|
|
|
|
|
|
invalid_code_path;
|
|
|
|
}
|
|
|
|
}
|
2022-04-16 11:00:32 +00:00
|
|
|
|
|
|
|
scratch_release(scratch);
|
|
|
|
lumenarium_env_validate();
|
2022-03-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
en_cleanup(App_State* state)
|
|
|
|
{
|
2022-04-16 11:00:32 +00:00
|
|
|
lumenarium_env_validate();
|
2022-03-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
|