Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to set D3D rendering on the HDC I created?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 sainimu78   Members   -  Reputation: 121

Like
0Likes
Like

Posted 15 August 2014 - 12:05 AM

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.



Sponsor:

#2 Nik02   Crossbones+   -  Reputation: 2937

Like
2Likes
Like

Posted 15 August 2014 - 01:27 AM

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, 15 August 2014 - 01:34 AM.

Niko Suni


#3 sainimu78   Members   -  Reputation: 121

Like
0Likes
Like

Posted 15 August 2014 - 03:29 AM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS