#ifndef UTILITY_H
#define UTILITY_H

#include <cstring>
#include <ctime>
#include <vector>


namespace nsUtility {

extern const double PI;

typedef struct
{
	bool operator() (const char *first, const char *second) const
	{
		return strcmp(first, second) < 0;
	}
} CStringCompare;


class Vertex3F
{
	public:
		double x, y, z;

		Vertex3F(void)
		{
			this->x = 0;
			this->y = 0;
			this->z = 0;
		}

		Vertex3F(double x, double y, double z)
		{
			this->x = x;
			this->y = y;
			this->z = z;
		}
};


class Vector3F
{
	public:
		double x, y, z;

		Vector3F(void)
		{
			this->x = 0;
			this->y = 0;
			this->z = 0;
		}

		Vector3F(double x, double y, double z)
		{
			this->x = x;
			this->y = y;
			this->z = z;
		}
};


class Index3I
{
	public:
		int a, b, c;

		Index3I(void)
		{
			this->a = 0;
			this->b = 0;
			this->c = 0;
		}

		Index3I(int a, int b, int c)
		{
			this->a = a;
			this->b = b;
			this->c = c;
		}
};


class StopWatch
{
	private:
		clock_t startTicks;
		clock_t stopTicks;
		bool started;
		bool stopped;

	public:
		StopWatch(void);

		void start(void);
		void stop(void);
		void reset(void);

		long getElapsedSeconds(void);
		long getElapsedMilliseconds(void);
};


}

#define GL_ERROR_CHECK \
	{ \
		GLenum error; \
		if ((error = glGetError()) != GL_NO_ERROR) \
		{ \
			std::cerr << __FILE__ << '['  << __LINE__ << "]: gluErrorString() == " << gluErrorString(error) << std::endl; \
		} \
	}


#ifndef DEBUG
#define DEBUG_MESSAGE(MESSAGE)
#else
#define DEBUG_MESSAGE(MESSAGE) \
	std::cerr << __FILE__ << '[' << __LINE__ << "]: " MESSAGE << std::endl;
#endif

#endif
