//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_Glow_System.cpp
//
// Created by AAM - 09/06/2004 17:41:23
//
// Copyright (c) 2004 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

/******************************************************************************/
/* Included Files                                                             */
/******************************************************************************/

#include "Core/Asura.h"

#include "Camera/Asura_Camera.h"
#include "SpecialFX/Asura_Glow_System.h"

#include "Rendering/Asura_PS2_GS_Util.h"

/******************************************************************************/
/* Asura_Glow_System Class Functions                                          */
/******************************************************************************/

//
// Asura_Glow_System::Platform_Initialise()
//
// Parameters:		None
// Return value:	Pointless, ignored bool to say if initialisation was successful
//
// Initialises the glow system
//

bool Asura_Glow_System::Platform_Initialise() 
{
	return false;
}

//
// Asura_Glow_System::Platform_Shutdown()
//
// Parameters:		None
// Return values:	None
//
// Shuts down the glow system
//

void Asura_Glow_System::Platform_Shutdown() {}

//
// Asura_Glow_System::Platform_Render()
//
// Parameters:		RGB and strength parameters used for rendering.
// Return value:	None
//
// Renders the full-screen glows
//
// TODO: no need to the parameters as they could be got from Glow_System
//       Need to implement colour and level setting on PS2.

DEBUGVAR u_int dbg_uGlowAlphaFinal = 0x20;	// applied for the final pass
DEBUGVAR u_int dbg_uNumGlowDownsamples = 4;	// 512,256,128,64,32 or 640,320,160,80,40 x 448,224,112,56,28
void Asura_Glow_System::Platform_Render(float fRed, float fGreen, float fBlue, float fLevel) 
{
	u_int auGlowLevel[ASURA_MAX_NO_OF_CAMERAS];
	u_int uNumCameras = Asura_Camera::GetNumberOfCameras();
	for (u_int u = 0; u < uNumCameras; ++u)
	{
        auGlowLevel[u] = Asura_Maths::Min( 255, Asura_Maths::FloatToInt_Near(128.0f * fLevel * s_afCameraLevel[u]) );
	}
	Asura_PS2_GS_Util::RenderGlow(dbg_uGlowAlphaFinal, dbg_uNumGlowDownsamples, auGlowLevel, uNumCameras);
}

void Asura_Glow_System::Platform_PreReset() {}
void Asura_Glow_System::Platform_PostReset() {}
