#include <allegro.h>
const int scrx = 640;
const int scry = 480;
int main(int argc, char* argv[]) {
if (allegro_init()) {
allegro_message("Cannot initalize Allegro.\n");
return 1;
}
//Set the window title when in a GUI environment
set_window_title("Hello World");
if (install_keyboard()) {
allegro_message("Cannot initalize keyboard input.\n");
return 1;
}
//set graphics mode, trying all acceptable depths
set_color_depth(32);
if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
set_color_depth(24);
if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
set_color_depth(15);
if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
allegro_message("Video Error: %s.\n", allegro_error);
return 1;
}
}
}
}
//set text background color to bright blue
text_mode(makecol(0, 0, 255));
//prints yellow "Hello World!!!" in middle of screen
textout_centre(screen, font, "Hello World!!!", scrx/2,
scry/2, makecol(255, 255, 0));
//Wait for a key to be pressed
while (!keypressed()) {}
return 0;
//Allegro will automatically deinitalize itself on exit
}
END_OF_MAIN()
but it throws some crazy errors, like "undefined reference to <<something or other>>". The error log is attached. I used this makefile (command "make all"):
CC=gcc
NAME=main
FILES=main.c
LF=-lalleg
all: default
default: build
build:
$(CC) -o $(NAME) $(FILES) $(LF)
clean:
rm -rf *.o
rm -rf $(NAME)
destroy:
rm -rf ./*
Attached File(s)
-
allegerr.txt (31.75K)
Number of downloads: 262

New Topic/Question
Reply



MultiQuote





|