

#ifndef _CCORE
#define _CCORE

#include <conio.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "wrapglut.h"	//glut wrapper
#include "include/urarlib.h"
#include "wrapbass.h"
	
#define GLSTATE_BLEND		1
#define GLSTATE_LIGHTS		2
#define GLSTATE_DEPTH		3

const double PI=3.141592654f;
const double TWOPI=PI*2.0f;
const double HALFPI=PI/2.0f;
const double RAD=PI/180.0f;

enum
	{ 
	ERROR_FINVFN,
	ERROR_FNOTFOUND,
	ERROR_NOFRAME,
	};

static char errortable[][30] =	//error table(max string length=30)
{	"INVALID FILENAME\0",
	"FILE NOT FOUND\0",
	"INVALID FRAME\0"};

extern int sintab[360];
extern int costab[360];

extern float cam[3];
extern float look[3];

void GenSINCOS();
void Error(int errorcode);
void pushf(float num);
void pushi(int num);
void popf(float *num);
void popi(int *num);
float frand();		//random -0.5 -> 0.5
float f2rand();		//random 0 -> 1
int i3rand(int range);	//random number 0->range
void fclip(float lo,float hi,float *value);
void iclip(int lo,int hi,int *value);
void fwrap(float lo,float hi,float *value);
void iwrap(int lo,int hi,int *value);
FILE *FileOpen(char *filename);
void FileClose(FILE *fh0);
int sqri(int num);
float sqrf(float num);
int cubei(int num);
float cubef(float num);
int biggesti(int num1,int num2);
float biggestf(float num1,float num2);
int smallesti(int num1,int num2);
float smallestf(float num1,float num2);
float length3d(float x1,float y1,float z1,float x2,float y2,float z2);
float length2d(float x1,float y1,float x2,float y2);
void rotate3d(float *x,float *y,float *z,float xdeg,float ydeg,float zdeg);

void SaveGLState(int state);
void RestoreGLState(int state);

void Synk(int time,int time2);

void TimerReset();
float TimeElapsed();		//in seconds

#endif _CORE