PixelShader::PixelShader(wstring path)
{
    HRESULT result;

    auto shaderBuffer = Tools::ReadFileToVector(path);
    result = GetD3D11Device()->CreatePixelShader(&shaderBuffer[0], shaderBuffer.size(), nullptr, &m_Shader);
    Assert(result == S_OK);

    auto extensionIndex = path.find_last_of('.');
    auto metadataBuffer = Tools::ReadFileToVector(path.substr(0, extensionIndex + 1) + L"shadermetadata");

    Reflect(shaderBuffer, metadataBuffer);
}
Ejemplo n.º 2
0
bool VertexBuffer::CreateVB(UINT uiSize, const void* pData, bool bDynamic)
{
	D3D11_BUFFER_DESC vbd;
	vbd.Usage = bDynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_IMMUTABLE;
	vbd.ByteWidth = uiSize;
	vbd.CPUAccessFlags = bDynamic ? D3D11_CPU_ACCESS_WRITE : 0;
	vbd.MiscFlags = 0;
	vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	vbd.StructureByteStride = 0;

	if (bDynamic)
	{
		HR(GetD3D11Device()->CreateBuffer(&vbd, NULL, &m_pVB));
	}
	else
	{
		D3D11_SUBRESOURCE_DATA initData;
		initData.pSysMem = pData;
		HR(GetD3D11Device()->CreateBuffer(&vbd, &initData, &m_pVB));
	}


	return true;
}