Question

Is there a way to only draw(or show) a portion of an image/font in Allegro5?

For example if i have a square A and an image B and i only want the part of B that overlaps A(in this case C) to be drawn/shown, how would i do that?

Illustration:

    +-----+
    |B +--|-----+
    |  | C|     |
    +-----+     |
       |   A    |
       |        |
       +--------+

If i just use a primitive to cover the parts of B that i dont want to show, i may potentially cover previously drawn objects which lie where B is located.

Was it helpful?

Solution

I managed to solve it by using al_set_clipping_rectangle, making it possible to only clip a certain rectangle.

From Allegro5 documentation:

void al_set_clipping_rectangle(int x, int y, int width, int height)

Set the region of the target bitmap or display that pixels get clipped to. The default is to clip pixels to the entire bitmap.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top