2 Copyright © 1998, The AROS Development Team. All rights reserved.
5 Desc: Test for graphics.hidd
9 /*****************************************************************************
17 GCDrawText HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S
25 Creates a gc, draws some texts and disposes the gc.
28 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
29 (default: graphics.hidd)
30 WIDTH - width of bitmap (default: 320)
31 HEIGHT - height of bitmap (default: 200)
32 DEPTH - depth of bitmap (default: 8)
33 CHUNKY - create bitmap in chunky-mode (default: planar)
34 DISPLAYABLE - show bitmap (default: FALSE)
37 RETURN_OK - hidd works
38 RETURN_ERROR - hidd produce errors
39 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
53 ******************************************************************************/
60 #include <aros/config.h>
62 #include <exec/types.h>
64 #include <proto/exec.h>
65 #include <proto/graphics.h>
66 #include <proto/diskfont.h>
67 #include <proto/dos.h>
68 #include <proto/oop.h>
69 #include <proto/utility.h>
71 #include <graphics/text.h>
72 #include <utility/tagitem.h>
75 #include <hidd/graphics.h>
76 #include <hidd/graphics-amiga-intuition.h>
78 #include "gfxhiddtool.h"
83 #include <aros/debug.h>
85 struct DosLibrary
*DOSBase
;
86 struct Library
*OOPBase
;
87 struct Library
*HIDDGraphicsBase
;
88 struct Library
*DiskfontBase
;
89 struct GfxBase
*GfxBase
;
91 struct ght_OpenLibs LibsArray
[] =
93 GHT_LIB("dos.library" , 37, &DOSBase
),
94 GHT_LIB(AROSOOP_NAME
, 0, &OOPBase
),
95 GHT_LIB("diskfont.library" , 37, &DiskfontBase
),
96 GHT_LIB("graphics.library" , 37, &GfxBase
),
97 GHT_LIB(NULL
, 0, NULL
)
99 /***************************************************************/
101 int main(int argc
, char **argv
)
103 ULONG ret
= RETURN_FAIL
;
105 OOP_AttrBase HiddGCAttrBase
;
106 OOP_AttrBase HiddGfxAttrBase
;
107 OOP_AttrBase HiddBitMapAttrBase
;
113 STRPTR hiddName
= "graphics.hidd";
117 ULONG format
= vHidd_BitMap_Format_Planar
;
120 struct TextFont
*font
;
121 struct TextAttr attr
= {"ruby.font", 12, 0, 0};
133 struct Args args
= {hiddName
, &width
, &height
, &depth
, 0, 0};
137 if(ght_OpenLibs(LibsArray
))
139 rda
= ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR
*)&args
, NULL
);
142 if(args
.chunky
!= 0) format
= vHidd_BitMap_Format_Chunky
;
143 if(args
.displayable
!= 0) args
.displayable
= (ULONG
) TRUE
;
145 HIDDGraphicsBase
= OpenLibrary(args
.hiddName
, 0);
150 HiddGfxAttrBase
= OOP_ObtainAttrBase(IID_Hidd_Gfx
);
151 HiddBitMapAttrBase
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
152 HiddGCAttrBase
= OOP_ObtainAttrBase(IID_Hidd_GC
);
154 if(HiddGfxAttrBase
&& HiddBitMapAttrBase
&& HiddGCAttrBase
)
156 gfxHidd
= OOP_NewObject(NULL
, args
.hiddName
, NULL
);
159 struct TagItem bm_tags
[] =
161 {aHidd_BitMap_Width
, (IPTR
) *args
.width
},
162 {aHidd_BitMap_Height
, (IPTR
) *args
.height
},
163 {aHidd_BitMap_Depth
, (IPTR
) *args
.depth
},
164 {aHidd_BitMap_Format
, (IPTR
) format
},
165 {aHidd_BitMap_Displayable
, (IPTR
) args
.displayable
},
169 bitMap
= HIDD_Gfx_NewBitMap(gfxHidd
, bm_tags
);
172 struct TagItem gc_tags
[] =
174 {aHidd_GC_BitMap
, (IPTR
) bitMap
},
178 gc
= HIDD_Gfx_NewGC(gfxHidd
, gc_tags
);
181 font
= OpenDiskFont(&attr
);
184 OOP_SetAttrsTags(gc
, aHidd_GC_Font
, (IPTR
) font
, TAG_END
);
185 HIDD_BM_DrawText(gc
, 10, 30, "AROS - The AROS Research OS", 28);
187 printf("Press enter to continue");
196 HIDD_Gfx_DisposeBitMap(gfxHidd
, bitMap
);
199 if(gfxHidd
) OOP_DisposeObject(gfxHidd
);
201 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
203 if(HiddGfxAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_Gfx
);
204 if(HiddBitMapAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
205 if(HiddGCAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_GC
);
207 CloseLibrary(HIDDGraphicsBase
);
208 } /* if(HIDDGraphicsBase) */
213 PrintFault(IoErr(), "");
214 } /* if (rda != NULL) */
215 } /* if OpenLibs() */
217 ght_CloseLibs(LibsArray
);