/// <summary> /// calculates a new shadow. /// </summary> public void ResetShadow() { ShadowDirty = false; if (!Shadow) { return; } GLShader SaveShader = this.Shader; RenderKind = RenderKind.Render; Matrix SaveP = ProjectionMatrix; Texture SaveTexture = texture; GL.Enable(EnableCap.PolygonOffsetFill); GL.PolygonOffset(1, 0); Shader = ShadowDepthShader; ProjectionMatrix = GetLightProjectionMatrix(); ShadowFBO.EnableWriting(); OnPaint(); ShadowFBO.DisableWriting(); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, ShadowFBO.FboTexture); ProjectionMatrix = SaveP; Shader = SaveShader; GL.ActiveTexture(TextureUnit.Texture0); }
Texture GetPatternTexture(OpenGlDevice Device) { Texture Save = Device.texture; if (Pattern == null) { return(null); } Rectangled R = new Rectangled(Pattern.PatternX, Pattern.PatternY, Pattern.PatternWidth, Pattern.PatternHeight); FBO FrameBuffer = new FBO(); FrameBuffer.BackGround = System.Drawing.Color.Transparent; Device.PushMatrix(); xyz RU = new xyz(R.Width, R.Height, 0); xyz RD = new xyz(R.X, R.Y, 0); Point _RU = Device.ToScr(RU); Point _RD = Device.ToScr(RD); FrameBuffer.Init((int)(_RU.X - _RD.X), (int)(_RD.Y - _RU.Y)); FrameBuffer.EnableWriting(); Pattern.Paint(Device); Device.PopMatrix(); FrameBuffer.DisableWriting(); Texture result = FrameBuffer.Texture; Device.texture = Save; result.WorldWidth = R.Width; result.WorldHeight = R.Height; result.Translation = new xy(R.X, R.Y); FrameBuffer.Dispose(true); return(result); }
/// <summary> /// plays the scene in Bitmap. /// </summary> /// <returns></returns> public Bitmap ScreenShot() { FBO FrameBuffer = new FBO((int)ViewPort.Width, (int)ViewPort.Height); Texture Save = texture; FrameBuffer.EnableWriting(); Refresh(); FrameBuffer.DisableWriting(); texture = Save; Bitmap Result = FrameBuffer.ReadBitmap(); FrameBuffer.Dispose(); return(Result); }