Namespace SpiderGL.WebGL.Context
The SpiderGL.WebGL.Context namespace.
- Defined in: webgl.js
Constructor Attributes | Constructor Name and Description |
---|---|
The SpiderGL.WebGL.Context namespace.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
SpiderGL.WebGL.Context.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL.
|
<static> |
SpiderGL.WebGL.Context.DEFAULT_UNPACK_FLIP_Y
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL.
|
<static> |
SpiderGL.WebGL.Context.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL.
|
<static> <constant> |
SpiderGL.WebGL.Context.WEBGL_STRING
The string for obtaining a WebGLRenderingContext from a canvas.
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
<static> |
SpiderGL.WebGL.Context.get(canvas, args)
Retrieves the WebGLRenderingContext from a canvas.
|
<static> |
SpiderGL.WebGL.Context.getHijacked(canvas, args)
Creates a WebGLRenderingContext and hijacks it.
|
<static> |
SpiderGL.WebGL.Context.hijack(gl)
Hijacks a WebGLRenderingContext for SpiderGL.WebGL.ObjectGL wrappers.
|
<static> |
SpiderGL.WebGL.Context.isHijacked(gl)
Tests whether a WebGLRenderingContext is hijacked.
|
<static> |
SpiderGL.WebGL.Context.setStandardGLUnpack(gl)
Sets pixel store unpack parameters to standard OpenGL SpiderGL values.
|
Namespace Detail
SpiderGL.WebGL.Context
The SpiderGL.WebGL.Context namespace.
Field Detail
<static>
SpiderGL.WebGL.Context.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL.
- See:
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_FLIP_Y
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
- SpiderGL.WebGL.Context.setStandardGLUnpack
- Default Value:
- WebGLRenderingContext.NONE
<static>
SpiderGL.WebGL.Context.DEFAULT_UNPACK_FLIP_Y
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL.
- See:
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_COLORSPACE_CONVERSION
- SpiderGL.WebGL.Context.setStandardGLUnpack
- Default Value:
- true
<static>
SpiderGL.WebGL.Context.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL.
- See:
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_FLIP_Y
- SpiderGL.WebGL.Context.DEFAULT_UNPACK_COLORSPACE_CONVERSION
- SpiderGL.WebGL.Context.setStandardGLUnpack
- Default Value:
- true
<static> <constant>
SpiderGL.WebGL.Context.WEBGL_STRING
The string for obtaining a WebGLRenderingContext from a canvas.
Method Detail
-
<static> {WebGLRenderingContext} SpiderGL.WebGL.Context.get(canvas, args)Retrieves the WebGLRenderingContext from a canvas. The WebGLRenderingContext is obtained by calling the getContext() method of the canvas object.
- Parameters:
- {HTMLCanvasElement} canvas
- The HTMLCanvasElement from which retrieve the WebGL context.
- {object} args
- The optional WebGL context arguments.
- Returns:
- {WebGLRenderingContext} The canvas WebGL rendering context.
- See:
- SpiderGL.WebGL.Context.hijack
- SpiderGL.WebGL.Context.getHijacked
-
<static> {WebGLRenderingContext} SpiderGL.WebGL.Context.getHijacked(canvas, args)Creates a WebGLRenderingContext and hijacks it. The WebGLRenderingContext obtained from the canvas parameter with optional arguments is hijacked.
- Parameters:
- {HTMLCanvasElement} canvas
- The HTMLCanvasElement from which retrieve the WebGL context.
- {object} args
- The optional WebGL context arguments.
- Returns:
- {WebGLRenderingContext} The hijacked canvas WebGL rendering context.
- See:
- SpiderGL.WebGL.Context.get
- SpiderGL.WebGL.Context.getHijacked
- SpiderGL.WebGL.Context.isHijacked
-
<static> {bool} SpiderGL.WebGL.Context.hijack(gl)Hijacks a WebGLRenderingContext for SpiderGL.WebGL.ObjectGL wrappers. The WebGLRenderingContext is modified to allow SpiderGL.WebGL.ObjectGL wrappers to be edited without explicit bind and without affecting the WebGL object bindings. Most WebGL objects follow the "bind to edit" / "bind to use" paradigm. This means that the object must be bound to the WebGL context to modify some parameter or its resource data. As a side effect, binding the object just to modify it has the same result of binding it to be used during rendering. To prevent this side effect, all the WebGLRenderingContext functions that bind and modify object parameters or data, as long as the rendering functions, are wrapped. This allows SpiderGL wrappers (derived from SpiderGL.WebGL.ObjectGL) to be edited without affecting the binding state of the WebGLRenderingContext. The following example clarifies how bindings are handled.
var textureA = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, textureA); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); // other texture calls var textureB = new SpiderGL.WebGL.Texture2D(gl, parameters); textureB.minFilter = gl.LINEAR; // textureB is hiddenly bound to modify the minification filter gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); // textureA is automatically re-bound to keep WebGL semantic textureB.magFilter = gl.LINEAR; // textureB is hiddenly bound to modify another parameter gl.drawArrays(gl.TRIANGLES, 0, 3); // textureA is automatically re-bound to keep WebGL semantic textureB.bind(); // bind textureB to WebGL, breaking the binding with textureA gl.drawArrays(gl.TRIANGLES, 0, 3); // textureA is used
- Parameters:
- {WebGLRenderingContext} gl
- The WebGLRenderingContext to modify.
- Returns:
- {bool} True on success, false if the gl argument is not valid or has already been modified.
- See:
- SpiderGL.WebGL.Context.isHijacked
- SpiderGL.WebGL.Context.getHijacked
- SpiderGL.WebGL.Context.get
- SpiderGL.WebGL.ObjectGL
-
<static> {bool} SpiderGL.WebGL.Context.isHijacked(gl)Tests whether a WebGLRenderingContext is hijacked. The WebGLRenderingContext is hijacked after a successful call to SpiderGL.WebGL.Context.hijack.
- Parameters:
- {WebGLRenderingContext} gl
- The WebGLRenderingContext to test.
- Returns:
- {bool} True on success, false if the gl argument is not valid or has already been modified.
- See:
- SpiderGL.WebGL.Context.hijack
- SpiderGL.WebGL.Context.getHijacked
- SpiderGL.WebGL.Context.get
-
<static> SpiderGL.WebGL.Context.setStandardGLUnpack(gl)Sets pixel store unpack parameters to standard OpenGL SpiderGL values. The parameters to be set are UNPACK_FLIP_Y_WEBGL (true), UNPACK_PREMULTIPLY_ALPHA_WEBGL (false) and UNPACK_COLORSPACE_CONVERSION_WEBGL (WebGLRenderingContext.NONE).
- Parameters:
- {WebGLRenderingContext} gl
- The target WebGLRenderingContext.