summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-10-20 18:33:15 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-10-20 18:33:15 +0800
commit7b6a5111c9ed061bcfe9fc7c93055f952f4a34a0 (patch)
tree3de3b69a6f6b53f5f9a055abf6485f40c921d4d9
downloadallegro4-master.tar.gz
Example with Makefile.HEADmaster
-rw-r--r--.gitignore2
-rw-r--r--Makefile26
-rw-r--r--README.txt3
-rw-r--r--main.c45
4 files changed, 76 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..17fbe89
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.o
+*.out
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..cb82c9a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+CC = cc
+TARGET = app
+
+SRC = main.c
+OBJ = $(SRC:.c=.o)
+
+CFLAGS = -std=c99
+CFLAGS += -Os
+CFLAGS += -Wall
+CFLAGS += -I /usr/local/include
+
+LDFLAGS = -L /usr/local/lib
+LDFLAGS += -lalleg -lalleg_unsharable
+
+all: app
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+app: $(OBJ)
+ $(CC) $(LDFLAGS) $(OBJ) -o $(TARGET).out
+
+.PHONY: clean
+
+clean:
+ rm *.o *.out
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..b419f85
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,3 @@
+README
+
+
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..b012c2d
--- /dev/null
+++ b/main.c
@@ -0,0 +1,45 @@
+#include <allegro.h>
+
+int main(void)
+{
+ /* you should always do this at the start of Allegro programs */
+ if (allegro_init() != 0)
+ return 1;
+
+ /* set up the keyboard handler */
+ install_keyboard();
+
+ /* set a graphics mode sized 320x200 */
+ if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
+ if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
+ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
+ allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
+ return 1;
+ }
+ }
+
+ /* set the color palette */
+ set_palette(desktop_palette);
+
+ /* clear the screen to white */
+ clear_to_color(screen, makecol(255, 255, 255));
+
+ /* you don't need to do this, but on some platforms (eg. Windows) things
+ * will be drawn more quickly if you always acquire the screen before
+ * trying to draw onto it.
+ */
+ acquire_screen();
+
+ /* write some text to the screen with black letters and transparent background */
+ textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1);
+
+ /* you must always release bitmaps before calling any input functions */
+ release_screen();
+
+ /* wait for a key press */
+ readkey();
+
+ return 0;
+}
+
+END_OF_MAIN()