///<summary> /// This function acts very similar to <see cref="GLES2FBORenderTexture.AttachDepthBuffer">The difference between D3D & OGL is that D3D setups the DepthBuffer before rendering, /// while OGL setups the DepthBuffer per FBO. So the DepthBuffer (RenderBuffer) needs to /// be attached for OGL. ///</summary> ///<param name="depthBuffer"> </param> public void AttachDepthBuffer(DepthBuffer depthBuffer) { var glDepthBuffer = depthBuffer as GLES2DepthBuffer; GL.BindFramebuffer(GLenum.Framebuffer, this._multiSampleFB > 0 ? this._multiSampleFB : this._fb); GLES2Config.GlCheckError(this); if (glDepthBuffer != null) { GLES2RenderBuffer depthBuf = glDepthBuffer.DepthBuffer; GLES2RenderBuffer stencilBuf = glDepthBuffer.StencilBuffer; //Attach depth buffer, if it has one. if (depthBuf != null) { depthBuf.BindToFramebuffer(GLenum.DepthAttachment, 0); } //Attach stencil buffer, if it has one. if (stencilBuf != null) { stencilBuf.BindToFramebuffer(GLenum.StencilAttachment, 0); } } else { GL.FramebufferRenderbuffer(GLenum.Framebuffer, GLenum.DepthAttachment, GLenum.Renderbuffer, 0); GLES2Config.GlCheckError(this); GL.FramebufferRenderbuffer(GLenum.Framebuffer, GLenum.StencilAttachment, GLenum.Renderbuffer, 0); GLES2Config.GlCheckError(this); } }
public GLES2SurfaceDesc RequestRenderBuffer(GLenum format, int width, int height, int fsaa) { var retVal = new GLES2SurfaceDesc(); retVal.buffer = null; if (format != GLenum.None) { var key = new RBFormat(format, width, height, fsaa); if (this.renderBufferMap.ContainsKey(key)) { retVal.buffer = this.renderBufferMap[key].buffer; retVal.zoffset = 0; retVal.numSamples = fsaa; } else { //New one var rb = new GLES2RenderBuffer(format, width, height, fsaa); this.renderBufferMap.Add(key, new RBRef(rb)); retVal.buffer = rb; retVal.zoffset = 0; retVal.numSamples = fsaa; } } return(retVal); }
/// <summary> /// </summary> /// <param name="poolId"> </param> /// <param name="renderSystem"> </param> /// <param name="creatorContext"> </param> /// <param name="depth"> </param> /// <param name="stencil"> </param> /// <param name="width"> </param> /// <param name="height"> </param> /// <param name="fsaa"> </param> /// <param name="multiSampleQuality"> </param> /// <param name="isManual"> </param> public GLES2DepthBuffer(PoolId poolId, GLES2RenderSystem renderSystem, GLES2Context creatorContext, GLES2RenderBuffer depth, GLES2RenderBuffer stencil, int width, int height, int fsaa, int multiSampleQuality, bool isManual) : base(poolId, 0, width, height, fsaa, "", isManual) { this._creatorContext = creatorContext; this._multiSampleQuality = multiSampleQuality; this._depthBuffer = depth; this._stencilBuffer = stencil; this._renderSystem = renderSystem; if (this._depthBuffer != null) { switch (this._depthBuffer.GLFormat) { case OpenTK.Graphics.ES20.All.DepthComponent16: bitDepth = 16; break; case GLenum.DepthComponent24Oes: case GLenum.DepthComponent32Oes: case GLenum.Depth24Stencil8Oes: //Packed depth / stencil bitDepth = 32; break; } } }
protected override void dispose(bool disposeManagedResources) { if (this._stencilBuffer != null && this._stencilBuffer != this._depthBuffer) { this._stencilBuffer.Dispose(); this._stencilBuffer = null; } if (this._depthBuffer == null) { this._depthBuffer.Dispose(); this._depthBuffer = null; } base.dispose(disposeManagedResources); }
/// <summary> /// </summary> /// <param name="poolId"> </param> /// <param name="renderSystem"> </param> /// <param name="creatorContext"> </param> /// <param name="depth"> </param> /// <param name="stencil"> </param> /// <param name="width"> </param> /// <param name="height"> </param> /// <param name="fsaa"> </param> /// <param name="multiSampleQuality"> </param> /// <param name="isManual"> </param> public GLES2DepthBuffer( PoolId poolId, GLES2RenderSystem renderSystem, GLES2Context creatorContext, GLES2RenderBuffer depth, GLES2RenderBuffer stencil, int width, int height, int fsaa, int multiSampleQuality, bool isManual ) : base( poolId, 0, width, height, fsaa, "", isManual ) { this._creatorContext = creatorContext; this._multiSampleQuality = multiSampleQuality; this._depthBuffer = depth; this._stencilBuffer = stencil; this._renderSystem = renderSystem; if ( this._depthBuffer != null ) { switch ( this._depthBuffer.GLFormat ) { case OpenTK.Graphics.ES20.All.DepthComponent16: bitDepth = 16; break; case GLenum.DepthComponent24Oes: case GLenum.DepthComponent32Oes: case GLenum.Depth24Stencil8Oes: //Packed depth / stencil bitDepth = 32; break; } } }
public DepthBuffer CreateDepthBufferFor( RenderTarget renderTarget ) { GLES2DepthBuffer retVal = null; //Only FBO & ppbuffer support different depth buffers, so everything //else creates dummy (empty containers GLES2FrameBufferObject fbo = null; fbo = (GLES2FrameBufferObject) renderTarget[ "FBO" ]; if ( fbo != null ) { // Presence of an FBO means the manager is an FBO Manager, that's why it's safe to downcast // Find best depth & stencil format suited for the RT's format GLenum depthFormat = GLenum.None, stencilFormat = GLenum.None; ( this.rttManager as GLES2FBOManager ).GetBestDepthStencil( fbo.Format, ref depthFormat, ref stencilFormat ); var depthBuffer = new GLES2RenderBuffer( depthFormat, fbo.Width, fbo.Height, fbo.FSAA ); GLES2RenderBuffer stencilBuffer = depthBuffer; if ( stencilBuffer != null ) { stencilBuffer = new GLES2RenderBuffer( stencilFormat, fbo.Width, fbo.Height, fbo.FSAA ); } //No "custom-quality" multisample for now in GL retVal = new GLES2DepthBuffer( 0, this, this.currentContext, depthBuffer, stencilBuffer, fbo.Width, fbo.Height, fbo.FSAA, 0, false ); } return retVal; }
public RBRef(GLES2RenderBuffer buffer) { this.buffer = buffer; this.refCount = 1; }
public RBRef(GLES2RenderBuffer buffer, int refCount) { this.buffer = buffer; this.refCount = refCount; }
public GLES2SurfaceDesc RequestRenderBuffer( GLenum format, int width, int height, int fsaa ) { var retVal = new GLES2SurfaceDesc(); retVal.buffer = null; if ( format != GLenum.None ) { var key = new RBFormat( format, width, height, fsaa ); if ( this.renderBufferMap.ContainsKey( key ) ) { retVal.buffer = this.renderBufferMap[ key ].buffer; retVal.zoffset = 0; retVal.numSamples = fsaa; } else { //New one var rb = new GLES2RenderBuffer( format, width, height, fsaa ); this.renderBufferMap.Add( key, new RBRef( rb ) ); retVal.buffer = rb; retVal.zoffset = 0; retVal.numSamples = fsaa; } } return retVal; }
public RBRef( GLES2RenderBuffer buffer ) { this.buffer = buffer; this.refCount = 1; }
public RBRef( GLES2RenderBuffer buffer, int refCount ) { this.buffer = buffer; this.refCount = refCount; }
protected override void dispose( bool disposeManagedResources ) { if ( this._stencilBuffer != null && this._stencilBuffer != this._depthBuffer ) { this._stencilBuffer.Dispose(); this._stencilBuffer = null; } if ( this._depthBuffer == null ) { this._depthBuffer.Dispose(); this._depthBuffer = null; } base.dispose( disposeManagedResources ); }