当前位置: 首页>>代码示例>>C++>>正文


C++ TVector::Add方法代码示例

本文整理汇总了C++中TVector::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector::Add方法的具体用法?C++ TVector::Add怎么用?C++ TVector::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TVector的用法示例。


在下文中一共展示了TVector::Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateInputLayoutDescFromVertexShaderSignature

HRESULT FMaterial::CreateInputLayoutDescFromVertexShaderSignature(ID3D11ShaderReflection* VertexShaderReflection, ID3DBlob* VertexShaderBlob, ID3D11Device* Device)
{
	// Get shader info
	D3D11_SHADER_DESC ShaderDescription;
	VertexShaderReflection->GetDesc(&ShaderDescription);

	// Read input layout description from shader info
	TVector<D3D11_INPUT_ELEMENT_DESC> InputLayoutDesc;
	for (size_t i = 0; i < ShaderDescription.InputParameters; i++)
	{
		D3D11_SIGNATURE_PARAMETER_DESC ParamDescription;
		VertexShaderReflection->GetInputParameterDesc(i, &ParamDescription);

		// fill out input element desc
		D3D11_INPUT_ELEMENT_DESC ElementDesc;
		ElementDesc.SemanticName = ParamDescription.SemanticName;
		ElementDesc.SemanticIndex = ParamDescription.SemanticIndex;
		ElementDesc.InputSlot = 0;
		ElementDesc.AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
		ElementDesc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
		ElementDesc.InstanceDataStepRate = 0;

		// determine DXGI format
		if (ParamDescription.Mask == 1)
		{
			if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32_UINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32_SINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32_FLOAT;
		}
		else if (ParamDescription.Mask <= 3)
		{
			if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32_UINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32_SINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32_FLOAT;
		}
		else if (ParamDescription.Mask <= 7)
		{
			if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_UINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_SINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
		}
		else if (ParamDescription.Mask <= 15)
		{
			if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_SINT;
			else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
		}

		if (strcmp(ParamDescription.SemanticName, "COLOR") == 0)
		{
			// Special case: colour is actually a r8b8g8a8_unorm.
			ElementDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
		}

		//save element desc
		InputLayoutDesc.Add(ElementDesc);
	}

	// Special case here:
	// If we're using SV_VertexID only then we don't actually need an input layout.

	if (InputLayoutDesc.Size() == 1 && strcmp(InputLayoutDesc[0].SemanticName, "SV_VertexID") != -1)
	{
		return S_OK;
	}

	// Try to create Input Layout
	HRESULT hr = Device->CreateInputLayout(&InputLayoutDesc[0], InputLayoutDesc.Size(), VertexShaderBlob->GetBufferPointer(), VertexShaderBlob->GetBufferSize(), &InputLayout);

	return hr;

}
开发者ID:subr3v,项目名称:s-engine,代码行数:72,代码来源:Material.cpp


注:本文中的TVector::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。