Example #1
0
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();
}
Example #2
0
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();
}
// 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;
			}
		}
	}
Example #4
0
////////////////////////////////////////////////////////////////////////////////////
// ObjectiveC Interop
////////////////////////////////////////////////////////////////////////////////////
UIKIT_XAML_EXPORT void XamlCreateProgressRing(IInspectable** created) {
    Microsoft::WRL::ComPtr<IInspectable> inspectable = InspectableFromObject(ref new UIKit::Xaml::ProgressRing());
    *created = inspectable.Detach();
}