view LightClone/Source/Interface.cpp @ 15:ee1c2510096d

Work on GUI system
author koryspansel <koryspansel@bendbroadband.com>
date Wed, 14 Sep 2011 11:04:18 -0700
parents 292e534f00c2
children 88f7c22e7b45
line wrap: on
line source

/*
 * Interface
 */

#include "Interface.h"
#include "VertexTypes.h"
#include "InputManager.h"

/*
 * pActionTextureName
 */
static const char* pActionTextureName[] = 
{
	"Data\\Textures\\Forward.tga",
	"Data\\Textures\\RotateCW.tga",
	"Data\\Textures\\RotateCCW.tga",
	"Data\\Textures\\Jump.tga",
	"Data\\Textures\\Light.tga",
	"Data\\Textures\\Function1.tga",
	"Data\\Textures\\Function2.tga",
};

/*
 * pControlTextureName
 */
const char* pControlTextureName[] =
{
	"Data\\Textures\\Play.tga",
	"Data\\Textures\\Stop.tga",
	"Data\\Textures\\Exit.tga",
};

/*
 * pArrowTextureName
 */
const char* pArrowTextureName[] =
{
	"Data\\Textures\\Left.tga",
	"Data\\Textures\\Right.tga",
};

/*
 * Interface
 */
Interface::Interface()
{
	pEffect				= NULL;
	pFont				= NULL;
	pVertexBuffer		= NULL;
	pBackgroundTexture	= NULL;
	pCursorTexture		= NULL;
	pDialog1Texture		= NULL;
	pDialog2Texture		= NULL;

	memset(pActionTexture, 0, sizeof(pActionTexture));
	memset(pControlTexture, 0, sizeof(pControlTexture));
	memset(pArrowTexture, 0, sizeof(pArrowTexture));
}

/*
 * Initialize
 */
//ErrorCode Interface::Initialize(EventSystem* pSystem, ResourceManager* pManager)
ErrorCode Interface::Initialize(InputManager* pInput, ResourceManager* pManager);
{
	ErrorCode eCode = pManager->CreateEffectFromFile("Data\\Shaders\\TexturedQuad.fx", &pEffect);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	eCode = pManager->CreateFontFromName("Courier New", 18, FW_BOLD, &pFont);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	eCode = pManager->CreateVertexBuffer(TrianglesPerFace * VerticesPerTriangle * sizeof(Vertex::Quad), D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED, &pVertexBuffer);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	eCode = pManager->CreateTextureFromFile("Data\\Textures\\Background00.tga", &pBackgroundTexture);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	for(uint32 i = 0; i < Action_Count; ++i)
	{
		eCode = pManager->CreateTextureFromFile(pActionTextureName[i], pActionTexture + i);
		if(eCode != Error_Success)
		{
			Terminate();
			return Error_Fail;
		}
	}

	for(uint32 i = 0; i < sizeof(pControlTextureName) / sizeof(pControlTextureName[0]); ++i)
	{
		eCode = pManager->CreateTextureFromFile(pControlTextureName[i], pControlTexture + i);
		if(eCode != Error_Success)
		{
			Terminate();
			return Error_Fail;
		}
	}

	for(uint32 i = 0; i < sizeof(pArrowTextureName) / sizeof(pArrowTextureName[0]); ++i)
	{
		eCode = pManager->CreateTextureFromFile(pArrowTextureName[i], pArrowTexture + i);
		if(eCode != Error_Success)
		{
			Terminate();
			return Error_Fail;
		}
	}

	eCode = pManager->CreateTextureFromFile("Data\\Textures\\Dialog1.tga", &pDialog1Texture);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	eCode = pManager->CreateTextureFromFile("Data\\Textures\\Dialog2.tga", &pDialog2Texture);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	eCode = pManager->CreateTextureFromFile("Data\\Textures\\Arrow.tga", &pCursorTexture);
	if(eCode != Error_Success)
	{
		Terminate();
		return Error_Fail;
	}

	//pEventSystem = pSystem;
	//pEventSystem->AddSink(this);

	return SetupVertexBuffer();
}

/* 
 * Terminate
 */
void Interface::Terminate()
{
	//pEventSystem->RemoveSink(this);
	//pEventSystem = NULL;

	if(pCursorTexture)
	{
		pCursorTexture->Release();
		pCursorTexture = NULL;
	}

	if(pDialog1Texture)
	{
		pDialog1Texture->Release();
		pDialog1Texture = NULL;
	}

	if(pDialog2Texture)
	{
		pDialog2Texture->Release();
		pDialog2Texture = NULL;
	}

	for(uint32 i = 0; i < sizeof(pArrowTexture) / sizeof(pArrowTexture[0]); ++i)
	{
		if(pArrowTexture[i])
		{
			pArrowTexture[i]->Release();
			pArrowTexture[i] = NULL;
		}
	}

	for(uint32 i = 0; i < sizeof(pControlTexture) / sizeof(pControlTexture[0]); ++i)
	{
		if(pControlTexture[i])
		{
			pControlTexture[i]->Release();
			pControlTexture[i] = NULL;
		}
	}

	for(uint32 i = 0; i < Action_Count; ++i)
	{
		if(pActionTexture[i])
		{
			pActionTexture[i]->Release();
			pActionTexture[i] = NULL;
		}
	}

	if(pBackgroundTexture)
	{
		pBackgroundTexture->Release();
		pBackgroundTexture = NULL;
	}

	if(pVertexBuffer)
	{
		pVertexBuffer->Release();
		pVertexBuffer = NULL;
	}

	if(pFont)
	{
		pFont->Release();
		pFont = NULL;
	}

	if(pEffect)
	{
		pEffect->Release();
		pEffect = NULL;
	}
}

/*
 * Render
 */
void Interface::Render(RenderContext& kContext, Camera& kCamera)
{
	/*
	if(pModel->nGameState != GameState_Exit)
	{
		kContext.SetupCamera2D(pEffect);

		uint32 nPasses = 0;

		pEffect->SetTechnique(pEffect->GetTechnique(0));
		pEffect->Begin(&nPasses, 0);
		pEffect->BeginPass(0);

		RenderBackground(kContext, pModel);
		RenderToolbar(kContext, pModel);
		RenderMain(kContext, pModel);
		RenderFunctions(kContext, pModel);
		RenderControls(kContext, pModel);

		if(pModel->nGameState == GameState_Active)
		{
		}
		else

		if(pModel->nGameState == GameState_Complete)
		{
			char kMessage[256];
			sprintf_s(kMessage, "Congratulations!\nYou have completed level %d", pModel->nCurrentLevel);

			RenderDialog(kContext, pModel, kMessage, "Ok");

			//TODO: This would occur before entering the complete state:
			//pLevelDialog->SetMessage(kMessage);
			//pLevelDialog->SetVisible(true);
			//
			//nGameState = GameState_Complete;
		}
		else

		if(pModel->nGameState == GameState_Over)
		{
			const char* pMessage = "Congratulations!\nYou have won the game!";

			RenderDialog(kContext, pModel, pMessage, "Ok");
		}
		else

		if(pModel->nGameState == GameState_Confirm)
		{
			const char* pMessage = "Are you sure you want to quit the game?";

			RenderDialog(kContext, pModel, pMessage, "Yes", "No");
		}

		RenderCursor(kContext, pModel);

		pEffect->EndPass();
		pEffect->End();
	}
	*/
}

/*
 * ProcessEvent
 */
int32 Interface::ProcessEvent(const Event& kEvent)
{
	//HACK: Only have one event struct at the moment
	const InputEvent& kInputEvent = (const InputEvent&)kEvent;

	if(kEvent.nType == InputEventType_KeyDown)
	{
		if(kInputEvent.nKey == DIK_SPACE)
		{
			OutputDebugStringA("Events!  Yay!\n");
			return EventResult_Stop;
		}
	}
	else

	if(kEvent.nType == InputEventType_MouseMove)
	{
		char kBuffer[64];
		sprintf_s(kBuffer, "%d %d\n", (int)kInputEvent.fX, (int)kInputEvent.fY);

		OutputDebugStringA(kBuffer);
		return EventResult_Stop;
	}

	return EventResult_Continue;
}

