2 Copyright © 1998, The AROS Development Team. All rights reserved.
5 Desc: Test for graphics.hidd
9 /*****************************************************************************
17 GCDrawLine HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S
25 Creates a gc, draws some lines with and without a pattern and
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)
38 RETURN_OK - hidd works
39 RETURN_ERROR - hidd produce errors
40 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
54 ******************************************************************************/
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>
73 #include <hidd/graphics.h>
74 #include <hidd/graphics-amiga-intuition.h>
76 #include "gfxhiddtool.h"
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
;
107 STRPTR hiddName
= "graphics.hidd";
111 ULONG format
= vHidd_BitMap_Format_Planar
;
125 struct Args args
= {hiddName
, &width
, &height
, &depth
, 0, 0};
129 if(ght_OpenLibs(LibsArray
))
131 rda
= ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR
*)&args
, NULL
);
134 if(args
.chunky
!= 0) format
= vHidd_BitMap_Format_Chunky
;
135 if(args
.displayable
!= 0) args
.displayable
= (ULONG
) TRUE
;
137 HIDDGraphicsBase
= OpenLibrary(args
.hiddName
, 0);
142 HiddGfxAttrBase
= OOP_ObtainAttrBase(IID_Hidd_Gfx
);
143 HiddBitMapAttrBase
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
144 HiddGCAttrBase
= OOP_ObtainAttrBase(IID_Hidd_GC
);
146 if(HiddGfxAttrBase
&& HiddBitMapAttrBase
&& HiddGCAttrBase
)
148 gfxHidd
= OOP_NewObject(NULL
, args
.hiddName
, NULL
);
151 struct TagItem bm_tags
[] =
153 {aHidd_BitMap_Width
, (IPTR
) *args
.width
},
154 {aHidd_BitMap_Height
, (IPTR
) *args
.height
},
155 {aHidd_BitMap_Depth
, (IPTR
) *args
.depth
},
156 {aHidd_BitMap_Format
, (IPTR
) format
},
157 {aHidd_BitMap_Displayable
, (IPTR
) args
.displayable
},
161 bitMap
= HIDD_Gfx_NewBitMap(gfxHidd
, bm_tags
);
164 struct TagItem gc_tags
[] =
166 {aHidd_GC_BitMap
, (IPTR
) bitMap
},
170 gc
= HIDD_Gfx_NewGC(gfxHidd
, gc_tags
);
173 OOP_SetAttrsTags(gc
, aHidd_GC_Foreground
, ~0, TAG_END
);
175 HIDD_BM_DrawLine(gc
, 160, 100, 160, 20);
176 HIDD_BM_DrawLine(gc
, 160, 100, 260, 100);
177 HIDD_BM_DrawLine(gc
, 160, 100, 160, 180);
178 HIDD_BM_DrawLine(gc
, 160, 100, 60, 100);
180 OOP_SetAttrsTags(gc
, aHidd_GC_LinePattern
, 0xF0F0, TAG_END
);
181 OOP_GetAttr(gc
, aHidd_GC_LinePattern
, &linePat
);
182 printf("Line pattern: %lx\n", linePat
);
183 HIDD_BM_DrawLine(gc
, 0, 10, 30, 10);
185 OOP_SetAttrsTags(gc
, aHidd_GC_LinePattern
, 0x5252, TAG_END
);
186 OOP_GetAttr(gc
, aHidd_GC_LinePattern
, &linePat
);
187 printf("Line pattern: %lx\n", linePat
);
188 HIDD_BM_DrawLine(gc
, 0, 14, 30, 14);
190 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
);