/**
 * @file
 * @brief Spriteインターフェースの共通実装を行う.
 * 
 * 派生クラスで共通で使用できそうなメソッド、メンバをここで記述します。
 * @author S.F.
 * @version $Id:
 *
 * Copyright (C) 2000-2002 Satoshi Fujiwara. All Rights Reserved.
 */

#pragma warning( disable : 4786 )	//STLの警告外し

// メモリーリーク検出用
#include "sfdebug.h"

// SYSTEM INCLUDES
//
#include <stdio.h>
#include <queue>
#include "windows.h"
#include "windowsx.h"

#include "d3d11.h"
#include "d3dx11.h"
#include "dxerr8sf.h"

// PROJECT INCLUDES
//


#include "exception.h"
#include "sound.h"
#include "System.h"
#include "console.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include "Obj.h"
#include "Obj2D.h"
#include "ObjRectangle.h"
#include "ObjQuadrangle.h"
#include "Obj3D.h"
#include "Obj3DL.h"
#include "input.h"
#include "AbstractSprite.h"
#include "ConsoleImpl.h"
#include "Main.h"

//template class SFDLL std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >;

using namespace sf::system::console;
using namespace sf::system::console::sprite;

//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////

AbstractSprite::AbstractSprite()
{
//	mpSpriteVtBuf = NULL;
//	mpSpriteTexture = NULL;
//	mpSprite3DVtBuf = NULL;
	mpD3DDevice = NULL;
	mbUse = false;
	mCenterX = mCenterY = 0.0f;
	mWidth = mHeight = 0.0f;
//	mpMeshMaterials = NULL;
//	mpMeshTextures = NULL;
//	mNumMaterials = 0L; 
//	mpMesh = NULL;
//	mCellWidth = 0.0f;
//	mCellHeight = 0.0f;
//	mCellCount = 0;
}

AbstractSprite::~AbstractSprite()
{

}

// 描画用レンダリングステートの設定 --------------------------------------------
void AbstractSprite::setRenderState(const DrawMode value)
{
		switch (value)
		{
		case DRAW_TRANS:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
			break;
		case DRAW_ADD:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
			break;
		case DRAW_ADD1:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
			break;
		case DRAW_SHADOW:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ZERO);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
			break;
		case DRAW_INV:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_INVSRCCOLOR);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ZERO);
			break;
		case DRAW_MUL:
			mpD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ZERO);
			mpD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR);
			break;
		}

}// setRenderState
