本文整理汇总了C++中microsoft::wrl::ComPtr::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::Get方法的具体用法?C++ ComPtr::Get怎么用?C++ ComPtr::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void D2DComponent::BeginDraw(Windows::Foundation::Rect updateRect)
{
Microsoft::WRL::ComPtr<IDXGISurface> surface;
POINT offset;
RECT updateRectNative =
{
(LONG)updateRect.Left,
(LONG)updateRect.Top,
(LONG)updateRect.Right,
(LONG)updateRect.Bottom
};
HRESULT beginDrawHR = _sisNative->BeginDraw(updateRectNative, &surface, &offset);
if (beginDrawHR == DXGI_ERROR_DEVICE_REMOVED || beginDrawHR == DXGI_ERROR_DEVICE_RESET)
{
CreateDeviceResources();
BeginDraw(updateRect);
}
else
{
ThrowIfFailed(beginDrawHR);
}
Microsoft::WRL::ComPtr<ID2D1Bitmap1> bitmap;
ThrowIfFailed(_d2dDeviceContext->CreateBitmapFromDxgiSurface(surface.Get(), nullptr, &bitmap));
_d2dDeviceContext->BeginDraw();
_d2dDeviceContext->SetTarget(bitmap.Get());
}
示例2: CreatePipelineState
void Model::CreatePipelineState()
{
Microsoft::WRL::ComPtr<ID3DBlob> VertexShader;
Microsoft::WRL::ComPtr<ID3DBlob> PixelShader;
LoadAndCompileShader(VertexShader, PixelShader);
std::array<D3D12_INPUT_ELEMENT_DESC, 2> InputElementDesc
{ {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
} };
D3D12_GRAPHICS_PIPELINE_STATE_DESC PipelineStateDesc = {};
PipelineStateDesc.InputLayout = { InputElementDesc.data(), static_cast<UINT>(InputElementDesc.size()) };
PipelineStateDesc.pRootSignature = RootSignature.Get();
PipelineStateDesc.VS = CD3DX12_SHADER_BYTECODE(VertexShader.Get());
PipelineStateDesc.PS = CD3DX12_SHADER_BYTECODE(PixelShader.Get());
PipelineStateDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
PipelineStateDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
PipelineStateDesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
PipelineStateDesc.SampleMask = UINT_MAX;
PipelineStateDesc.SampleDesc.Count = 1;
PipelineStateDesc.NumRenderTargets = 1;
PipelineStateDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
PipelineStateDesc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
PipelineStateDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
Utility::ThrowOnFail(DeviceContext.GetDevice()->CreateGraphicsPipelineState(&PipelineStateDesc, IID_PPV_ARGS(&PipelineState)));
}
示例3: glClear
void glClear(GLbitfield mask)
{
if( g_pD3DContext )
{
g_pD3DContext->ClearRenderTargetView( g_pD3DRenderTargetView.Get(), g_ClearColor );
g_pD3DContext->ClearDepthStencilView( g_pD3DDepthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0 );
}
}
示例4: DrawStrikethrough
IFACEMETHODIMP CustomTextRenderer::DrawStrikethrough(
_In_opt_ void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
_In_ DWRITE_STRIKETHROUGH const* strikethrough,
IUnknown* clientDrawingEffect
)
{
HRESULT hr;
D2D1_RECT_F rect = D2D1::RectF(
0,
strikethrough->offset,
strikethrough->width,
strikethrough->offset + strikethrough->thickness
);
Microsoft::WRL::ComPtr<ID2D1RectangleGeometry> rectangleGeometry;
hr = D2DFactory.Get()->CreateRectangleGeometry(
&rect,
&rectangleGeometry
);
// Initialize a matrix to translate the origin of the strikethrough
D2D1::Matrix3x2F const matrix = D2D1::Matrix3x2F(
1.0f, 0.0f,
0.0f, 1.0f,
baselineOriginX, baselineOriginY
);
Microsoft::WRL::ComPtr<ID2D1TransformedGeometry> transformedGeometry;
if (SUCCEEDED(hr))
{
hr = D2DFactory.Get()->CreateTransformedGeometry(
rectangleGeometry.Get(),
&matrix,
&transformedGeometry
);
}
// Draw the outline of the rectangle
D2DDeviceContext.Get()->DrawGeometry(
transformedGeometry.Get(),
outlineBrush.Get()
);
// Fill in the rectangle
D2DDeviceContext.Get()->FillGeometry(
transformedGeometry.Get(),
fillBrush.Get()
);
return S_OK;
}
示例5:
Microsoft::WRL::ComPtr<ID3D12Resource> Renderer::UploadIndexData(void *data, long dataSize)
{
WaitForGpu();
// Command list allocators can only be reset when the associated
// command lists have finished execution on the GPU; apps should use
// fences to determine GPU execution progress.
ThrowIfFailed(_commandAllocators[_frameIndex]->Reset());
// However, when ExecuteCommandList() is called on a particular command
// list, that command list can then be reset at any time and must be before
// re-recording.
ThrowIfFailed(_commandList->Reset(_commandAllocators[_frameIndex].Get(), NULL));
Microsoft::WRL::ComPtr<ID3D12Resource> indexBuffer;
Microsoft::WRL::ComPtr<ID3D12Resource> indexBufferUpload;
ThrowIfFailed(_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(dataSize),
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr,
IID_PPV_ARGS(&indexBuffer)));
ThrowIfFailed(_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(dataSize),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&indexBufferUpload)));
// Copy data to the intermediate upload heap and then schedule a copy
// from the upload heap to the vertex buffer.
UINT8* pIndexDataBegin;
ThrowIfFailed(indexBufferUpload->Map(0, &CD3DX12_RANGE(0, dataSize), reinterpret_cast<void**>(&pIndexDataBegin)));
memcpy(pIndexDataBegin, data, dataSize);
indexBufferUpload->Unmap(0, nullptr);
_commandList->CopyBufferRegion(indexBuffer.Get(), 0, indexBufferUpload.Get(), 0, dataSize);
_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(indexBuffer.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_INDEX_BUFFER));
// Close the command list and execute it to begin the vertex buffer copy into
// the default heap.
ThrowIfFailed(_commandList->Close());
ID3D12CommandList* ppCommandLists[] = { _commandList.Get() };
_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);
WaitForGpu();
return indexBuffer;
}
示例6: call
EncodedJSValue JSC_HOST_CALL COMMethodCall::call(ExecState* execState) {
COMMethodCall* callee = jsCast<COMMethodCall*>(execState->callee());
if (execState->argumentCount() != callee->_parameterCells.size()) {
// TODO: error
CRASH();
}
COMInterop* interop = jsCast<GlobalObject*>(execState->lexicalGlobalObject())->interop();
size_t numberOfABIParameters = callee->_parameterCells.size() + (callee->_isVoid ? 1 : 2);
HRESULT hr;
Microsoft::WRL::ComPtr<IUnknown> self;
hr = interop->wrap(execState->thisValue(), callee->_methodInterface, self.GetAddressOf());
void** vtable = *reinterpret_cast<void***>(self.Get());
void* fn = vtable[callee->_methodIndex];
WTF::Vector<void*> arguments;
arguments.reserveCapacity(numberOfABIParameters);
IUnknown* thisValue = self.Get();
arguments.append(&thisValue);
for (int i = 0; i < callee->_parameterCells.size(); i++) {
JSCell* type = callee->_parameterCells[i].get();
void* buffer = _alloca(std::max(sizeof(ffi_arg), callee->_parameterTypes[i + 1]->size));
getFFIMethodTable(type)->marshalJSToNative(type, execState, execState->uncheckedArgument(i), buffer);
arguments.append(buffer);
}
void* returnBuffer = nullptr;
if (!callee->_isVoid) {
returnBuffer = _alloca(std::max(sizeof(ffi_arg), callee->_parameterTypes[numberOfABIParameters - 1]->size));
arguments.append(&returnBuffer);
}
ffi_call(&callee->_cif, FFI_FN(fn), &hr, arguments.data());
JSValue jsResult;
if (!SUCCEEDED(hr)) {
_com_error error(hr, nullptr);
jsResult = execState->vm().throwException(execState, createError(execState, error.ErrorMessage()));
} else if (!callee->_isVoid) {
JSCell* returnType = callee->_returnType.get();
jsResult = getFFIMethodTable(returnType)->marshalNativeToJS(returnType, execState, returnBuffer);
} else {
jsResult = jsUndefined();
}
return JSValue::encode(jsResult);
}
示例7: UpdateDepthState
void UpdateDepthState()
{
if( g_DepthTestEnabled == true && g_DepthMaskEnabled == true )
g_pD3DContext->OMSetDepthStencilState( g_pD3DDepthStencilState_DepthTestEnabled_DepthWriteEnabled.Get(), 1 );
else if( g_DepthTestEnabled == false && g_DepthMaskEnabled == true )
g_pD3DContext->OMSetDepthStencilState( g_pD3DDepthStencilState_DepthTestDisabled_DepthWriteEnabled.Get(), 1 );
else if( g_DepthTestEnabled == true && g_DepthMaskEnabled == false )
g_pD3DContext->OMSetDepthStencilState( g_pD3DDepthStencilState_DepthTestEnabled_DepthWriteDisabled.Get(), 1 );
else if( g_DepthTestEnabled == false && g_DepthMaskEnabled == false )
g_pD3DContext->OMSetDepthStencilState( g_pD3DDepthStencilState_DepthTestDisabled_DepthWriteDisabled.Get(), 1 );
}
示例8: DrawWorld
// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void DrawWorld(
void* userData //< Passed into AddRenderCallback
,
osvr::renderkit::GraphicsLibrary library //< Graphics library context to use
,
osvr::renderkit::RenderBuffer buffers //< Buffers to use
,
osvr::renderkit::OSVR_ViewportDescription
viewport //< Viewport we're rendering into
,
OSVR_PoseState pose //< OSVR ModelView matrix set by RenderManager
,
osvr::renderkit::OSVR_ProjectionMatrix
projection //< Projection matrix set by RenderManager
,
OSVR_TimeValue deadline //< When the frame should be sent to the screen
) {
// Make sure our pointers are filled in correctly.
if (library.D3D11 == nullptr) {
std::cerr
<< "DrawWorld: No D3D11 GraphicsLibrary, this should not happen"
<< std::endl;
return;
}
if (buffers.D3D11 == nullptr) {
std::cerr << "DrawWorld: No D3D11 RenderBuffer, this should not happen"
<< std::endl;
return;
}
ID3D11DeviceContext* context = library.D3D11->context;
ID3D11RenderTargetView* renderTargetView = buffers.D3D11->colorBufferView;
// Set vertex buffer
UINT stride = sizeof(SimpleVertex);
UINT offset = 0;
context->IASetVertexBuffers(0, 1, &g_vertexBuffer, &stride, &offset);
// Set primitive topology
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// Set depth/stencil state
context->OMSetDepthStencilState(g_depthStencilState, 1);
// Draw a triangle using the simple shaders
context->VSSetShader(vertexShader.Get(), nullptr, 0);
context->PSSetShader(pixelShader.Get(), nullptr, 0);
context->Draw(3, 0);
}
示例9: Draw
void Draw(const Microsoft::WRL::ComPtr<ID3D11DeviceContext> &pDeviceContext)
{
// VBのセット
ID3D11Buffer* pBufferTbl[] = { m_pVertexBuf.Get() };
UINT SizeTbl[] = { sizeof(Vertex) };
UINT OffsetTbl[] = { 0 };
pDeviceContext->IASetVertexBuffers(0, 1, pBufferTbl, SizeTbl, OffsetTbl);
// IBのセット
pDeviceContext->IASetIndexBuffer(m_pIndexBuf.Get(), DXGI_FORMAT_R32_UINT, 0);
// プリミティブタイプのセット
pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
pDeviceContext->DrawIndexed(m_indices // index count
, 0, 0);
}
示例10: CreateDepthStencilView
ID3D11DepthStencilView* CreateDepthStencilView(ID3D11Device* pDevice,DWORD dwWidth, DWORD dwHeight)
{
HRESULT hr;
ID3D11DepthStencilView* pDSV = nullptr;
Microsoft::WRL::ComPtr<ID3D11Texture2D> pDSTexture = nullptr;
D3D11_TEXTURE2D_DESC DescDepth;
DescDepth.Width = dwWidth;
DescDepth.Height = dwHeight;
DescDepth.MipLevels = 1;
DescDepth.ArraySize = 1;
DescDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
DescDepth.SampleDesc.Count = 1;
DescDepth.SampleDesc.Quality = 0;
DescDepth.Usage = D3D11_USAGE_DEFAULT;
DescDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
DescDepth.CPUAccessFlags = 0;
DescDepth.MiscFlags = 0;
if (FAILED(hr = pDevice->CreateTexture2D(&DescDepth, NULL, &pDSTexture)))
{
return nullptr;
}
D3D11_DEPTH_STENCIL_VIEW_DESC dsvd;
ZeroMemory(&dsvd, sizeof(dsvd));
dsvd.Format = DescDepth.Format;
dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
dsvd.Texture2D.MipSlice = 0;
if (FAILED(hr = pDevice->CreateDepthStencilView(
pDSTexture.Get(), &dsvd, &pDSV)))
{
return nullptr;
}
return pDSV;
}
示例11: SetGlyphRun
void FlowLayoutSink::SetGlyphRun(
float x,
float y,
UINT32 glyphCount,
const UINT16* glyphIndices, // [glyphCount]
const float* glyphAdvances, // [glyphCount]
const DWRITE_GLYPH_OFFSET* glyphOffsets, // [glyphCount]
Microsoft::WRL::ComPtr<IDWriteFontFace> fontFace,
float fontEmSize,
UINT8 glyphOrientation,
bool isReversed,
bool isSideways
)
{
// Append this glyph run to the list.
m_glyphRuns.resize(m_glyphRuns.size() + 1);
CustomGlyphRun& glyphRun = m_glyphRuns.back();
UINT32 glyphStart = static_cast<UINT32>(m_glyphAdvances.size());
m_glyphIndices.insert (m_glyphIndices.end(), glyphIndices, glyphIndices + glyphCount);
m_glyphAdvances.insert(m_glyphAdvances.end(), glyphAdvances, glyphAdvances + glyphCount);
m_glyphOffsets.insert (m_glyphOffsets.end(), glyphOffsets, glyphOffsets + glyphCount);
glyphRun.x = x;
glyphRun.y = y;
glyphRun.glyphOrientation = glyphOrientation;
glyphRun.glyphStart = glyphStart;
glyphRun.isSideways = isSideways;
glyphRun.isReversed = isReversed;
glyphRun.glyphCount = glyphCount;
glyphRun.fontEmSize = fontEmSize;
glyphRun.fontFace = fontFace.Get();
}
示例12: RequestDescriptorHeap
ID3D12DescriptorHeap* DynamicDescriptorHeap::RequestDescriptorHeap(void)
{
std::lock_guard<std::mutex> LockGuard(sm_Mutex);
while (!sm_RetiredDescriptorHeaps.empty() && g_CommandManager.IsFenceComplete(sm_RetiredDescriptorHeaps.front().first))
{
sm_AvailableDescriptorHeaps.push(sm_RetiredDescriptorHeaps.front().second);
sm_RetiredDescriptorHeaps.pop();
}
if (!sm_AvailableDescriptorHeaps.empty())
{
ID3D12DescriptorHeap* HeapPtr = sm_AvailableDescriptorHeaps.front();
sm_AvailableDescriptorHeaps.pop();
return HeapPtr;
}
else
{
D3D12_DESCRIPTOR_HEAP_DESC HeapDesc = {};
HeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
HeapDesc.NumDescriptors = kNumDescriptorsPerHeap;
HeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
HeapDesc.NodeMask = 1;
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> HeapPtr;
ASSERT_SUCCEEDED(g_Device->CreateDescriptorHeap(&HeapDesc, MY_IID_PPV_ARGS(&HeapPtr)));
sm_DescriptorHeapPool.emplace_back(HeapPtr);
return HeapPtr.Get();
}
}
示例13: Create
void Model::Create()
{
CreateRootSignature();
CreatePipelineState();
Microsoft::WRL::ComPtr<ID3D12CommandAllocator> CommandAllocator;
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> CommandList;
Microsoft::WRL::ComPtr<ID3D12Resource> VertexUploadResource;
Microsoft::WRL::ComPtr<ID3D12Resource> IndexUploadResource;
GPUFence Fence;
Fence.Initialize(DeviceContext.GetDevice());
Utility::ThrowOnFail(DeviceContext.GetDevice()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&CommandAllocator)));
Utility::ThrowOnFail(DeviceContext.GetDevice()->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, CommandAllocator.Get(), nullptr, IID_PPV_ARGS(&CommandList)));
UploadVertices(CommandList, VertexUploadResource);
UploadIndices(CommandList, IndexUploadResource);
Utility::ThrowOnFail(CommandList->Close());
ID3D12CommandList * CommandListPointer = CommandList.Get();
DeviceContext.GetCommandQueue()->ExecuteCommandLists(1, &CommandListPointer);
Fence.SetAndWait(DeviceContext.GetCommandQueue());
}
示例14: LoadBitmapFromFile
HRESULT Sample2DSceneRenderer::CreateBitmapBrush(PCWSTR uri, ID2D1BitmapBrush **ppBitmapBrush)
{
Microsoft::WRL::ComPtr<ID2D1Bitmap> ppBitmap;
auto hr = LoadBitmapFromFile(m_deviceResources.get(), uri, &ppBitmap);
auto context = m_deviceResources->GetD2DDeviceContext();
hr = context->CreateBitmapBrush(ppBitmap.Get(), &m_pBitmapBrush);
return hr;
}
示例15: End
void PrimitveDrawer::End()
{
Microsoft::WRL::ComPtr<ID3D11RasterizerState> pRSState;
m_pContext->RSGetState(&pRSState);
m_pContext->RSSetState(m_pStates->CullClockwise());
m_pDirectXBatch->End();
m_pContext->RSSetState(pRSState.Get());
}