• Advertisement
Sign in to follow this  

How to set D3D rendering on the HDC I created?

This topic is 1256 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a window and I can get a HDC via GetDC() from the window. Now I want a cube rendering on the HDC that can be gotten from my own window, how should I do?

The rendering function looks like this:

void D3dRender(HDC myHdc)
{
    //usual D3dRender on the HDC I provide
} 

Only can I find examples of rendering on the HDC created by D3D itself.

Thus I can pD3dSurface->GetDC(), but can't "pD3dSurface->SetDC()". Yes, there is no such method in IDirect3DSurface9 class.

Share this post


Link to post
Share on other sites
Advertisement

Direct3D Device object itself is basically a graphics device context. The GetDC method of the surface interface is provided for interoperability reasons (so you can draw to D3D surfaces with GDI).

 

You can redirect rendering given a window handle, though; the device's Present method optionally takes a HWND that represents the desktop area to present to.

 

If you only have the HDC of the window, you could use WindowFromDC function to get the associated HWND. Be sure to cache the HWND you get if you go this route; the function is heavier than you might think.

Edited by Nik02

Share this post


Link to post
Share on other sites

Direct3D Device object itself is basically a graphics device context. The GetDC method of the surface interface is provided for interoperability reasons (so you can draw to D3D surfaces with GDI).

 

You can redirect rendering given a window handle, though; the device's Present method optionally takes a HWND that represents the desktop area to present to.

 

If you only have the HDC of the window, you could use WindowFromDC function to get the associated HWND. Be sure to cache the HWND you get if you go this route; the function is heavier than you might think.

Thanks a lot. Your advices are very helpful and my problem get solved  . biggrin.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement