/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/sgx/graphics/fogging.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/graphics/graphics.hpp"

void
CSGXGraphicsEngine::setFoggingMode(const sgxFogging &fog)
{
	m_Fogging.setState(fog);
}

sgxFogging 
CSGXGraphicsEngine::getFoggingMode() const 
{
	return m_Fogging.getState();
}


sgxFogging::sgxFogging()
{
	bActive = FALSE;

	iMode = SGX_FOG_LOGARITHMIC;
	fRed = fBlue = fGreen = 0.5f;
	fAlpha = 0.7f;
	
	fStart = 0.0f;
	fEnd = 10.0f;

	fDensity = 0.1f;
}

bool sgxFogging::operator!=(const sgxFogging &other)
{
	if (bActive != other.bActive) {
		return true;
	}
	if (iMode != other.iMode) {
		return true;
	}
	if (fRed != other.fRed) {
		return true;
	}
	if (fBlue != other.fBlue) {
		return true;
	}
	if (fGreen != other.fGreen) {
		return true;
	}
	if (fAlpha != other.fAlpha) {
		return true;
	}
	if (fStart != other.fStart) {
		return true;
	}
	if (fEnd != other.fEnd) {
		return true;
	}
	if (fDensity != other.fDensity) {
		return true;
	}

	return false;
}

sgxFogging &sgxFogging::operator=(const sgxFogging &ref)
{
	bActive = ref.bActive;

	iMode = ref.iMode;
	if (iMode != SGX_FOG_LOGARITHMIC) {
		iMode = SGX_FOG_LINEAR;
	}

	fRed = sgxRange<tREAL32>(ref.fRed, 0, 1.0f);
	fBlue = sgxRange<tREAL32>(ref.fBlue, 0, 1.0f);
	fGreen = sgxRange<tREAL32>(ref.fGreen, 0, 1.0f);
	fAlpha = sgxRange<tREAL32>(ref.fAlpha, 0, 1.0f);

	fStart = ref.fStart;
	fEnd = ref.fEnd;

	fDensity = sgxRange<tREAL32>(ref.fDensity, 0, 1.0f);

	return *this;
}
