0

I am using the following code, which should clear the screen with black color, but it is blue.

#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>

int main()
{
 al_init();
 ALLEGRO_DISPLAY* display = al_create_display(800, 600);
 al_clear_to_color(al_map_rgb(0, 0, 0));
 al_flip_display();
 al_rest(5.0);
 return 0;
}

enter image description here

alufers
  • 134
  • 2
  • 10
  • 1
    It works fine for me. It shows a regular black window. (Archlinux, kernel 4.3.3, allegro 5.0.11-1) – Michael Jan 14 '16 at 20:19
  • 1
    Tested on Archlinux as well, and I get a black window. Try changing the color though, as I got a black window even when clearing to, say, red. – rcorre Jan 14 '16 at 20:45

1 Answers1

2

Try flipping, then waiting a bit before flipping again:

ALLEGRO_DISPLAY *display = al_create_display(800,600);

al_flip_display();
al_rest(0.1);

al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();

al_rest(2.0);

Ordinarily you'd be clearing the screen in an update-draw loop, so you wouldn't see this sort of thing, but it can occur if you're just trying to clear and flip it once (I believe it may have to do with double-buffering, but don't quote me on that).

rcorre
  • 6,477
  • 3
  • 28
  • 33