aboutsummaryrefslogtreecommitdiffstats
path: root/src/video.adb
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2025-01-11 12:14:28 -0500
committerClyne Sullivan <clyne@bitgloo.com>2025-01-11 12:14:28 -0500
commit8fa66b024f91e47d8b5273e8c85ec5f60fe42d5b (patch)
tree1e3da4ec5bdfbbcb36ebd30ab9c055c45f50f279 /src/video.adb
parentcf8c3a51cb01b64ad2bc700fdd2b4906ef864877 (diff)
initial upload
Diffstat (limited to 'src/video.adb')
-rw-r--r--src/video.adb59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/video.adb b/src/video.adb
new file mode 100644
index 0000000..0a93592
--- /dev/null
+++ b/src/video.adb
@@ -0,0 +1,59 @@
+with Sf.Window;
+with Sf.Window.Event;
+with Sf.Graphics.Color;
+
+package body Video is
+ procedure Clear_Screen is
+ begin
+ for X in 0 .. sfUint32 (Width) - 1 loop
+ for Y in 0 .. sfUint32 (Height) - 1 loop
+ Image.setPixel (Pixels, X, Y, Color.sfBlack);
+ end loop;
+ end loop;
+ end Clear_Screen;
+
+ procedure Initialize is
+ begin
+ Sprite.setTexture (Pixels_Sprite, Pixels_Texture);
+ Sprite.setPosition (Pixels_Sprite, (Float (0), Float (0)));
+ Sprite.setScale (Pixels_Sprite, (Float (Scale), Float (Scale)));
+ RenderWindow.setFramerateLimit (app, 60);
+ end Initialize;
+
+ function Is_Running return Boolean is
+ begin
+ return RenderWindow.isOpen (app) = sfTrue;
+ end Is_Running;
+
+ procedure Display is
+ use Sf.Window.Event;
+
+ e : sfEvent;
+ begin
+ while RenderWindow.pollEvent (app, event => e) = sfTrue loop
+ if e.eventType = sfEvtClosed then
+ RenderWindow.close (app);
+ end if;
+ end loop;
+
+ RenderWindow.clear (app, Color.sfWhite);
+ Texture.updateFromImage (Pixels_Texture, Pixels, 0, 0);
+ RenderWindow.drawSprite (app, Pixels_Sprite);
+ RenderWindow.display (app);
+ end Display;
+
+ function Toggle_Pixel (X, Y : sfUint32) return Boolean is
+ use Color;
+
+ P : constant sfColor := Image.getPixel (Pixels, X, Y);
+ R : constant Boolean := P = sfWhite;
+ begin
+ Image.setPixel (Pixels, X, Y, (if R then sfBlack else sfWhite));
+ return R;
+ end Toggle_Pixel;
+
+ procedure Finish is
+ begin
+ RenderWindow.close (app);
+ end Finish;
+end Video;