• Advertisement
Sign in to follow this  

RenderToSurface question

This topic is 4249 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

Hi! What exactly is RenderToSurface DirectX class for and how can i use it? Right now i've got this code to render my scene to a surface:
public void Render()
{     
  using(Surface previousSurface = device.GetRenderTarget(0))
  using (Surface sceneSurface = sceneTexture.GetSurfaceLevel(0))
  {
    device.SetRenderTarget(0, sceneSurface);

    device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.FromArgb(64, 64, 192).ToArgb(), 1.0f, 0);
    try
    {
      int passes = effect.Begin(0);
      for (int pass = 0; pass < passes; pass++)
      {
        effect.BeginPass(pass);
        mesh.DrawSubset(0);
        effect.EndPass();
      }
      effect.End();
    }
    finally
    {
      device.SetRenderTarget(0, previousSurface);
    }
  }
}

Could i use RenderToSurface here somehow? Or is it for something completely different?

Share this post


Link to post
Share on other sites
Advertisement
Hi, just a quick reply, (hope someone else can help somemore), I've seen render to surface used quite often for some shader techniques. Basicly instead of rendering to the backbuffer, you render to the surface you provide, at the moment i am using it for some small sub-display type things so I render my entire scene to an offscreen surface (setRenderTarget(0, MyOffScreenSurface), then after that (in the same loop), I reset the rendertarget to the back buffer (thats why you save it, - because you have to put it back), then render the scene as normal, but also render a quad with my now with my render target surface as its texture. -So I get my scene and then a little copy of it in the corner :) pretty neat really! Of course there are lots of other uses for it. I'm still using the fixed function pipeline at the moment so I'm not sure about using it with shaders.

Share this post


Link to post
Share on other sites
Thanks, but that's exactly what i'm doing right now :)

I was asking what is "RenderToSurface" class for as i can render to surface without it, exactly like you've said. Does "RenderToSurface" make it simpler? Does it have some additional functionality?

Share this post


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

  • Advertisement