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


C++ ComPtr::CreateSamplerState方法代码示例

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


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

示例1: D3DCreateSamplerStates

void D3DCreateSamplerStates()
{
    HRESULT result;

    // Set up the common properties for our samplers
    D3D11_SAMPLER_DESC samplerDesc;
    ZeroMemory( &samplerDesc, sizeof(D3D11_SAMPLER_DESC) );

    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerDesc.MipLODBias = 0.0f;
    samplerDesc.MaxAnisotropy = 1;
    samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    samplerDesc.BorderColor[0] = 0;
    samplerDesc.BorderColor[1] = 0;
    samplerDesc.BorderColor[2] = 0;
    samplerDesc.BorderColor[3] = 0;
    samplerDesc.MinLOD = 0;
    samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

    // Create a texture sampler state for nearest/point sampling and wrapping uv's
    result = g_pD3DDevice->CreateSamplerState( &samplerDesc, &g_pD3DSampleStateNearestWrap );
    if( FAILED( result ) )
    {
        LOGInfo( LOGTag, "Failed to create SamplerState\n" );
    }

    // Create a texture sampler state for tri-linear sampling and wrapping uv's
    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    result = g_pD3DDevice->CreateSamplerState( &samplerDesc, &g_pD3DSampleStateLinearWrap );
    if( FAILED( result ) )
    {
        LOGInfo( LOGTag, "Failed to create SamplerState\n" );
    }
}
开发者ID:pmeneguzzi,项目名称:MyFramework,代码行数:37,代码来源:DXWrapper.cpp

示例2: Initialize

	bool Initialize(const Microsoft::WRL::ComPtr<ID3D11Device> &device
            , const std::shared_ptr<imageutil::Image> &image)
	{
		D3D11_TEXTURE2D_DESC desc;
		desc.Width = image->Width();
		desc.Height = image->Height();
		desc.MipLevels = 1;
		desc.ArraySize = 1;
		desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
		desc.SampleDesc.Count = 1;
		desc.SampleDesc.Quality = 0;
		desc.Usage = D3D11_USAGE_DEFAULT;
		desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
		desc.CPUAccessFlags = 0;
		desc.MiscFlags = 0;

		D3D11_SUBRESOURCE_DATA initData;
		initData.pSysMem = image->Pointer();
		initData.SysMemPitch = image->Stride();
		initData.SysMemSlicePitch = image->Size();

		auto hr = device->CreateTexture2D(&desc, &initData, &m_texture);
		if (FAILED(hr)){
			return false;
		}

		D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
		SRVDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
		SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
		SRVDesc.Texture2D.MipLevels = 1;

		hr = device->CreateShaderResourceView(m_texture.Get(), &SRVDesc, &m_srv);
		if (FAILED(hr))
		{
			return false;
		}

        D3D11_SAMPLER_DESC samplerDesc;
        samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
        samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
        samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
        samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
        samplerDesc.MipLODBias = 0.0f;
        samplerDesc.MaxAnisotropy = 1;
        samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
        samplerDesc.BorderColor[0] = 0;
        samplerDesc.BorderColor[1] = 0;
        samplerDesc.BorderColor[2] = 0;
        samplerDesc.BorderColor[3] = 0;
        samplerDesc.MinLOD = 0;
        samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

        // Create the texture sampler state.
        hr = device->CreateSamplerState(&samplerDesc, &m_sampler);
        if(FAILED(hr))
        {
            return false;
        }

		return true;
	}
开发者ID:HatsuneMiku,项目名称:MinTriangle,代码行数:61,代码来源:shader.cpp


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