On Mon, 26 Feb 2001, Brian S. Julin wrote:
> > BTW: Can everyone, who has some pieces of code (even some lines are
> > acceptable), that belongs to libgalloc, send to me, please?
>
> Low code to text ratio, but these two archived posts are critical. Take the
> second one as just a suggestion, a few people liked the idea and noone
> said it was crap.
>
> http://marc.theaimsgroup.com/?l=ggi-develop&m=94103638018698&w=2
> http://marc.theaimsgroup.com/?l=ggi-develop&m=94518579709657&w=2
>
> I think I sent you everything from the original proposal which
> was pertinant -- there was some other code/ideas, but it was trying to
> define an API where the sprites/etc were full visuals, what idea
> was scrapped when we realized just how much space the overhead
> would take in a 3d FPS :).
TNX.
Now I have worked out an API for libGalloc. It is attached.
Any further suggestions? Is the namespace ok?
CU,
Christoph Egger
E-Mail: [EMAIL PROTECTED]
/*
******************************************************************************
LibGalloc: extension API header file
Copyright (C) 2001 Christoph Egger [[EMAIL PROTECTED]]
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************
*/
#ifndef _GGI_GALLOC_H
#define _GGI_GALLOC_H
#include <ggi/ggi.h>
__BEGIN_DECLS
/* Extension management
*/
int ggiGallocInit(void);
int ggiGallocExit(void);
int ggiGallocAttach(ggi_visual_t vis);
int ggiGallocDetach(ggi_visual_t vis);
/* Structure
*/
#ifdef HAVE_STRUCT_GALLOC
typedef struct ggiResource *ggiResource_t;
#else
typedef void *ggiResource_t;
#endif
enum Resourcetype {
/* defined by extension */
RT_SUBTYPE_MASK = 0x00000fff,
RT_TYPE_MASK = 0x000ff000,
/* # of hardware "layers" */
RT_OVERLAY_MASK = 0x0ff00000,
/* hardware buffers mask */
RT_BUFFER_MASK = 0xf0000000,
/* generic drawing area in same format as the main fb */
RT_SWATCH = 0x00002000,
/* Right/left eye data */
RT_STEREO = 0x00003000,
/* Sprite/hw cursors */
RT_SPRITE = 0x00004000,
/* video */
RT_VIDEO = 0x00005000,
/* any window */
RT_WINDOW = 0x00006000,
/* e.g. feature connector */
RT_PASSTHRU = 0x00007000,
/* there is direct MMIO access to the feature's data */
RT_DIRECTBUFFER = 0x10000000,
/* Subtypes for sprite features */
RT_SPRITE_DONTCARE = 0x00000000,
/* Hardware pointer cursor */
RT_SPRITE_POINTER = 0x00000001,
/* Hardware text cursor */
RT_SPRITE_CURSOR = 0x00000002,
/* True sprite (a-la C-64) */
RT_SPRITE_SPRITE = 0x00000003,
/* Subtypes for video features */
RT_VIDEO_DONTCARE = 0x00000000,
/* motion video */
RT_VIDEO_MOTION = 0x00000010,
/* streaming video */
RT_VIDEO_STREAMING = 0x00000011,
/* Subtypes for window features */
RT_WINDOW_DONTCARE = 0x00000000,
/* YUV-Viewport */
RT_WINDOW_YUV = 0x00000020,
/* Subtypes of (direct)buffer types */
RT_BUFFER_DONTCARE = 0x00000000,
/* zbuffer */
RT_BUFFER_ZBUFFER = 0x00000030,
/* alpha-buffer */
RT_BUFFER_ABUFFER = 0x00000031,
/* stencil-buffer */
RT_BUFFER_SBUFFER = 0x00000032,
/* texture-buffer */
RT_BUFFER_TBUFFER = 0x00000033,
};
enum ResourceOption {
/* Doesn't matter if system memory or VRAM is used for
* resource-type.
*/
RO_DONTCARE = 0x00000000,
/* Force to use system memory */
RO_MEMORY = 0x00000001,
/* Force to use VRAM */
RO_VRAM = 0x00000002,
};
struct ResourceProperties {
enum Resourcetype res_type;
enum ResourceOption res_option;
int width, height, depth;
};
/* GAlloc error-codes */
#include <ggi/errors.h>
#define GALLOC_OK GGI_OK
#define GALLOC_EUNAVAILABLE -1
#define GALLOC_MODIFIED -2 /* Returned by ggiGallocCheck */
/* fill in helper */
#define GALLOC_FILL_RESOURCE(res, width, height, depth) \
res.res_type = RT_DIRECTBUFFER; \
res.res_option = RO_DONTCARE; \
res.width = width; \
res.height = height; \
res.depth = depth;
/* API functions
*/
/* checks, if an object of the given properties is available.
* If not, then it fails else it allocates it with the given size.
*/
ggiResource_t ggiGAlloc(ggi_visual_t vis,
struct ResourceProperties *props,
int width, int height);
/* checks, if an object of the given properties will work.
* If not, then the modified properties passed back should work.
* If NOTHING would work on the current target, then it returns
* GALLOC_EUNAVAILABLE.
*/
int ggiGallocCheck(ggi_visual_t vis,
struct ResourceProperties *props,
int width, int height);
/* free's the allocated area by ggiOvlAllocate
*/
int ggiResourceFree(ggiResource_t ovl);
__END_DECLS
#endif /* _GGI_GALLOC_H */