Jump to content
  • Advertisement
Sign in to follow this  
royteusink

[c#] RenderToSurface

This topic is 4054 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 all, Hmm this code gives me an error on the following line, Why?!:
RTSOnderwater.BeginScene(OnderwaterSurface, OnderwaterView);



Texture OnderwaterTexture;
    RenderToSurface RTSOnderwater;
    Plane reflectPlane;

    public void RefractionTex(Device device, Matrix view, Matrix Projection)
    {
        RTSOnderwater = new RenderToSurface(device, cGlobal.WindowWidth, cGlobal.WindowHeight, Format.X8R8G8B8, true, DepthFormat.D24X8);
        OnderwaterTexture = new Texture(device, cGlobal.WindowWidth, cGlobal.WindowHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
        reflectPlane = Microsoft.DirectX.Plane.FromPointNormal(new Vector3(0, -1f, 0), new Vector3(0, 1, 0));

        Surface OnderwaterSurface = OnderwaterTexture.GetSurfaceLevel(0);
        Viewport OnderwaterView = new Viewport();
        OnderwaterView.Width = cGlobal.WindowWidth;
        OnderwaterView.Height = cGlobal.WindowHeight;
        OnderwaterView.MaxZ = 1.0f;

        RTSOnderwater.BeginScene(OnderwaterSurface, OnderwaterView); // <--- Why does it fail on this line? (error in application)
        device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, 0, 1.0f, 0);

            Matrix reflectViewMatrix = Matrix.Identity;
            reflectViewMatrix.Reflect(reflectPlane);
            reflectViewMatrix = reflectViewMatrix * view;

            device.Transform.View = reflectViewMatrix;
            device.Transform.Projection = Projection;

            device.ClipPlanes[0].Enabled = true;
            device.ClipPlanes[0].Plane = reflectPlane;
            device.RenderState.Clipping = true;

            // render scene
            //
    
            device.RenderState.Clipping = false;
            device.ClipPlanes[0].Enabled = false;

        RTSOnderwater.EndScene(Filter.None);

    }



[Edited by - royteusink on August 14, 2007 9:24:55 AM]

Share this post


Link to post
Share on other sites
Advertisement
Switch directx to debug-mode, and start dbmon (from your visual-studio tools dir) - this should give you a better errormessage to start from.

Share this post


Link to post
Share on other sites
Results from DBMon

1904: Direct3D9: :====> ENTER: DLLMAIN(0475e6e0): Process Attach: 00000770, tid=
00001454
1904: Direct3D9: :====> EXIT: DLLMAIN(0475e6e0): Process Attach: 00000770
1904: Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
1904: D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled
with D3D_DEBUG_INFO
1904: Direct3D9: (INFO) :======================= Hal HWVP Pure device selected
1904:
1904: Direct3D9: (INFO) :HalDevice Driver Style 9
1904:
1904: Direct3D9: :BackBufferCount not specified, considered default 1
1904: Direct3D9: :DoneExclusiveMode
1904: Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 0, Stat
e: 2
1904:
1904: Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 0, Stat
e: 3
1904:
1904: Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 1, Stat
e: 2
1904:
1904: Direct3D9: (WARN) :Ignoring redundant SetRenderState - 207
1904:
1904: Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 0, Stat
e: 2
1904:
1904: Direct3D9: (WARN) :Ignoring redundant SetTextureStageState. Stage: 0, Stat
e: 3
1904:
1904: Direct3D9: (ERROR) :BeginScene, already in scene. BeginScene failed.
1904:


Share this post


Link to post
Share on other sites
you can't use render to surface inside a begin/endscene block because render to surface open the scene by himself.

So use endscene before begin a scene with render to surface object

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!