/*
 * SetupVertexBuffer
 */
ErrorCode Interface::SetupVertexBuffer()
{
	Vertex::Quad* pVertices = NULL;

	HRESULT hResult = pVertexBuffer->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD);
	if(FAILED(hResult))
	{
		return Error_Fail;
	}

	pVertices[0]	= Vertex::Quad(+0.0f, -1.0f, 1.0f, 0.0f, 1.0f);
	pVertices[1]	= Vertex::Quad(+0.0f, +0.0f, 1.0f, 0.0f, 0.0f);
	pVertices[2]	= Vertex::Quad(+1.0f, +0.0f, 1.0f, 1.0f, 0.0f);
	pVertices[3]	= Vertex::Quad(+0.0f, -1.0f, 1.0f, 0.0f, 1.0f);
	pVertices[4]	= Vertex::Quad(+1.0f, +0.0f, 1.0f, 1.0f, 0.0f);
	pVertices[5]	= Vertex::Quad(+1.0f, -1.0f, 1.0f, 1.0f, 1.0f);

	pVertexBuffer->Unlock();

	return Error_Success;
}

/*
 * RenderBackground
 */
void Interface::RenderBackground(RenderContext& kContext)
{
	/*
	const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

	D3DSURFACE_DESC kDescriptor;
	pBackgroundTexture->GetLevelDesc(0, &kDescriptor);

	const float fX = ScreenSizeX - (float)kDescriptor.Width;
	const float fY = 0.0f;

	D3DXMATRIX kScale;
	D3DXMatrixScaling(&kScale, (float)kDescriptor.Width, (float)kDescriptor.Height, 1.0f);

	D3DXMATRIX kTranslate;
	D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + fX + 0.5f, 0.5f * ScreenSizeY - fY + 0.5f, 0.0f);

	D3DXMATRIX kWorldMatrix;
	D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

	pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
	pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
	pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pBackgroundTexture);
	pEffect->CommitChanges();

	kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
	*/
}

/*
 * RenderToolbar
 */
void Interface::RenderToolbar(RenderContext& kContext)
{
	/*
	const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

	for(uint32 i = 0; i < Action_Count; ++i)
	{
		const Rectangle2& kBounds = pModel->kToolbar.GetBounds(i);

		D3DXMATRIX kScale;
		D3DXMatrixScaling(&kScale, kBounds.Width, kBounds.Height, 1.0f);

		D3DXMATRIX kTranslate;
		D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + kBounds.X, 0.5f * ScreenSizeY - kBounds.Y, 0.0f);

		D3DXMATRIX kWorldMatrix;
		D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

		pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
		pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
		pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pActionTexture[i]);
		pEffect->CommitChanges();

		kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
	}
	*/
}

/*
 * RenderMain
 */
void Interface::RenderMain(RenderContext& kContext)
{
	/*
	Code* pCode = pModel->GetFunction(0);
	if(pCode)
	{
		const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

		for(uint32 i = 0; i < Max(pCode->GetSize(), pModel->kMain.GetMaximum()); ++i)
		{
			const uint32 nAction = pCode->GetSlot(i);

			if(Action_Forward <= nAction && nAction <= Action_FunctionB)
			{
				const Rectangle2& kBounds = pModel->kMain.GetBounds(i);

				D3DXMATRIX kScale;
				D3DXMatrixScaling(&kScale, kBounds.Width, kBounds.Height, 1.0f);

				D3DXMATRIX kTranslate;
				D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + kBounds.X, 0.5f * ScreenSizeY - kBounds.Y, 0.0f);

				D3DXMATRIX kWorldMatrix;
				D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

				pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
				pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
				pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pActionTexture[nAction - Action_Forward]);
				pEffect->CommitChanges();

				kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
			}
		}

		RECT kRectangle;
		kRectangle.left		= 1008;
		kRectangle.top		= 199;
		kRectangle.right	= kRectangle.left + 200;
		kRectangle.bottom	= kRectangle.top + 200; 

		pFont->DrawTextA(NULL, "Main", -1, &kRectangle, 0, D3DCOLOR_XRGB(0, 0, 0));
	}
	*/
}

