DXViewportView.RenderToBitmap no longer working
#1
Hello, Just updating AB4D to the latest version from v7.1 and it looks like it has broken some of my code for doing an offscreen render then saving to a bitmap.

Calling RendToBitmap on a DXViewportView used to work. But now it's just a blank image. Rendering the camera still works, but is very slow.

Any ideas on a fix?

Best regards,

Simon

Code snippet below

Code:
  var viewport3D = new Viewport3D();
            var directxViewPort = new DXViewportView();
            directxViewPort.InitializeScene();

            directxViewPort.BeginInit();

            directxViewPort.Viewport3D = viewport3D;
            directxViewPort.Height = 2048;
            directxViewPort.Width = 2048;

            viewport3D.Width = 2048;
            viewport3D.Height = 2048;

            var camera = new FirstPersonCamera();
            camera.Position = new Point3D(0, 0, 0);
            camera.Bank = 0;
            camera.Heading = 0;
            camera.Attitude = -90;
            camera.FieldOfView = 92;
            camera.TargetViewport3D = viewport3D;

            foreach (var m in objs.Values)
            {
                viewport3D.Children.Add(m.CreateModelVisual3D());
            }

            camera.Refresh();


            directxViewPort.EndInit();

            var img2 = directxViewPort.RenderToBitmap(2048, 2048, -1, 96, 96);  //this line used to work, but now the image is just blank

            var img = camera.RenderToBitmap(backgroundBrush);  //this works but is very very slow
#2
I am sorry that the new version does not work anymore with your code.

I have fixed that so this will work again in the next version.

Unitil then, please reorder the code so that the size of the DXViewportView is set before calling the InitializeScene:

Code:
            var viewport3D = new Viewport3D();
            var directxViewPort = new DXViewportView();

            directxViewPort.Viewport3D = viewport3D;
            directxViewPort.Height = 2048;
            directxViewPort.Width = 2048;

            viewport3D.Width = 2048;
            viewport3D.Height = 2048;

            directxViewPort.InitializeScene();

After that the directxViewPort.RenderToBitmap will produce the bitmap with rendered 3D objects.
Andrej Benedik
#3
Excellent - that seems to have fixed it.

Thanks again for your fast help!
  


Forum Jump:


Users browsing this thread:
1 Guest(s)