Direct3D render to desktop

hi all!

How render 3d scene to desktop



Answer this question

Direct3D render to desktop

  • khan2025

    Yes, DirectDraw was removed from DX8 and all subsequent versions. It's most annoying, and that's why I had to fall back on DX7 to get stuff done.

    All versions of DX and the SDKs are backwards compatible, however, so you can still write stuff for DirectDraw and compile and run it on the latest versions.

  • rdrast

    no, GetDesktopWindow() will return desktop rectangle< but if render here(in theory) you will erase all.

    only way i see is like WinAmp cisualization plugins does, set desktop color, and use overlay, but i cant conect direct3d and directdraw :(


  • Aryan_Patel_05

    aint directdraw been removed from dx9
  • LittleNew

    As far as I know, there are 2 ways to do this, and none is better than the other.

    The first method involves writing an ActiveX control that does all the rendering you want, as Richard Fine wrote above. I've been able to do this - you can then embed it into an HTML page and set it as a background when Active Desktop is enabled. The HTML file itself can control the size of the window of the control (width and height attributes). Getting this to partially work isn't really difficult - it's a day's work to get such a renderer working.

    The problem I faced here is that once set as a desktop background, any mouse-desktop interaction was lost. All mouse events were routed to my ActiveX control, so the user wouldn't be able to activate icons or drag them or bring up a popup menu, etc. Theoretically, this could've been solved by forwarding mouse messages to the desktop window - I tried that but it didn't work. Not sure why either, because the project was halted and I moved on to other things.

    The second method would be to use overlays. This works great if you don't want to do any 3D rendering with Direct3D, although you'd have to deal with the different overlay formats supported by different cards (nVidia cards don't seem to support RGB overlays, but rather YUV ones). Also, with ATi cards (and the most recent drivers), overlays with size >= 1024x768 are blurred for some reason.

    I recommend the first method. There's some DX8.1 dynamic-background application that's available as a shareware version, and it uses the ActiveX method (not sure what it's name was, it's developed by an independent developer who's also developed a game called Starscape or something similar).



  • Steve Severance

    fictionforever wrote:

    no, i mean render to desktop background, under icons and all windows.



    With a great degree of difficulty.

    Your one possible chance is to use Active Desktop. You'd develop your thing as an ActiveX control and then embed it as a "web component." I believe you have no control over the size of the rectangle you get to render into, nor can you prevent people mousing-over the edges of your display and getting a popup toolbar. At least, that's how things seemed to work back in Win98.

    If you want to do it more directly, you're looking at a custom shell.


  • T0M101


    Something like this:

    This API exist in Windows :

    HWND hWndDesktop = GetDesktopWindow()->m_hWnd;

    Create a SwapChain...

    Get it's surface...pSurface

    Get the Render to send command on it's surface....

    pDevice->SetRenderTarget(pSurface);


    pDevice->Begin()

    draw stuff

    pDevice->End()

    When you call Present with the SwapChain you simply use the hWnd

    SwapChain->Present(NULL, NULL, hWndDesktop, NULL);


  • Jazz Soft

    I could be wrong as I never have checked it by myself but as far as I know you can’t create a Direct3D device for a window that is owned by another process.



  • Harris Syed

    i know what u mean :)

    therefor u need the get the desktop window handle (hWnd) ... im sure there is one ... each control has it ... so the desktop must have it too


  • AlexSok

    The best method would be to set the desktop background to a particular colour, and then use DirectDraw overlays to key and replace on this colour.

    You can even get Direct3D to render to a DirectDraw surface, and then blit that surface onto your overlay so you can have 3D graphics on your desktop too.

    Create your surface with the dwCaps options to be DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE

    Create a directdraw surface with :
    ddraw->CreateDevice(IID_IDirect3DHALDevice, surface, &device);

    and then render to this device as you would normally with D3D.

    I've only managed to get this working with Direct3D7, which is a bit old. I haven't found a way of getting D3D9 to draw to a DirectDraw surface (which is directX7). If anyone has, I'd be greatly appreciative if you could tell me how.



  • Ju Wu

    lol, why u wanna render your desktop :s

    Maybe u can use the platform SDK to find some API's to get the desktop hWnd. Once u got that, u should be able to render on the desktop


  • Jack2005

    fictionforever wrote:

    no, GetDesktopWindow() will return desktop rectangle

    HWND GetDesktopWindow()

    It returns the windows handle of the desktop ... so u should be able to use it.

    Unless its protected. I tryd the GetMessage using the desktop windows handle and it aint returning any messages, maybe cause the desktop allready processed the messages

    But u can give it a try to use the desktop windows handle


  • Pedro Remedios

    no, i mean render to desktop background, under icons and all windows.

    i know about overlay mode, but not know how copy d3d surface to ddraw surface.


  • Direct3D render to desktop