Updated PCI IDs to latest snapshot.
[tangerine.git] / test / gfx.c
blobe878b88229e26e4e2d813005b78a346d8af00b8c
1 #include <proto/exec.h>
2 #include <proto/graphics.h>
3 #include <proto/layers.h>
4 #include <exec/types.h>
5 #include <intuition/intuition.h>
6 #include <aros/oldprograms.h>
7 #include <graphics/gfxbase.h>
8 #include <graphics/rastport.h>
9 #include <graphics/regions.h>
10 #include <stdio.h>
12 struct NewWindow MyWin =
14 20,20,300,200,-1,-1,IDCMP_CLOSEWINDOW|/*IDCMP_DELTAMOVE|*/IDCMP_MOUSEMOVE,
15 WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|WINDOWSIZING|WFLG_SMART_REFRESH|WFLG_REPORTMOUSE,
16 NULL,NULL,(char *)"Testwindow",
17 NULL,NULL,0,0,0,0,WBENCHSCREEN
20 struct GfxBase * GfxBase;
21 struct Library * LayersBase;
23 void installClipRegion(struct Window * w)
25 int width, height;
26 struct Rectangle Rect;
27 ULONG x,y,line;
28 struct Region * R = NewRegion();
29 printf("Width of ClipRegion Rectangles: ");
30 scanf("%i",&width);
31 printf("Height of ClipRegion Rectangles: ");
32 scanf("%i",&height);
34 if (height == 0 || width == 0)
35 return;
36 y = 0;
37 line = 0;
38 while (y < w->Height)
40 x = (line & 1) * width;
41 while (x < w->Width)
43 Rect.MinX = x;
44 Rect.MinY = y;
45 Rect.MaxX = x+width-1;
46 Rect.MaxY = y+height-1;
47 OrRectRegion(R,&Rect);
49 x += (2*width);
51 y += height;
52 line ++;
55 InstallClipRegion(w->WLayer, R);
59 void uninstallClipRegion(struct Window * w)
61 struct Region * R = InstallClipRegion(w->WLayer, NULL);
62 if (NULL != R)
63 DisposeRegion(R);
66 int main(void)
68 LayersBase = OpenLibrary("layers.library",0);
69 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
70 if (NULL != GfxBase)
72 struct IntuitionBase * IntuitionBase =
73 (struct IntuitionBase *)OpenLibrary("intuition.library",0);
74 if (NULL != IntuitionBase)
76 struct Window * TheDude = OpenWindow(&MyWin);
77 if (NULL != TheDude)
79 struct RastPort * rp = TheDude->RPort;
80 struct TmpRas tmpras;
81 struct IntuiMessage * Msg;
82 UWORD areabuffer[250];
83 char c;
84 struct AreaInfo myAreaInfo;
85 installClipRegion(TheDude);
86 InitArea(&myAreaInfo, &areabuffer[0], 50);
87 rp->AreaInfo = &myAreaInfo;
88 InitTmpRas(&tmpras, AllocRaster(320,200),RASSIZE(320,200));
89 rp->TmpRas = &tmpras;
91 /* Let's draw something */
92 SetAPen(rp,1);
93 SetOutlinePen(rp,3);
96 AreaMove(rp,10,20);
97 AreaDraw(rp,110,30);
98 AreaDraw(rp,110,100);
99 AreaDraw(rp,10,110);
100 AreaEnd(rp);
103 /**/
104 AreaMove(rp,10,20);
105 AreaDraw(rp,110,30);
106 AreaDraw(rp,110,100);
107 AreaDraw(rp,10,50);
108 AreaEnd(rp);
109 /**/
111 AreaEllipse(rp, 110, 30, 50, 20);
112 AreaEnd(rp);
115 Move(rp,0,0);
116 Draw(rp,0,100);
117 Draw(rp,100,110);
118 Draw(rp,100,0);
119 Draw(rp,0,0);
120 SetAPen(rp, 1);
121 Flood(rp,0,50,50);
124 ScrollRaster(&IntuitionBase->ActiveScreen->RastPort,
129 100,
130 100);
132 printf("press a key and hit return!");
133 scanf("%c",&c);
134 ScrollRaster(rp,
135 -10,
136 -10,
139 100,
140 100);
143 while (TRUE)
145 WaitPort(TheDude->UserPort);
146 Msg = (struct IntuiMessage *)GetMsg(TheDude->UserPort);
147 if (IDCMP_CLOSEWINDOW == Msg->Class)
148 break;
149 if (IDCMP_MOUSEMOVE == Msg->Class)
151 printf("Received a delta move message! (%i,%i)\n",Msg->MouseX,Msg->MouseY);
153 ReplyMsg((struct Message *)Msg);
155 uninstallClipRegion(TheDude);
156 CloseWindow(TheDude);
158 CloseLibrary((struct Library *)IntuitionBase);
160 CloseLibrary((struct Library *)GfxBase);
163 return 0;