public override void PreDraw(UISpriteBatch batch) { if (!Visible) { return; } base.PreDraw(batch); if (Mask) { var gd = batch.GraphicsDevice; var size = Size; if (Target == null || (int)size.X != Target.Width || (int)size.Y != Target.Height) { Target?.Dispose(); Target = new RenderTarget2D(gd, (int)size.X, (int)size.Y, false, SurfaceFormat.Color, DepthFormat.None); } batch.End(); gd.SetRenderTarget(Target); gd.Clear(Color.Transparent); var pos = LocalPoint(0, 0); batch.Begin(transformMatrix: Microsoft.Xna.Framework.Matrix.CreateTranslation(-pos.X, -pos.Y, 0), blendState: BlendState.AlphaBlend, sortMode: SpriteSortMode.Deferred); batch.GraphicsDevice.RasterizerState = RasterizerState.CullNone; _Draw(batch); batch.End(); gd.SetRenderTarget(null); } }
public override void PreDraw(UISpriteBatch batch) { //If our matrix is dirty, recalculate it if (_MtxDirty) { CalculateMatrix(); } if (!Visible) { return; } var gd = batch.GraphicsDevice; if (Invalidated) { var size = Size * Scale; if (Target == null || (int)size.X != Target.Width || (int)size.Y != Target.Height) { Target?.Dispose(); Target = new RenderTarget2D(gd, (int)size.X, (int)size.Y, false, SurfaceFormat.Color, (UseZ)?DepthFormat.Depth24:DepthFormat.None); } lock (Children) { foreach (var child in Children) { if (child == DynamicOverlay) { continue; } child.PreDraw(batch); } } batch.End(); gd.SetRenderTarget(Target); gd.Clear(ClearColor); var pos = LocalPoint(0, 0); batch.Begin(transformMatrix: Microsoft.Xna.Framework.Matrix.CreateTranslation(-(pos.X - BackOffset.X), -(pos.Y - BackOffset.Y), 0), blendState: BlendState.AlphaBlend, sortMode: SpriteSortMode.Deferred); batch.GraphicsDevice.RasterizerState = RasterizerState.CullNone; lock (Children) { foreach (var child in Children) { if (child == DynamicOverlay) { continue; } child.Draw(batch); } } batch.End(); gd.SetRenderTarget(null); Invalidated = false; } DynamicOverlay.PreDraw(batch); }
public override void Removed() { base.Removed(); Target?.Dispose(); Batch?.Dispose(); Target = null; Batch = null; }
private void CheckTargets(RenderTarget2D target) { if (_preCompositorTarget == null || _preCompositorTarget.Width != target.Width || _preCompositorTarget.Height != target.Height) { _preCompositorTarget?.Dispose(); _preCompositorTarget = new RenderTarget2D(GraphicsDevice, target.Width, target.Height); } if (_worldTempTarget == null || _worldTempTarget.Width != target.Width || _worldTempTarget.Height != target.Height) { _worldTempTarget?.Dispose(); _worldTempTarget = new RenderTarget2D(GraphicsDevice, target.Width, target.Height); } }
public void PreRender(SpriteBatch sb, Rectangle window) { if (_currentRect.Size.Equals(window.Size)) { return; } _currentRect = new Rectangle(Point.Zero, window.Size); _cachedBackground?.Dispose(); _cachedBackground = new RenderTarget2D(sb.GraphicsDevice, window.Width, window.Height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); sb.GraphicsDevice.SetRenderTarget(_cachedBackground); sb.UsualBegin(); var columns = window.Width / Ui.Background.Width + 1; var rows = window.Height / Ui.Background.Height + 1; for (int y = 0; y < rows; y++) { for (int x = 0; x < columns; x++) { sb.Draw(_spriteSheet, new Vector2(x * Ui.Background.Width, y * Ui.Background.Height), Ui.Background, Color.White); } } sb.UsualEnd(); }
private void CreateRenderTargets(int width, int height) { _ssaoTarget?.Dispose(); _blurTarget?.Dispose(); _ssaoTarget = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None); _blurTarget = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None); }
private void CreateRenderTargets(int width, int height) { Colors?.Dispose(); Albedo?.Dispose(); Normals?.Dispose(); Depth?.Dispose(); #if OPENGL Colors = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); Albedo = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); Normals = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8); Depth = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8); #else Colors = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8); Albedo = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8); Normals = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8); Depth = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8); #endif _bufferTextureSize = new Vector2(width, height); _gBufferTargets = new[] { new RenderTargetBinding(Colors), new RenderTargetBinding(Normals), new RenderTargetBinding(Depth), new RenderTargetBinding(Albedo) }; _lightMap?.Dispose(); _lightMap = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); }
public LoadingScreen(GraphicsDevice graphics) { #if !(LINUX || OSX) if (GameMain.Config.EnableSplashScreen) { try { splashScreenVideo = GameMain.Instance.Content.Load <Video>("utg_4"); } catch (Exception e) { DebugConsole.ThrowError("Failed to load splashscreen", e); GameMain.Config.EnableSplashScreen = false; } } #endif backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png"); monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png"); titleTexture = TextureLoader.FromFile("Content/UI/titleText.png"); renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); GameMain.Instance.OnResolutionChanged += () => { renderTarget?.Dispose(); renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); }; DrawLoadingText = true; selectedTip = TextManager.Get("LoadingScreenTip", true); }
public override void Dispose() { base.Dispose(); LotThumbTarget?.Dispose(); ObjThumbTarget?.Dispose(); Dome?.Dispose(); }
public static int inc = 0; //todo remove this public void InitRT(Point baseSize) { Debug.WriteLine("Initting RenderTarget"); renderTarget?.Dispose(); renderTarget = new RenderTarget2D(Graphics.Device, baseSize.X / cameraTargetPixelSize, baseSize.Y / cameraTargetPixelSize, false, SurfaceFormat.Color, DepthFormat.Depth16, 0, RenderTargetUsage.PreserveContents); renderTarget.Name = inc++.ToString(); }
public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout) { var layoutWidth = layout.Width - skinLayout.HorizontalScrollBarHeight; var layoutHeight = layout.Height - skinLayout.VerticalScrollBarWidth; int childWidth, childHeight; if (!(_child is IHasDesiredSize)) { childWidth = layoutWidth; childHeight = layoutHeight; } else { var hasDesiredSize = (IHasDesiredSize)_child; childWidth = hasDesiredSize.GetDesiredWidth(skinLayout) ?? layoutWidth; childHeight = hasDesiredSize.GetDesiredHeight(skinLayout) ?? layoutHeight; if (childWidth < layoutWidth) { childWidth = layoutWidth; } if (childHeight < layoutHeight) { childHeight = layoutHeight; } } if (_renderTarget == null || _renderTarget.Width != childWidth || _renderTarget.Height != childHeight) { _renderTarget?.Dispose(); _renderTarget = new RenderTarget2D( context.GraphicsDevice, Math.Max(1, childWidth), Math.Max(1, childHeight)); } context.SpriteBatch.End(); context.PushRenderTarget(_renderTarget); context.GraphicsDevice.Clear(Color.Transparent); context.SpriteBatch.Begin(); try { _child?.Render( context, skinLayout, skinDelegator, new Rectangle(0, 0, childWidth, childHeight)); } finally { context.SpriteBatch.End(); context.PopRenderTarget(); context.SpriteBatch.Begin(); } skinDelegator.Render(context, layout, this); }
public virtual void Cleanup() { Context?.ClearState(); Context?.Flush(); BackBuffer?.Dispose(); BackBuffer = null; ZBuffer?.Dispose(); ZBuffer = null; RenderTargetViewRef?.Dispose(); RenderTargetViewRef = null; DepthStencilSRVRef?.Dispose(); DepthStencilSRVRef = null; DepthStencilViewRef?.Dispose(); DepthStencilViewRef = null; FactoryDWrite?.Dispose(); FactoryDWrite = null; Factory2D?.Dispose(); Factory2D = null; RenderTarget2D?.Dispose(); RenderTarget2D = null; Context?.Dispose(); DeviceRef?.Dispose(); DeviceRef = null; }
public void Dispose() { ShadowTarg?.Dispose(); ObjShadowTarg?.Dispose(); OutsideShadowTarg?.Dispose(); LightMap?.Dispose(); }
public override void Unload() { ItemHold.Clear(); try { Plugin.OnDisconnected(); } catch { } TargetManager.Reset(); // special case for wmap. this allow us to save settings UIManager.GetGump <WorldMapGump>() ?.SaveSettings(); ProfileManager.Current?.Save ( UIManager.Gumps.OfType <Gump>() .Where(s => s.CanBeSaved) .Reverse() .ToList() ); Macros.Save(); InfoBars.Save(); ProfileManager.UnLoadProfile(); StaticFilters.CleanCaveTextures(); StaticFilters.CleanTreeTextures(); NetClient.Socket.Disconnected -= SocketOnDisconnected; NetClient.Socket.Disconnect(); _lightRenderTarget?.Dispose(); _world_render_target?.Dispose(); CommandManager.UnRegisterAll(); Weather.Reset(); UIManager.Clear(); World.Clear(); UOChatManager.Clear(); DelayedObjectClickManager.Clear(); _useItemQueue?.Clear(); _useItemQueue = null; Hotkeys = null; Macros = null; MessageManager.MessageReceived -= ChatOnMessageReceived; Settings.GlobalSettings.WindowSize = new Point(Client.Game.Window.ClientBounds.Width, Client.Game.Window.ClientBounds.Height); Settings.GlobalSettings.IsWindowMaximized = Client.Game.IsWindowMaximized(); Client.Game.SetWindowBorderless(false); base.Unload(); }
protected override void Dispose(bool disposing) { SpriteBatch?.Dispose(); renderSurface?.Dispose(); graphics.Dispose(); AudioManager?.Dispose(); base.Dispose(disposing); }
public void Dispose() { ShadowTarg?.Dispose(); ObjShadowTarg?.Dispose(); OutsideShadowTarg?.Dispose(); OutsideShadowTargPost?.Dispose(); LightMap?.Dispose(); LightMapDirection?.Dispose(); }
public void SetWindowSize(int width, int height) { _graphicDeviceManager.PreferredBackBufferWidth = width; _graphicDeviceManager.PreferredBackBufferHeight = height; _graphicDeviceManager.ApplyChanges(); _buffer?.Dispose(); _buffer = new RenderTarget2D(GraphicsDevice, _graphicDeviceManager.PreferredBackBufferWidth, _graphicDeviceManager.PreferredBackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); }
public void Dispose() { text?.Dispose(); text = null; target?.Dispose(); target = null; Font = null; batch?.Dispose(); batch = null; }
public void ReallocateEffectBuffers(int width, int height) { _effectBuffer1?.Dispose(); _effectBuffer2?.Dispose(); _intermediate?.Dispose(); _effectBuffer1 = new RenderTarget2D(_gpu, width, height); _effectBuffer2 = new RenderTarget2D(_gpu, width, height); _intermediate = new RenderTarget2D(_gpu, width, height); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); RenderTarget2D?.Dispose(); RenderTarget2D = null; TilemapData?.Dispose(); TilemapData = null; }
public void Dispose() { _renderedText?.Dispose(); _renderedText = null; _renderTarget?.Dispose(); _renderTarget = null; Font = null; _sb?.Dispose(); _sb = null; }
private void CreateRenderTargets(GraphicsDevice graphics) { renderTarget?.Dispose(); renderTargetBackground?.Dispose(); renderTargetWater?.Dispose(); renderTargetFinal?.Dispose(); renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight); renderTargetFinal = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None); }
/// <summary> //Dispose our RenderTargets. This is not covered by the Garbage Collector so we have to do it manually /// </summary> public void Dispose() { _bloomRenderTarget2DMip0?.Dispose(); _bloomRenderTarget2DMip1?.Dispose(); _bloomRenderTarget2DMip2?.Dispose(); _bloomRenderTarget2DMip3?.Dispose(); _bloomRenderTarget2DMip4?.Dispose(); _bloomRenderTarget2DMip5?.Dispose(); _graphicsDevice?.Dispose(); _bloomEffect?.Dispose(); }
public void Dispose() { renderTarget?.Dispose(); if (LogicalNode is ImageNode) { primitive?.Dispose(); primitive = null; } renderTarget = null; LogicalNode = null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _renderTarget?.Dispose(); } _graphicsDeviceService?.Release(disposing); }
private void DestroySurfaces() { color?.Dispose(); depth?.Dispose(); normal?.Dispose(); specular?.Dispose(); colorAccum?.Dispose(); LumAccumulator?.Dispose(); LumStorage?.Dispose(); }
public void UpdateAOTarget() { _ambientOcclusionTarget?.Dispose(); int halfWidth = GameSettings.ao_HalfRes ? GameSettings.g_ScreenWidth / 2 : GameSettings.g_ScreenWidth; int halfHeight = GameSettings.ao_HalfRes ? GameSettings.g_ScreenHeight / 2 : GameSettings.g_ScreenHeight; _ambientOcclusionShader.Resolution = new Vector2(halfWidth, halfHeight); _ambientOcclusionTarget = new RenderTarget2D(_graphics, halfWidth, halfHeight, false, SurfaceFormat.Vector4, DepthFormat.Depth24Stencil8); _animatedModelShader.AoMap = _aoUseBlur ? _ambientOcclusionBlur1 : _ambientOcclusionTarget; }
private void EnsureRenderTargetSizing() { if (_worldTarget == null || _worldTarget.Width != GraphicsDevice.Viewport.Width || _worldTarget.Height != GraphicsDevice.Viewport.Height) { _worldTarget?.Dispose(); _worldTarget = new RenderTarget2D( GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); } }
private void CheckTarget(int drawWidth, int drawHeight) { if (_shadowBuffer?.Width != drawWidth || _shadowBuffer?.Height != drawHeight) { _shadowBuffer?.Dispose(); _shadowBuffer = new RenderTarget2D(GraphicsDevice, drawWidth, drawHeight); } if (_outputBuffer?.Width != drawWidth || _outputBuffer?.Height != drawHeight) { _outputBuffer?.Dispose(); _outputBuffer = new RenderTarget2D(GraphicsDevice, drawWidth, drawHeight); } }
public void Resize(int width, int height) { _view.Resize((uint)width, (uint)height); _renderTarget?.Dispose(); _renderTarget = null; _finalRenderTarget?.Dispose(); _finalRenderTarget = null; _renderTarget = _rn.CreateRenderTarget(width, height); _finalRenderTarget = _rn.CreateRenderTarget(width, height); }