diff --git a/README.md b/README.md index 0028eb5..3fd1144 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ This small demo is based on [Azur](https://gitea.planet-casio.com/Lephenixnoir/Azur). It uses its ultra fast rendering pipeline with specific a specific high speed quadratic calculation algorithm written by Lephenixnoir a,d able to handle both : - Mandelbrot's set calculations : `Z_(n+1) = Z_n^2 + C` with `Z_0 = 0 + 0 i` and `C` covering the complex plan +![image](https://gitea.planet-casio.com/Slyvtt/MandAzur/images/fxlink-image-2023.01.19-20h38-1.png) - Julia's set calculations : `Z_(n+1) = Z_n^2 + C` with `C = A + B i` and `Z_n` covering the complex plan +![image](https://gitea.planet-casio.com/Slyvtt/MandAzur/images/fxlink-image-2023.01.19-20h38-2.png) Both Mandelbrot - *named as per Benoît MANDELBROT (1924-2010)* - and Julia - *named as per Gaston JULIA (1893-1978)* - fractals are based on the convergence determination of the equation `Z_(n+1) = Z_n^2 + C`. @@ -13,31 +15,35 @@ Both Mandelbrot - *named as per Benoît MANDELBROT (1924-2010)* - and Julia - *n Control keys are : --[**EXIT**] to leave to the Operating System +- [**EXIT**] to leave to the Operating System --[**F1**] to [**F4**] to show/switch off some informations on the screen : - - [ ] [F1] : hide everything - - [ ] [F2] : minimal output FPS + rendering time - - [ ] [F3] : detailed update/rendering time - - [ ] [F4] : memory usage +- [**F1**] to [**F4**] to show/switch off some informations on the screen : + - [F1] : hide everything + - [F2] : minimal output FPS + rendering time + - [F3] : detailed update/rendering time + - [F4] : memory usage --[**F5**]/[**F6**] : switch fractal mode - - [ ] [F5] : set Mandelbrot fractal - - [ ] [F6] : set Julia fractal +- [**F5**]/[**F6**] : switch fractal mode + - [F5] : set Mandelbrot fractal + - [F6] : set Julia fractal --[**OPTN**]/[**VARS**] : switch resolution - - [ ] [OPTN] : set resolution scale to 1, the fractals are computed on a 396x224 grid - - [ ] [VARS] : set resolution scale to 0.5 (2x2 pixels), the fractals are computed on a 198x112 grid (much faster but lower quality) +- [**OPTN**]/[**VARS**] : switch resolution + - [OPTN] : set resolution scale to 1, the fractals are computed on a 396x224 grid + - [VARS] : set resolution scale to 0.5 (2x2 pixels), the fractals are computed on a 198x112 grid (much faster but lower quality) For the Julia set only : - --[**SHIFT**]+[**Directional Cross**] : change the value of the C value (`C = A + B i`) - - [ ] [**SHIFT+LEFT**] : A = A - 0.002 - - [ ] [**SHIFT+RIGHT**] : A = A + 0.002 - - [ ] [**SHIFT+DOWN**] : B = B - 0.002 - - [ ] [**SHIFT+UP**] : B = B + 0.002 +- [**SHIFT**]+[**Directional Cross**] : change the value of the C value (`C = A + B i`) + - [**SHIFT+LEFT**] : A = A - 0.002 + - [**SHIFT+RIGHT**] : A = A + 0.002 + - [**SHIFT+DOWN**] : B = B - 0.002 + - [**SHIFT+UP**] : B = B + 0.002 A and B are constrained in the range [-2.000 .. 2.000] +If you have a running session of `fxlink` : +- [**7**] to [**9**] to export the calculator screen to fxlink : + - [7] : take a screenshot + - [8] : start video output (not : this is just rendered in a SDL2 window, not recorded, OBS/ffmpeg may be your very best friends to do so) + - [9] : stop video output Have fun !!! diff --git a/images/fxlink-image-2023.01.19-20h38-1.png b/images/fxlink-image-2023.01.19-20h38-1.png new file mode 100644 index 0000000..dc082ad Binary files /dev/null and b/images/fxlink-image-2023.01.19-20h38-1.png differ diff --git a/images/fxlink-image-2023.01.19-20h38-2.png b/images/fxlink-image-2023.01.19-20h38-2.png new file mode 100644 index 0000000..79181b7 Binary files /dev/null and b/images/fxlink-image-2023.01.19-20h38-2.png differ diff --git a/src/main.cpp b/src/main.cpp index cbd0bf4..37e84bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,40 @@ static void update( float dt ) } + +static void hook_prefrag(int id, void *fragment, int size) +{ + if(!screenshot && !record) + return; + + /* Screenshot takes precedence */ + char const *type = screenshot ? "image" : "video"; + + int pipe = usb_ff_bulk_output(); + + if(id == 0) { + usb_fxlink_header_t h; + usb_fxlink_image_t sh; + int size = azrp_width * azrp_height * 2; + + usb_fxlink_fill_header(&h, "fxlink", type, size + sizeof sh); + sh.width = htole32(azrp_width); + sh.height = htole32(azrp_height); + sh.pixel_format = htole32(USB_FXLINK_IMAGE_RGB565); + + usb_write_sync(pipe, &h, sizeof h, 4, false); + usb_write_sync(pipe, &sh, sizeof sh, 4, false); + } + + usb_write_sync(pipe, fragment, size, 4, false); + + if(id == azrp_frag_count - 1) { + usb_commit_sync(pipe); + screenshot = false; + } +} + + static void get_inputs( void ) { key_event_t ev; @@ -62,8 +96,9 @@ static void get_inputs( void ) if(keydown(KEY_EXIT)) {exitToOS = true; }; if(keydown(KEY_7)) {screenshot = true;}; - if(keydown(KEY_8)) {record = !record; }; - if(keydown(KEY_9)) {textoutput = true;}; + if(keydown(KEY_8)) {record = true; }; + if(keydown(KEY_9)) {record = false; }; + if(keydown(KEY_DEL)) {textoutput = true;}; if(keydown(KEY_OPTN)) { @@ -73,6 +108,7 @@ static void get_inputs( void ) azrp_shader_image_rgb16_configure(); azrp_shader_image_p8_configure(); azrp_shader_image_p4_configure(); + azrp_hook_set_prefrag(hook_prefrag); azrp_mandelbrot_init(); azrp_julia_init(); @@ -86,6 +122,7 @@ static void get_inputs( void ) azrp_shader_image_rgb16_configure(); azrp_shader_image_p8_configure(); azrp_shader_image_p4_configure(); + azrp_hook_set_prefrag(hook_prefrag); azrp_mandelbrot_init(); azrp_julia_init(); @@ -140,6 +177,7 @@ int main(void) azrp_shader_image_rgb16_configure(); azrp_shader_image_p8_configure(); azrp_shader_image_p4_configure(); + azrp_hook_set_prefrag(hook_prefrag); azrp_mandelbrot_init(); azrp_julia_init(); @@ -199,6 +237,7 @@ int main(void) elapsedTime = ((float) (time_update+time_render)); +/* if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); @@ -209,6 +248,7 @@ int main(void) { usb_fxlink_videocapture(false); } +*/ if (textoutput && usb_is_open()) {