/**
* OpenGL Screen Effects
* @version: 3-20-2005
* @author Joseph 'Pcjoe' Florencio
*/

#ifndef FXSCREENEFFECTS_H
#define FXSCREENEFFECTS_H

typedef enum
{	FXSTEX_RADBLURRANGE=0,
	FXSTEX_RADBLURRANGE_INV,
	FXSTEX_SCREENTEXBLUR,
	FXSTEX_SCREENSAVE,
	FXSTEX_SCREENSAVEBLUR,
	FXSTEX_MAX
}FXRADIALBLURTEX;

class CFXScreenEffects;
extern CFXScreenEffects g_ScreenEffects;

/*
* Screen Shake
*/
class CFXScreenShake
{
public:
	// Constructor
	CFXScreenShake();
	// Destructor
	~CFXScreenShake() {}

	// Get Shake Offset
	vec3_t getShakeOffset( void );

	// Can Use
	bool canUse( void );

	/*
	* Accessors
	*/
	// Screen Shake Amplitude (Amp<=0 is disabled)
	void setScreenShakeAmplitude( float flAmplitude ) { m_flAmplitude = flAmplitude; }
	float getScreenShakeAmplitude( void ) { return m_flAmplitude; }
private:
	float	m_flAmplitude;
};

/*
* Radial Blur
*/
class CFXRadialBlur
{
public:
	// Constructor
	CFXRadialBlur();
	// Destructor
	~CFXRadialBlur() { }

	// Precache
	void Precache( void );

	// Think
	void Think( void );

	// Cap Texture Index
	int capTexIdx( int idx )
	{	if(idx>=FXSTEX_MAX) { idx = FXSTEX_MAX-1; }
		else if(idx<0) { idx = 0; }
		return idx;
	}

	// Do Radial Blur
	void doRadialBlur( int iAmount, float flBlurInc );

	// Set Orthogonal Projection
	void setOrthogonal( void );

	// Set ModelView Projection
	void setModelView( void );

	// Draw quad
	void drawQuad( void );

	// Draw Radial Blur Multitextured quad
	void drawQuadRadialMultitex( GLuint iFirstTex, GLuint iSecondTex, GLenum dfactor);
	/*
	* Accessors
	*/
	// Radial Blur Status
	void setRadialBlurStatus( bool bStatus ) { m_bRadialBlurStatus = bStatus; }
	bool getRadialBlurStatus( void ) { return m_bRadialBlurStatus; }

	// Error (never run)
	void setErrorStatus( bool bError ) { m_bError = bError; }
	bool getErrorStatus( void ) { return m_bError; }

	// Radial Blur Alpha
	void setRadialBlurAlpha( float flAlpha ) { m_flRadialBlurAlpha = flAlpha; }
	float getRadialBlurAlpha( void ) { return m_flRadialBlurAlpha; }

	// Textures
	void setTexture( int idx, GLuint iTex ) { m_iTextures[capTexIdx(idx)] = iTex; }
	GLuint getTexture( int idx ) { return m_iTextures[capTexIdx(idx)]; }

private:
	bool	m_bRadialBlurStatus;
	bool	m_bError;
	float	m_flRadialBlurAlpha;
	
	GLuint m_iTextures[FXSTEX_MAX];
};

/*
* Screen Effects
*/
class CFXScreenEffects
{
public:
	// Constructor
	CFXScreenEffects();
	// Destructor
	~CFXScreenEffects() { }

	// Precache
	void Precache( void );

	// Think
	void Think( void );

	/*
	* Accessors
	*/
	// Screen Shake
	CFXScreenShake *getScreenShake( void ) { return &m_ScreenShake; }
	// Radial Blur
	CFXRadialBlur *getRadialBlur( void ) { return &m_RadialBlur; }
private:
	CFXScreenShake	m_ScreenShake;
	CFXRadialBlur	m_RadialBlur;
};

#endif