logo

bytemedia

Home to byte-level sounds, images, videos, … git clone https://hacktivis.me/git/bytemedia.git
commit: c2eeca02aa928cf763ff5062d797cf86ec58a2b1
parent b9a421087eedd6541d0fdab179b7e80599f65880
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 14 Dec 2021 02:22:49 +0100

C/wayland: optimise rendering loop

Diffstat:

MC/wayland.c14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/C/wayland.c b/C/wayland.c @@ -91,9 +91,11 @@ draw_frame(struct client_state *state) { int t = (int)state->offset; /* Let the fun begin! */ - for(int y = 0; y < state->height; ++y) + for(int y = 0; y < state->height; y++) { - for(int x = 0; x < state->width; ++x) + int x_base = y * state->width; + + for(int x = 0; x < state->width; x++) { //if (((x + offset) + (y + offset) / 8 * 8) % 16 < 8) // data[y * WIDTH + x] = 0xFF666666; @@ -101,13 +103,15 @@ draw_frame(struct client_state *state) // data[y * WIDTH + x] = 0xFFEEEEEE; // munching squares - //state->shm_data[y * WIDTH + x] = (x - t | y - t) + t << t % 16; + //state->shm_data[y * state->width + x] = (x - t | y - t) + t << 16; + + state->shm_data[x_base + x] = (x|y) * t <<16; //glichy munching squares - state->shm_data[y * state->width + x] = (x | y) * t; + //state->shm_data[y * state->width + x] = (x | y) * t; // color enumeration - //data[y * WIDTH + x] = t*2|t*4<<8|t*8<<16; + //state->shm_data[y * state->width + x] = t*2|t*4<<8|t*8<<16; } } }