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 --- fbgl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fbgl.h') 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