/*
 * RenderFunctions
 */
void Interface::RenderFunctions(RenderContext& kContext)
{
	/*
	Code* pCode = pModel->GetFunction(pModel->nCurrentFunction + 1);
	if(pCode)
	{
		const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

		//TODO: Need to draw slots first, then action

		for(uint32 i = 0; i < Max(pCode->GetSize(), pModel->kFunction.GetMaximum()); ++i)
		{
			const uint32 nAction = pCode->GetSlot(i);

			if(Action_Forward <= nAction && nAction <= Action_FunctionB)
			{
				const Rectangle2& kBounds = pModel->kFunction.GetBounds(i);

				D3DXMATRIX kScale;
				D3DXMatrixScaling(&kScale, kBounds.Width, kBounds.Height, 1.0f);

				D3DXMATRIX kTranslate;
				D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + kBounds.X, 0.5f * ScreenSizeY - kBounds.Y, 0.0f);

				D3DXMATRIX kWorldMatrix;
				D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

				pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
				pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
				pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pActionTexture[nAction - Action_Forward]);
				pEffect->CommitChanges();

				kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
			}
		}

		for(uint32 i = 0; i < sizeof(pModel->kArrowBounds) / sizeof(pModel->kArrowBounds[0]); ++i)
		{
			D3DXMATRIX kScale;
			D3DXMatrixScaling(&kScale, pModel->kArrowBounds[i].Width, pModel->kArrowBounds[i].Height, 1.0f);

			D3DXMATRIX kTranslate;
			D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + pModel->kArrowBounds[i].X, 0.5f * ScreenSizeY - pModel->kArrowBounds[i].Y, 0.0f);

			D3DXMATRIX kWorldMatrix;
			D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

			pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
			pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
			pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pArrowTexture[i]);
			pEffect->CommitChanges();

			kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
		}

		RECT kRectangle;

		kRectangle.left		= 1008;
		kRectangle.top		= 472;
		kRectangle.right	= kRectangle.left + 200;
		kRectangle.bottom	= kRectangle.top + 200; 

		pFont->DrawTextA(NULL, "Function", -1, &kRectangle, 0, D3DCOLOR_XRGB(0, 0, 0));

		char kBuffer[16];
		sprintf_s(kBuffer, "%d", pModel->nCurrentFunction + 1);

		kRectangle.left		= 1225;
		kRectangle.top		= 473;
		kRectangle.right	= kRectangle.left + 200;
		kRectangle.bottom	= kRectangle.top + 200; 

		pFont->DrawTextA(NULL, kBuffer, -1, &kRectangle, 0, D3DCOLOR_XRGB(0, 0, 0));
	}
	*/
}

/*
 * RenderControls
 */
void Interface::RenderControls(RenderContext& kContext)
{
	/*
	const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

	for(uint32 i = 0; i < pModel->kControls.GetSize(); ++i)
	{
		const Rectangle2& kBounds = pModel->kControls.GetBounds(i);

		D3DXMATRIX kScale;
		D3DXMatrixScaling(&kScale, kBounds.Width, kBounds.Height, 1.0f);

		D3DXMATRIX kTranslate;
		D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + kBounds.X, 0.5f * ScreenSizeY - kBounds.Y, 0.0f);

		D3DXMATRIX kWorldMatrix;
		D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

		pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
		pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
		pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pControlTexture[i]);
		pEffect->CommitChanges();

		kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
	}
	*/
}

/*
 * RenderDialog
 */
