al_draw_rectangle does different output between linux and windows
gameovera

Hi.

I compiled the below code for linux and windows.

[EDIT] #include backslash to slash

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/allegro_image.h> 3#include <allegro5/allegro_primitives.h> 4 5int main(int argc, char **argv) 6{ 7 al_init(); 8 al_install_keyboard(); 9 al_init_image_addon(); 10 al_init_primitives_addon(); 11 12 ALLEGRO_DISPLAY *disp = al_create_display(640, 480); 13 ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue(); 14 15 al_register_event_source(queue, al_get_display_event_source(disp)); 16 al_register_event_source(queue, al_get_keyboard_event_source()); 17 18 bool running = true; 19 ALLEGRO_EVENT ev; 20 21 while (running) { 22 while (al_get_next_event(queue, &ev)) { 23 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) running = false; 24 if (ev.type == ALLEGRO_EVENT_KEY_DOWN) running = false; 25 } 26 27 al_clear_to_color(al_map_rgb(0, 0, 0)); 28 al_draw_rectangle(0, 0, 32, 32, al_map_rgb(255, 0, 0), 1); 29 al_flip_display(); 30 al_rest(1.0/60.0); 31 } 32 33 al_save_bitmap("disp.png", al_get_target_bitmap()); 34 35 al_destroy_display(disp); 36 al_destroy_event_queue(queue); 37 38 return 0; 39}

result(scale 8x):
{"name":"608225","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83c391ea44fb40f7610527e8b51ccfd8.png","w":647,"h":299,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83c391ea44fb40f7610527e8b51ccfd8"}608225

How about it in your environment?

my environment:

- Allegro 5.0.10

- Ubuntu 13.0.10 on virtualbox 4.3.6
- Windows 7

- AMD HD 7800 series GPU with latest driver

Arthur Kalliokoski

After converting the backslashes in the #includes to forward slashes, I get this

{"name":"608226","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/9\/095d8329210338c3641e17da45d7ccaf.png","w":656,"h":624,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/9\/095d8329210338c3641e17da45d7ccaf"}608226

Slackware 14.1
Allegro 5.1.7
Geforce GTX 650

Elias

Try drawing the rectangle like this:

al_draw_rectangle(0.5, 0.5, 31.5, 31.5, al_map_rgb(255, 0, 0), 1);

The rectangle is not drawn by Allegro but directly sent to your graphics card. And for the GPU the positions 0/0 as well as 32/32 both lie on the intersection of 4 adjacent pixels. The kind of rectangle to draw is therefore ambiguous (and any possibility the GPU chooses is correct).

See here for more details: http://www.liballeg.org/a5docs/refman/primitives.html#pixel-precise-output

gameovera

Thanks Arthur Kalliokoski and Elias.

I assumed the rasterization of pixels boundary as independent GPU.

Thread #613754. Printed from Allegro.cc