From ff43c66c491b443b7522a3b3d716905ee9732b60 Mon Sep 17 00:00:00 2001 From: lvntky Date: Sun, 24 Nov 2024 21:25:56 +0300 Subject: [refactor] faster rendering without bound check --- .gitignore | 1 + asset/bmp/FLAG_B24.BMP | Bin 46182 -> 0 bytes asset/font.psf | Bin 29728 -> 0 bytes asset/font_2.ttf | Bin 120240 -> 0 bytes asset/tga_textures/doom.tga | Bin 0 -> 1440018 bytes asset/tr.tga | Bin 4367378 -> 0 bytes example/.gitignore | 2 +- example/texture.c | 4 +++- fbgl.h | 5 +++-- 9 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .gitignore delete mode 100644 asset/bmp/FLAG_B24.BMP delete mode 100644 asset/font.psf delete mode 100644 asset/font_2.ttf create mode 100644 asset/tga_textures/doom.tga delete mode 100644 asset/tr.tga diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1f6fec --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +fbgl-test-env/ diff --git a/asset/bmp/FLAG_B24.BMP b/asset/bmp/FLAG_B24.BMP deleted file mode 100644 index b61d368..0000000 Binary files a/asset/bmp/FLAG_B24.BMP and /dev/null differ diff --git a/asset/font.psf b/asset/font.psf deleted file mode 100644 index 071330e..0000000 Binary files a/asset/font.psf and /dev/null differ diff --git a/asset/font_2.ttf b/asset/font_2.ttf deleted file mode 100644 index af3f57c..0000000 Binary files a/asset/font_2.ttf and /dev/null differ diff --git a/asset/tga_textures/doom.tga b/asset/tga_textures/doom.tga new file mode 100644 index 0000000..4f7a447 Binary files /dev/null and b/asset/tga_textures/doom.tga differ diff --git a/asset/tr.tga b/asset/tr.tga deleted file mode 100644 index 86f10ae..0000000 Binary files a/asset/tr.tga and /dev/null differ diff --git a/example/.gitignore b/example/.gitignore index 4a6e1b0..567609b 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1 +1 @@ -build/core.* +build/ diff --git a/example/texture.c b/example/texture.c index da614d4..d1c25bd 100644 --- a/example/texture.c +++ b/example/texture.c @@ -32,7 +32,8 @@ int main(int argc, char **argv) int dy = 3; // Vertical speed (adjust for desired marquee speed) // Main rendering loop - while (1) { + int framesize = 30 * 30; + while (framesize) { // Clear the framebuffer (set background) fbgl_set_bg(&framebuffer, 0x000000); @@ -56,6 +57,7 @@ int main(int argc, char **argv) } usleep(50000); // Delay to make the marquee effect visible (adjust as needed) + framesize--; } // Wait for the user to press the escape key before exiting diff --git a/fbgl.h b/fbgl.h index 0f108fc..6b2b3f0 100644 --- a/fbgl.h +++ b/fbgl.h @@ -296,6 +296,7 @@ void fbgl_set_bg(fbgl_t *fb, uint32_t color) void fbgl_put_pixel(int x, int y, uint32_t color, fbgl_t *fb) { +#ifdef FBGL_VALIDATE_PUT_PIXEL if (!fb || !fb->pixels) { fprintf(stderr, "Error: framebuffer not initialized.\n"); return; @@ -304,7 +305,7 @@ void fbgl_put_pixel(int x, int y, uint32_t color, fbgl_t *fb) if (x < 0 || x >= fb->width || y < 0 || y >= fb->height) { return; // Ignore out-of-bound coordinates } - +#endif // FBGL_VALIDATE_PUT_PIXEL size_t index = y * fb->width + x; fb->pixels[index] = color; } @@ -685,4 +686,4 @@ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ -*/ \ No newline at end of file +*/ -- cgit v1.2.3