Skip to content

Commit a7706f6

Browse files
committed
bump to v7.0.0
1 parent 2b0e1da commit a7706f6

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

CHANGELIST.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
# Change List
22

3+
* 7.0.0
4+
5+
Support for uploading mipmaps in 1 call.
6+
7+
As it was you could upload individual mips by calling `setTextureFromElement` or `setTextureFromArray`
8+
but not really from `createTexture`, `createTextures`. Those 2 functions would call `gl.generateMipmap`
9+
for you though if it was possible and you didn't specifically opt out.
10+
11+
Now, `createTexture`, `createTextures`, and `setTextureFromArray`, if passed an array or typedarray as `src`,
12+
will attempt to fill mip levels based on how much data you pass in.
13+
14+
So for example, an RGBA8 10x7 texture takes
15+
16+
* (10x7)x4 - 280bytes for mip level 0
17+
* (5x3)x4 - 60bytes for mip level 1
18+
* (2x1)x4 - 8bytes for mip level 2
19+
* (1x1)x4 - 4bytes for mip level 3
20+
21+
So:
22+
23+
* If you pass in 280+60+8+4 or 352 bytes then all 4 mips will be filled out.
24+
* If you pass 348 bytes then the first 3 levels will be filled out.
25+
* If you pass 72 bytes and pass `level: 1` then the last 3 mips will be filled out.
26+
27+
(note: you would likely only do this with `setTextureFromArray`)
28+
29+
For this to work, you must pass in a `width` and `height` because otherwise, twgl guesses the size of the texture based
30+
on the size of the data.
31+
32+
Note that this also works for compressed textures. You must pass blocks worth of data.
33+
Following the same pattern if you were using a texture format that has 4x4 blocks and each
34+
block is 8 bytes then, if you had a 12x8 texture
35+
36+
* (12x8) is 3x2 blocks * 8 bytes per block = 48 bytes
37+
* (6x4) is 2x1 blocks * 8 bytes per block = 16 bytes
38+
* (3x2) is 1 block * 8 bytes per block = 8 bytes
39+
* (1x1) is 1 block * 8 bytes per block = 8 bytes
40+
41+
So if you pass in (48+16+8+8) or 80 bytes then twgl will upload to all 4 mip levels.
42+
43+
Note though that this is a breaking change! This is because before this change, if you
44+
called `createTexture` and passed in `width: 4, height: 4, src: someUint8ArrayOf100Bytes`
45+
twgl would just use the first 64 bytes. Now though it would error out trying to use the first
46+
64 bytes for mip level 0, then the next 16 bytes for mip level 1, then the next 4 bytes mip
47+
level 1. Which is different than what it used to do.
48+
349
* 6.2.0
450

551
Support compressed textures

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twgl.js",
3-
"version": "6.2.0",
3+
"version": "7.0.0",
44
"description": "A Tiny WebGL helper library",
55
"main": "dist/6.x/twgl-full.js",
66
"types": "dist/6.x/twgl-full.d.ts",

0 commit comments

Comments
 (0)