({ levels, format, dataType, width, height })
| 944 | } |
| 945 | |
| 946 | createMipmapTextureHandle({ levels, format, dataType, width, height }) { |
| 947 | const gl = this.GL; |
| 948 | const texture = gl.createTexture(); |
| 949 | |
| 950 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 951 | |
| 952 | // Determine GL format and data type |
| 953 | const glFormat = gl.RGBA; |
| 954 | const glDataType = gl.UNSIGNED_BYTE; |
| 955 | |
| 956 | for (let level = 0; level < levels.length; level++) { |
| 957 | gl.texImage2D( |
| 958 | gl.TEXTURE_2D, |
| 959 | level, |
| 960 | glFormat, |
| 961 | glFormat, |
| 962 | glDataType, |
| 963 | levels[level] |
| 964 | ); |
| 965 | } |
| 966 | |
| 967 | // Set mipmap-appropriate filtering |
| 968 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); |
| 969 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); |
| 970 | |
| 971 | gl.bindTexture(gl.TEXTURE_2D, null); |
| 972 | |
| 973 | return { texture, glFormat, glDataType }; |
| 974 | } |
| 975 | |
| 976 | /* Binds a buffer to the drawing context |
| 977 | * when passed more than two arguments it also updates or initializes |
no test coverage detected