Context
A WebGL2 context on the web page's canvas.
Static methods
function hxnAdopt(hxnRaw:Handle):ContextAn object for a value the library returned.
function create():ContextA WebGL2 context on the web page's canvas. Throws when the browser has no WebGL2 or the page no canvas.
Properties
var hxnRaw:HandleMethods
function setSize(width:Int, height:Int):VoidSets the size of the canvas's drawing buffer, in pixels.
function width():IntThe width of the canvas's drawing buffer.
function height():IntThe height of the canvas's drawing buffer.
function renderer():StringGL_RENDERER.
function version():StringGL_VERSION.
function extensions():StringThe extensions WebGL2 supports here, separated by spaces.
function error():IntgetError: 0, or the first error since the last call.
function createBuffer(target:BufferTarget, size:Int64, usage:Usage):BufferA buffer of size bytes, zeroed, for target.
function createBufferWith(target:BufferTarget, bytes:Bytes, usage:Usage):BufferA buffer holding bytes, for target.
function createTexture(width:Int, height:Int, format:TextureFormat):TextureA 2D texture of one level, with immutable storage.
function createSampler(min:Filter, mag:Filter, wrapS:Wrap, wrapT:Wrap):SamplerA sampler with these filters and wrap modes.
function createProgram(vertex:String, fragment:String):ProgramA program linked from GLSL ES 3.00 vertex and fragment sources. Compile and link errors are thrown with WebGL's log.
function createVertexArray():VertexArrayAn empty vertex array.
function createFramebuffer(color:Texture):FramebufferA framebuffer rendering into color. Throws unless it is complete.
function bindFramebuffer(framebuffer:Framebuffer):VoidRenders into framebuffer from now on.
function bindDefaultFramebuffer():VoidRenders into the web page's canvas from now on.
function viewport(x:Int, y:Int, width:Int, height:Int):Voidfunction scissor(x:Int, y:Int, width:Int, height:Int):Voidfunction clear(bits:Int, r:Float, g:Float, b:Float, a:Float):VoidClears the bound framebuffer's color, depth or stencil: bits are ClearBits or-ed together.
function useProgram(program:Program):Voidfunction bindVertexArray(vertexArray:VertexArray):Voidfunction bindUniformBuffer(index:Int, buffer:Buffer):VoidBinds buffer to uniform buffer binding point index.
function bindTexture(unit:Int, texture:Texture, sampler:Sampler):VoidBinds texture and sampler to texture unit unit.
function drawArrays(primitive:Primitive, first:Int, count:Int, instances:Int):VoiddrawArraysInstanced.
function drawElements(primitive:Primitive, count:Int, kind:ComponentType, offset:Int, instances:Int):VoiddrawElementsInstanced, with indices from the bound vertex array's element buffer, starting offset bytes in.
function readPixels(x:Int, y:Int, width:Int, height:Int):BytesThe 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():Voidflush.
function finish():Voidfinish.
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():VoidShows 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():VoidReleases the native value now. The collector does it otherwise. Using this object afterwards throws.