1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
BOOL FlashPlayer::Render()
{
HRESULT hr;
if (m_pRenderTexture && m_pVertexBuffer)
{
LPDIRECT3DSURFACE9 pRenderSurface = NULL, pRenderSurfaceTMP = NULL;
hr = m_pRenderTexture->GetSurfaceLevel(0, &pRenderSurface);
if (pRenderSurface == NULL)
return FALSE;
hr = m_pD3DDevice->CreateOffscreenPlainSurface(m_nWidth, m_nHeight,
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &pRenderSurfaceTMP, 0);
if (FAILED(hr))
int delme = 1;
hr = m_pD3DDevice->GetRenderTargetData(pRenderSurface,pRenderSurfaceTMP);
if (FAILED(hr))
int delme = 1;
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};
m_hbrBackground = ::CreateSolidBrush(m_dwBackground);
::FillRect(hDC, (RECT*)&rcRect, m_hbrBackground);
// Draw onto the DC!
hr = m_pViewObject->Draw(DVASPECT_CONTENT, 1,
NULL, NULL, NULL, hDC, &rcRect, NULL, NULL,
0);
}
// Draw the surface
hr = m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(Vertex));
if (FAILED(hr))
int delme = 1;
hr = m_pD3DDevice->SetTexture( 0, m_pRenderTexture );
if (FAILED(hr))
int delme = 1;
hr = m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
if (FAILED(hr))
int delme = 1;
pRenderSurface->Release();
::DeleteObject(m_hbrBackground);
pRenderSurfaceTMP->ReleaseDC(hDC);
pRenderSurfaceTMP->Release();
m_hbrBackground = NULL;
return TRUE;
}
|