#include "Gos.pch"
#include "Graphics.h"

GosPixelShader*	(*GosPixelShader::CreateFromMemory)(DWORD * ) = PixelShader::CreateFromMemory;

GosPixelShader*	PixelShader::CreateFromMemory(DWORD *pFunction )
{
	LOG_API("PixelShader::CreateFromMemory");
	DWORD Handle;
	HRESULT rc;
	rc = Graphics::D3DDevice()->CreatePixelShader( pFunction, &Handle );
	if( FAILED(rc) )
		STOP(("Failed to create D3D Pixel Shader"));

	PixelShader *pPixelShader = new PixelShader( Handle );
	if( !pPixelShader )
		STOP(("Failed to create Pixel Shader Object"));

	return (GosPixelShader *)pPixelShader;
}

PixelShader::PixelShader( DWORD Handle )
{
	m_Handle = Handle;
}

DWORD PixelShader::GetFunction( DWORD *pBuffer )
{
	DWORD Size;
	HRESULT rc;
	rc = Graphics::D3DDevice()->GetPixelShaderFunction( m_Handle, pBuffer, &Size );
	STOP(("Failed to get D3D Pixel Shader function"));
	return Size;
}

PixelShader::~PixelShader()
{
	HRESULT rc;
	rc = Graphics::D3DDevice()->DeletePixelShader( m_Handle );
	if( FAILED(rc) )
		STOP(("Failed to delete D3D Pixel Shader"));
}

GosPixelShader::~GosPixelShader()
{
	;
}
