Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / cgfx / cybergraphics_init.c
blobab77943a05df71e27267aae962a4d51123df5b11
1 #include <aros/debug.h>
2 #include <aros/symbolsets.h>
3 #include <hidd/graphics.h>
4 #include <proto/oop.h>
6 #include "cybergraphics_intern.h"
8 static void ReleaseAttrBases(struct IntCGFXBase *CyberGfxBase)
10 if (__IHidd_BitMap)
11 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
12 if (__IHidd_GC)
13 OOP_ReleaseAttrBase(IID_Hidd_GC);
14 if (__IHidd_Sync)
15 OOP_ReleaseAttrBase(IID_Hidd_Sync);
16 if (__IHidd_PixFmt)
17 OOP_ReleaseAttrBase(IID_Hidd_PixFmt);
18 if (__IHidd_Gfx)
19 OOP_ReleaseAttrBase(IID_Hidd_Gfx);
22 static int cgfx_init(struct IntCGFXBase *CyberGfxBase)
24 EnterFunc(bug("[CGX] cgfx_init()\n"));
26 /* Initialize the semaphore used for the chunky buffer */
27 InitSemaphore(&CyberGfxBase->pixbuf_sema);
29 /* Init the needed attrbases */
31 __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap);
32 __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC);
33 __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync);
34 __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt);
35 __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx);
37 CyberGfxBase->basegc = OOP_FindClass(CLID_Hidd_GC);
38 CyberGfxBase->basebm = OOP_FindClass(CLID_Hidd_BitMap);
40 if (__IHidd_BitMap &&
41 __IHidd_GC &&
42 __IHidd_Sync &&
43 __IHidd_PixFmt &&
44 __IHidd_Gfx)
46 CyberGfxBase->pixel_buf=AllocMem(PIXELBUF_SIZE,MEMF_ANY);
47 if (CyberGfxBase->pixel_buf)
49 WORD i;
51 for (i = 0; i < 256; i++)
53 CyberGfxBase->greytab[i] = i * 0x010101;
56 ReturnInt("[CGX] cgfx_init", int, TRUE);
61 ReleaseAttrBases(CyberGfxBase);
62 ReturnInt("[CGX] cgfx_init", int, FALSE);
65 static int cgfx_expunge (struct IntCGFXBase *CyberGfxBase)
67 FreeMem(CyberGfxBase->pixel_buf, PIXELBUF_SIZE);
68 ReleaseAttrBases(CyberGfxBase);
70 return TRUE;
73 ADD2INITLIB(cgfx_init, 0);
74 ADD2EXPUNGELIB(cgfx_expunge, 0);