squashed commit of private hostlib-resource branch
[tangerine.git] / test / HiddGraphics / GCDrawEllipse.c
blob71667abb8f8db619bae663f9eb8dcd99938a9de7
1 /*
2 Copyright © 1998, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Test for graphics.hidd
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME
13 GCDrawEllipse
15 SYNOPSIS
17 GCDrawEllipse HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S
19 LOCATION
21 test/HiddGraphics
23 FUNCTION
25 Creates a gc, draws some hollow and solid ellipses and
26 disposes the gc.
28 INPUTS
29 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
30 (default: graphics.hidd)
31 WIDTH - width of bitmap (default: 320)
32 HEIGHT - height of bitmap (default: 200)
33 DEPTH - depth of bitmap (default: 8)
34 CHUNKY - create bitmap in chunky-mode (default: planar)
35 DISPLAYABLE - show bitmap (default: FALSE)
37 RESULT
38 RETURN_OK - hidd works
39 RETURN_ERROR - hidd produce errors
40 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 #define AROS_USE_OOP
58 #include <stdlib.h>
59 #include <stdio.h>
61 #include <aros/config.h>
63 #include <exec/types.h>
65 #include <proto/exec.h>
66 #include <proto/dos.h>
67 #include <proto/oop.h>
68 #include <proto/utility.h>
70 #include <utility/tagitem.h>
72 #include <oop/oop.h>
73 #include <hidd/graphics.h>
74 #include <hidd/graphics-amiga-intuition.h>
76 #include "gfxhiddtool.h"
78 #undef SDEBUG
79 #undef DEBUG
80 #define DEBUG 1
81 #include <aros/debug.h>
83 struct DosLibrary *DOSBase;
84 struct Library *OOPBase;
85 struct Library *HIDDGraphicsBase;
87 struct ght_OpenLibs LibsArray[] =
89 GHT_LIB("dos.library" , 37, &DOSBase),
90 GHT_LIB(AROSOOP_NAME , 0, &OOPBase),
91 GHT_LIB(NULL , 0, NULL)
93 /***************************************************************/
95 int main(int argc, char **argv)
97 ULONG ret = RETURN_FAIL;
99 OOP_AttrBase HiddGCAttrBase;
100 OOP_AttrBase HiddGfxAttrBase;
101 OOP_AttrBase HiddBitMapAttrBase;
103 OOP_Object *gfxHidd;
104 OOP_Object *bitMap;
105 OOP_Object *gc;
107 STRPTR hiddName = "graphics.hidd";
108 ULONG width = 320;
109 ULONG height = 200;
110 ULONG depth = 8;
111 ULONG format = vHidd_BitMap_Format_Planar;
112 char wait;
114 struct Args
116 STRPTR hiddName;
117 IPTR *width;
118 IPTR *height;
119 IPTR *depth;
120 IPTR *chunky;
121 ULONG displayable;
124 struct Args args = {hiddName, &width, &height, &depth, 0, 0};
125 struct RDArgs *rda;
128 if(ght_OpenLibs(LibsArray))
130 rda = ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR *)&args, NULL);
131 if (rda != NULL)
133 if(args.chunky != 0) format = vHidd_BitMap_Format_Chunky;
134 if(args.displayable != 0) args.displayable = (ULONG) TRUE;
136 HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
137 if(HIDDGraphicsBase)
139 ret = RETURN_ERROR;
141 HiddGfxAttrBase = OOP_ObtainAttrBase(IID_Hidd_Gfx);
142 HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
143 HiddGCAttrBase = OOP_ObtainAttrBase(IID_Hidd_GC);
145 if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase)
147 gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
148 if(gfxHidd)
150 struct TagItem bm_tags[] =
152 {aHidd_BitMap_Width, (IPTR) *args.width},
153 {aHidd_BitMap_Height, (IPTR) *args.height},
154 {aHidd_BitMap_Depth, (IPTR) *args.depth},
155 {aHidd_BitMap_Format, (IPTR) format},
156 {aHidd_BitMap_Displayable, (IPTR) args.displayable},
157 {TAG_DONE, 0UL}
160 bitMap = HIDD_Gfx_NewBitMap(gfxHidd, bm_tags);
161 if(bitMap)
163 struct TagItem gc_tags[] =
165 {aHidd_GC_BitMap, (IPTR) bitMap},
166 {TAG_DONE, 0UL}
169 gc = HIDD_Gfx_NewGC(gfxHidd, gc_tags);
170 if(gc)
172 HIDD_BM_DrawEllipse(gc, 50, 100, 30, 30);
173 HIDD_BM_DrawEllipse(gc, 200, 100, 60, 25);
175 HIDD_BM_FillEllipse(gc, 160, 150, 45, 25);
178 ret = RETURN_OK;
181 printf("Press enter to continue");
182 scanf("%c", &wait);
184 HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
187 if(gfxHidd) OOP_DisposeObject(gfxHidd);
189 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
191 if(HiddGfxAttrBase) OOP_ReleaseAttrBase(IID_Hidd_Gfx);
192 if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
193 if(HiddGCAttrBase) OOP_ReleaseAttrBase(IID_Hidd_GC);
195 CloseLibrary(HIDDGraphicsBase);
196 } /* if(HIDDGraphicsBase) */
197 FreeArgs(rda);
199 else
201 PrintFault(IoErr(), "");
202 } /* if (rda != NULL) */
203 } /* if OpenLibs() */
205 ght_CloseLibs(LibsArray);
207 return(ret);