public override bool Upload() { if (isDisposed) { return(false); } lock (this) { if (dataToBeUploaded != null) { parent.SetData(dataToBeUploaded, bounds, levelToBeUploaded, formatToBeUploaded); parent.Upload(); dataToBeUploaded = null; return(true); } } return(false); }
internal RenderTarget2D(TextureGlSingle texture, RenderbufferInternalFormat?renderBufferType = null) { Texture = texture; this.renderBufferType = renderBufferType; viewport = new Rectangle(0, 0, Width, Height); // Make sure the texture is generated and allocated to the proper size. Texture.SetData(new byte[0]); Texture.Upload(); if (OsuGlControl.CanUseFBO) { lastFrameBuffer = currentFrameBuffer; currentFrameBuffer = frameBuffer = GL.GenFramebuffer(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, All.ColorAttachment0, TextureTarget2d.Texture2D, Texture.TextureId, 0); OsuGlControl.BindTexture(0); if (renderBufferType != null) { renderBuffer = GL.GenRenderbuffer(); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, renderBuffer); GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.DepthComponent16, Width, Height); GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, All.DepthAttachment, RenderbufferTarget.Renderbuffer, renderBuffer); TotalRenderBuffers++; } currentFrameBuffer = lastFrameBuffer; GL.BindFramebuffer(FramebufferTarget.Framebuffer, lastFrameBuffer); TotalFrameBuffers++; } SetCopyRectangle(); }