public virtual void Dispose() { UnregisterRenderRequest(); if (FrontFbo != null) { FrontFbo.Dispose(); } if (BackFbo != null) { BackFbo.Dispose(); } if (FboMs != null) { FboMs.Dispose(); } Quad.Dispose(); GameObjectPainter.Dispose(); EffectPainter.Dispose(); PostprocessPainter.Dispose(); OverlayPainter.Dispose(); ImagePainter.Dispose(); }
public virtual void Init() { PositionCenterV = new Vector3(PositionCenterV2, !GameObjects.Use3D ? 2 : 2.4f); // Set up color and blending const int baseIntensity = 50; GL.ClearColor(System.Drawing.Color.FromArgb(baseIntensity, baseIntensity, baseIntensity)); GL.BlendEquation(BlendEquationMode.FuncAdd); // Set up framebuffers { bool newRes = FrontFbo == null || Resolution.Width != FrontFbo.Size.X || Resolution.Height != FrontFbo.Size.Y; if (newRes) { // Reallocate front fbo if (FrontFbo != null) { FrontFbo.Dispose(); } FrontFbo = new BasicFbo(Renderer.RenderTargetManager, (Vector2I)Resolution); // Reallocate back fbo; only if it was already allocated if (BackFbo != null) { BackFbo.Dispose(); } BackFbo = new BasicFbo(Renderer.RenderTargetManager, (Vector2I)Resolution); } // Reallocate MS fbo if (MultisampleLevel > 0) { int multisampleCount = 1 << (int)MultisampleLevel; // 4x to 32x (4 levels) if (newRes || FboMs == null || multisampleCount != FboMs.MultisampleCount) { if (FboMs != null) { FboMs.Dispose(); } FboMs = new BasicFboMultisample(Renderer.RenderTargetManager, (Vector2I)Resolution, multisampleCount); } // No need to enable Multisample capability, it is enabled automatically // GL.Enable(EnableCap.Multisample); } } // Setup geometry Quad = Renderer.GeometryManager.Get <Quad>(); GameObjectPainter.Init(Renderer, World, GameObjects); EffectPainter.Init(Renderer, World, Effects); PostprocessPainter.Init(Renderer, World, Postprocessing); OverlayPainter.Init(Renderer, World, Overlay); ImagePainter.Init(Renderer, World, Image); }