public override void Begin()
        {
            base.Begin();

            if (_retain)
            {
                //TODO - frugalize me
                if (rt != null)
                    rt.Dispose();
                rt = GL.CreateRenderTarget(Width, Height);
                rt.Bind();
            }
        }
Esempio n. 2
0
		public void FreeRenderTarget(RenderTarget rt)
		{
			//not needed 1st pass ??
			//int id = rt.Id.ToInt32();
			//var rtw = ResourceIDs.Lookup[id] as RenderTargetWrapper;
			//rtw.Target.Dispose();
			//ResourceIDs.Free(rt.Id);
		}
Esempio n. 3
0
		public void BindRenderTarget(RenderTarget rt)
		{
			_CurrRenderTarget = rt;
			if(rt == null)
				GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
			else
				GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, (int)rt.Opaque);
		}
Esempio n. 4
0
		public void FreeRenderTarget(RenderTarget rt)
		{
			rt.Texture2d.Dispose();
			GL.Ext.DeleteFramebuffer((int)rt.Opaque);
		}
Esempio n. 5
0
        public void BindRenderTarget(RenderTarget rt)
        {
            _CurrRenderTarget = rt;

            if (rt == null)
            {
                //this dispose is needed for correct device resets, I have no idea why
                //don't try caching it either
                var surface = _CurrentControl.SwapChain.GetBackBuffer(0);
                dev.SetRenderTarget(0, surface);
                surface.Dispose();

                dev.DepthStencilSurface = null;
                return;
            }

            //dispose doesn't seem necessary for reset here...
            var tw = rt.Opaque as TextureWrapper;
            dev.SetRenderTarget(0, tw.Texture.GetSurfaceLevel(0));
            dev.DepthStencilSurface = null;
        }
Esempio n. 6
0
        public unsafe RenderTarget CreateRenderTarget(int w, int h)
        {
            TextureWrapper tw = new TextureWrapper();
            tw.SDBitmap = new Bitmap(w,h, sdi.PixelFormat.Format32bppArgb);
            IntPtr texid = GenTexture();
            ResourceIDs.Lookup[texid.ToInt32()] = tw;
            var tex = new Texture2d(this, texid, null, w, h);

            var rt = new RenderTarget(this, ResourceIDs.Alloc(ResourceIdManager.EResourceType.RenderTarget), tex);
            int id = rt.Id.ToInt32();
            RenderTargetWrapper rtw = new RenderTargetWrapper(this);
            rtw.Target = rt;
            ResourceIDs.Lookup[id] = rtw;
            return rt;
        }
Esempio n. 7
0
 public RenderTargetWrapper RenderTargetWrapperForRt(RenderTarget rt)
 {
     return ResourceIDs.Lookup[rt.Id.ToInt32()] as RenderTargetWrapper;
 }
Esempio n. 8
0
		public void BindRenderTarget(RenderTarget rt)
		{
			if(rt == null)
				GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
			else
				GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, rt.Id.ToInt32());
		}
Esempio n. 9
0
 public void BindRenderTarget(RenderTarget rt)
 {
     //if (rt == null)
     //{
     //  //null means to use the default RT for the current control
     //  CurrentRenderTargetWrapper = CurrentControl.RenderTargetWrapper;
     //}
     //else
     //{
     //  CurrentRenderTargetWrapper = RenderTargetWrapperForRt(rt);
     //}
 }
Esempio n. 10
0
        public void FreeRenderTarget(RenderTarget rt)
        {
            var rtw = rt.Opaque as RenderTargetWrapper;

            rtw.Dispose();
        }
Esempio n. 11
0
		public void FreeRenderTarget(RenderTarget rt)
		{
			rt.Texture2d.Dispose();
			GL.Ext.DeleteFramebuffer(rt.Id.ToInt32());
		}
Esempio n. 12
0
 public void BindRenderTarget(RenderTarget rt)
 {
     if (rt == null)
     {
         //null means to use the default RT for the current control
         CurrentRenderTargetWrapper = CurrentControl.RenderTargetWrapper;
     }
     else
     {
         CurrentRenderTargetWrapper = RenderTargetWrapperForRt(rt);
     }
 }
Esempio n. 13
0
 public unsafe RenderTarget CreateRenderTarget(int w, int h)
 {
     Texture2d tex = null;
     var rt = new RenderTarget(this, ResourceIDs.Alloc(ResourceIdManager.EResourceType.RenderTarget), tex);
     int id = rt.Id.ToInt32();
     RenderTargetWrapper rtw = new RenderTargetWrapper(this);
     rtw.Target = rt;
     ResourceIDs.Lookup[id] = rtw;
     return rt;
 }
