/* :ts=8 */
/************************************************************************/
/*                                                                      */
/* Global variables. There's too many of these :(			*/
/*                                                                      */
/************************************************************************/
#include <stdio.h>
#include <string.h>

#include "general.h"
#include "globals.h"

	/* Delay before drawing splines when modifying:		*/
unsigned long	Delay_Draw_Seconds	= 1;
unsigned long	Delay_Draw_Micros	= 0;

	/* Flag set to TRUE when quitting program:		*/
Boolean_T	Quit_Flag 		= FALSE;

	/* Flag set to non-zero when redraw wanted:		*/
long		Redraw_Mask 		= 0;

	/* Current perspective view rotation vector (degrees):	*/
Vector_T	Rotation_Vector		= { 0.0, 0.0, 0.0 };

	/* Current position of origin:				*/
Vector_T	Origin			= { 0.0, 0.0, 0.0 };

	/* Current 'state' of program:				*/
State_T		State;

	/* The current view rotation matrix:			*/
Matrix_T	M_Rotation	= {
				1.0,	0.0,	0.0,
				0.0,	1.0,	0.0,
				0.0,	0.0,	1.0
			};

	/* The inverse of M_Rotation: 				*/
Matrix_T	M_InvRotation	= {	
				1.0,	0.0,	0.0,
				0.0,	1.0,	0.0,
				0.0,	0.0,	1.0
			};

	/* Array containing points:				*/
Point_T		Points[Max_Nbr_Points];

	/* Array containing saved points:			*/
Point_T		Saved_Points[Max_Nbr_Points];

	/* Array containing splines:				*/
Spline_T	*Splines	= NULL;

	/* TRUE if in group mode:            			*/
Boolean_T	Group_Mode		= FALSE;

	/* TRUE if some points are hidden:     			*/
Boolean_T	Points_Hidden		= FALSE;

	/* Current selected view, knot, spline & point:		*/
short		Select_View_Id		= -1;
Knot_T		*Select_Knot		= NULL;
Spline_T	*Select_Spline		= NULL;
short		Select_Point_Id		= -1;

	/* Current world position:				*/
Vector_T	Current_Pos		= { 0.0, 0.0, 0.0 };

	/* Mask defining what to be drawn:			*/
long		What_Mask		= What_All;

	/* Resolution when drawing splines:			*/
short		Spline_Resolution		= 4;

	/* Resolution when tesselating patches:			*/
short		Patch_Resolution		= 4;

	/* True if SIPP should use backface culling: 		*/
Boolean_T	Backface_Culling		= FALSE;

#ifdef NTSC
	/* Width & Height of screen:				*/
short		Screen_Width 		= 640;
short   	Screen_Height		= 200;

	/* Current aspect ratio of screen:			*/
double		Aspect_Ratio		= 2.36;

#else

	/* Width & Height of screen:				*/
short		Screen_Width 		= 640;
short   	Screen_Height		= 256;

	/* Current aspect ratio of screen:			*/
double		Aspect_Ratio		= 2.0; /* 1.82; */

#endif

	/* Current scale factors:				*/
double		X_Scale_Factor;
double		Y_Scale_Factor;

	/* Current max select distance:				*/
double		Max_Dist;

	/* World coordinate of point in center of views:	*/
Vector_T 	Offset;

	/* Size of grid:					*/
double		Grid_Size	 	= 20.0;

	/* Should grid be shown?				*/
Boolean_T	Grid_Active	 	= FALSE;

	/* Should we snap to the grid?				*/
Boolean_T  	Grid_Snap_Active 	= FALSE;

	/* Rendering mode:					*/
Rendering_Mode_T Rendering_Mode		= RM_Gouraud;
