Hi everyone, I have just tried what ori-on suggested, but I'm still seeing a black window (I want to see at least the line I drew using GDI+, and later, that line drawn over the other texture, which contains a triangle). Here's the code:
This function renders to a texture using GDI+:
void RenderOverlays(){ //Lock texture and render D3DLOCKED_RECT lockedRect; g_pOORT->LockRect(0, &lockedRect, NULL, 0); Gdiplus::Bitmap bitmap(300, 300, lockedRect.Pitch, PixelFormat32bppARGB , (BYTE*)lockedRect.pBits); Gdiplus::Graphics graphics( &bitmap ); graphics.Clear( Gdiplus::Color::Transparent ); Gdiplus::Pen pen( Gdiplus::Color::Red ); graphics.DrawLine(&pen, 10, 10, 120, 120); ::GdiFlush(); g_pOORT->UnlockRect(0);}
This is the way I create the texture:
HRESULT InitOORT(){ // Create a blank texture if( FAILED( g_pd3dDevice->CreateTexture(300, 300, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pOORT, NULL) ) ) { return E_FAIL; } // GDI+ stuff GdiplusStartup(>,&gsi,NULL); return S_OK;}
And this is my render loop:
VOID Render(){ // Clear the backbuffer to a blue color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 ); // Render "offline" (outside render loop) RenderOverlays(); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Draw the triangles in the vertex buffer. This is broken into a few // steps. We are passing the Vertices down a "stream", so first we need // to specify the source of that stream, which is our vertex buffer. Then // we need to let D3D know what vertex shader to use. Full, custom vertex // shaders are an advanced topic, but in most cases the vertex shader is // just the FVF, so that D3D knows what type of Vertices we are dealing // with. Finally, we call DrawPrimitive() which does the actual rendering // of our geometry (in this case, just one triangle). g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); // 5 - Set the texture on stage 0 g_pd3dDevice->SetTexture(0, g_pOORT); // 6 - Render a screen space quad g_pd3dDevice->SetStreamSource( 0, g_pVBTQ, 0, sizeof(CUSTOMVERTEX2) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 2 ); // End the scene g_pd3dDevice->EndScene(); } // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL );}
If I comment out from the render loop sections 5 and 6, I can see the triangle. So the problem is definitely in the way I render the other texture.
[Edited by - dario_ramos on December 4, 2009 6:38:51 AM]