This WebSharper Extension provides a set of classes and functions almost identical to the ones documented in glMatrix, version 2.2.0. When used in WebSharper projects, these stub classes delegate the work to the actual classes implemented by the browser.
After adding the reference to the project all the classes can be found
The GlMatrix WebSharper extension is as far as possible a one-to-one mapping of glMatrix. Therefore, this documentation will only discuss the differences between glMatrix and the WebSharper extension. For a complete reference, see the glMatrix homepage.
In order to enforce strong typing and take advantage of F# features such as method overloading, we made a few modifications over the glMatrix API.
Float32Arrayobjects, the WebSharper extension defines classes for each one of
Quad. These classes inherit from the standard
Float32Array, which allows you to pass them directly to WebGL methods such as the
As the name suggests, glMatrix is mainly intended as a toolbox for coordinate transformation for WebGL. The following example shows a typical use to set the projection and modelview matrices of a given WebGL shader program.
1 2 3 4 5 6 7 8 9 10 11
let SetupView (gl : WebGLRenderingContext, program : WebGLProgram) = // Set the projection matrix let proj = Mat4.Perspective(Mat4.Create(), 45., 4./3., 0.1, 1000.) let u_projection = gl.GetUniformLocation(program, "projectionMatrix") gl.UniformMatrix4fv(u_projection, false, proj) // Set the modelview matrix let cameraPosition = Mat4.Identity(Mat4.Create()) Mat4.Translate(cameraPosition, cameraPosition, Vec3.FromValues(0.2, 2.3, -5.2)) |> ignore let u_modelview = gl.GetUniformLocation(program, "modelviewMatrix") gl.UniformMatrix4fv(u_modelview, false, cameraPosition)