So while for al_draw_pixel the origin is (1, 1), al_draw_bitmap thinks it is (0, 0). Is there any simple explanation for this? I couldn't find anything in the reference documentation and neither helped searching for "Allegro coordinate system" and such.

Even trickier is the following. I'm creating a 32x32 bitmap, clearing it and then I draw lines in it:

Only these exact coordinates will draw lines from top left -> top right -> bottom right -> bottom left -> top left of the bitmap. I tried to change the zeros to ones and w and h to w-1 and h-1, but those coordinates will leave 1-pixel-gaps (I checked with gimp...). Replacing the ones with zeros is not necessary though to get the full width / height (but will make the line invisible in other cases...).

To sum this up: For the top line, x=0 is the leftmost. But for the left line, it is x=1. The left line has to start at y=0, while the top line is only visible for y=1.

Changing the line thickness to 1 has no effect on this.

Can someone explain those contradicting coordinate systems to me? Is it maybe that primitives are different from the bitmap graphics core? Or even floating point to integer (display) translation issues?

In a pure integer coordinate system with (0, 0) as the top left, a horizontal line with width w would go from (0, 0) to (w-1, 0). Considering how the GPU interpolates floats to actual screen pixels, I guess a value of 0 (which is between the coordinates -0.5 and +0.5) can be either pixel -1 or pixel 0. So if I choose 0.1 instead of 0, the GPU will interpolate to pixel 0, because 0.1 is clearly positive. Is this correct?

Adding 0.5f to (w-1) wasn't enough to cover the last pixel, I tested out that I need something about 0.5597f; any idea why?

In allegro the top left pixel is at 0,0 and the bottom right pixel is at width-1,height-1. However, the center of the top left pixel is at 0.5,0.5 and the center of the bottom right pixel is at width-0.5,height-0.5.

This code actually fails to properly outline the display. I'll tell you why below. It's actually in the page I linked to as well.

So you can see that the bottom right pixel is not lit. What you actually want to do when drawing axis aligned lines is to draw at the middle of the line along its width, and extend to the full width you desire along its length.

So you can see the two lines on the bottom and the right both failed to draw the bottom right pixel. When drawing the horizontal line it should have been :

So the horizontal line is vertically centered around y = h - 0.5, and is drawn from x = 0 to x = w. And the vertical line is horizontally centered around x = w-0.5 and is drawn from y = 0 to y = h. You can see it in the blue line in the second image in the page I linked you to.

Note also that this isn't a thing specific to Allegro - it will be the case any time you do hardware-accelerated rendering.

I find it helps if you think of the display as a sheet of graph paper. Each box on the sheet is a pixel, and points are plotted at intersections, rather than inside the boxes. Only if a fragment passes through the center of a "pixel box" will it light the pixel.