m.gl.js

please.gl.set_context

please.gl.set_context (canvas_id, options)

This function is used for setting the current rendering context (which canvas element M.GRL will be drawing to), as well as creating the “gl” namespace (window.gl, not please.gl), which is used extensively by M.GRL, and therefor this function is usually the first thing your program should call.

Please note that this method can only be called once, and if it is called, please.dom.set_context may not be used.

The “options” paramater is an object which is passed to the canvas.getContext function, but may be omitted if you do not wish to initialize the rendering context with any special options. For more details see:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext

please.gl.get_program

please.gl.get_program (name)

Returns an object representing a compiled shader program.

If ‘name’ is null, the currently active shader program is returned, if applicable.

If ‘name’ is a string, then this function returns the shader program that shares the same name.

If ‘name’ is an array of source URI, then this function will return a shader program that was built from the named sources if one exists.

If no applicable shader program can be found, this function returns null.

please.set_clear_color

please.set_clear_color (red, green, blue, alpha)

This function wraps gl.clearColor. You should use this version if you want mgrl to automatically set the “mgrl_clear_color” uniform in your shader program.

please.gl.get_texture

please.gl.get_texture (uri, use_placeholder, no_error)

Helper function for creating texture objects from the asset cache. Calls please.load if the uri was not already loaded. This method is mostly used internally.

please.gl.nearest_power

please.gl.nearest_power (number)

Returns the lowest power of two that is greater than or equal to the number passed to this function.

please.glsl

please.glsl (name /*, shader_a, shader_b,... */)

Constructor function for building a shader program. Give the program a name (for caching), and pass any number of shader objects to the function.

please.gl.vbo

please.gl.vbo (vertex_count, attr_map, options)

Create a VBO from attribute array data.

please.gl.ibo

please.gl.ibo (data, options)

Create a IBO.

please.gl.blank_texture

please.gl.blank_texture (options)

Create a new render texture. This is mostly intended to be used by please.gl.register_framebuffer

please.gl.register_framebuffer

please.gl.register_framebuffer (handle, options)

Create a new framebuffer with a render texture attached.

please.gl.set_framebuffer

please.gl.set_framebuffer (handle)

Set the current render target. If ‘handle’ is null, then direct rendering will be used.

please.gl.reset_viewport

please.gl.reset_viewport ()

Reset the viewport dimensions so that they are synced with the rendering canvas’s dimensions.

Usually, this function is called when the canvas has been resized.

please.gl.make_quad

please.gl.make_quad * **(width, height, origin, draw_hint)*

Create and return a vertex buffer object containing a square. This generates vertices and normals, but not texture coordinates.

please.gl.splat

please.gl.splat ()

Splat fills the screen with fragments. Useful for postprocessing effects.

please.gl.pick

please.gl.pick (x, y)

Returns the RGBA formatted color value for the given x/y coordinates in the canvas. X and Y are within the range 0.0 to 1.0.