//********************************************************************
// Ninfa3D Engine 
// copyright 2008-2009
// By Viz_Fuerte
// VC: 9.0
// Texture
//********************************************************************

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

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

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

	extern IVideoDriver* driver;
	

	extern unsigned int bg_red;
	extern unsigned int bg_green;
	extern unsigned int bg_blue;
	

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

extern "C"
{

	/*====================================================================
	Carga la textura*/

	DLL_EXPORT void* DLL_APIENTRY LoadTexture(const char* file)
	{
		ITexture* texture = driver->getTexture(file);
		return (void*)texture;
	}

	/*====================================================================
	//Carga la textura in image*/

	DLL_EXPORT void* DLL_APIENTRY nGetImage(const char* file)
	{
		
		IImage* image=driver->createImageFromFile(file);
		return (void*)image;
	}

	/*====================================================================
	Lock texture*/

	DLL_EXPORT void* DLL_APIENTRY LockTexture(ITexture* Texture)
	{
		return (void*)Texture->lock();
	}

	/*====================================================================
	Unlock texture*/

	DLL_EXPORT void DLL_APIENTRY UnLockTexture(ITexture* Texture)
	{
		Texture->unlock();
		Texture->regenerateMipMapLevels();
	}

	/*====================================================================
	ColorKey Texture*/

	DLL_EXPORT void DLL_APIENTRY ColorKeyTexture(ITexture* Texture,unsigned int R,unsigned int G,unsigned int B)
	{
		driver->makeColorKeyTexture(Texture,SColor(0,R,G,B));
	}

	/*====================================================================
	Create render target texture*/

	DLL_EXPORT void* DLL_APIENTRY CreateRTT(int sx,int sy)
	{
		ITexture* rt = driver->addRenderTargetTexture(dimension2d<u32>(sx,sy));
		return (void*)rt;
	}

	/*====================================================================
	Render target*/

	DLL_EXPORT void DLL_APIENTRY RenderTarget(ITexture* rt)
	{
		driver->setRenderTarget(rt,true,true,SColor(0,bg_red,bg_green,bg_blue));
	}

	/*====================================================================
	Find texture*/

	DLL_EXPORT void* DLL_APIENTRY FindTexture(const char* File)
	{
		return (void*)driver->findTexture(File);
	}

	/*====================================================================
	Anchura de la textura*/

	DLL_EXPORT int DLL_APIENTRY TextureWidth(ITexture* Texture)
	{
		return Texture->getOriginalSize().Width;
	}

	/*====================================================================
	Anchura de la textura*/

	DLL_EXPORT int DLL_APIENTRY TextureHeight(ITexture* Texture)
	{
		return Texture->getOriginalSize().Height;
	}




}