diff --git a/run_tree/win32/intel/debug/debug.rdbg b/run_tree/win32/intel/debug/debug.rdbg index 3304be4..715158d 100644 Binary files a/run_tree/win32/intel/debug/debug.rdbg and b/run_tree/win32/intel/debug/debug.rdbg differ diff --git a/run_tree/win32/intel/debug/lumenarium_first_win32.obj b/run_tree/win32/intel/debug/lumenarium_first_win32.obj index 314cb7c..0420798 100644 Binary files a/run_tree/win32/intel/debug/lumenarium_first_win32.obj and b/run_tree/win32/intel/debug/lumenarium_first_win32.obj differ diff --git a/src_v2/editor/lumenarium_editor.cpp b/src_v2/editor/lumenarium_editor.cpp index 1aba45d..833730d 100644 --- a/src_v2/editor/lumenarium_editor.cpp +++ b/src_v2/editor/lumenarium_editor.cpp @@ -207,6 +207,47 @@ ed_init(App_State* state) ed_sculpture_visualizer_init(state); } +internal u8* +ed_leds_to_texture(App_State* state, Allocator_Scratch* scratch, u32 pixels_dim) +{ + u32 at = 0; + u32* pixels = allocator_alloc_array(scratch->a, u32, pixels_dim * pixels_dim); + for (u32 a = 0; a < state->assemblies.len; a++) + { + Assembly_Pixel_Buffer leds = state->assemblies.pixel_buffers[a]; + for (u32 p = 0; p < leds.len; p++) + { + Assembly_Pixel led = leds.pixels[p]; + u32 index = at++; + pixels[index] = ( + led.r << 0 | + led.g << 8 | + led.b << 16 | + 0xFF << 24 + ); + } + } +#if 0 + for (u32 y = 0; y < pixels_dim; y++) + { + for (u32 x = 0; x < pixels_dim; x++) + { + r32 rp = (r32)y / (r32)pixels_dim; + r32 bp = (r32)x / (r32)pixels_dim; + u8 rb = (u8)(255 * rp); + u8 bb = (u8)(255 * bp); + u32 c = ( + 0xFF0000FF | + (rb << 8) | + (bb << 16) + ); + pixels[(y * pixels_dim) + x] = c; + } + } +#endif + return (u8*)pixels; +} + internal void ed_sculpture_updated(App_State* state, r32 scale, r32 led_size) { @@ -299,24 +340,8 @@ ed_sculpture_updated(App_State* state, r32 scale, r32 led_size) // TODO(PS): destroy the old texture } - u32* pixels = allocator_alloc_array(scratch.a, u32, pixels_count); - for (u32 y = 0; y < pixels_dim; y++) - { - for (u32 x = 0; x < pixels_dim; x++) - { - r32 rp = (r32)y / (r32)pixels_dim; - r32 bp = (r32)x / (r32)pixels_dim; - u8 rb = (u8)(255 * rp); - u8 bb = (u8)(255 * bp); - u32 c = ( - 0xFF0000FF | - (rb << 8) | - (bb << 16) - ); - pixels[(y * pixels_dim) + x] = c; - } - } - ed->sculpture_tex = platform_texture_create((u8*)pixels, pixels_dim, pixels_dim, pixels_dim); + u8* pixels = ed_leds_to_texture(state, &scratch, pixels_dim); + ed->sculpture_tex = platform_texture_create(pixels, pixels_dim, pixels_dim, pixels_dim); } internal void @@ -328,7 +353,15 @@ ed_frame_prepare(App_State* state) internal void ed_frame(App_State* state) { - UI* ui = &state->editor->ui; + Editor* ed = state->editor; + UI* ui = &ed->ui; + + { + scratch_get(scratch); + u32 w = ed->sculpture_tex.w; + u8* pixels = ed_leds_to_texture(state, &scratch, w); + platform_texture_update(ed->sculpture_tex, pixels, w, w, w); + } edr_render_begin(state); ui_draw(&state->editor->ui); diff --git a/src_v2/editor/lumenarium_editor_sculpture_visualizer.cpp b/src_v2/editor/lumenarium_editor_sculpture_visualizer.cpp index 8a0de1d..40e86ac 100644 --- a/src_v2/editor/lumenarium_editor_sculpture_visualizer.cpp +++ b/src_v2/editor/lumenarium_editor_sculpture_visualizer.cpp @@ -83,7 +83,7 @@ ed_sculpture_visualizer(App_State* state) ); // TODO(PS): TEMPORARY CAMERA CODE - cam_theta += 0.05f; + //cam_theta += 0.05f; v3 camera_pos = v3{sinf(cam_theta) * 50, 0, cosf(cam_theta) * 50}; r32 aspect = view_dim.x / view_dim.y; m44 proj = HMM_Perspective(45.0, aspect, 0.01f, 500); diff --git a/src_v2/engine/lumenarium_engine.cpp b/src_v2/engine/lumenarium_engine.cpp index 93f3e1e..2f0704f 100644 --- a/src_v2/engine/lumenarium_engine.cpp +++ b/src_v2/engine/lumenarium_engine.cpp @@ -5,6 +5,7 @@ en_init(App_State* state, App_Init_Desc desc) state->assemblies = assembly_array_create(permanent, desc.assembly_cap); Output* o = &state->output; + register_output_method(o, OutputData_Invalid, 0, 0); register_output_method(o, OutputData_NetworkSACN, output_network_sacn_build, output_network_sacn_init()); register_output_method(o, OutputData_ComUART, output_network_sacn_build, output_com_uart_init()); } @@ -15,19 +16,40 @@ en_frame_prepare(App_State* state) } +global r32 tt = 0; + internal void en_frame(App_State* state) { -#if 0 + scratch_get(scratch); + Assembly_Array assemblies = state->assemblies; + + /////////////////////////////////////// + // Temp Pattern Simulation + + tt += 1.0f / 60.0f; + + r32 hrange = 1; + r32 range = hrange * 2; + for (u32 i = 0; i < assemblies.len; i++) + { + Assembly_Pixel_Buffer pixels = assemblies.pixel_buffers[i]; + for (u32 j = 0; j < pixels.len; j++) + { + v4 p = pixels.positions[j]; + pixels.pixels[j].r = (u8)(((sinf((5 * tt) + (p.x * 10)) + 1) * 0.5f) * 255); + pixels.pixels[j].b = (u8)(((sinf((5 * tt) + (p.z * 10)) + 1) * 0.5f) * 255); + } + } + /////////////////////////////////////// // Output Data Output_Data_Queue output_queue = {}; - output_queue.a = scratch; + output_queue.a = scratch.a; // build output data buffers - Output_Methods methods; - Assembly_Array assemblies = state->assemblies; + Output_Methods methods = state->output.methods; for (u32 i = 0; i < assemblies.len; i++) { Assembly_Strip_Array strips = assemblies.strip_arrays[i]; @@ -65,7 +87,6 @@ en_frame(App_State* state) invalid_code_path; } } -#endif } internal void