private void InitCameraViewFromTarget() { int textureSize = 1024; cameraTexture = TextureManager.Instance.Create( TextureManager.Instance.GetUniqueName("RemoteView"), Texture.Type.Type2D, new Vec2I(textureSize, textureSize), 1, 0, PixelFormat.R8G8B8, Texture.Usage.RenderTarget); RenderTexture renderTexture = cameraTexture.GetBuffer().GetRenderTarget(); rmCamera = SceneManager.Instance.CreateCamera("RemoteView"); rmCamera.ProjectionType = ProjectionTypes.Perspective; rmCamera.PolygonMode = PolygonMode.Wireframe; renderTexture.AddViewport(rmCamera); }
/////////////// private bool CreateRenderTexture() { Vec2I size = new Vec2I(512, 256); string textureName = TextureManager.Instance.GetUniqueName("RenderToTextureExample"); texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, size, 1, 0, PixelFormat.R8G8B8, Texture.Usage.RenderTarget); if (texture == null) { return(false); } renderTexture = texture.GetBuffer().GetRenderTarget(); //you can update render texture manually by means renderTexture.Update() method. For this task set AutoUpdate = false; renderTexture.AutoUpdate = true; //create camera string cameraName = SceneManager.Instance.GetUniqueCameraName("RenderToTextureExample"); camera = SceneManager.Instance.CreateCamera(cameraName); camera.Purpose = Camera.Purposes.Special; camera.AllowMapCompositorManager = false; //add viewport viewport = renderTexture.AddViewport(camera); viewport.BackgroundColor = new ColorValue(0, 0, 0, 1); viewport.ShadowsEnabled = false; viewport.MaterialScheme = ""; //add listener renderTargetListener = new SceneRenderTargetListener(this); renderTexture.AddListener(renderTargetListener); return(true); }