A framebuffer that can be used as target for rendering.

There is no pre-defined width and height, instead, the textures provided with setColorTexture() and setDepthTexture() defines the target resolution.

Static methods

@:value({ type : "unsigned_byte", alphaChannel : true })staticcreate2D(width:Int, height:Int, alphaChannel:Bool = true, type:String = "unsigned_byte"):FoxFramebuffer

Convenience method to create a 2D framebuffer (no depth nor stencil attached)

@:value({ type : "unsigned_byte", alphaChannel : true })staticcreate3D(width:Int, height:Int, alphaChannel:Bool = true, type:String = "unsigned_byte"):FoxFramebuffer

Convenience method to create a 3D framebuffer (depth+stencil buffers attached)

@:value({ precision : "32F", bufferCount : 1 })staticcreateDeferred(width:Int, height:Int, bufferCount:Int = 1, precision:String = "32F"):FoxFramebuffer

Convenience method to create a Deferred 3D framebuffer

Deferred Rendering is a technique where lighting calculations are postponed until after all the geometry has been processed.

To do this we need multiple buffers to store information and combine them in the passes.

By default, FoxLite shaders and passes are all Forward Rendered, meaning lighting happens when the geometry is rendered.

Note: This requires GL_EXT_draw_buffers extension support in the OpenGL context, otherwise no data will be writen to the buffers other than the first one.

Note 2: Alpha channel will be always available for extra storage.

If bufferCount is 0, only the depth buffer will be attached to the framebuffer, which may not work on all platforms.

staticcreateShadowMap(width:Int, height:Int):FoxFramebuffer

Convenience method to create a shadowmap with the minimal amount of memory usage

This creates a depth texture and a single channel color texture for compatibility.

Constructor

new()

Variables

@:value(null)glTexture:Texture = null

@:value(null)stencilBuffer:GLRenderbuffer = null

@:value(null)depthBuffer:FoxTexture = null

@:value([])colorBuffers:Array<FoxTexture> = []

@:value(false)hasDepth:Bool = false

@:value(false)hasStencil:Bool = false

@:value(null)context:Context3D = null

@:value([])drawBuffers:Array<Int> = []

read onlywidth:Int

read onlyheight:Int

Methods

privateget_width():Int

privateget_height():Int

private__initTexture():Void

@:value({ withStencil : true })setDepthTexture(?texture:FoxTexture, withStencil:Bool = true):Bool

Attaches a depth texture to this framebuffer.

Setting texture to null removes the attachment.

Parameters:

texture

A valid FoxTexture

Returns:

true if the framebuffer attachment has been successful

setColorTexture(index:Int, ?texture:FoxTexture):Bool

Attaches a color texture to this framebuffer, you can also specify a color buffer output (first attachment MUST be 0)

Setting texture to null removes the attachment.

Parameters:

texture

A valid FoxTexture

Returns:

true if the framebuffer attachment has been successful

resize(newWidth:Int, newHeight:Int):Void

Warning! This will resize all color buffers aswell as the depth and stencil buffers if attached!

Intended for output framebuffers only!

@:value({ y : 0, x : 0 })readPixels(x:Int = 0, y:Int = 0, ?width:Int, ?height:Int):UInt8Array

Reads a region of the framebuffer texture in the GPU and stores it in a buffer.

This function isn't properly implemented yet.

Note: This operation is slow!

Parameters:

x

The X coordinate of the region

y

The Y coordinate of the region

width

The Width of the region

height

The Height of the region

@:value({ y : 0, x : 0 })readDepth(x:Int = 0, y:Int = 0, ?width:Int, ?height:Int):Float32Array

Same as readPixels() but for the depth buffer instead (if attached)

Note: This operation is slow!

Note 2: Due to WebGL limitations, this does not work in HTML5.

Returns:

a Float32Array containing depth values

isCubemap():Bool

@:value({ destroyBuffers : false })destroy(destroyBuffers:Bool = false):Void