configure: when detecting linux include directory for kernel compiler use target...
[AROS.git] / test / graphics / obtainpentest.c
blob927c927737fd0b076ad216fbc0b2d81c93dd046f
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/graphics.h>
7 #include <proto/exec.h>
8 #include <intuition/intuitionbase.h>
9 #include <intuition/screens.h>
10 #include <graphics/view.h>
12 #include <stdio.h>
14 int main(void)
16 struct IntuitionBase * IntuitionBase;
17 struct Library * GfxBase;
18 struct ViewPort * vp;
19 struct ColorMap * cm;
20 #define NUMCOLORS 32
21 ULONG n[2*NUMCOLORS];
22 ULONG i;
24 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
25 GfxBase = OpenLibrary("graphics.library",0);
27 vp = &IntuitionBase->ActiveScreen->ViewPort;
28 cm = vp->ColorMap;
30 n[0] = ObtainPen(cm,
31 -1,
32 0xa0000000,
33 0xb0000000,
34 0xc0000000,
35 0);
37 printf("Got pen number %ld.\n",(long)n[0]);
39 printf("Trying to obtain the same pen as shared.\n");
40 n[1] = ObtainPen(cm,
41 -1,
42 0xa0000000,
43 0xb0000000,
44 0xc0000000,
45 0);
47 printf("Got pen number %ld (=%ld!).\n",(long)n[1],(long)n[0]);
49 printf("Trying to obtain a pen as exclusive.\n");
50 n[2] = ObtainPen(cm,
51 -1,
52 0xa0000000,
53 0xb0000000,
54 0xc0000000,
55 PENF_EXCLUSIVE);
57 printf("Got pen number %ld.\n",(long)n[2]);
59 printf("Trying to allocate pen %ld as exclusive again.\n",(long)n[2]);
60 n[3] = ObtainPen(cm,
61 n[2],
62 0xa0000000,
63 0xb0000000,
64 0xc0000000,
65 PENF_EXCLUSIVE);
67 printf("Got pen number %ld.\n",(long)n[3]);
69 printf("Trying to allocate pen %ld as shared.\n",(long)n[2]);
70 n[4] = ObtainPen(cm,
71 n[2],
72 0xa0000000,
73 0xb0000000,
74 0xc0000000,
75 0);
77 printf("Got pen number %ld.\n",(long)n[4]);
79 printf("Releasing all pens.\n");
80 ReleasePen(cm, n[4]);
81 ReleasePen(cm, n[3]);
82 ReleasePen(cm, n[2]);
83 ReleasePen(cm, n[1]);
84 ReleasePen(cm, n[0]);
86 printf("Obtaining a shared pen.\n");
87 n[0] = ObtainPen(cm,
88 -1,
89 0xa0000000,
90 0xb0000000,
91 0xc0000000,
92 0);
94 printf("Got pen number %ld.\n",(long)n[0]);
96 ReleasePen(cm, n[0]);
98 printf("---------------------------\n");
100 printf("Trying to allocate %d shared pens\n",NUMCOLORS);
101 i = 0;
102 while (i < NUMCOLORS)
104 n[i] = ObtainPen(cm, -1, i << 28, i << 24, i << 20,0);
106 printf("Got pen %ld\n",(long)n[i]);
107 i++;
110 printf("Trying to get %d exclusive pens (no pen was released)\n",NUMCOLORS);
111 i = 0;
112 while (i < NUMCOLORS)
114 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
116 printf("Got pen %ld (=-1)\n",(long)n[i+NUMCOLORS]);
117 i++;
120 printf("Releasing all pens!\n");
121 i = 0;
122 while (i < 2 * NUMCOLORS)
124 ReleasePen(cm, n[i]);
125 i++;
128 printf("---------------------------\n");
131 printf("Trying to get %d exclusive pens\n",NUMCOLORS);
132 i = 0;
133 while (i < NUMCOLORS)
135 n[i] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
137 printf("Got pen %ld\n",(long)n[i]);
138 i++;
141 printf("Trying to allocate %d shared pens (no pen was released)\n",NUMCOLORS);
142 i = 0;
143 while (i < NUMCOLORS)
145 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,0);
147 printf("Got pen %ld (=-1)\n",(long)n[i+NUMCOLORS]);
148 i++;
151 printf("Releasing all pens!\n");
152 i = 0;
153 while (i < 2*NUMCOLORS)
155 ReleasePen(cm, n[i]);
156 i++;
159 printf("---------------------------\n");
161 printf("Trying to allocate %d shared pens at certain indices\n",NUMCOLORS);
162 i = 0;
163 while (i < NUMCOLORS)
165 n[i] = ObtainPen(cm, i, 0, 0, 0,0);
167 printf("Got pen %ld\n",(long)n[i]);
168 i++;
171 printf("Trying to get %d exclusive pens (no pen was released)\n",NUMCOLORS);
172 i = 0;
173 while (i < NUMCOLORS)
175 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
177 printf("Got pen %ld (=-1)\n",(long)n[i+NUMCOLORS]);
178 i++;
181 printf("Releasing all pens!\n");
182 i = 0;
183 while (i < 2 * NUMCOLORS)
185 ReleasePen(cm, n[i]);
186 i++;
189 printf("---------------------------\n");
191 printf("Trying to get %d exclusive pens at certain indices\n",NUMCOLORS);
192 i = 0;
193 while (i < NUMCOLORS)
195 n[i] = ObtainPen(cm, i, 0,0,0,PENF_EXCLUSIVE);
197 printf("Got pen %ld\n",(long)n[i]);
198 i++;
201 printf("Trying to allocate %d shared pens (no pen was released)\n",NUMCOLORS);
202 i = 0;
203 while (i < NUMCOLORS)
205 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,0);
207 printf("Got pen %ld (=-1)\n",(long)n[i+NUMCOLORS]);
208 i++;
211 printf("Releasing all pens!\n");
212 i = 0;
213 while (i < 2*NUMCOLORS)
215 ReleasePen(cm, n[i]);
216 i++;
219 printf("---------------------------\n");
221 return 0;