Esempio n. 14
0
 public RenderTarget CreateRenderTarget(int w, int h)
 {
     var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
     var tw = new TextureWrapper() { Texture = d3dtex };
     var tex = new Texture2d(this, tw, w, h);
     RenderTarget rt = new RenderTarget(this, tw, tex);
     ResetHandlers.Add(rt, "RenderTarget",
         () =>
         {
             d3dtex.Dispose();
             tw.Texture = null;
         },
         () =>
         {
             d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
             tw.Texture = d3dtex;
         }
     );
     return rt;
 }
Esempio n. 15
0
		public RenderTarget CreateRenderTarget(int w, int h)
		{
			var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
			var tw = new TextureWrapper() { Texture = d3dtex };
			var tex = new Texture2d(this, tw, w, h);
			RenderTarget rt = new RenderTarget(this, tw, tex);
			return rt;
		}
Esempio n. 16
0
		public void FreeRenderTarget(RenderTarget rt)
		{
			var rtw = rt.Opaque as RenderTargetWrapper;
			rtw.Dispose();
		}
Esempio n. 17
0
		public void BindRenderTarget(RenderTarget rt)
		{
			_CurrRenderTarget = rt;

			if (rt == null)
			{
				var bb = _CurrentControl.SwapChain.GetBackBuffer(0);
				dev.SetRenderTarget(0, bb);
				bb.Dispose();
				dev.DepthStencilSurface = null;
				return;
			}

			var tw = rt.Opaque as TextureWrapper;
			//TODO - cache surface level in an RT wrapper
			dev.SetRenderTarget(0, tw.Texture.GetSurfaceLevel(0));
			dev.DepthStencilSurface = null;
		}
Esempio n. 18
0
		public unsafe RenderTarget CreateRenderTarget(int w, int h)
		{
			TextureWrapper tw = new TextureWrapper();
			tw.SDBitmap = new Bitmap(w,h, sdi.PixelFormat.Format32bppArgb);
			var tex = new Texture2d(this, tw, w, h);

			RenderTargetWrapper rtw = new RenderTargetWrapper(this);
			var rt = new RenderTarget(this, rtw, tex);
			rtw.Target = rt;
			return rt;
		}
Esempio n. 19
0
 public void FreeRenderTarget(RenderTarget rt)
 {
     int id = rt.Id.ToInt32();
     var rtw = ResourceIDs.Lookup[id] as RenderTargetWrapper;
     ResourceIDs.Free(rt.Id);
 }
Esempio n. 20
0
		public void BindRenderTarget(RenderTarget rt)
		{
			if (_CurrentOffscreenGraphics != null)
			{
				_CurrentOffscreenGraphics.Dispose();
				_CurrentOffscreenGraphics = null;
			}

			_CurrRenderTarget = rt;
			if (CurrentRenderTargetWrapper != null)
			{
				if (CurrentRenderTargetWrapper == CurrentControl.RenderTargetWrapper)
				{
					//dont do anything til swapbuffers
				}
				else
				{
					//CurrentRenderTargetWrapper.MyBufferedGraphics.Render();
				}
			}

			if (rt == null)
			{
				//null means to use the default RT for the current control
				CurrentRenderTargetWrapper = CurrentControl.RenderTargetWrapper;
			}
			else
			{
				var tw = rt.Texture2d.Opaque as TextureWrapper;
				CurrentRenderTargetWrapper = rt.Opaque as RenderTargetWrapper;
				_CurrentOffscreenGraphics = Graphics.FromImage(tw.SDBitmap);
				//if (CurrentRenderTargetWrapper.MyBufferedGraphics == null)
				//  CurrentRenderTargetWrapper.CreateGraphics();
			}
		}
Esempio n. 21
0
        public void BindRenderTarget(RenderTarget rt)
        {
            if (CurrentRenderTargetWrapper != null)
            {
                if (CurrentRenderTargetWrapper == CurrentControl.RenderTargetWrapper)
                {
                    //dont do anything til swapbuffers
                }
                else
                    CurrentRenderTargetWrapper.MyBufferedGraphics.Render();
            }

            if (rt == null)
            {
                //null means to use the default RT for the current control
                CurrentRenderTargetWrapper = CurrentControl.RenderTargetWrapper;
            }
            else
            {
                CurrentRenderTargetWrapper = RenderTargetWrapperForRt(rt);
                if (CurrentRenderTargetWrapper.MyBufferedGraphics == null)
                    CurrentRenderTargetWrapper.CreateGraphics();
            }
        }
Esempio n. 22
0
 public void FreeRenderTarget(RenderTarget rt)
 {
     rt.Texture2d.Dispose();
     GL.Ext.DeleteFramebuffer((int)rt.Opaque);
 }