#ifndef INCLUDED_RENDERER_OPENGLUTILS
#define INCLUDED_RENDERER_OPENGLUTILS

#include <Math/Vector.h>
#include <Math/Rectangle.h>

#include <GLES/gl.h>

//////////////////////////////////////////////////////////////
namespace Dubious {
namespace Renderer {

class Color;

/// @brief Util class for OpenGL commands
///
/// Provides wrappers for OpenGL commands that take some of my native types.
/// Just convenience stuff, so I can pass a single Math::Vector instead of
/// three floats (for example).  It's a static class, not need to create
class OpenGLUtils
{
public:

	/// @brief glTranslate
	/// @param V - [in] translate by this amount
	template <int T>
	static void         Translate( const Math::VectorTemplate<T>& V )
	{
		glTranslatef( V.X(), V.Y(), V.Z() );
	}

	/// @brief glClearColor
	static void			ClearColor( const Color& C );

	/// @brief glViewport
	template <int T>
	static void			Viewport( const Math::Rectangle<T>& R )
	{
		glViewport( R.Origin().X(), R.Origin().Y(), R.Dimensions().X(), R.Dimensions().Y() );
	}

	/// @brief gluPerspective
	static void			Perspective( float FOVY, float Aspect, float Near, float Far );

	/// @bief glOrtho
	static void			Ortho( const Math::RectangleYDown& Dimensions );

	/// @brief gluLookAt
	static void			LookAt( const Math::Vector& Position, const Math::Vector& Target,
								const Math::Vector& Up );

	/// @brief gluUnproject
	static void 		Unproject( const Math::Point& Position, float ModelMatrix[16],
								   float ProjectionMatrix[16],	int Viewport[4], Math::Vector& V );

	/// @brief glMaterial
	static void			Material( int Light, const Color& C );

	/// @brief Sets the light position information.
	/// @param Light - [in] LIGHT0
	/// @param Position - [in] For now I only do directional lights.
	static void			LightPosition( int Light, const Math::Vector& Position );

	/// @brief Sets the light color
	/// @param Light - [in] LIGHT0
	/// @param Type - [in] GL_AMBIENT, GL_DIFFUSE, or GL_SPECULAR
	/// @param Color - [in] what color you want it to be
	static void			LightColor( int Light, int Type, const Renderer::Color& Color );

private:
	OpenGLUtils();
	~OpenGLUtils();
	OpenGLUtils( const OpenGLUtils& );
	OpenGLUtils& operator=( const OpenGLUtils& );
};

}
}

#endif