void Interface::RenderDialog(RenderContext& kContext, const char* pMessage, const char* pChoiceA, const char* pChoiceB)
{
	/*
	if(pMessage && pChoiceA)
	{
		IDirect3DTexture9* pDialogTexture = pChoiceB ? pDialog2Texture : pDialog1Texture;

		D3DSURFACE_DESC kDescriptor;
		pDialogTexture->GetLevelDesc(0, &kDescriptor);

		const float fSizeX	= (float)kDescriptor.Width;
		const float fSizeY	= (float)kDescriptor.Height;

		{
			D3DXMATRIX kScale;
			D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f);

			D3DXMATRIX kTranslate;
			D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f);

			D3DXMATRIX kWorldMatrix;
			D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

			pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
			pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialogTexture);
			pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f));
			pEffect->CommitChanges();

			kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
		}

		#if 0
		{
			D3DXMATRIX kScale;
			D3DXMatrixScaling(&kScale, pModel->kDialog1Bounds[0].Width, pModel->kDialog1Bounds[0].Height, 1.0f);

			D3DXMATRIX kTranslate;
			D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + pModel->kDialog1Bounds[0].X, 0.5f * ScreenSizeY - pModel->kDialog1Bounds[0].Y, 0.0f);

			D3DXMATRIX kWorldMatrix;
			D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

			pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
			pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture);
			pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f));
			pEffect->CommitChanges();

			kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
		}
		#endif

		RECT kRectangle;

		kRectangle.left		= ScreenSizeX / 2;
		kRectangle.top		= ScreenSizeY / 2 - 24;
		kRectangle.right	= ScreenSizeX / 2;
		kRectangle.bottom	= ScreenSizeY / 2 - 24;

		pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER | DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0));
		pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0));

		kRectangle.left		= (int32)pModel->kDialog1Bounds[0].X;
		kRectangle.right	= (int32)(pModel->kDialog1Bounds[0].X + pModel->kDialog1Bounds[0].Width);
		kRectangle.top		= (int32)pModel->kDialog1Bounds[0].Y;
		kRectangle.bottom	= (int32)(pModel->kDialog1Bounds[0].Y + pModel->kDialog1Bounds[0].Height);

		pFont->DrawTextA(NULL, pChoiceA, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0));

		if(pChoiceB)
		{
		}
	}
	*/
}

/*
 * RenderCursor
 */
void Interface::RenderCursor(RenderContext& kContext)
{
	/*
	const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);

	if(pCursorTexture)
	{
		const float fMouseX = pModel->kInputManager.GetMouseX();
		const float fMouseY = pModel->kInputManager.GetMouseY();

		if(pModel->kDragController.IsActive())
		{
			const uint32 nAction = pModel->kDragController.GetParameter() - Action_Forward;

			D3DSURFACE_DESC kDescriptor;
			pActionTexture[nAction]->GetLevelDesc(0, &kDescriptor);

			const float fSizeX = (float)kDescriptor.Width;
			const float fSizeY = (float)kDescriptor.Height;

			D3DXMATRIX kScale;
			D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f);

			D3DXMATRIX kTranslate;
			D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + (fMouseX - 0.5f * fSizeX) + 0.5f, 0.5f * ScreenSizeY - (fMouseY - 0.5f * fSizeY) + 0.5f, 0.0f);

			D3DXMATRIX kWorldMatrix;
			D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

			pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
			pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
			pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pActionTexture[nAction]);
			pEffect->CommitChanges();

			kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
		}

		D3DSURFACE_DESC kDescriptor;
		pCursorTexture->GetLevelDesc(0, &kDescriptor);

		D3DXMATRIX kScale;
		D3DXMatrixScaling(&kScale, (float)kDescriptor.Width, (float)kDescriptor.Height, 1.0f);

		D3DXMATRIX kTranslate;
		D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + fMouseX + 0.5f, 0.5f * ScreenSizeY - fMouseY + 0.5f, 0.0f);

		D3DXMATRIX kWorldMatrix;
		D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);

		pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
		pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
		pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pCursorTexture);
		pEffect->CommitChanges();

		kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
	}
	*/
}


/*
Drag & Drop Handling:
	1.	Separate into 2 stages: drag detection and drop detection
*/