Skip to content

Instantly share code, notes, and snippets.

@walidjabari walidjabari/allegro Secret
Last active Apr 13, 2018

Embed
What would you like to do?
#include <allegro.h>
#include <stdio.h>
#include <stdlib.h>
#include <winalleg.h>
void find_resolution(int * x, int * y ) ///finding the resolution of the screen in order to initialize allegro in full screen mode
{
* x = GetSystemMetrics(SM_CXSCREEN);
* y = GetSystemMetrics(SM_CYSCREEN);
}
int main()
{
int monitor_width, monitor_height;
find_resolution(&monitor_width,&monitor_height);
allegro_init();
install_keyboard();
install_mouse();
set_color_depth( desktop_color_depth() );
if (set_gfx_mode(GFX_AUTODETECT, monitor_width, monitor_height, 0, 0)!=0)
{
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("%s\n",allegro_error);
allegro_exit();
exit(EXIT_FAILURE);
}
show_mouse(screen);
BITMAP * bmp; ///declaring a bitmap
bmp = create_bitmap(SCREEN_W , SCREEN_H); ///allocating the bitmap with the same dimensions as the screen
clear_to_color(bmp , makecol(0 , 255 , 0)); ///making the bitmap green
draw_sprite(screen , bmp , 0 , 0 ); ///drawing the bitmap to the screen. the screen is now green
fade_out(5); ///attempt to fade out the green color to black
clear_bitmap(screen);
while ( !key[KEY_ESC] )
{
}
return 0;
}
END_OF_MAIN();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.