Re: [AD] scanline extension |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
tom st denis wrote :
>
> --- Bertrand Coconnier <bcoconni@xxxxxxxxxx> wrote:
> > tom st denis wrote :
> > >
> > > ok I gave it more thought... lets use this...
> > >
> > > typedef struct {
> > > BITMAP *dest, /* destination bitmap */
> > > *txt; /* texture map if any */
> > > int x1, x2, /* x start and end coords */
> > > y, /* line to draw on */
> > > u1, u2, /* texture x start/end */
> > > v1, v2, /* texture y start/end */
> > > c1, c2; /* color start/end */
> > > float z1,z2; /* scanline start/end Z */
> > > } scanlineinfo;
> > >
> > > void draw_scanline(scanlineinfo *sli);
> > >
> > > Then you tell allegro
> > >
> > > add_scanline_drawer(&draw_scanline, MYTYPE)
> > >
> > > Where MYTYPE is an integer.
> >
> > You are reinventing the wheel :-) If you take a look at iscan.s (ASM
> > rendering func) or cscan.h (C rendering func) you'll see that :
> >
> > 1. The struct you are talking about already exists : it is called
> > POLYGON_SEGMENT (declared in private headers file
> > include/allegro/aintern.h)
> > 2. The actual rendering functions are declared this way :
> >
> > void _poly_scanline_the_mode(unsigned long addr, int w,
> > POLYGON_SEGMENT
> > *info)
> >
> > where - addr is the BITMAP address where the scanline will be
> > rendered
> > - w is the scanline width
> > - info is the structure which contains (u, du, v, dv, c, dc,
> > texture address, etc...)
>
> So can support for user renderer be added?
Yep ! The general idea is useful. IMHO we would need to :
1. create the scanline renderer type :
typedef void SCANLINE_FUNC(unsigned long, int, POLYGON_SEGMENT*);
and a structure :
typedef struct SCANLINE_MAP {
SCANLINE_FUNC func8; /* 8 bpp scanline renderer */
SCANLINE_FUNC func15; /* 15 bpp scanline renderer */
SCANLINE_FUNC func16; /* 16 bpp scanline renderer */
SCANLINE_FUNC func24; /* 24 bpp scanline renderer */
SCANLINE_FUNC func32; /* 32 bpp scanline renderer */
SCANLINE_FUNC zfunc8;
SCANLINE_FUNC zfunc15;
SCANLINE_FUNC zfunc16; /* same as before + Z-buffer support */
SCANLINE_FUNC zfunc24;
SCANLINE_FUNC zfunc32;
} SCANLINE_MAP;
2. add a new function to the lib which may look like :
int add_scanline_drawer(SCANLINE_MAP* my_scan_map, int mytype, int
interp_var)
where (mytype) is the new type handled by 'my_scan_map' map and
(interp_var) describes the variables which need to be interpolated (see
arrays 'polytype_interp_pal' and 'polytype_interp_tc' in poly3d.c).
3. This function would update 'polytype_info' arrays in poly3d.c as well
as the 'flag_table' in clip3d.c and clip3d_f.c some other minor things.
Bertrand.