summaryrefslogtreecommitdiff
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
parent766962f9970cc3d8ee5b49c8bc987fe14c9eda7c (diff)
[refactor] faster rendering without bound check
-rw-r--r--.gitignore1
-rw-r--r--asset/bmp/FLAG_B24.BMPbin46182 -> 0 bytes
-rw-r--r--asset/font.psfbin29728 -> 0 bytes
-rw-r--r--asset/font_2.ttfbin120240 -> 0 bytes
-rw-r--r--asset/tga_textures/doom.tgabin0 -> 1440018 bytes
-rw-r--r--asset/tr.tgabin4367378 -> 0 bytes
-rw-r--r--example/.gitignore2
-rw-r--r--example/texture.c4
-rw-r--r--fbgl.h5
9 files changed, 8 insertions, 4 deletions
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
--- a/asset/bmp/FLAG_B24.BMP
+++ /dev/null
Binary files differ
diff --git a/asset/font.psf b/asset/font.psf
deleted file mode 100644
index 071330e..0000000
--- a/asset/font.psf
+++ /dev/null
Binary files differ
diff --git a/asset/font_2.ttf b/asset/font_2.ttf
deleted file mode 100644
index af3f57c..0000000
--- a/asset/font_2.ttf
+++ /dev/null
Binary files differ
diff --git a/asset/tga_textures/doom.tga b/asset/tga_textures/doom.tga
new file mode 100644
index 0000000..4f7a447
--- /dev/null
+++ b/asset/tga_textures/doom.tga
Binary files differ
diff --git a/asset/tr.tga b/asset/tr.tga
deleted file mode 100644
index 86f10ae..0000000
--- a/asset/tr.tga
+++ /dev/null
Binary files 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
+*/