Just installed Allegro 4.2.2, and I'm trying to run a simple program.
When launched, screen is totally black, but input normally reacts to keys. I found that screen
is 0x00000000 (a nullptr). Anyway, set_gfx_mode
returns no error.
MinGW doesn't yell at all, no warnings, nothing. Code Blocks has linked only liballeg.a
and liballeg_s.a
with other options:
-lalleg_s -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
#include <time.h>
int main() {
srand( time( NULL ) );
allegro_init();
// screen
set_color_depth( 32 );
if ( set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ) < 0 ) {
printf( "Error set_gfx_mode: %s\n", allegro_error );
}
BITMAP* buffer = create_bitmap_ex( 32, SCREEN_W, SCREEN_H );
printf( "Screen location: %p\n", screen );
// keyboard and mouse
install_keyboard();
install_mouse();
show_os_cursor( 1 );
// main loop
bool done = false;
while ( !done ) {
// keys
if ( keypressed() ) {
int keyID = readkey() & 0xFF;
switch ( keyID ) {
case 27: { // escape
done = true;
break;
}
}
}
// rendering
clear_bitmap( buffer );
rectfill( buffer, 50, 50, 150, 150, 0x00FFFFFF );
blit( buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H );
}
destroy_bitmap( buffer );
allegro_exit();
return 0;
}
END_OF_MAIN()