#ifndef _TPFSCREEN_H
#define _TPFSCREEN_H

#include "f1616.h"
#include "vec.h"
#include "ang.h"

/* Contains code to represent a screen buffer and its pending draw operations */

/* Internal structure - do not use */
typedef struct _tpfDrawObj {
	f1616 z; /* Distance of line */
	char *texline; /* The texture strip to use */
	f1616 y; /* Y pos of top of screen */
	f1616 yscale; /* Y scale */
	struct _tpfDrawObj *next,*prev;
} tpfDrawObj;

/* Screen buffer structure
   Use the functions below as opposed to manipulating it directly */
typedef struct {
	int x,y; /* Size (e.g. 320,256) */
	int stride; /* Stride between lines */
	int buffer; /* 8bpp only */
	tpfVec pos; /* Camera pos */
	tpfAng fovleft,fovright;
	tpfAng fovtop,fovbottom;
	f1616 *zbuffer;
	tpfDrawObj **drawlist;
} tpfScreen;

#ifdef __cplusplus
extern "C" {
#endif

/* Create a new tpfScreen */
extern tpfScreen *TpfScreen_New();

/* Delete a tpfScreen */
extern void TpfScreen_Delete();

/* Set up a tpfScreen
   x,y are the width and height of the screen in pixels (e.g. 320,256)
   stride is the gap between each row, in bytes
   buffer is the address of the screen buffer
   The buffer should be 256 colour (i.e. 1 byte per pixel) */
extern void TpfScreen_SetScreen(tpfScreen *s,int x,int y,int stride,int buffer);

/* Set the location of the 'camera' used to view the world */
extern void TpfScreen_SetViewPos(tpfScreen *s,tpfVec *p);

/* Set the field of view used to view the world
   left,right are the angles of the left and right edges of the view area
   top,bottom are the angles of the top and bottom edges of the view area */
extern void TpfScreen_SetFov(tpfScreen *s,tpfAng left,tpfAng right,tpfAng top,tpfAng bottom);

/* Clear the Z buffer used during the rendering process */
extern void TpfScreen_ClearZBuffer(tpfScreen *s);

#ifdef __cplusplus
}
#endif

#endif
