public override Endogine.BitmapHelpers.PixelDataProvider TransformIntoRenderTarget(Endogine.BitmapHelpers.PixelDataProvider pdp) { Surface surf = ((PixelDataProvider)pdp).Texture.GetSurfaceLevel(0); bool isTarget = ((int)surf.Description.Usage & (int)Usage.RenderTarget) != 0; if (isTarget) { return(pdp); } Surface oldSurfRT = this._device.GetRenderTarget(0); PixelDataProvider pdpRT = new PixelDataProvider(pdp.Width, pdp.Height, pdp.BitsPerPixel / 8, this._device, Usage.RenderTarget); this.RenderTarget = pdpRT; Endogine.SpriteRenderStrategy rs = this.CreateRenderStrategy(); rs.Init(); rs.SetPixelDataProvider(pdp); ERectangleF rctDrawTarget = new ERectangleF(0, 0, pdp.Width, pdp.Height);//-pdp.Width, -pdp.Height, pdp.Width * 2, pdp.Height * 2) * 2; //rs.SourceClipRect = sourceClipRect; rs.CalcRenderRegion(rctDrawTarget, 0, new EPoint(), new EPoint(pdp.Width, pdp.Height)); //render: this.PreUpdate(); rs.SubDraw(); this.EndUpdate(); //reset renderer and finish up: this._device.SetRenderTarget(0, oldSurfRT); this.PostUpdate(); return(pdpRT); }
public void OnPaint(System.Windows.Forms.PaintEventArgs e) { //TODO: DK Ej OnPaint!! //Application.DoEvents(); System.Drawing.Point pnt = this.Stage.RenderControl.PointToScreen(new Point(0, 0)); m_pntMouseLoc.X = System.Windows.Forms.Form.MousePosition.X - pnt.X; m_pntMouseLoc.Y = System.Windows.Forms.Form.MousePosition.Y - pnt.Y; if (Stage == null) { return; } if (EnterFrameEvent != null) { EnterFrameEvent(); } if (m_bSendMouseEventsToSprites || true) //TODO: .... { Stage.RootSprite.CheckChildrenMouse(new MouseEventArgs(System.Windows.Forms.Control.MouseButtons, 0, m_pntMouseLoc.X, m_pntMouseLoc.Y, 0), m_pntMouseLoc.ToEPointF(), false, m_bMouseDown); //TODO: unnecessary to check sprites again. Optimize! ArrayList aSprites = Stage.RootSprite.GetSpritesUnderLoc(m_pntMouseLoc.ToEPointF(), 1); if (aSprites.Count > 0 && ((Sprite)aSprites[0]).Cursor != null) { object cursor = ((Sprite)aSprites[0]).Cursor; if (cursor.GetType() == typeof(System.Windows.Forms.Cursor)) { this.Stage.RenderControl.Cursor = (System.Windows.Forms.Cursor)cursor; } } else { this.Stage.RenderControl.Cursor = System.Windows.Forms.Cursors.Default; } } //TODO: remove, just testing renderToTexture: bool renderToTexture = false; // (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift); if (renderToTexture) { //this.Stage.Capture(); Endogine.BitmapHelpers.PixelDataProvider pdp = this.Stage.CreatePixelDataProvider(256, 256, 4); this.Stage.RenderTarget = pdp; } this._stage.Update(); if (renderToTexture) { this.Stage.RenderTarget = null; } }
public override Endogine.BitmapHelpers.PixelDataProvider UglyConvertRenderTargetToReadable(Endogine.BitmapHelpers.PixelDataProvider pdpTarget) { PixelDataProvider pdp3DTarget = (PixelDataProvider)pdpTarget; //http://www.gamedev.net/community/forums/topic.asp?topic_id=388869 //http://www.gamedev.net/community/forums/topic.asp?topic_id=384658&whichpage=1& //http://www.gamedev.net/community/forums/topic.asp?topic_id=388736 //TODO: EXTREMELY ugly!! First copy to system memory, then back to card!! Surface sfSrc = pdp3DTarget.Texture.GetSurfaceLevel(0); //this._device.StretchRectangle(sfSrc, new System.Drawing.Rectangle(0,0,pdpTarget.Width,pdpTarget.Height), Surface sfDst = this._device.CreateOffscreenPlainSurface(pdp3DTarget.Width, pdp3DTarget.Height, pdp3DTarget.SurfaceDescription.Format, Pool.SystemMemory); //Pool.SystemMemory Managed this._device.GetRenderTargetData(sfSrc, sfDst); //Surface sfDst2 = new Surface(this._device, //SurfaceLoader.FromSurface(sfDst2, Texture tx = new Texture(this._device, pdp3DTarget.Width, pdp3DTarget.Height, 1, Usage.None, pdp3DTarget.SurfaceDescription.Format, Pool.Managed); //this._device.UpdateSurface(sfDst, sf); //unsafe //{ // byte* ptr; // //byte[] array = (byte[])ptr; // Buffer.BlockCopy(ptr, 0, ptr, 0, 20000); //} PixelDataProvider pdpCP = new PixelDataProvider(sfDst); Endogine.BitmapHelpers.Canvas cCP = Endogine.BitmapHelpers.Canvas.Create(pdpCP); cCP.Locked = true; PixelDataProvider pdp = new PixelDataProvider(tx); Endogine.BitmapHelpers.Canvas c1 = Endogine.BitmapHelpers.Canvas.Create(pdp); c1.Locked = true; for (int y = c1.Height - 1; y >= 0; y--) { for (int x = c1.Width - 1; x >= 0; x--) { c1.SetPixel(x, y, cCP.GetPixel(x, y)); } } c1.Locked = false; cCP.Locked = false; //return pdpCP; return(pdp); }
public override Endogine.BitmapHelpers.PixelDataProvider TransformIntoRenderTarget(Endogine.BitmapHelpers.PixelDataProvider pdp) { Surface surf = ((PixelDataProvider)pdp).Texture.GetSurfaceLevel(0); bool isTarget = ((int)surf.Description.Usage & (int)Usage.RenderTarget) != 0; if (isTarget) return pdp; Surface oldSurfRT = this._device.GetRenderTarget(0); PixelDataProvider pdpRT = new PixelDataProvider(pdp.Width, pdp.Height, pdp.BitsPerPixel / 8, this._device, Usage.RenderTarget); this.RenderTarget = pdpRT; Endogine.SpriteRenderStrategy rs = this.CreateRenderStrategy(); rs.Init(); rs.SetPixelDataProvider(pdp); ERectangleF rctDrawTarget = new ERectangleF(0,0, pdp.Width, pdp.Height);//-pdp.Width, -pdp.Height, pdp.Width * 2, pdp.Height * 2) * 2; //rs.SourceClipRect = sourceClipRect; rs.CalcRenderRegion(rctDrawTarget, 0, new EPoint(), new EPoint(pdp.Width, pdp.Height)); //render: this.PreUpdate(); rs.SubDraw(); this.EndUpdate(); //reset renderer and finish up: this._device.SetRenderTarget(0, oldSurfRT); this.PostUpdate(); return pdpRT; }
public override void SetPixelDataProvider(Endogine.BitmapHelpers.PixelDataProvider pdp) { }
/// <summary> /// Use instead of SetMember when members aren't applicable (e.g. when using rendering without Endogine game loop and sprite system) /// </summary> /// <param name="pdp"></param> abstract public void SetPixelDataProvider(Endogine.BitmapHelpers.PixelDataProvider pdp);
public override void SetValue(string name, Endogine.BitmapHelpers.PixelDataProvider val) { this._effect.SetValue(name, ((PixelDataProvider)val).Texture); }
public virtual Endogine.BitmapHelpers.PixelDataProvider TransformIntoRenderTarget(Endogine.BitmapHelpers.PixelDataProvider pdp) { return(pdp); }
/// <summary> /// Extremely ugly - needed because a RenderTarget obviously can't be readable. Ugly! An abomination! Only implemented for Direct3D renderer, others return the rendertarget. /// </summary> /// <returns></returns> public virtual Endogine.BitmapHelpers.PixelDataProvider UglyConvertRenderTargetToReadable(Endogine.BitmapHelpers.PixelDataProvider pdpTarget) { return(this.RenderTarget); }
public override void SetPixelDataProvider(Endogine.BitmapHelpers.PixelDataProvider pdp) { this.OnCreateVertexBuffer(_vertexBuffer, null); this._tx = ((PixelDataProvider)pdp).Texture; }
public abstract void SetValue(string name, Endogine.BitmapHelpers.PixelDataProvider val);