表面问题-DirectX 9 [英] Problem with surface - DirectX 9
本文介绍了表面问题-DirectX 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在DirectX 9中有此代码,在其中我需要从COM接口获取DC并进行绘制.我确实获得了DC,并且其中包含图像,但是却出现了黑屏.有什么想法吗?
Hi, I have this code in DirectX 9, in which I need to get the DC from a COM interface and draw it. I do get the DC and it contains the image, but I get a black screen. Any ideas why?
LPDIRECT3DSURFACE9 pRenderSurface = NULL, pRenderSurfaceTMP = NULL;
m_pRenderTexture->GetSurfaceLevel(0, &pRenderSurface);
if (pRenderSurface == NULL)
return FALSE;
m_pD3DDevice->CreateOffscreenPlainSurface(m_nWidth, m_nHeight,
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &pRenderSurfaceTMP, 0);
m_pD3DDevice->GetRenderTargetData(pRenderSurface,pRenderSurfaceTMP);
HDC hDC = NULL;
hr = pRenderSurfaceTMP->GetDC(&hDC);
if (FAILED(hr))
return FALSE;
if (m_pViewObject != NULL)
{
// RECT is relative to the windowless container rect
RECTL rcRect = {0, 0, m_nWidth, m_nHeight};
// Draw onto the DC!
hr = m_pViewObject->Draw(DVASPECT_CONTENT, 1,
NULL, NULL, NULL, hDC, &rcRect, NULL, NULL,
0);
}
pRenderSurface->ReleaseDC(hDC);
pRenderSurface->Release();
// Draw the surface
m_pD3DDevice->SetStreamSource( 0, m_pVertexBuffer, 0, sizeof(Vertex) );
m_pD3DDevice->SetTexture( 0, m_pRenderTexture );
hr = m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
m_hbrBackground = NULL;
pRenderSurfaceTMP->Release();
预先感谢,
yakobom
Thanks in advance,
yakobom
推荐答案
SoMad,
基本上您是正确的,但是我逐行调试了它,一切似乎都还不错.另外,我确实知道我的图片在DC中(我将其从hDC打印到文件中).
您知道什么地方可能出问题吗?
yakobom
Hi SoMad,
Basically you are correct, but I debugged it line by line and everything seemed ok. Plus, I do know I have the picture in the dc (I printed it to a file from hDC).
Do you have any idea what can be wrong?
yakobom
这篇关于表面问题-DirectX 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文