#include "StdAfx.h"

// ダミー変数
D3DMFORMAT dummy_d3dmfmt_float[1];

// CreateIndexBuffer()のD3DMPOOL引数
D3DMCAPS g_deviceCaps;
D3DMPOOL g_indexBufferPool;
D3DMPOOL g_vertexBufferPool;

// Direct3D Mobileには存在しない関数
char *DXGetErrorString9(HRESULT hr) {
	// ToDo:実装する
	static char msg[16];
	_snprintf(msg, sizeof(msg), "%x", hr);
	return msg;
}

UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF) { 
    UINT result = 0; 
    UINT texCount, i; 
     
    switch (FVF & D3DFVF_POSITION_MASK){ 
        case(D3DFVF_XYZ): 
            result += 4*3; 
            break; 
        #if 0 
        //fixme: this is DX8 version of function, and DX8 doesn't have D3DFVF_XYZW 
        case()://D3DFVF_XYZW): 
            result += 4*4; 
            break; 
        #endif 
        case(D3DFVF_XYZRHW): 
            result += 4*4; 
            break; 
    }; 
     
    if (FVF & D3DFVF_DIFFUSE) 
        result += 4; 
    if (FVF & D3DFVF_NORMAL) 
        result += 4*3; 
    if (FVF & D3DFVF_SPECULAR) 
        result += 4; 
         
    texCount = (FVF & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT; 
    for (i = 0; i < texCount; i++){ 
        switch((FVF >> (i * 2 + 16))&3){ 
            case(D3DFVF_TEX1): 
                result += 4; 
                break; 
            case(D3DFVF_TEX2): 
                result += 4*2; 
                break; 
            case(D3DFVF_TEX3): 
                result += 4*3; 
                break; 
            case(D3DFVF_TEX4): 
                result += 4*4; 
                break;                 
        } 
    } 
     
    return result; 
}
