1drawing_mode(3) Allegro manual drawing_mode(3)
2
3
4
6 drawing_mode - Sets the graphics drawing mode. Allegro game programming
7 library.
8
10 #include <allegro.h>
11
12
13 void drawing_mode(int mode, BITMAP *pattern, int x_anchor, int
14 y_anchor);
15
17 Sets the graphics drawing mode. This only affects the geometric rou‐
18 tines like putpixel, lines, rectangles, circles, polygons, floodfill,
19 etc, not the text output, blitting, or sprite drawing functions. The
20 mode should be one of the following constants:
21
22 DRAW_MODE_SOLID - the default, solid color
23 drawing
24 DRAW_MODE_XOR - exclusive-or drawing
25 DRAW_MODE_COPY_PATTERN - multicolored pattern fill
26 DRAW_MODE_SOLID_PATTERN - single color pattern fill
27 DRAW_MODE_MASKED_PATTERN - masked pattern fill
28 DRAW_MODE_TRANS - translucent color blending
29
30 In DRAW_MODE_SOLID, pixels of the bitmap being drawn onto are simply
31 replaced by those produced by the drawing function.
32
33 In DRAW_MODE_XOR, pixels are written to the bitmap with an exclusive-or
34 operation rather than a simple copy, so drawing the same shape twice
35 will erase it. Because it involves reading as well as writing the bit‐
36 map memory, xor drawing is a lot slower than the normal replace mode.
37
38 With the patterned modes, you provide a pattern bitmap which is tiled
39 across the surface of the shape. Allegro stores a pointer to this bit‐
40 map rather than copying it, so you must not destroy the bitmap while it
41 is still selected as the pattern. The width and height of the pattern
42 must be powers of two, but they can be different, eg. a 64x16 pattern
43 is fine, but a 17x3 one is not. The pattern is tiled in a grid starting
44 at point (x_anchor, y_anchor). Normally you should just pass zero for
45 these values, which lets you draw several adjacent shapes and have the
46 patterns meet up exactly along the shared edges. Zero alignment may
47 look peculiar if you are moving a patterned shape around the screen,
48 however, because the shape will move but the pattern alignment will
49 not, so in some situations you may wish to alter the anchor position.
50
51 When you select DRAW_MODE_COPY_PATTERN, pixels are simply copied from
52 the pattern bitmap onto the destination bitmap. This allows the use of
53 multicolored patterns, and means that the color you pass to the drawing
54 routine is ignored. This is the fastest of the patterned modes.
55
56 In DRAW_MODE_SOLID_PATTERN, each pixel in the pattern bitmap is com‐
57 pared with the mask color, which is zero in 256-color modes or bright
58 pink for truecolor data (maximum red and blue, zero green). If the pat‐
59 tern pixel is solid, a pixel of the color you passed to the drawing
60 routine is written to the destination bitmap, otherwise a zero is writ‐
61 ten. The pattern is thus treated as a monochrome bitmask, which lets
62 you use the same pattern to draw different shapes in different colors,
63 but prevents the use of multicolored patterns.
64
65 DRAW_MODE_MASKED_PATTERN is almost the same as DRAW_MODE_SOLID_PATTERN,
66 but the masked pixels are skipped rather than being written as zeros,
67 so the background shows through the gaps.
68
69 In DRAW_MODE_TRANS, the global color_map table or truecolor blender
70 functions are used to overlay pixels on top of the existing image. This
71 must only be used after you have set up the color mapping table (for
72 256 color modes) or blender functions (for truecolor modes). Because it
73 involves reading as well as writing the bitmap memory, translucent
74 drawing is very slow if you draw directly to video RAM, so wherever
75 possible you should use a memory bitmap instead.
76
77
79 xor_mode(3), solid_mode(3), color_map(3), set_trans_blender(3), exal‐
80 pha(3), excolmap(3), exjoy(3), expat(3), extrans(3)
81
82
83
84Allegro version 4.2.3 drawing_mode(3)