Search code examples
cwindowswinapiallegro

C/C++ Allegro program causes Windows 7 to switch to Aero Basic


I'm just trying out the allegro library, and here is the code which I've got so far:

#include <allegro.h>

int main(int argc, char *argv[]) {
    allegro_init();  // initialize the allegro libraries
    install_keyboard(); // initialize keyboard functions
    
    set_color_depth(16); // set the color depth
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); // set up 640*480px window
    
    BITMAP *pic = NULL;
    pic = load_bitmap("C:/picture.bmp", NULL); // load the picture
    blit(pic, screen, 0, 0, 0, 0, 1000, 1000);

    readkey();
    destroy_bitmap(pic);
    return 0;
} 
END_OF_MAIN()

It works fine, but when I run it, while the program's window is open, Windows 7 changes the theme from Aero to Aero basic. If you aren't sure what I mean, this pops up (I got this from Google, which is why it says Vista rather than Windows 7):

http://www.suitedcowboys.com/wp-content/uploads/2007/01/010607_0906_HelloVistai28.png
(source: suitedcowboys.com)

  1. Why?
  2. How can I ensure that this doesn't happen?

Solution

  • Aero needs color set to 32 bit, but you're setting it to 16:

    set_color_depth(16);