bool Create(Device& device) { if (failed(Renderer::Create(device))) { return false; } // シェーダの作成。 const TCHAR* SHADER_FILE_PATH = _T("..\\Rakugaki_MikuMikuDance_2\\pmd.sh"); _shaderDependencyObjects.resize(SHADER_KIND_MAX); ShaderDependencyObjects& shaderDefault = _shaderDependencyObjects[PMD_DEFAULT]; shaderDefault._shader = device.CreateShader( SHADER_FILE_PATH, "VS", "vs_4_0", NULL, NULL, "PS_default", "ps_4_0" ); if (shaderDefault._shader == ShaderHandle::INVALID) { return false; } ShaderDependencyObjects& shaderTexture = _shaderDependencyObjects[PMD_TEXTURE]; shaderTexture._shader = device.CreateShader( SHADER_FILE_PATH, "VS", "vs_4_0", NULL, NULL, "PS_texture", "ps_4_0" ); if (shaderTexture._shader == ShaderHandle::INVALID) { return false; } // 入力レイアウトの作成。 D3D10_INPUT_ELEMENT_DESC layout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(ShaderInput, position), D3D10_INPUT_PER_VERTEX_DATA, 0}, {"COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(ShaderInput, color), D3D10_INPUT_PER_VERTEX_DATA, 0}, {"TEXTURE", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(ShaderInput, uv), D3D10_INPUT_PER_VERTEX_DATA, 0}, }; InputLayoutHandle inputLayout = device.CreateInputLayout( layout, _countof(layout), shaderDefault._shader ); if (inputLayout == InputLayoutHandle::INVALID) return false; shaderDefault._inputLayout = inputLayout; shaderTexture._inputLayout = inputLayout; return true; }
bool CreateVertices() { auto_interface<ID3D10Device> pNativeDevice(_device.GetNativeDevice()); // 頂点バッファ。 struct Vertex initialVertexDatas[] = { { D3DXVECTOR3(-1.0f,1.0f,-1.0f), D3DXVECTOR3(0.0f,0.0f,0.0f) }, { D3DXVECTOR3(1.0f,1.0f,-1.0f), D3DXVECTOR3(0.0f,0.0f,1.0f) }, { D3DXVECTOR3(1.0f,-1.0f,-1.0f), D3DXVECTOR3(0.0f,1.0f,0.0f) }, { D3DXVECTOR3(-1.0f,-1.0f,-1.0f), D3DXVECTOR3(0.0f,1.0f,1.0f) }, { D3DXVECTOR3(-1.0f,1.0f,1.0f), D3DXVECTOR3(1.0f,0.0f,0.0f) }, { D3DXVECTOR3(1.0f,1.0f,1.0f), D3DXVECTOR3(1.0f,0.0f,1.0f) }, { D3DXVECTOR3(1.0f,-1.0f,1.0f), D3DXVECTOR3(1.0f,1.0f,0.0f) }, { D3DXVECTOR3(-1.0f,-1.0f,1.0f), D3DXVECTOR3(1.0f,1.0f,1.0f) }, }; _vertices = _device.CreateVertexBuffer(D3D10_USAGE_DEFAULT, 0, sizeof(Vertex), _countof(initialVertexDatas), initialVertexDatas); if (_vertices == VertexBufferHandle::INVALID) return false; // インデックスバッファ。 UINT initialIndexDatas[] = { 0,1,3, 1,2,3, 1,5,2, 5,6,2, 5,4,6, 4,7,6, 4,5,0, 5,1,0, 4,0,7, 0,3,7, 3,2,7, 2,6,7 }; _indices = _device.CreateIndexBuffer(D3D10_USAGE_IMMUTABLE, 0, sizeof(UINT), _countof(initialIndexDatas), initialIndexDatas); if (_indices == IndexBufferHandle::INVALID) return false; // 入力レイアウト・オブジェクトの作成 D3D10_INPUT_ELEMENT_DESC layout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Position), D3D10_INPUT_PER_VERTEX_DATA, 0}, {"COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Color), D3D10_INPUT_PER_VERTEX_DATA, 0} }; _inputLayout = _device.CreateInputLayout( layout, _countof(layout), _shader ); if (_inputLayout == InputLayoutHandle::INVALID) { return false; } return true; }