-
7.0.0
Support for uploading mipmaps in 1 call.
As it was you could upload individual mips by calling
setTextureFromElementorsetTextureFromArraybut not really fromcreateTexture,createTextures. Those 2 functions would callgl.generateMipmapfor you though if it was possible and you didn't specifically opt out.Now,
createTexture,createTextures, andsetTextureFromArray, if passed an array or typedarray assrc, will attempt to fill mip levels based on how much data you pass in.So for example, an RGBA8 10x7 texture takes
- (10x7)x4 - 280bytes for mip level 0
- (5x3)x4 - 60bytes for mip level 1
- (2x1)x4 - 8bytes for mip level 2
- (1x1)x4 - 4bytes for mip level 3
So:
-
If you pass in 280+60+8+4 or 352 bytes then all 4 mips will be filled out.
-
If you pass 348 bytes then the first 3 levels will be filled out.
-
If you pass 72 bytes and pass
level: 1then the last 3 mips will be filled out.(note: you would likely only do this with
setTextureFromArray)
For this to work, you must pass in a
widthandheightbecause otherwise, twgl guesses the size of the texture based on the size of the data.Note that this also works for compressed textures. You must pass blocks worth of data. Following the same pattern if you were using a texture format that has 4x4 blocks and each block is 8 bytes then, if you had a 12x8 texture
- (12x8) is 3x2 blocks * 8 bytes per block = 48 bytes
- (6x4) is 2x1 blocks * 8 bytes per block = 16 bytes
- (3x2) is 1 block * 8 bytes per block = 8 bytes
- (1x1) is 1 block * 8 bytes per block = 8 bytes
So if you pass in (48+16+8+8) or 80 bytes then twgl will upload to all 4 mip levels.
Note though that this is a breaking change! This is because before this change, if you called
createTextureand passed inwidth: 4, height: 4, src: someUint8ArrayOf100Bytestwgl would just use the first 64 bytes. Now though it would error out trying to use the first 64 bytes for mip level 0, then the next 16 bytes for mip level 1, then the next 4 bytes mip level 1. Which is different than what it used to do. -
6.2.0
Support compressed textures
-
6.1.1
Fix bug in
createProgramif you pass it an existing shader -
6.1.0
Added
createTextureAsyncandcreateTexturesAsync -
6.0.0
Internal change.
gl.pixelStoreistate forUNPACK_COLORSPACE_CONVERSION_WEBGLUNPACK_PREMULTIPLY_ALPHA_WEBGLandUNPACK_FLIP_Y_WEBGLis now saved and restored as the previous behavior had a race condition.Before v6.0.0
t1 = twgl.createTexture(gl, {src: 'https://p.com/slow.jpg'}); // may or may not be flipped!!!! t2 = twgl.createTexture(gl, {src: 'https://p.com/fast.jpg', flipY: true }); // flipped
In the example above, whether or not
t1is flipped was unknown since ift2loads first, it would be flipped. Ift1loads first it would not be flipped.The fix is to save and restore the
pixelStoreistate for each texture.Unfortunately, this is a breaking change.
Before v6.0.0
twgl.createTexture(gl, {src: someImageElem1, flipY: true }); // flipped twgl.createTexture(gl, {src: someImageElem2 }); // also flipped
From v6.0.0 on
twgl.createTexture(gl, {src: someImage, flipY: true }); // flipped twgl.createTexture(gl, {src: someImage }); // NOT flipped
Note: in all versions the behavior was and still is, that if you set the
pixelStoreiparameters outside they applied.gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true) twgl.createTexture(gl, {src: someImage }); // flipped twgl.createTexture(gl, {src: someImage }); // flipped
-
5.6.0
Support offsets and shared buffers in uniform block infos.
-
5.5.0
add
compareModeandcompareFuncto texture options -
5.4.0
- Keep JSDoc docstrings in .d.ts files
-
5.3.1
- Add missing
drawTypeto FullArraySpec - Allow binding null for a texture in
setUniformsfor texture arrays
- Add missing
-
5.3.0
- Allow binding null for a texture in
setUniforms
- Allow binding null for a texture in
-
5.2.0
- added
createPrograms,createProgramInfos,createProgramsAsync, andcreateProgramInfosAsync
- added
-
5.1.0
- Allow FullArraySpec.type to be typedArray type or GL type
-
5.0.2
- Make isX functions (internal) work across realms
-
5.0.0
-
Always set attribute divisor if it exists
This is a breaking change since before twgl didn't set the divisors if you didn't assign an divisor to an attribute.
-
-
4.24.0
- Have createFramebufferInfo call drawBuffers
-
4.23.0
- Add async shader compilation support
-
4.22.0
- Add samples to attachment options
-
4.21.0
- Add support for partial uniform paths.
-
4.20.0
- Add support for more easily setting uniform and uniform block structures and arrays.
-
4.19.5
- Fix issue with uniform blocks and built-in uniforms
-
4.19.4
- Fix JSDocs for blockspec and related stuff
- Fix more Uniform Block padding issues.
- Add browser testing infrastructure.
-
4.19.2
- WebGLObject -> WebGLTexture|WebGLRenderbuffer for typescript
- Fix glEnumToString for non-number
-
4.19.0
- Reset UNPACK_SKIP_etc... state to defaults
-
4.18.0
- Fixed padding issue with arrays in uniform blocks
-
4.17.0
- better errors for shaders
-
4.16.1
- fix how twgl figures out a uniform is an array
-
4.16.0
- support WebGL1 depth textures 😅
-
4.15.2
- fix s/texTarget/target/ on use of AttachmentOptions
-
4.15.0
- Allow anything not otherwise handled to be sent to
texImage2Das aTexImageSource
- Allow anything not otherwise handled to be sent to
-
4.14.2
- Add width and height to FrameBufferInfo docs
- Adjust normals on cone
-
4.14.0
- Use constants everywhere. eg
TEXTURE_2Dinstead ofgl.TEXTURE_2D
- Use constants everywhere. eg
-
4.13.1
- Make AttachmentOptions extend TextureOptions
-
4.13.0
- Made
resizeTexturehandle3Dand2D_ARRAY.
- Made
-
4.12.0
- Add es6 module
-
4.11.5
- Fix type info for
m4.setAxis
- Fix type info for
-
4.11.4
-
add
nullas parameter tobindFramebufferInfo -
fix return types of
createXYQuadBufferInfoandcreateXYQuadBuffers
-
-
4.11.3
- fix issues with TEXTURE_2D_ARRAY and arrays
-
4.11.0
- Support
layerattachment option forcreateFramebufferInfo
- Support
-
4.10.0
- Support constant attribute values for float, vec2, vec3 (used to only support vec4)
-
4.9.4
- Make helper.js more node friendly
-
4.9.3
- Use instanceof Type in helper.js
-
4.9.2
- Add .map to twgl-base npm package
-
4.9.0
-
added v3.lerpV, v3.min, v3.max
-
fixed issue with urlISSameDomain on servers
-
-
4.8.2
-
Fixed IE URL issue
-
Fixed building with new JS
-
-
4.8.0
- add typescript types
-
4.7.0
- expose
getFormatAndTypeForInternalFormat,canFilter, andcanGenerateMipmap.
- expose
-
4.6.0
-
Crossorigin settings for images are now automatic by default
-
Fixed bug in
getShaderTypeFromScriptType
-
-
4.5.0
- Add support for constant attributes
-
4.4.0
-
Support passing arrays of
TexImageSourcetocreateTexture(s). -
Fix callback arguments for cubemaps and slices
-
-
4.3.2
- Support slicing image in workers.
-
4.3.1
- Make TWGL work in workers.
-
4.3.0
- Remove references to
windowso twgl can be used in workers
- Remove references to
-
4.2.0
- add
EXT_color_buffer_float,WEBGL_compressed_texture_s3tc_srgb, andEXT_disjoint_timer_query_webgl2totwgl.addExtensionsToContext.
- add
-
4.1.0
-
Added
twgl.glEnumToStringThis was an internal function used to make a few error messages more useful but might as well export it.
-
Fix bug in
resizeTexturefor WebGL2.
-
-
4.0.1
- Added check for built in uniforms and attributes
-
4.0.0
-
Switch to es6 modules for source
Webpack still builds UMD version
-
-
3.8.0
- Add
SharedArrayBuffersupport
- Add
-
3.7.1
- Fix
ortho
- Fix
-
3.7.0
-
Support instances with
drawBufferInfoanddrawObjectList. -
Support passing a multiplier smaller than 1 to
resizeCanvasToDisplaySize.
-
-
3.6.0
-
Added
twgl.addExtensionsToContextAdds most extensions directly on the context so they have the same API as WebGL2 or OpenGL ES 3.0
-
Added instancing support
Added
divisortoAttribInfoandFullArraySpecand calls togl.vertexAttribDivisor. NOTE: It's up to you to clear the divisor. You can either use vertex array objects (recommended) OR setdivisorto 0 otherAttribInfos etc. (not recommended)
-
-
3.5.0
- Added
leveltoTextureOptions
- Added
-
3.4.1
-
use
getBoundingClientRectforresizeCanvasToDisplaySizeunlike
clientWidthandclientHeight,getBoundingClientRectreturns fractional dimensions. This is important when passing in devicePixelRatio to calculate and actual native size.
-
-
3.4.0
- Support
minMagfor framebuffers
- Support
-
3.3.0
-
Make
createProgramaccept ids, source, and shaders as input.This kind of removes the need for
createProgramFromSourcesandcreateProgramFromScripts
-
-
3.1.0
-
Add support for transform feedback
At least an attempt at something. I'd need more examples of how it's used to see if it fits.
-
-
3.0.0
-
Fix package.json
It was pointing to
distinstead ofdist/2.x. Because that means fixing it will bump users of npm 2.x from 1.x to 2.x I had to bump to 3.x because and a breaking change.
-
-
2.8.2
- Use spec compatible texSubImage3D parameters
-
2.8.1
-
Fill out TEXTURE_2D_ARRAY with first image
This is so there is something to render in all slices
-
-
2.8
-
Add support for TEXTURE_2D_ARRAY
You can pass a list of images to
twgl.createTextureand it will load each image into a slice of aTEXTURE_2D_ARRAYif the target isTEXTURE_2D_ARRAY
-
-
2.7
-
mangle some property names
saves about 4k
-
add
minMagproperty toTextureOptionsIt sets both
TEXTURE_MIN_FILTERandTEXTURE_MAG_FILTER -
Change texture filtering to use internalFormat
In WebGL1 we checked power of 2 in width and height. In WebGL2 we check if the internal format supports filtering. This might break things going from WebGL1 to WebGL2 if you expected a non-power-of-2 texture to use gl.LINEAR.
Note: One issue is TWGL can't tell if you've enabled
OES_texture_float_linearso you use float textures it can't tell if it can generate mips or not and you'll have to be explicit with texture settings. Currently it assumes you can generate mips. Pass inauto: falsetocreateTexture(s)if you didn't enableOES_texture_float_linearor similarly for half float formats. -
Support samplers
-
Support webgl2 texture formats
-
-
2.6.2
- remove "experimental-webgl2" which never existed
-
2.6.1
- allow offset=0 in setAttributeInfoBufferFromArray
-
2.6
- make createBuffersFromArrays add a numElements and elementType properties.
-
2.5
- switch to webpack + babel
-
2.4
- Support int attributes
-
2.3
- Make all
createProgramXXXfunctions take aProgramOptionsargument
- Make all
-
2.1
- Made guessing numComponents for attributes case insensitive as well ask looking for "text" and "colour"
-
2.0
-
Changed
m4.multiplyto match most other math libraries.m4.multiply(a, b)was multiplyingbon the left. Now it's doing the more standard thing of multiplyingbon the right.For example this means these 2 statements are equivalent
m4.multiply(someMatrix, m4.translation([1, 2, 3])); m4.translate(someMatrix, [1, 2, 3]);In 1.x the first statement would have been
m4.multiply(m4.translation([1, 2, 3]), someMatrix); -
Changed
twgl.drawBufferInfoso second argument isBufferInfoIn other words in 1.x it was
twgl.drawBufferInfo(gl, primitiveType, bufferInfo)Now in 2.x it's
twgl.drawBufferInfo(gl, bufferInfo, primitiveType)This lets
primitiveTypebe optional with the default beinggl.TRIANGLES.
-
-
1.9
-
support
mat2,mat3, andmat4attributes -
allow buffer offsets for
UniformBlockInfos
-
-
1.8
-
framebuffers have better texture defaults
before 1.8 textures created for framebuffers used the texture defaults which meant power of 2 dimensions got mips. As of 1.8 twgl only creates mip level 0 by default for framebuffer textures.
-
-
1.7
- Add support for 3d textures (WebGL2)
-
1.6
-
Made
createProgramInfoandcreateProgramXXXmulti-signaturetwgl.createProgramInfo(gl, [vs, fs], opt_errFunc); twgl.createProgramInfo(gl, [vs, fs], opt_attribs, opt_errFunc); twgl.createProgramInfo(gl, [vs, fs], opt_attribs, opt_locations, opt_errFunc);
-
-
1.5
- separated twgl src into more modules
-
1.4
- add Vertex Array Object support