2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function GetGBuffers()
8 #include <graphics/gels.h>
9 #include <graphics/rastport.h>
10 #include "graphics_intern.h"
12 /*****************************************************************************
15 #include <proto/graphics.h>
17 AROS_LH3(BOOL
, GetGBuffers
,
20 AROS_LHA(struct AnimOb
*, anOb
, A0
),
21 AROS_LHA(struct RastPort
*, rp
, A1
),
22 AROS_LHA(BOOL
, db
, D0
),
25 struct GfxBase
*, GfxBase
, 28, Graphics
)
28 Allocate all buffers for a whole AnimOb. In particular this
29 means getting buffers for
33 - ImageShadow (points to the same memory as CollMask does)
34 - if db is set to TRUE the user wants double-buffering, so we need
39 anOb = pointer to AnimOb structure to be added to list of
41 rp = pointer to a valid RastPort with initialized GelsInfo
43 db = TRUE when double-buffering is wanted
46 TRUE, if all the memory allocations were successful, otherwise
50 If an AnimOb is passed to GetGBuffers twice new buffers will
51 be allocated and therefore old pointers to buffers will be
59 FreeGBuffers(), graphics/gels.h
62 Are real VSprites possible as a part of an AnimOb?
63 If yes, then different sizes of memory would have to be
64 allocated for BorderLine and CollMask. Currently the
65 sizes of memory allocated for this are most of the time
66 too large as they are just allocated for a Bob. If this
67 code is changed then the code of FreeGBuffers() will
68 have to be changed, too, and this text can be erased :-))
72 *****************************************************************************/
76 struct AnimComp
* CurAnimComp
= anOb
-> HeadComp
;
78 /* visit all the components of this AnimOb */
79 while (NULL
!= CurAnimComp
)
81 /* visit all the sequences of a component
82 the sequences are connected like a ring!! */
83 struct AnimComp
* CurSeqAnimComp
= CurAnimComp
;
86 struct Bob
* CurBob
= CurSeqAnimComp
-> AnimBob
;
87 struct VSprite
* CurVSprite
= CurBob
-> BobVSprite
;
90 /* Attention: width of a Bob/VSprite is the number of *words* it
91 uses for it's width */
94 /* allocate height*(width*2) bytes of Chip-Ram for the ImageShadow */
95 memsize
= (CurVSprite
-> Height
) *
96 (CurVSprite
-> Width
) * 2;
97 if (NULL
==(CurBob
-> ImageShadow
= AllocMem(memsize
, MEMF_CHIP
|MEMF_CLEAR
)))
100 /* CollMask points to the same memory as ImageShadow */
101 CurVSprite
-> CollMask
= CurBob
-> ImageShadow
;
103 /* allocate height*(width*2)*depth bytes of Chip-Ram for
105 memsize
*= (CurVSprite
-> Depth
);
106 if (NULL
==(CurBob
-> SaveBuffer
= AllocMem(memsize
, MEMF_CHIP
|MEMF_CLEAR
)))
110 /* allocate width*2 bytes = width words for BorderLine
111 * !!! this is more than enough for VSprites as for a real VSprite
112 * its size in pixels is given in CurVSprite->Width
114 if (NULL
==(CurVSprite
-> BorderLine
= AllocMem(CurVSprite
-> Width
* 2,
115 MEMF_CHIP
|MEMF_CLEAR
)))
118 /* are we using double buffering for this AnimOb? */
121 /* allocate a DBufPacket structure */
122 if (NULL
==(CurBob
-> DBuffer
= AllocMem(sizeof(struct DBufPacket
),
126 /* BufBuffer needs as much memory as SaveBuffer */
127 /* memsize still contains the size of memory required for SaveBuffer */
128 if (NULL
==(CurBob
-> DBuffer
-> BufBuffer
=
129 AllocMem(memsize
, MEMF_CHIP
|MEMF_CLEAR
)))
133 /* go to the next sequence of this component */
134 CurSeqAnimComp
= CurSeqAnimComp
-> NextSeq
;
136 while (CurAnimComp
!= CurSeqAnimComp
);
138 /* go to next component */
139 CurAnimComp
= CurAnimComp
-> NextComp
;
141 /* all allocations went OK */