예제 #1
0
void D3DTexture2D::DrawAsDc(std::function<void (const HDC, RECT**)> fn){
	IDXGISurface1* surface = nullptr;
	HRESULT hr = texture->QueryInterface(__uuidof(IDXGISurface1), (void**)&surface);
	IF_NG(hr) {
		LOG_DBG("Failed to get IDXGISurface1 Interface.\r\n");
		return;
	}

	HDC dc = nullptr;
	hr = surface->GetDC(false, &dc);
	IF_NG(hr) {
		LOG_DBG("Failed to get HDC Handle.\r\n");
		surface->Release();
		return;
	}

	RECT* prect;

	fn(dc, &prect);

	surface->ReleaseDC(prect);

	if (prect) delete prect;
	surface->Release();
}
예제 #2
0
void DrawFrame()
{
	float clearColor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
	g_immediateContext->ClearRenderTargetView(g_renderTargetView, clearColor);

	g_immediateContext->IASetInputLayout( g_pVertexLayout );

	UINT stride = sizeof( Vertex );
	UINT offset = 0;
	g_immediateContext->IASetVertexBuffers( 0, 1, &g_pVertexBuffer, &stride, &offset );
	g_immediateContext->IASetIndexBuffer( g_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);

	// Set the shaders
	g_immediateContext->VSSetShader( g_pVertexShader, NULL, 0 );
	g_immediateContext->PSSetShader( g_pPixelShader, NULL, 0 );

	const RECT* unitedRect = NULL;
	if (g_flashPlayer->IsNeedUpdate(&unitedRect))
	{
		// Get DXGI surface of the texture
		IDXGISurface1 *pSurface = NULL;

		HRESULT hResult = g_flashTexture->QueryInterface(__uuidof(IDXGISurface1), (void**)&pSurface);
		assert(SUCCEEDED(hResult));

		// Get surface DC for the texture
		HDC hDC;
		hResult = pSurface->GetDC(TRUE, &hDC);
		assert(SUCCEEDED(hResult));

		g_flashPlayer->DrawFrame(hDC);

		// Release the DC specifying the dirty rect
		pSurface->ReleaseDC((RECT*)unitedRect);

		pSurface->Release();
	}

	g_immediateContext->PSSetShaderResources( 0, 1, &g_pTextureRV );
	g_immediateContext->DrawIndexed( g_indexCount, 0, 0 );

	// Present to screen
	g_swapChain->Present(0, 0);
}
예제 #3
0
bool KCore::GameInit()
{
	HRESULT hr;
	if (FAILED(CreateGIFactory()))
	{
		return 0;
	}
	if (FAILED(InitDevice()))
	{
		CleanupDevice();
		return 0;
	}
	if (FAILED(InitSwapChain()))
	{
		return 0;
	}
	if (FAILED(SetRenderTarget()))
	{
		return 0;
	}
	if (FAILED(SetViewPort()))
	{
		return 0;
	}
	KDxState::SetState(g_pd3dDevice);

	m_Timer.Init();
	I_Input.Init();

	// font 
	IDXGISurface1*  pSurface;
	hr = g_pSwapChain->GetBuffer(0,
		__uuidof(IDXGISurface1),
		(LPVOID*)&pSurface);
	m_Font.Set(pSurface);
	pSurface->Release();

	Init();
	return true;
}