/**
*
* \file Asura_PlatformRenderShards.cpp
*
* Created by Andrew Weinkove - 03/12/2002 
*
* Copyright (C) 2002 Rebellion, All Rights Reserved.
*
**/

#include "Core/Asura.h"
#include "SpecialFX/Asura_Shard_System.h"
#include "Camera/Asura_Camera.h"
#include "Rendering/Asura_Render.h"
#include "Core/Asura_TextureManagement.h"
#include "Rendering/Asura_Direct3D.h"
#include "Rendering/Asura_Direct3D_Shaders.h"

void Asura_Shard_System::Platform_BeginRender(void)
{
}

void Asura_Shard_System::Platform_EndRender(void)
{
}

// Placeholder shard renderer.aw.
void RenderShard(Asura_Shard *shardPtr, int TextureIndex, int colour)
{
	Asura_Direct3D_Shaders::RequestFixedFunctionVertexShader(D3DFVF_GENERICVERTEX);

	D3DGenericVertex v[3];
	
	for (int i=0;i<3;i++)
	{
		v[i].U = shardPtr->m_afU[i];
		v[i].V = shardPtr->m_afV[i];
		v[i].X = shardPtr->m_axVertices[i].x;
		v[i].Y = shardPtr->m_axVertices[i].y;
		v[i].Z = shardPtr->m_axVertices[i].z;
		v[i].Diffuse = colour;
	}

	Asura_Render::CurrentStates.RequestTextureIndex(0,TextureIndex);
	Asura_Render::CurrentStates.RequestTranslucencyMode(ASURA_TRANSLUCENCY_NORMAL);

	short indices[6] = 
	{
		0,1,2,
		0,2,1,
	};
	Asura_Direct3D::D3DDevice->DrawIndexedPrimitiveUP
	(
		D3DPT_TRIANGLELIST,
		0,
		3,
		2,
		(void*)indices,
		D3DFMT_INDEX16,
		(void*)v,
		sizeof(D3DGenericVertex)
	);

	Asura_Render::AddToTrianglesRendered(2);
}
