new WebGLHelper(opt_options)
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Options.
|
Extends
- module:ol/Disposable~Disposable
Methods
-
bindBuffer(buffer)
webgl/Helper.js, line 364 -
Just bind the buffer if it's in the cache. Otherwise create the WebGL buffer, bind it, populate it, and add an entry to the cache.
Name Type Description buffer
module:ol/webgl/Buffer~WebGLArrayBuffer Buffer.
-
createTexture(size, opt_data, opt_texture){WebGLTexture}
webgl/Helper.js, line 810 -
Will create or reuse a given webgl texture and apply the given size. If no image data specified, the texture will be empty, otherwise image data will be used and the
size
parameter will be ignored. Note: wrap parameters are set to clamp to edge, min filter is set to linear.Name Type Description size
Array.<number> Expected size of the texture
data
ImageData | HTMLImageElement | HTMLCanvasElement Image data/object to bind to the texture
texture
WebGLTexture Existing texture to reuse
Returns:
The generated texture
-
drawElements(start, end)
webgl/Helper.js, line 480 -
Execute a draw call based on the currently bound program, texture, buffers, attributes.
Name Type Description start
number Start index.
end
number End index.
-
enableAttributes(attributes)
webgl/Helper.js, line 773 -
Will enable the following attributes to be read from the currently bound buffer, i.e. tell the GPU where to read the different attributes in the buffer. An error in the size/type/order of attributes will most likely break the rendering and throw a WebGL exception.
Name Type Description attributes
Array.<module:ol/webgl/Helper~AttributeDescription> Ordered list of attributes to read from the buffer
-
finalizeDraw(frameState)
webgl/Helper.js, line 495 -
Apply the successive post process passes which will eventually render to the actual canvas.
Name Type Description frameState
current frame state
Name Type Description pixelRatio
number The pixel ratio of the frame.
time
number The time when rendering of the frame was requested.
viewState
module:ol/View~State The state of the current view.
animate
boolean coordinateToPixelTransform
module:ol/transform~Transform extent
null | module:ol/extent~Extent declutterItems
Array.<module:ol/PluggableMap~DeclutterItems> index
number layerStatesArray
Array.<module:ol/layer/Layer~State> layerIndex
number pixelToCoordinateTransform
module:ol/transform~Transform postRenderFunctions
Array.<module:ol/PluggableMap~PostRenderFunction> size
module:ol/size~Size tileQueue
module:ol/TileQueue~TileQueue usedTiles
Object.<string, Object.<string, boolean>> viewHints
Array.<number> wantedTiles
Object.<string, Object.<string, boolean>> -
flushBufferData(buffer)
webgl/Helper.js, line 385 -
Update the data contained in the buffer array; this is required for the new data to be rendered
Name Type Description buffer
module:ol/webgl/Buffer~WebGLArrayBuffer Buffer.
-
getAttributeLocation(name){number}
webgl/Helper.js, line 694 -
Will get the location from the shader or the cache
Name Type Description name
string Attribute name
Returns:
attribLocation
-
getCanvas(){HTMLCanvasElement}
webgl/Helper.js, line 506 -
Returns:
Canvas.
-
getGL(){WebGLRenderingContext}
webgl/Helper.js, line 515 -
Get the WebGL rendering context
Returns:
The rendering context.
-
getProgram(fragmentShaderSource, vertexShaderSource){WebGLProgram}
webgl/Helper.js, line 643 -
Create a program for a vertex and fragment shader. The shaders compilation may have failed: use
WebGLHelper.getShaderCompileErrors()
to have details if any.Name Type Description fragmentShaderSource
string Fragment shader source.
vertexShaderSource
string Vertex shader source.
Returns:
Program
-
getShaderCompileErrors(){string|null}
webgl/Helper.js, line 671 -
Will return the last shader compilation errors. If no error happened, will return null;
Returns:
Errors description, or null if last compilation was successful
-
getUniformLocation(name){WebGLUniformLocation}
webgl/Helper.js, line 681 -
Will get the location from the shader or the cache
Name Type Description name
string Uniform name
Returns:
uniformLocation
-
makeProjectionTransform(frameState, transform){module:ol/transform~Transform}
webgl/Helper.js, line 709 -
Modifies the given transform to apply the rotation/translation/scaling of the given frame state. The resulting transform can be used to convert world space coordinates to view coordinates.
Name Type Description frameState
module:ol/PluggableMap~FrameState Frame state.
transform
module:ol/transform~Transform Transform to update.
frameState.pixelRatio
number The pixel ratio of the frame.
frameState.time
number The time when rendering of the frame was requested.
frameState.viewState
module:ol/View~State The state of the current view.
frameState.animate
boolean frameState.coordinateToPixelTransform
module:ol/transform~Transform frameState.extent
null | module:ol/extent~Extent frameState.declutterItems
Array.<module:ol/PluggableMap~DeclutterItems> frameState.index
number frameState.layerStatesArray
Array.<module:ol/layer/Layer~State> frameState.layerIndex
number frameState.pixelToCoordinateTransform
module:ol/transform~Transform frameState.postRenderFunctions
Array.<module:ol/PluggableMap~PostRenderFunction> frameState.size
module:ol/size~Size frameState.tileQueue
module:ol/TileQueue~TileQueue frameState.usedTiles
Object.<string, Object.<string, boolean>> frameState.viewHints
Array.<number> frameState.wantedTiles
Object.<string, Object.<string, boolean>> Returns:
The updated transform object.
-
prepareDraw(frameState)
webgl/Helper.js, line 419 -
Clear the buffer & set the viewport to draw. Post process passes will be initialized here, the first one being bound as a render target for subsequent draw calls.
Name Type Description frameState
current frame state
Name Type Description pixelRatio
number The pixel ratio of the frame.
time
number The time when rendering of the frame was requested.
viewState
module:ol/View~State The state of the current view.
animate
boolean coordinateToPixelTransform
module:ol/transform~Transform extent
null | module:ol/extent~Extent declutterItems
Array.<module:ol/PluggableMap~DeclutterItems> index
number layerStatesArray
Array.<module:ol/layer/Layer~State> layerIndex
number pixelToCoordinateTransform
module:ol/transform~Transform postRenderFunctions
Array.<module:ol/PluggableMap~PostRenderFunction> size
module:ol/size~Size tileQueue
module:ol/TileQueue~TileQueue usedTiles
Object.<string, Object.<string, boolean>> viewHints
Array.<number> wantedTiles
Object.<string, Object.<string, boolean>> -
setUniformFloatValue(uniform, value)
webgl/Helper.js, line 731 -
Give a value for a standard float uniform
Name Type Description uniform
string Uniform name
value
number Value
-
setUniformMatrixValue(uniform, value)
webgl/Helper.js, line 741 -
Give a value for a standard matrix4 uniform
Name Type Description uniform
string Uniform name
value
Array.<number> Matrix value
-
useProgram(program){boolean}
webgl/Helper.js, line 605 -
Use a program. If the program is already in use, this will return
false
.Name Type Description program
WebGLProgram Program.
Returns:
Changed.