Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DirectX: "render to surface" or "render to device" (unmanaged)

DirectX: "render to surface" or "render to device" (unmanaged)

Scheduled Pinned Locked Moved C / C++ / MFC
questioncssgraphicsgame-devperformance
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pixinger77
    wrote on last edited by
    #1

    Hi, I googled around a lot and found basically two ways to render contents to a directX device. The first way is to render directly to the device (that's what I call it :~): IDirect3DDevice9* pDevice; //for simplicity no initialization code here pDevice->Clear(); pDevice->BeginScene(); HRESULT hResult = pDevice->DrawPrimitiveUP( /* ... */ ); pDevice->EndScene(); pDevice->Present(); The second way I found is to render first to a surface and then the complete surface at once to the device: IDirect3DDevice9* pDevice; //for simplicity no initialization code here // now comes the new part of the code: I will first render to surface... CSurface* pBackBuffer; // created by D3DXCreateTexture() and GetSurfaceLevel(); ID3DXRenderToSurface* pRenderTarget; // created by D3DXCreateRenderToSurface(); pRenderTarget->BeginScene(pSurface, 0); pDevice->SetTexture(0); pDevice->DrawPrimitiveUP( /* ... */ ); pRenderTarget->EndScene(D3DTEXF_NONE); // ... and then to the device: the whole surface at once. pDevice->Clear(); pDevice->BeginScene(); pDevice->SetTexture(pTexture); pDevice->DrawPrimitiveUP( /* ... */ ); //Rendering now the Texture to the device. pDevice->EndScene(); pDevice->Present(); --------------------- My question now is: What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering? Do I have more possibilities with the second approach? My second question is: I found a forum-thread where they told that it is no advised to render directly into a surface, because it would destroy performance. The thread applied to managed directx. Is this true? Does it apply to unmanaged DirectX also? Is it slower to render to surfaces? Thanks in advance Snowprog

    CPalliniC S 2 Replies Last reply
    0
    • P Pixinger77

      Hi, I googled around a lot and found basically two ways to render contents to a directX device. The first way is to render directly to the device (that's what I call it :~): IDirect3DDevice9* pDevice; //for simplicity no initialization code here pDevice->Clear(); pDevice->BeginScene(); HRESULT hResult = pDevice->DrawPrimitiveUP( /* ... */ ); pDevice->EndScene(); pDevice->Present(); The second way I found is to render first to a surface and then the complete surface at once to the device: IDirect3DDevice9* pDevice; //for simplicity no initialization code here // now comes the new part of the code: I will first render to surface... CSurface* pBackBuffer; // created by D3DXCreateTexture() and GetSurfaceLevel(); ID3DXRenderToSurface* pRenderTarget; // created by D3DXCreateRenderToSurface(); pRenderTarget->BeginScene(pSurface, 0); pDevice->SetTexture(0); pDevice->DrawPrimitiveUP( /* ... */ ); pRenderTarget->EndScene(D3DTEXF_NONE); // ... and then to the device: the whole surface at once. pDevice->Clear(); pDevice->BeginScene(); pDevice->SetTexture(pTexture); pDevice->DrawPrimitiveUP( /* ... */ ); //Rendering now the Texture to the device. pDevice->EndScene(); pDevice->Present(); --------------------- My question now is: What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering? Do I have more possibilities with the second approach? My second question is: I found a forum-thread where they told that it is no advised to render directly into a surface, because it would destroy performance. The thread applied to managed directx. Is this true? Does it apply to unmanaged DirectX also? Is it slower to render to surfaces? Thanks in advance Snowprog

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      Snowprog77 wrote:

      My question now is: What benefits do I get from the second approach?

      Snowprog77 wrote:

      For me it looks like I just put one more step in the row. Is there less flickering?

      Yes, AFAIK. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • P Pixinger77

        Hi, I googled around a lot and found basically two ways to render contents to a directX device. The first way is to render directly to the device (that's what I call it :~): IDirect3DDevice9* pDevice; //for simplicity no initialization code here pDevice->Clear(); pDevice->BeginScene(); HRESULT hResult = pDevice->DrawPrimitiveUP( /* ... */ ); pDevice->EndScene(); pDevice->Present(); The second way I found is to render first to a surface and then the complete surface at once to the device: IDirect3DDevice9* pDevice; //for simplicity no initialization code here // now comes the new part of the code: I will first render to surface... CSurface* pBackBuffer; // created by D3DXCreateTexture() and GetSurfaceLevel(); ID3DXRenderToSurface* pRenderTarget; // created by D3DXCreateRenderToSurface(); pRenderTarget->BeginScene(pSurface, 0); pDevice->SetTexture(0); pDevice->DrawPrimitiveUP( /* ... */ ); pRenderTarget->EndScene(D3DTEXF_NONE); // ... and then to the device: the whole surface at once. pDevice->Clear(); pDevice->BeginScene(); pDevice->SetTexture(pTexture); pDevice->DrawPrimitiveUP( /* ... */ ); //Rendering now the Texture to the device. pDevice->EndScene(); pDevice->Present(); --------------------- My question now is: What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering? Do I have more possibilities with the second approach? My second question is: I found a forum-thread where they told that it is no advised to render directly into a surface, because it would destroy performance. The thread applied to managed directx. Is this true? Does it apply to unmanaged DirectX also? Is it slower to render to surfaces? Thanks in advance Snowprog

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        Snowprog77 wrote:

        What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering?

        Yes - graphics hardware has highly optimised bit-blit operations, which is precisely what's used to move the off-screen surface to the device.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups