summaryrefslogtreecommitdiff
path: root/fbgl.h
diff options
context:
space:
mode:
authorlvntky <klevent1903@gmail.com>2024-11-24 21:25:56 +0300
committerlvntky <klevent1903@gmail.com>2024-11-24 21:25:56 +0300
commitff43c66c491b443b7522a3b3d716905ee9732b60 (patch)
treebee1e5df60f4add24e23975a63959a0216bcc464 /fbgl.h
parent766962f9970cc3d8ee5b49c8bc987fe14c9eda7c (diff)
[refactor] faster rendering without bound check
Diffstat (limited to 'fbgl.h')
-rw-r--r--fbgl.h5
1 files changed, 3 insertions, 2 deletions
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
+*/