0

The code below won't work; it produces a blank screen. But if I change the filled rectangle line toward the bottom line to:

    al_draw_filled_rectangle(100, 100, 100+15, 100+15, al_map_rgb(155, 255, 155));

It produces a square at the correct coordinates. What's up?

    #define ALLEGRO_STATICLINK



     #include <allegro5/allegro.h>
     #include <allegro5/allegro_primitives.h>



    int main(int argc, char **argv)

{
    ALLEGRO_DISPLAY *display;


    if(!al_init())
    {
         return -1;
    }

    display = al_create_display(640, 480);
    if(!display)
    {
        return -1;
    }

    if(!al_init_primitives_addon())
    {
        return -1;
    }


    al_draw_filled_rectangle(73, 493, 73+15, 493+15, al_map_rgb(155, 255, 155));

    al_flip_display();

    al_rest(10);

    return 0;
}
ScottJShea
  • 7,041
  • 11
  • 44
  • 67
user701329
  • 127
  • 2
  • 7

1 Answers1

4

You are trying to draw at a Y coordinate greater than the screen height...

al_draw_filled_rectangle(73, 493, 73+15, 493+15, al_map_rgb(155, 255, 155));

Draws at 493 to 493+15

493 > 480 and 493+15 > 480

display = al_create_display(640, 480);

This set 480 as your screen height so drawing above that number will result in nothing being shown.

When you use

al_draw_filled_rectangle(100, 100, 100+15, 100+15, al_map_rgb(155, 255, 155));

You are now actually on the screen so it works.

M. Laing
  • 1,607
  • 11
  • 25