//////////////////////////////////////////////////////////////////////
//
//                             Pixie
//
// Copyright © 1999 - 2003, Okan Arikan
//
// Contact: okan@cs.berkeley.edu
//
// This library 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 2 of the License, or (at your option) any later version.
// 
// This library 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 this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//
//  File				:	global.h
//  Classes				:	-
//  Description			:	Some global definitions
//
////////////////////////////////////////////////////////////////////////


//
//
//
//
//
//
//		This header has to be included from every file
//
//
//
//
//
//
//
#ifndef GLOBAL_H
#define	GLOBAL_H

// The Pixie version
#define	VERSION_RELEASE	1
#define	VERSION_BETA	3
#define	VERSION_ALPHA	16

// Come constant definitions
// Math constants

#ifndef INFINITY
#define	INFINITY							(float) 1e30
#endif

#ifndef EPSILON
#define	EPSILON								(float) 1e-6
#endif


// The most famous number
#ifndef PI
#ifdef M_PI
#define PI M_PI
#else
#define PI                                  (float) 3.141592653589793238462643383279502884197169399375105820974944592308
#endif
#endif

#ifndef DOUBLE_PI
#ifdef M_PIl
#define DOUBLE_PI M_PIl
#else
#define DOUBLE_PI                           3.141592653589793238462643383279502884197169399375105820974944592308
#endif
#endif



// Logic constants
#define	TRUE								1
#define	FALSE								0


// Misc Options and Attributes constants
#ifdef min
#undef min
#endif

#ifdef max
#undef max
#endif

#ifdef zero
#undef zero
#endif

#ifdef equal
#undef equal
#endif

#ifdef radians
#undef radians
#endif

#ifdef degrees
#undef degrees
#endif

#define			min(a,b)					((a) < (b) ? (a) : (b))
#define			max(a,b)					((a) > (b) ? (a) : (b))
#define			clamp(a,b,c)				((b) < (a) ? (a) : (b) > (c) ? (c) : (b)))
#define			zero(a)						(fabs(a) < EPSILON ? TRUE : FALSE)
#define			equal(a,b)					(zero(((a)-(b))))
#define			radians(a)					((a)*DOUBLE_PI/180.)
#define			degrees(a)					((a)*180./ DOUBLE_PI)

#define			getPointer(a)				(((unsigned long) a) & (~3))
#define			getData(a)					(((unsigned long) a) & 3)
#define			getToken(a,b)				(((unsigned long) a) | b)


// This structure encapsulates a 32 bit word
typedef union {
	int				integer;
	unsigned int	uinteger;
	float			real;
	void			*pointer;
	char			*string;
	char			character;
} T32;


#define USE_MEMORY_MANAGER

#include "memoryman.h"


#ifdef WIN32
#ifdef _DEBUG
#include <assert.h>
#endif
#endif

#ifndef assert
#define assert(__cond)
#endif


#endif
