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


C++ DeviceContext类代码示例

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


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

示例1: UpdateTexture2

	void UpdateTexture2( HContext _context, HTexture _handle, UINT32 _size, const void* _data )
	{
		mxASSERT(_size > 0);
		mxASSERT_PTR(_data);
		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->UpdateTexture2( _handle, _data, _size );
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:7,代码来源:gr_frontend.cpp

示例2: Render

static void Render(HWND window)
{
    if (!target)
    {
        auto device = Direct3D::CreateDevice();
        target = factory.CreateDevice(device).CreateDeviceContext();
        auto dxgi = device.GetDxgiFactory();

        Dxgi::SwapChainDescription1 description;
        description.SwapEffect = Dxgi::SwapEffect::Discard;

        swapChain = dxgi.CreateSwapChainForHwnd(device,
                                                window,
                                                description);

        CreateDeviceSwapChainBitmap(swapChain,
                                    target);

        auto const dpi = factory.GetDesktopDpi();
        target.SetDpi(dpi, dpi);
        CreateDeviceResources();
    }

    target.BeginDraw();
    Draw();
    target.EndDraw();

    auto const hr = swapChain.Present();

    if (S_OK != hr && DXGI_STATUS_OCCLUDED != hr)
    {
        ReleaseDevice();
    }
}
开发者ID:dbremner,项目名称:dx,代码行数:34,代码来源:DesktopDeviceContext.cpp

示例3: SetBlendState

	void SetBlendState( HContext _context, HBlendState blendState, const float* blendFactor /*= NULL*/, UINT32 sampleMask /*= ~0*/ )
	{
		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->SetBlendState( blendState, blendFactor, sampleMask );
		//tr.commands.WriteToken(RC_SET_BLEND_STATE);
		//tr.commands.Put(blendState);
		//tr.commands.AlignPointer<4>();
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:8,代码来源:gr_frontend.cpp

示例4: DeviceGetContext

void
DeviceContext::ShutdownCallback(
    _In_ WDFOBJECT Object
    )
{
    DeviceContext* deviceContext = DeviceGetContext(Object);
    deviceContext->Shutdown();
}
开发者ID:Microsoft,项目名称:NFC-Class-Extension-Driver,代码行数:8,代码来源:Device.cpp

示例5: SetRasterizerState

	void SetRasterizerState( HContext _context, HRasterizerState rasterizerState )
	{
		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->SetRasterizerState( rasterizerState );
		//tr.commands.WriteToken(RC_SET_RASTERIZER_STATE);
		//tr.commands.Put(rasterizerState);
		//tr.commands.AlignPointer<4>();
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:8,代码来源:gr_frontend.cpp

示例6: CreateDeviceSwapChainBitmap

static void CreateDeviceSwapChainBitmap(Dxgi::SwapChain const & swapChain,
                                        DeviceContext const & target)
{
    auto props = BitmapProperties1(BitmapOptions::Target | BitmapOptions::CannotDraw,
                                   PixelFormat(Dxgi::Format::B8G8R8A8_UNORM, AlphaMode::Ignore));

    target.SetTarget(target.CreateBitmapFromDxgiSurface(swapChain,
                                                        props));
}
开发者ID:dbremner,项目名称:dx,代码行数:9,代码来源:DesktopDeviceContext.cpp

示例7: SetDepthStencilState

	void SetDepthStencilState( HContext _context, HDepthStencilState depthStencilState, UINT8 stencilReference )
	{
		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->SetDepthStencilState( depthStencilState, stencilReference );
		//tr.commands.WriteToken(RC_SET_DEPTH_STENCIL_STATE);
		//tr.commands.Put(depthStencilState);
		//tr.commands.Put(stencilReference);
		//tr.commands.AlignPointer<4>();
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:9,代码来源:gr_frontend.cpp

示例8: Submit

	void Submit( HContext _context, const DrawCall& batch )
	{
		mxASSERT(batch.program.IsValid());
		//mxASSERT(batch.inputLayout.IsValid());
		mxASSERT(batch.topology != Topology::Undefined);
		mxASSERT(batch.vertexCount > 0);

		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->SubmitBatch( batch );
		//tr.commands.WriteToken(RC_DRAW_BATCH);
		//tr.commands.Put(batch);
		//tr.numBatches++;
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:13,代码来源:gr_frontend.cpp

示例9: UpdateBuffer

	void UpdateBuffer( HContext _context, HBuffer _handle, UINT32 _size, const void* _data, UINT32 _start )
	{
		mxASSERT(_size > 0);
		mxASSERT_PTR(_data);
		DeviceContext* deviceContext = (DeviceContext*) _context.ptr;
		deviceContext->UpdateBuffer( _handle, _start, _data, _size );
		//tr.commands.WriteToken(CMD_UPDATE_BUFFER);
		//tr.commands.Put(handle);
		//tr.commands.Put(start);
		//tr.commands.Put(size);
		//tr.commands.AlignPointer<16>();
		//tr.commands.Put(data, size);
	}
开发者ID:S-V,项目名称:SummerTraining,代码行数:13,代码来源:gr_frontend.cpp

示例10: draw

    /////////////////////////////////////////////////////////////////////////////////////////
    // ThemedSkin::draw const
    //! Draws a standard button control
    //! 
    //! \param[in,out] &btn - Button to be drawn
    //! \param[in,out] &dc - Output device context
    //! \param[in] const &rc - Drawing rectangle
    /////////////////////////////////////////////////////////////////////////////////////////
    void draw(Button<ENC>& btn, DeviceContext& dc, const RectL& rc) const override
    {
      Theme theme(btn.handle(), L"Button");

      // Determine state
      ::PUSHBUTTONSTATES state = PBS_NORMAL;
      if (!btn.Enabled)
        state = PBS_DISABLED;
      else if (btn.State == ButtonState::Pushed) //else if (args.State && OwnerDrawState::Selected)
        state = PBS_PRESSED;
      else if (btn.isMouseOver())
        state = PBS_HOT;
      
      // Draw background 
      theme.fill(dc, BP_PUSHBUTTON, state, rc);

      // Query content rect
      RectL rcContent = theme.content(dc, BP_CHECKBOX, state, rc);

      // Pressed: Offset drawing rect
      if (state == PBS_PRESSED)
        rcContent += PointL(1,1);

      // Draw icon
      if (btn.Icon.exists()) 
      {
        RectL rcIcon = rcContent.arrange(Metrics::WindowIcon, {RectL::FromLeft,Metrics::WindowEdge.Width}, RectL::Centre);
        dc.draw(btn.Icon, rcIcon);
      }
      
      // Calculate text rectangle
      RectL rcText = rcContent;
      if (btn.Icon.exists()) 
        rcText.Left += Metrics::WindowIcon.Width + Metrics::WindowEdge.Width;

      // Draw text
      if (state != PBS_DISABLED)
        theme.write(dc, BP_PUSHBUTTON, state, btn.Text(), rcText, DrawTextFlags::Centre|DrawTextFlags::VCentre|DrawTextFlags::SingleLine);
      else
      {
        const auto grayString = choose<ENC>(::GrayStringA,::GrayStringW);
        grayString(dc.handle(), StockBrush::AppWorkspace, nullptr, (LPARAM)btn.Text().c_str(), btn.Text().size(), rcText.Left, rcText.Top, rcText.width(), rcText.height());
      }
      
      // [FOCUS] Draw focus rectangle
      if (btn.Focus)   
      {
        RectL rcFocus = rcContent.inflate(-Metrics::WindowEdge);
        dc.focus(rcFocus);
      }
    }
开发者ID:nick-crowley,项目名称:Win32-Template-Library,代码行数:59,代码来源:ThemedSkin.hpp

示例11: moveptr

DepthStencilView::DepthStencilView(DeviceContext& context)
{
    // get the currently bound depth stencil view from the context
    ID3D::DepthStencilView* rawPtr = nullptr;
    context.GetUnderlying()->OMGetRenderTargets(0, nullptr, &rawPtr);
    _underlying = moveptr(rawPtr);
}
开发者ID:coreafive,项目名称:XLE,代码行数:7,代码来源:RenderTargetView.cpp

示例12: float

ObjectManager::SpriteBatch::SpriteBatch(DeviceContext & deviceContext, Texture & texture, std::shared_ptr<SpriteCoordinateReader>& coordinate, std::shared_ptr<SpriteSequenceReader>& sequence)
	: _deviceContext(deviceContext), _texture(texture), _coordinate(coordinate), _sequence(sequence)
{
	const auto width = float(coordinate->Width) / 2.f;
	const auto height = float(coordinate->Height) / 2.f;
	const UINT remapable = 1;

	SpriteVertex vertices[] =
	{
		{ { -width, height, 0.5f }, remapable },
		{ { width, height, 0.5f }, remapable },
		{ { -width, -height, 0.5f }, remapable },
		{ { width, -height, 0.5f }, remapable }
	};

	auto d3dDevice = _deviceContext.D3DDevice;

	{
		D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
		heapDesc.NumDescriptors = 1;
		heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
		// 此标志指示此描述符堆可以绑定到管道,并且其中包含的描述符可以由根表引用。
		heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
		ThrowIfFailed(d3dDevice->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&_sequenceUavHeap)));
	}

	ComPtr<ID3D12GraphicsCommandList> commandList;
	_deviceContext.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, nullptr, IID_PPV_ARGS(&commandList));

	_vertexBuffer = _deviceContext.CreateVertexBuffer(commandList.Get(), std::begin(vertices), std::end(vertices), _vertexBufferView);

	ThrowIfFailed(commandList->Close());
	deviceContext.ExecuteCommandList(commandList.Get());
}
开发者ID:ChinaRAUnion,项目名称:RedAlertPlus,代码行数:34,代码来源:ObjectManager.cpp

示例13: moveptr

 IndexBuffer::IndexBuffer(DeviceContext& context)
 {
     ID3D::Buffer* rawPtr = nullptr;
     DXGI_FORMAT fmt = DXGI_FORMAT_UNKNOWN;
     unsigned offset = 0;
     context.GetUnderlying()->IAGetIndexBuffer(&rawPtr, &fmt, &offset);
     _underlying = moveptr(rawPtr);
 }
开发者ID:Clever-Boy,项目名称:XLE,代码行数:8,代码来源:Buffer.cpp

示例14: measure

    /////////////////////////////////////////////////////////////////////////////////////////
    // ThemedSkin::measure const
    //! Measures a standard CheckBox control 
    //! 
    //! \param[in,out] &chk - CheckBox to be measured
    //! \param[in,out] &dc - Output device context
    //! \return SizeL - Required size
    /////////////////////////////////////////////////////////////////////////////////////////
    SizeL measure(CheckBox<ENC>& chk, DeviceContext& dc) const override
    {
      Theme theme(chk.handle(), L"Button");

      // Measure checkbox + text + edges
      return theme.measure(dc, BP_CHECKBOX, CBS_UNCHECKEDNORMAL) 
           + dc.measure(chk.Text()) 
           + SizeL(3*Metrics::WindowEdge.Width, 0);
    }
开发者ID:nick-crowley,项目名称:Win32-Template-Library,代码行数:17,代码来源:ThemedSkin.hpp

示例15: XlCopyMemory

    void    ConstantBuffer::Update(DeviceContext& context, const void* data, size_t byteCount)
    {
        // context.GetUnderlying()->UpdateSubresource(
        //     _underlying, 0, nullptr, data, byteCount, byteCount);

        D3D11_MAPPED_SUBRESOURCE result;
        ID3D::DeviceContext* devContext = context.GetUnderlying();
        HRESULT hresult = devContext->Map(_underlying.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &result);
        if (SUCCEEDED(hresult) && result.pData) {
            XlCopyMemory(result.pData, data, byteCount);
            devContext->Unmap(_underlying.get(), 0);
        }
    }
开发者ID:Clever-Boy,项目名称:XLE,代码行数:13,代码来源:Buffer.cpp


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