WebGL Extensioneer - Easier WebGL Extensions

Jul. 31, 2012
comments

Handling WebGL extensions is a big of a headache becuse of vendor prefixes, which the Khronos WebGL working group choose to conflate with the meaning of experimental (draft) extensions. In order to solve this problem I've written a small library to get rid of the need to use vendor extension names, yet be able to specify if you want draft extensions as well.

Contents

Source

You'll find the sourcecode for this library on github

Usage

Include the library in your page.

<script src="webgl-extensioneer.js"></script>

Use extensions as before

var fptex = gl.getExtension('OES_texture_float');
var anisotropic = gl.getExtension(
    'EXT_texture_filter_anisotropic'
); //will likely be null

Also get draft extensions

var anisotropic = gl.getExtension(
    'EXT_texture_filter_anisotropic', {draft:true}
);

API

  • getExtension(name, [specification])
  • specification: object

Specification defaults to

  • draft: false
  • approved: true
  • ref: 'browser' or 'spec', defaults to 'browser', if you set it to 'spec' you will need to regularly update your copy of the library.

The test performed is to only return extensions if they match the specification (i.e. setting approved to false will not return approved extensions)

License

Copyright (c) 2012, Florian Boesch http://codeflow.org/

WebGL Extensioneer is licensed under any of the following licenses at your choosing:

  • MIT: see mit-license
  • GPL: see gpl-license
  • BSD: see bsd-license