2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
7 Example for custom screen
9 This time we are setting the colors directly.
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/graphics.h>
15 #include <proto/intuition.h>
19 static struct Window
*window
;
20 static struct Screen
*screen
;
21 static struct RastPort
*rp
;
23 static void clean_exit(CONST_STRPTR s
);
24 static void draw_stuff(void);
25 static void handle_events(void);
28 Initial color values for the screen.
29 Must be an array with index, red, green, blue for each color.
30 The range for each color component is between 0 and 255.
32 static struct ColorSpec colors
[] =
34 {0, 240, 100, 0}, // Color 0 is background
37 {-1} // Array must be terminated with -1
43 screen
= OpenScreenTags(NULL
,
50 if (! screen
) clean_exit("Can't open screen\n");
52 window
= OpenWindowTags(NULL
,
56 WA_IDCMP
, IDCMP_VANILLAKEY
,
58 WA_NoCareRefresh
, TRUE
, // We don't want to listen to refresh messages
59 WA_CustomScreen
, screen
, // Link to screen
62 if (! window
) clean_exit("Can't open window\n");
75 static void draw_stuff(void)
79 Text(rp
, "Press any key to quit", 21);
89 We can change single colors with SetRGB32() or a range of
90 colors with LoadRGB32(). In contrast to the color table above
91 we need 32 bit values for the color components.
93 SetRGB32(&screen
->ViewPort
, 2, 0, 0xFFFFFFFF, 0);
96 Even when we use the same pen number as before we have to
105 static void handle_events(void)
107 struct IntuiMessage
*imsg
;
108 struct MsgPort
*port
= window
->UserPort
;
110 BOOL terminated
= FALSE
;
114 Wait(1L << port
->mp_SigBit
);
116 while ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
120 case IDCMP_VANILLAKEY
:
124 ReplyMsg((struct Message
*)imsg
);
130 static void clean_exit(CONST_STRPTR s
)
134 // Give back allocated resourses
135 if (window
) CloseWindow(window
);
136 if (screen
) CloseScreen(screen
);