//********************************************************************
// This source file is part of Ninfa3D Engine
// 
// Copyright (C) 2008-2009 Viz_fuerte. All rights reserved.
// 
// LIMITED WARRANTY
// This software is provided "as-is", without any express or implied warranty.
// In no event shall the author be held liable for any damages arising from the use of this software.
// This is a contract. By accepting the Ninfa3D Engine (the SOFTWARE), 
// you (either an individual or a single entity, the LICENSEE) accept the terms and conditions of this licensing agreement.
// 
// If the LICENSEE does not accept the terms and conditions, then LICENSEE must not accept the SOFTWARE.
// If at a later time the LICENSEE decides not to continue licensing the SOFTWARE under these terms and 
// conditions, then the LICENSEE must delete permanently all files constituting the SOFTWARE.
//
// File: System.cpp
//********************************************************************

/*--------------------------------------------------------------------
Includos*/

	#include "..\..\Header Files\Ninfa3D.h"

/*--------------------------------------------------------------------
Variables externas*/

	extern IrrlichtDevice* device;
	extern IVideoDriver* driver;

/*--------------------------------------------------------------------
Declaration global de funciones*/

extern "C"
{

	/*====================================================================
	CAMBIA EL TITULO DE LA VENTANA*/

	DLL_EXPORT void DLL_APIENTRY AppTitle(const char* Text)
	{
		stringw c(Text);
		device->setWindowCaption(c.c_str());
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta Stencil Buffer*/

	DLL_EXPORT bool DLL_APIENTRY SupportStencilBuffer()
	{
		return driver->queryFeature(EVDF_STENCIL_BUFFER);
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta Multitextura*/

	DLL_EXPORT bool DLL_APIENTRY SupportMultiTexture()
	{
		return driver->queryFeature(EVDF_MULTITEXTURE);
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta Hardware T&L*/

	DLL_EXPORT bool DLL_APIENTRY SupportHardwareTL()
	{
		return driver->queryFeature(EVDF_HARDWARE_TL);
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta GLSL*/

	DLL_EXPORT bool DLL_APIENTRY SupportGLSL()
	{
		return driver->queryFeature(EVDF_ARB_GLSL);
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta ARB*/

	DLL_EXPORT bool DLL_APIENTRY SupportARB()
	{
		if(driver->queryFeature(EVDF_ARB_VERTEX_PROGRAM_1) && driver->queryFeature(EVDF_ARB_FRAGMENT_PROGRAM_1))
			return true;
		else
			return false;
	}

	/*====================================================================
	Devuelve TRUE si el sistema soporta ARB*/

	DLL_EXPORT unsigned int DLL_APIENTRY ProcessorSpeed()
	{
		unsigned int Mhz;
		device->getOSOperator()->getProcessorSpeedMHz(&Mhz);
		return Mhz;
	}

	/*====================================================================
	DEVUELVE LA MEMORIA TOTAL DEL SISTEMA.*/

	DLL_EXPORT unsigned int DLL_APIENTRY TotalMemory()
	{
		unsigned int Total,Avail;
		device->getOSOperator()->getSystemMemory(&Total,&Avail);
		return Total;
	}

	/*====================================================================
	DEVUELVE LA MEMORIA SIN USAR DEL SISTEMA.*/

	DLL_EXPORT unsigned int DLL_APIENTRY AvailableMemory()
	{
		unsigned int Total,Avail;
		device->getOSOperator()->getSystemMemory(&Total,&Avail);
		return Avail;
	}

	/*====================================================================
	DEVUELVE LOS MODOS DE VIDEO.*/

	DLL_EXPORT int DLL_APIENTRY VideoModeCount()
	{
		return device->getVideoModeList()->getVideoModeCount();
	}

	/*====================================================================
	DEVUELVE LA PROFUNDIDAD DEL MODO DE VIDEO SELECCIONADO.*/

	DLL_EXPORT int DLL_APIENTRY VideoModeDepth(int ModeNumber)
	{
		return device->getVideoModeList()->getVideoModeDepth(ModeNumber);
	}

	/*====================================================================
	DEVUELVE LA ANCHURA DEL MODO DE VIDEO SELECCIONADO.*/

	DLL_EXPORT int DLL_APIENTRY VideoModeResolutionWidth(int ModeNumber)
	{
		return device->getVideoModeList()->getVideoModeResolution(ModeNumber).Width;
	}

	/*====================================================================
	DEVUELVE LA ALTURA DEL MODO DE VIDEO SELECCIONADO.*/

	DLL_EXPORT int DLL_APIENTRY VideoModeResolutionHeight(int ModeNumber)
	{
		return device->getVideoModeList()->getVideoModeResolution(ModeNumber).Height;
	}

}