hxn

Context

A WebGL2 context on the web page's canvas.

Static methods

function hxnAdopt(hxnRaw:Handle):Context

An object for a value the library returned.

function create():Context

A WebGL2 context on the web page's canvas. Throws when the browser has no WebGL2 or the page no canvas.

Properties

var hxnRaw:Handle

Methods

function setSize(width:Int, height:Int):Void

Sets the size of the canvas's drawing buffer, in pixels.

function width():Int

The width of the canvas's drawing buffer.

function height():Int

The height of the canvas's drawing buffer.

function renderer():String

GL_RENDERER.

function version():String

GL_VERSION.

function extensions():String

The extensions WebGL2 supports here, separated by spaces.

function error():Int

getError: 0, or the first error since the last call.

function createBuffer(target:BufferTarget, size:Int64, usage:Usage):Buffer

A buffer of size bytes, zeroed, for target.

function createBufferWith(target:BufferTarget, bytes:Bytes, usage:Usage):Buffer

A buffer holding bytes, for target.

function createTexture(width:Int, height:Int, format:TextureFormat):Texture

A 2D texture of one level, with immutable storage.

function createSampler(min:Filter, mag:Filter, wrapS:Wrap, wrapT:Wrap):Sampler

A sampler with these filters and wrap modes.

function createProgram(vertex:String, fragment:String):Program

A program linked from GLSL ES 3.00 vertex and fragment sources. Compile and link errors are thrown with WebGL's log.

function createVertexArray():VertexArray

An empty vertex array.

function createFramebuffer(color:Texture):Framebuffer

A framebuffer rendering into color. Throws unless it is complete.

function bindFramebuffer(framebuffer:Framebuffer):Void

Renders into framebuffer from now on.

function bindDefaultFramebuffer():Void

Renders into the web page's canvas from now on.

function viewport(x:Int, y:Int, width:Int, height:Int):Void
function scissor(x:Int, y:Int, width:Int, height:Int):Void
function clear(bits:Int, r:Float, g:Float, b:Float, a:Float):Void

Clears the bound framebuffer's color, depth or stencil: bits are ClearBits or-ed together.

function useProgram(program:Program):Void
function bindVertexArray(vertexArray:VertexArray):Void
function bindUniformBuffer(index:Int, buffer:Buffer):Void

Binds buffer to uniform buffer binding point index.

function bindTexture(unit:Int, texture:Texture, sampler:Sampler):Void

Binds texture and sampler to texture unit unit.

function drawArrays(primitive:Primitive, first:Int, count:Int, instances:Int):Void

drawArraysInstanced.

function drawElements(primitive:Primitive, count:Int, kind:ComponentType, offset:Int, instances:Int):Void

drawElementsInstanced, with indices from the bound vertex array's element buffer, starting offset bytes in.

function readPixels(x:Int, y:Int, width:Int, height:Int):Bytes

The bound framebuffer's pixels in a rectangle, as 8-bit RGBA, bottom row first. On the canvas, read in the same frame as the drawing: the browser clears the canvas after showing it.

function flush():Void

flush.

function finish():Void

finish.

function claimCanvas():Future<Unit>

Takes the web page's canvas, which present shows the drawing buffer on. With threads the context draws on a canvas of its own, and fails here when the page has no canvas or another browser agent holds it; without, it settles at once.

function present():Void

Shows what was drawn into the default framebuffer on the web page's canvas. Without threads the browser shows it once the program returns to its event loop.

function completed():Future<Unit>

Settles when the GPU has finished every command so far, through a WebGL fence.

function close():Void

Releases the native value now. The collector does it otherwise. Using this object afterwards throws.