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


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

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


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

示例1: CreateVertexBuffer

void BasicShapes::CreateVertexBuffer(
    _In_ unsigned int numVertices,
    _In_ BasicVertex *vertexData,
    _Out_ ID3D11Buffer **vertexBuffer
    )
{
    *vertexBuffer = nullptr;
    Microsoft::WRL::ComPtr<ID3D11Buffer> vertexBufferInternal;

    D3D11_BUFFER_DESC VertexBufferDesc;
    VertexBufferDesc.ByteWidth = sizeof(BasicVertex) * numVertices;
    VertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    VertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    VertexBufferDesc.CPUAccessFlags = 0;
    VertexBufferDesc.MiscFlags = 0;
    VertexBufferDesc.StructureByteStride = 0;

    D3D11_SUBRESOURCE_DATA VertexBufferData;
    VertexBufferData.pSysMem = vertexData;
    VertexBufferData.SysMemPitch = 0;
    VertexBufferData.SysMemSlicePitch = 0;

    DX::ThrowIfFailed(
        m_d3dDevice->CreateBuffer(
            &VertexBufferDesc,
            &VertexBufferData,
            &vertexBufferInternal
            )
        );


    *vertexBuffer = vertexBufferInternal.Detach();
}
开发者ID:mbin,项目名称:Win81App,代码行数:33,代码来源:BasicShapes.cpp

示例2: CreateIndexBuffer

void BasicShapes::CreateIndexBuffer(
    _In_ unsigned int numIndices,
    _In_ unsigned short *indexData,
    _Out_ ID3D11Buffer **indexBuffer
    )
{
    *indexBuffer = nullptr;
    Microsoft::WRL::ComPtr<ID3D11Buffer> indexBufferInternal;

    D3D11_BUFFER_DESC IndexBufferDesc;
    IndexBufferDesc.ByteWidth = sizeof(unsigned short) * numIndices;
    IndexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    IndexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    IndexBufferDesc.CPUAccessFlags = 0;
    IndexBufferDesc.MiscFlags = 0;
    IndexBufferDesc.StructureByteStride = 0;

    D3D11_SUBRESOURCE_DATA IndexBufferData;
    IndexBufferData.pSysMem = indexData;
    IndexBufferData.SysMemPitch = 0;
    IndexBufferData.SysMemSlicePitch = 0;

    DX::ThrowIfFailed(
        m_d3dDevice->CreateBuffer(
            &IndexBufferDesc,
            &IndexBufferData,
            &indexBufferInternal
            )
        );

    *indexBuffer = indexBufferInternal.Detach();
}
开发者ID:mbin,项目名称:Win81App,代码行数:32,代码来源:BasicShapes.cpp

示例3: Initialize

// Initialize the DirectX resources required to run.
void Graphics::Initialize(void)
{
	ASSERT(s_SwapChain1 == nullptr, "Graphics has already been initialized");

	Microsoft::WRL::ComPtr<ID3D12Device> pDevice;

#if _DEBUG
	Microsoft::WRL::ComPtr<ID3D12Debug> debugInterface;
	if (SUCCEEDED(D3D12GetDebugInterface(MY_IID_PPV_ARGS(&debugInterface))))
		debugInterface->EnableDebugLayer();
	else
		Utility::Print("WARNING:  Unable to enable D3D12 debug validation layer\n");
#endif

	// Obtain the DXGI factory
	Microsoft::WRL::ComPtr<IDXGIFactory4> dxgiFactory;
	ASSERT_SUCCEEDED(CreateDXGIFactory2(0, MY_IID_PPV_ARGS(&dxgiFactory)));

	// Create the D3D graphics device
	Microsoft::WRL::ComPtr<IDXGIAdapter1> pAdapter;

	static const bool bUseWarpDriver = false;

	if (!bUseWarpDriver)
	{
		for (uint32_t Idx = 0; DXGI_ERROR_NOT_FOUND != dxgiFactory->EnumAdapters1(Idx, &pAdapter); ++Idx)
		{
			DXGI_ADAPTER_DESC1 desc;
			pAdapter->GetDesc1(&desc);
			if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
				continue;

			if (SUCCEEDED(D3D12CreateDevice(pAdapter.Get(), D3D_FEATURE_LEVEL_12_0, MY_IID_PPV_ARGS(&pDevice))))
			{
				pAdapter->GetDesc1(&desc);
				Utility::Printf(L"D3D12-capable hardware found:  %s (%u MB)\n", desc.Description, desc.DedicatedVideoMemory >> 20);
				g_Device = pDevice.Detach();
				break;
			}
		}
	}
开发者ID:voidstorm,项目名称:DirectX-Graphics-Samples,代码行数:42,代码来源:GraphicsCore.cpp

示例4: XamlCreateProgressRing

////////////////////////////////////////////////////////////////////////////////////
// ObjectiveC Interop
////////////////////////////////////////////////////////////////////////////////////
UIKIT_XAML_EXPORT void XamlCreateProgressRing(IInspectable** created) {
    Microsoft::WRL::ComPtr<IInspectable> inspectable = InspectableFromObject(ref new UIKit::Xaml::ProgressRing());
    *created = inspectable.Detach();
}
开发者ID:RG-J,项目名称:WinObjC,代码行数:7,代码来源:ProgressRing.xaml.cpp


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