/* Span based drawing tools V1.13 12/9/04
   Copyright 2008 Jeffrey Lee
   This file is part of WOUM.
   WOUM is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   WOUM is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   You should have received a copy of the GNU General Public License
   along with WOUM.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _SPANDRAW_H
#define _SPANDRAW_H

#include "span.h"
#include "tmat.h"

/* Maximum number of verticies per polygon */
#define MAXVERT 16

/* Add a point/line/polygon, performing transformations for you
   Once transformed, polygons must be convex (No interior angle >= 180 degrees), lie on a plane, and have their verticies in clockwise order to be drawn
   The function also performs perspective projection.
   Once the perspective has been performed, the points (clipped so that X values are between -1 and +1) are scaled up & recentered to fill the defined viewport.
   You can leave tran as null if the verticies are already in viewspace coordinates (i.e. only perspective projection & viewport scaling is required).
   Return codes are the SPAN_* codes as in span.h
*/
extern int span_addpoly(int nverts,vec16 **verts,int col,tmat16 *tran);

/* Add a particle
   Returns SPAN_* codes */
extern int span_addpart(vec16 *a,int col);

/* Add a line
   Returns SPAN_* codes */
extern int span_addline(vec16 *a,vec16 *b,int col);

/* Add a rectangle
   All points are inclusive
   X and Y clipping are performed as normal, but Z clipping is ommitted in order to allow you to overlay rectangles ontop of 3D graphics - e.g.
     1. Swap a span set returned by span_do3 into use
     2. Add rectangles with a Z less than CLOSEST_Z for all the areas which your program has overwritten the screen, and in a colour not used by any of the polygons
     3. Swap the span set back out
     4. Call span_do3 to redraw the screen
   It will then think that the chosen areas of the screen contain a colour which they doesn't match the polygons you want shown there, so that area will get redrawn
   Returns SPAN_* codes
*/
extern int span_addrect(int lx,int rx,int ty,int by,f1616 z,int col);

/* Add a (2d) circle
   Full x,y,z clipping is performed
   Returns SPAN_* codes
*/
extern int span_addcirc(int x,int y,f1616 z,int radius,int col);

#endif
