public void ResizeBuffer(int bufferIndex, int width, int height) { var buffer = Buffers[bufferIndex]; if (buffer.Width != width || buffer.Height != height) { Buffers[bufferIndex] = PPXDepthEngine.CreateRenderTarget(Device, 1, 0, buffer.Format, width, height, buffer.DepthStencilFormat); buffer.Dispose(); } }
private void gd_DeviceReset(object sender, EventArgs e) { Invalidated = true; Buffers.Clear(); for (var i = 0; i < 3; i++) { Buffers.Add( PPXDepthEngine.CreateRenderTarget(base.GraphicsDevice, 1, 0, SurfaceFormat.Color, Width, Height, DepthFormat.None) ); } Invalidated = false; }
/// <summary> /// Creates a UISpriteBatch. Same as spritebatch with some extra functionality /// required by the UI system of this game. /// /// NumBuffers refers to a number of RenderTarget2D objects to create up front. /// These should be used for temp rendering for special effects. E.g. rendering /// part of the GUI to a texture and then painting it with opacity onto the main /// target. /// </summary> /// <param name="gd"></param> /// <param name="numBuffers">The number of rendering buffers to pre-alloc</param> public UISpriteBatch(GraphicsDevice gd, int numBuffers, int width, int height, int multisample) : base(gd) { _Width = width; _Height = height; for (var i = 0; i < numBuffers; i++) { Buffers.Add( PPXDepthEngine.CreateRenderTarget(gd, 1, multisample, SurfaceFormat.Color, width, height, DepthFormat.None) ); } base.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(gd_DeviceReset); }
public void GenBuffers(int bwidth, int bheight) { foreach (var buffer in Buffers) { buffer.Dispose(); } Buffers.Clear(); ResetMatrices(bwidth, bheight); ScreenWidth = bwidth; ScreenHeight = bheight; for (var i = 0; i < NumBuffers; i++) { int width = bwidth + ScrollBuffer; int height = bheight + ScrollBuffer; switch (i) { case 2: //World2D.BUFFER_OBJID width = 1; height = 1; break; case 3: //World2D.BUFFER_THUMB case 4: width = 1024; height = 1024; break; case 5: width = 576; height = 576; break; } if (NumBuffers == 2) { width = height = 1024; //special case, thumb only. } var depthformat = FSOEnvironment.SoftwareDepth ? DepthFormat.Depth24Stencil8 : DepthFormat.Depth24; //stencil is used for software depth Buffers.Add( PPXDepthEngine.CreateRenderTarget(Device, 1, 0, SurfaceFormats[i], width, height, (AlwaysDS[i] || (!FSOEnvironment.UseMRT && !FSOEnvironment.SoftwareDepth)) ? depthformat : DepthFormat.None) ); } }
public _2DWorldBatch(GraphicsDevice device, int numBuffers, SurfaceFormat[] surfaceFormats, bool[] alwaysDS, int scrollBuffer) { this.Device = device; this.Effect = WorldContent._2DWorldBatchEffect; //TODO: World size Sprites = new List <_2DSpriteGroup>(); ScrollBuffer = scrollBuffer; ResetMatrices(device.Viewport.Width, device.Viewport.Height); ScreenWidth = device.Viewport.Width; ScreenHeight = device.Viewport.Height; for (var i = 0; i < numBuffers; i++) { int width = device.Viewport.Width + scrollBuffer; int height = device.Viewport.Height + scrollBuffer; switch (i) { case 4: //World2D.BUFFER_OBJID width = 1; height = 1; break; case 0: //World2D.BUFFER_THUMB case 10: width = 1024; height = 1024; break; case 11: width = 1024; height = 1024; break; } if (numBuffers == 2 && i == 1) { width = height = 1024; //special case, thumb only. } Buffers.Add( PPXDepthEngine.CreateRenderTarget(device, 1, 0, surfaceFormats[i], width, height, (alwaysDS[i] || (!FSOEnvironment.UseMRT && !FSOEnvironment.SoftwareDepth))?DepthFormat.Depth24Stencil8:DepthFormat.None) ); } }
public void ResizeBuffer(int width, int height) { _Width = width; _Height = height; var numBuffers = AllBuffers.Count; foreach (var buf in AllBuffers) { buf.Dispose(); } Buffers.Clear(); AllBuffers.Clear(); for (var i = 0; i < numBuffers; i++) { Buffers.Add( PPXDepthEngine.CreateRenderTarget(base.GraphicsDevice, 1, 0, SurfaceFormat.Color, Width, Height, DepthFormat.None) ); } AllBuffers = new List <RenderTarget2D>(Buffers); }