@gjsify/webgl 0.4.34 → 0.4.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{WebGLUniformLocation as e}from"../../webgl-uniform-location.js";import{checkObject as t,checkUniform as n,isValidString as r}from"../../utils.js";import{WebGLProgram as i}from"../../webgl-program.js";import{WebGLActiveInfo as a}from"../../webgl-active-info.js";const o={getActiveAttrib(e,n){if(!t(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,i)){if(n>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let t=this._gl.getActiveAttrib(e._|0,n|0);if(t)return new a(t)}return null},getActiveUniform(e,n){if(!t(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,i)){if(n>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let t=this._gl.getActiveUniform(e._|0,n|0);if(t)return new a(t)}return null},getAttribLocation(e,n){if(!t(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(n+=``,!r(n)||n.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,i))return this._gl.getAttribLocation(e._|0,n+``);return-1},getUniform(e,r){if(!t(e)||!t(r))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!r)return null;if(this._checkWrapper(e,i)){if(!n(e,r))return this.setError(this.INVALID_OPERATION),null;let t=this._gl.getUniform(e._|0,r._|0);if(!t)return null;switch(r._activeInfo.type){case this.FLOAT:return t[0];case this.FLOAT_VEC2:return new Float32Array(t.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(t.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(t.slice(0,4));case this.INT:return t[0]|0;case this.INT_VEC2:return new Int32Array(t.slice(0,2));case this.INT_VEC3:return new Int32Array(t.slice(0,3));case this.INT_VEC4:return new Int32Array(t.slice(0,4));case this.BOOL:return!!t[0];case this.BOOL_VEC2:return[!!t[0],!!t[1]];case this.BOOL_VEC3:return[!!t[0],!!t[1],!!t[2]];case this.BOOL_VEC4:return[!!t[0],!!t[1],!!t[2],!!t[3]];case this.FLOAT_MAT2:return new Float32Array(t.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(t.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(t.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return t[0]|0;default:return null}}return null},getUniformLocation(n,a){if(!t(n))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(a+=``,!r(a))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(n,i)){let t=this._gl.getUniformLocation(n._|0,a);if(t!==null&&t>=0){let r=a;/\[\d+\]$/.test(a)&&(r=a.replace(/\[\d+\]$/,`[0]`));let i=r+`[0]`,o=null;for(let e=0;e<n._uniforms.length;++e){let t=n._uniforms[e];if(t.name===r||t.name===i){o={size:t.size,type:t.type,name:t.name};break}}o||={name:r,type:0,size:1};let s=new e(t,n,o),c=a.match(/\[(\d+)\]$/),l=c?+c[1]:-1;if(o.name.endsWith(`[0]`)&&(l===-1||l===0)){let e=o.name.replace(/\[0\]$/,``),t=[];this._saveError();for(let r=0;this.getError()===this.NO_ERROR;++r){let i=this._gl.getUniformLocation(n._|0,e+`[`+r+`]`);if(this.getError()!==this.NO_ERROR||i==null||i<0)break;t.push(i)}this._restoreError(this.NO_ERROR),s._array=t}else if(l>0&&l>=o.size)return null;return s}}return null}};function installIntrospectionMethods(e){Object.assign(e,o)}export{installIntrospectionMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{checkObject as e,isValidString as t}from"../../utils.js";import{WebGLProgram as n}from"../../webgl-program.js";import{WebGLShader as r}from"../../webgl-shader.js";const i={createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let t=new n(e,this);return this._programs[e]=t,t},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,n)},useProgram(t){if(!e(t))throw TypeError(`useProgram(WebGLProgram)`);if(t)this._checkWrapper(t,n)&&(this._activeProgram!==t&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=t,t._refCount+=1),this._gl.useProgram(t._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(t){if(!e(t))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(t,n)){t._linkCount+=1,t._attributes=[];let e=this.getError();for(let e of t._references)e instanceof r&&e._needsRecompile&&(this._gl.compileShader(e._|0),e._needsRecompile=!1);this._gl.linkProgram(t._|0);let n=this.getError();n===this.NO_ERROR&&(t._linkStatus=this._fixupLink(t)),this.getError(),this.setError(e||n)}},validateProgram(e){if(this._checkWrapper(e,n)){this._gl.validateProgram(e._|0);let t=this.getError();t===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(t)}},attachShader(t,i){if(!e(t)||!e(i))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!t||!i){this.setError(this.INVALID_VALUE);return}else if(t instanceof n&&i instanceof r&&this._checkOwns(t)&&this._checkOwns(i)&&!t._linked(i)){this._saveError(),this._gl.attachShader(t._|0,i._|0);let e=this.getError();this._restoreError(e),e===this.NO_ERROR&&t._link(i);return}this.setError(this.INVALID_OPERATION)},detachShader(t,i){if(!e(t)||!e(i))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(t,n)&&this._checkWrapper(i,r)&&(t._linked(i)?(this._gl.detachShader(t._,i._),t._unlink(i)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(r,i,a){if(!e(r)||typeof a!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);a+=``,!t(a)||a.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(a)?this.setError(this.INVALID_OPERATION):this._checkWrapper(r,n)&&this._gl.bindAttribLocation(r._|0,i|0,a)},getAttachedShaders(t){if(!e(t)||typeof t==`object`&&t&&!(t instanceof n))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!t)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(t,n))return t._references.filter(e=>e instanceof r);return null},getProgramInfoLog(t){if(!e(t))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(t,n)?t._linkInfoLog:null},getProgramParameter(t,r=0){if(!e(t))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(t,n)){switch(r){case this.DELETE_STATUS:return t._pendingDelete;case this.LINK_STATUS:return t._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(t._,r);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(t._,r);case this.ACTIVE_ATTRIBUTES:return t._linkStatus?t._attributes.length:this._gl.getProgramParameter(t._,r);case this.ACTIVE_UNIFORMS:return t._linkStatus?t._uniforms.length:this._gl.getProgramParameter(t._,r)}this.setError(this.INVALID_ENUM)}return null},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let t=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),n=Array.from({length:t});e._attributes.length=t;for(let r=0;r<t;++r)n[r]=this.getActiveAttrib(e,r)?.name,e._attributes[r]=this.getAttribLocation(e,n[r])|0;for(let t=0;t<n.length;++t)if(n[t].length>256)return e._linkInfoLog=`attribute `+n[t]+` is too long`,!1;for(let r=0;r<t;++r)e._attributes[r]<0||this._gl.bindAttribLocation(e._|0,e._attributes[r],n[r]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let r=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=r;for(let t=0;t<r;++t){let n=this.getActiveUniform(e,t);n&&(e._uniforms[t]=n)}for(let t=0;t<e._uniforms.length;++t)if(e._uniforms[t].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[t].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(t,n,r){if(!e(n))throw TypeError(t+`(`+r.name+`)`);if(n instanceof r&&this._checkOwns(n)){n._pendingDelete=!0,n._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installProgramLifecycleMethods(e){Object.assign(e,i)}export{installProgramLifecycleMethods};
@@ -0,0 +1,8 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{checkObject as e,isValidString as t}from"../../utils.js";import{WebGLShader as n}from"../../webgl-shader.js";import{WebGLShaderPrecisionFormat as r}from"../../webgl-shader-precision-format.js";import i from"glsl-tokenizer/string";const a={createShader(e=0){if(e!==this.FRAGMENT_SHADER&&e!==this.VERTEX_SHADER)return this.setError(this.INVALID_ENUM),null;let t=this._gl.createShader(e);if(t<0)return null;let r=new n(t,this,e);return this._shaders[t]=r,r},deleteShader(e){this._deleteLinkable(`deleteShader`,e,n)},compileShader(t){if(!e(t))throw TypeError(`compileShader(WebGLShader)`);if(this._checkWrapper(t,n)&&this._checkShaderSource(t)){let e=this.getError();this._gl.compileShader(t._|0),t._needsRecompile=!1;let n=this.getError();t._compileStatus=!!this._gl.getShaderParameter(t._|0,this.COMPILE_STATUS),t._compileInfo=this._gl.getShaderInfoLog(t._|0)||`null`,this.getError(),this.setError(e||n)}},shaderSource(r,i){if(!e(r))throw TypeError(`shaderSource(WebGLShader, String)`);if(!r||!i&&typeof i!=`string`){this.setError(this.INVALID_VALUE);return}t(i)?this._checkWrapper(r,n)&&(i=this._wrapShader(r._type,i),this._gl.shaderSource(r._|0,i),r._source=i,r._needsRecompile=!0):this.setError(this.INVALID_VALUE)},getShaderInfoLog(t){if(!e(t))throw TypeError(`getShaderInfoLog(WebGLShader)`);return this._checkWrapper(t,n)?t._compileInfo:null},getShaderParameter(t,r=0){if(!e(t))throw TypeError(`getShaderParameter(WebGLShader, GLenum)`);if(this._checkWrapper(t,n)){switch(r){case this.DELETE_STATUS:return t._pendingDelete;case this.COMPILE_STATUS:return t._compileStatus;case this.SHADER_TYPE:return t._type}this.setError(this.INVALID_ENUM)}return null},getShaderPrecisionFormat(e=0,t=0){if(!(e===this.FRAGMENT_SHADER||e===this.VERTEX_SHADER)||!(t===this.LOW_FLOAT||t===this.MEDIUM_FLOAT||t===this.HIGH_FLOAT||t===this.LOW_INT||t===this.MEDIUM_INT||t===this.HIGH_INT))return this.setError(this.INVALID_ENUM),null;let n=this._gl.getShaderPrecisionFormat(e,t);return n?new r(n):null},getShaderSource(t){if(!e(t))throw TypeError(`Input to getShaderSource must be an object`);return this._checkWrapper(t,n)?t._source:null},_checkShaderSource(e){let t=e._source,n=i(t),r=!1,a=[];for(let e=0;e<n.length;++e){let t=n[e];if(t)switch(t.type){case`ident`:this._validGLSLIdentifier(t.data)||(r=!0,a.push(t.line+`:`+t.column+` invalid identifier - `+t.data));break;case`preprocessor`:{let e=t.data.match(/^\s*#\s*(.*)$/);if(!e||e?.length<2)break;let n=i(e[1]);for(let e=0;e<n.length;++e){let i=n[e];(i.type===`ident`||i.type===void 0)&&(this._validGLSLIdentifier(i.data)||(r=!0,a.push(t.line+`:`+i.column+` invalid identifier - `+i.data)))}break}case`keyword`:switch(t.data){case`do`:r=!0,a.push(t.line+`:`+t.column+` do not supported`);break}break;case`builtin`:switch(t.data){case`dFdx`:case`dFdy`:case`fwidth`:!this._extensions.oes_standard_derivatives&&this._getGlslVersion(!0)===`100`&&(r=!0,a.push(t.line+`:`+t.column+` `+t.data+` not supported`));break}}}return r&&(e._compileInfo=a.join(`
2
+ `)),!r},_wrapShader(e,t){let n=t.startsWith(`#version`)||t.includes(`
3
+ #version`),r=``;if(!this._extensions.oes_standard_derivatives&&/#ifdef\s+GL_OES_standard_derivatives/.test(t)&&(r+=`#undef GL_OES_standard_derivatives
4
+ `),!this._extensions.webgl_draw_buffers&&!n&&(r+=`#define gl_MaxDrawBuffers 1
5
+ `),n){if(r){let e=t.indexOf(`
6
+ `);t=e===-1?t+`
7
+ `+r:t.slice(0,e+1)+r+t.slice(e+1)}}else if(this.canvas){let e=this.canvas.getGlArea().get_use_es(),n=/\b(attribute|varying)\b/.test(t)?e?`100`:`120`:this._getGlslVersion(e);n?t=`#version `+n+`
8
+ `+r+t:r&&(t=r+t)}else r&&(t=r+t);return t}};function installShaderLifecycleMethods(e){Object.assign(e,a)}export{installShaderLifecycleMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{WebGLUniformLocation as e}from"../../webgl-uniform-location.js";import{checkObject as t,listToArray as n,uniformTypeSize as r}from"../../utils.js";const i={uniform1f(e,t){this._checkUniformValid(e,t,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,t)},uniform1i(e,t){this._gl.uniform1i(e?._||0,t)},uniform2f(e,t,n){this._checkUniformValid(e,t,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,t,n)},uniform2i(e,t,n){this._checkUniformValid(e,t,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,t,n)},uniform3f(e,t,n,r){this._checkUniformValid(e,t,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,t,n,r)},uniform3i(e,t,n,r){this._checkUniformValid(e,t,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,t,n,r)},uniform4f(e,t,n,r,i){if(!this._checkUniformValid(e,t,`uniform4f`,4,`f`)){console.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,t,n,r,i)},uniform4i(e,t,n,r,i){this._checkUniformValid(e,t,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,t,n,r,i)},uniform1fv(e,t){if(!(!e||!this._checkUniformValueValid(e,t,`uniform1fv`,1,`f`))){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1f(r,t[e])}return}this._gl.uniform1f(e?._|0,t[0])}},uniform1iv(e,t){if(this._checkUniformValueValid(e,t,`uniform1iv`,1,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1i(r,t[e])}return}this.uniform1i(e,t[0])}},uniform2fv(e,t){if(this._checkUniformValueValid(e,t,`uniform2fv`,2,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2f(r,t[2*e],t[2*e+1])}return}this._gl.uniform2f(e?._||0,t[0],t[1])}},uniform2iv(e,t){if(this._checkUniformValueValid(e,t,`uniform2iv`,2,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2i(r,t[2*e],t[2*e+1])}return}this.uniform2i(e,t[0],t[1])}},uniform3fv(e,t){if(this._checkUniformValueValid(e,t,`uniform3fv`,3,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3f(r,t[3*e],t[3*e+1],t[3*e+2])}return}this._gl.uniform3f(e?._||0,t[0],t[1],t[2])}},uniform3iv(e,t){if(this._checkUniformValueValid(e,t,`uniform3iv`,3,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3i(r,t[3*e],t[3*e+1],t[3*e+2])}return}this.uniform3i(e,t[0],t[1],t[2])}},uniform4fv(e,t){if(this._checkUniformValueValid(e,t,`uniform4fv`,4,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4f(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this._gl.uniform4f(e?._||0,t[0],t[1],t[2],t[3])}},uniform4iv(e,t){if(this._checkUniformValueValid(e,t,`uniform4iv`,4,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4i(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this.uniform4i(e,t[0],t[1],t[2],t[3])}},uniformMatrix2fv(e,t,r){if(!this._checkUniformMatrix(e,t,r,`uniformMatrix2fv`,2))return;let i=new Float32Array(r);this._gl.uniformMatrix2fv(e?._||0,!!t,n(i))},uniformMatrix3fv(e,t,r){if(!this._checkUniformMatrix(e,t,r,`uniformMatrix3fv`,3))return;let i=new Float32Array(r);this._gl.uniformMatrix3fv(e?._||0,!!t,n(i))},uniformMatrix4fv(e,t,r){if(!this._checkUniformMatrix(e,t,r,`uniformMatrix4fv`,4))return;let i=new Float32Array(r);this._gl.uniformMatrix4fv(e?._||0,!!t,n(i))},_checkLocation(t){return t instanceof e?t._program._ctx!==this||t._linkCount!==t._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,n,i,a,o){if(!t(e))throw TypeError(`${i}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let t=e._activeInfo.type;if(t===this.SAMPLER_2D||t===this.SAMPLER_CUBE){if(a!==1)return this.setError(this.INVALID_VALUE),!1;if(o!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(n<0||n>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return r(this,t)>a?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,n,i,a,o){if(!t(e)||!t(n))throw TypeError(`${i}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof n!=`object`||!n||typeof n.length!=`number`)throw TypeError(`Second argument to ${i} must be array`);return r(this,e._activeInfo.type)>a?(this.setError(this.INVALID_OPERATION),!1):n.length>=a&&n.length%a===0?e._array||n.length===a?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,n,r,i,a){if(!t(e)||typeof r!=`object`)throw TypeError(i+`(WebGLUniformLocation, Boolean, Array)`);return n||typeof r!=`object`||!r||!r.length||r.length%a*a!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:r.length===a*a||e._array?!0:(this.setError(this.INVALID_VALUE),!1)}};function installUniformsMethods(e){Object.assign(e,i)}export{installUniformsMethods};
@@ -1,8 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{WebGLUniformLocation as e}from"../webgl-uniform-location.js";import{checkObject as t,checkUniform as n,isValidString as r,listToArray as i,uniformTypeSize as a}from"../utils.js";import{WebGLProgram as o}from"../webgl-program.js";import{WebGLShader as s}from"../webgl-shader.js";import{WebGLActiveInfo as c}from"../webgl-active-info.js";import{WebGLShaderPrecisionFormat as l}from"../webgl-shader-precision-format.js";import u from"glsl-tokenizer/string";const d={createShader(e=0){if(e!==this.FRAGMENT_SHADER&&e!==this.VERTEX_SHADER)return this.setError(this.INVALID_ENUM),null;let t=this._gl.createShader(e);if(t<0)return null;let n=new s(t,this,e);return this._shaders[t]=n,n},deleteShader(e){this._deleteLinkable(`deleteShader`,e,s)},compileShader(e){if(!t(e))throw TypeError(`compileShader(WebGLShader)`);if(this._checkWrapper(e,s)&&this._checkShaderSource(e)){let t=this.getError();this._gl.compileShader(e._|0),e._needsRecompile=!1;let n=this.getError();e._compileStatus=!!this._gl.getShaderParameter(e._|0,this.COMPILE_STATUS),e._compileInfo=this._gl.getShaderInfoLog(e._|0)||`null`,this.getError(),this.setError(t||n)}},shaderSource(e,n){if(!t(e))throw TypeError(`shaderSource(WebGLShader, String)`);if(!e||!n&&typeof n!=`string`){this.setError(this.INVALID_VALUE);return}r(n)?this._checkWrapper(e,s)&&(n=this._wrapShader(e._type,n),this._gl.shaderSource(e._|0,n),e._source=n,e._needsRecompile=!0):this.setError(this.INVALID_VALUE)},getShaderInfoLog(e){if(!t(e))throw TypeError(`getShaderInfoLog(WebGLShader)`);return this._checkWrapper(e,s)?e._compileInfo:null},getShaderParameter(e,n=0){if(!t(e))throw TypeError(`getShaderParameter(WebGLShader, GLenum)`);if(this._checkWrapper(e,s)){switch(n){case this.DELETE_STATUS:return e._pendingDelete;case this.COMPILE_STATUS:return e._compileStatus;case this.SHADER_TYPE:return e._type}this.setError(this.INVALID_ENUM)}return null},getShaderPrecisionFormat(e=0,t=0){if(!(e===this.FRAGMENT_SHADER||e===this.VERTEX_SHADER)||!(t===this.LOW_FLOAT||t===this.MEDIUM_FLOAT||t===this.HIGH_FLOAT||t===this.LOW_INT||t===this.MEDIUM_INT||t===this.HIGH_INT))return this.setError(this.INVALID_ENUM),null;let n=this._gl.getShaderPrecisionFormat(e,t);return n?new l(n):null},getShaderSource(e){if(!t(e))throw TypeError(`Input to getShaderSource must be an object`);return this._checkWrapper(e,s)?e._source:null},attachShader(e,n){if(!t(e)||!t(n))throw TypeError(`attachShader(WebGLProgram, WebGLShader)`);if(!e||!n){this.setError(this.INVALID_VALUE);return}else if(e instanceof o&&n instanceof s&&this._checkOwns(e)&&this._checkOwns(n)&&!e._linked(n)){this._saveError(),this._gl.attachShader(e._|0,n._|0);let t=this.getError();this._restoreError(t),t===this.NO_ERROR&&e._link(n);return}this.setError(this.INVALID_OPERATION)},detachShader(e,n){if(!t(e)||!t(n))throw TypeError(`detachShader(WebGLProgram, WebGLShader)`);this._checkWrapper(e,o)&&this._checkWrapper(n,s)&&(e._linked(n)?(this._gl.detachShader(e._,n._),e._unlink(n)):this.setError(this.INVALID_OPERATION))},bindAttribLocation(e,n,i){if(!t(e)||typeof i!=`string`)throw TypeError(`bindAttribLocation(WebGLProgram, GLint, String)`);i+=``,!r(i)||i.length>256?this.setError(this.INVALID_VALUE):/^_?webgl_a/.test(i)?this.setError(this.INVALID_OPERATION):this._checkWrapper(e,o)&&this._gl.bindAttribLocation(e._|0,n|0,i)},createProgram(){let e=this._gl.createProgram();if(e<=0)return null;let t=new o(e,this);return this._programs[e]=t,t},deleteProgram(e){this._deleteLinkable(`deleteProgram`,e,o)},useProgram(e){if(!t(e))throw TypeError(`useProgram(WebGLProgram)`);if(e)this._checkWrapper(e,o)&&(this._activeProgram!==e&&(this._switchActiveProgram(this._activeProgram),this._activeProgram=e,e._refCount+=1),this._gl.useProgram(e._|0));else{this._switchActiveProgram(this._activeProgram),this._activeProgram=null,this._gl.useProgram(0);return}},linkProgram(e){if(!t(e))throw TypeError(`linkProgram(WebGLProgram)`);if(this._checkWrapper(e,o)){e._linkCount+=1,e._attributes=[];let t=this.getError();for(let t of e._references)t instanceof s&&t._needsRecompile&&(this._gl.compileShader(t._|0),t._needsRecompile=!1);this._gl.linkProgram(e._|0);let n=this.getError();n===this.NO_ERROR&&(e._linkStatus=this._fixupLink(e)),this.getError(),this.setError(t||n)}},validateProgram(e){if(this._checkWrapper(e,o)){this._gl.validateProgram(e._|0);let t=this.getError();t===this.NO_ERROR&&(e._linkInfoLog=this._gl.getProgramInfoLog(e._|0)),this.getError(),this.setError(t)}},getActiveAttrib(e,n){if(!t(e))throw TypeError(`getActiveAttrib(WebGLProgram)`);if(!e)throw TypeError(`getActiveAttrib(WebGLProgram, GLuint)`);if(this._checkWrapper(e,o)){if(n>=(e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_ATTRIBUTES)))return this._gl.getError(),this.setError(this.INVALID_VALUE),null;let t=this._gl.getActiveAttrib(e._|0,n|0);if(t)return new c(t)}return null},getActiveUniform(e,n){if(!t(e))throw TypeError(`getActiveUniform(WebGLProgram, GLint)`);if(!e)throw TypeError(`getActiveUniform(WebGLProgram, GLuint)`);if(this._checkWrapper(e,o)){if(n>=(e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._|0,this.ACTIVE_UNIFORMS)))return this.setError(this.INVALID_VALUE),null;let t=this._gl.getActiveUniform(e._|0,n|0);if(t)return new c(t)}return null},getAttachedShaders(e){if(!t(e)||typeof e==`object`&&e&&!(e instanceof o))throw TypeError(`getAttachedShaders(WebGLProgram)`);if(!e)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,o))return e._references.filter(e=>e instanceof s);return null},getAttribLocation(e,n){if(!t(e))throw TypeError(`getAttribLocation(WebGLProgram, String)`);if(n+=``,!r(n)||n.length>256)this.setError(this.INVALID_VALUE);else if(this._checkWrapper(e,o))return this._gl.getAttribLocation(e._|0,n+``);return-1},getUniform(e,r){if(!t(e)||!t(r))throw TypeError(`getUniform(WebGLProgram, WebGLUniformLocation)`);if(!e)return this.setError(this.INVALID_VALUE),null;if(!r)return null;if(this._checkWrapper(e,o)){if(!n(e,r))return this.setError(this.INVALID_OPERATION),null;let t=this._gl.getUniform(e._|0,r._|0);if(!t)return null;switch(r._activeInfo.type){case this.FLOAT:return t[0];case this.FLOAT_VEC2:return new Float32Array(t.slice(0,2));case this.FLOAT_VEC3:return new Float32Array(t.slice(0,3));case this.FLOAT_VEC4:return new Float32Array(t.slice(0,4));case this.INT:return t[0]|0;case this.INT_VEC2:return new Int32Array(t.slice(0,2));case this.INT_VEC3:return new Int32Array(t.slice(0,3));case this.INT_VEC4:return new Int32Array(t.slice(0,4));case this.BOOL:return!!t[0];case this.BOOL_VEC2:return[!!t[0],!!t[1]];case this.BOOL_VEC3:return[!!t[0],!!t[1],!!t[2]];case this.BOOL_VEC4:return[!!t[0],!!t[1],!!t[2],!!t[3]];case this.FLOAT_MAT2:return new Float32Array(t.slice(0,4));case this.FLOAT_MAT3:return new Float32Array(t.slice(0,9));case this.FLOAT_MAT4:return new Float32Array(t.slice(0,16));case this.SAMPLER_2D:case this.SAMPLER_CUBE:return t[0]|0;default:return null}}return null},getUniformLocation(n,i){if(!t(n))throw TypeError(`getUniformLocation(WebGLProgram, String)`);if(i+=``,!r(i))return this.setError(this.INVALID_VALUE),null;if(this._checkWrapper(n,o)){let t=this._gl.getUniformLocation(n._|0,i);if(t!==null&&t>=0){let r=i;/\[\d+\]$/.test(i)&&(r=i.replace(/\[\d+\]$/,`[0]`));let a=r+`[0]`,o=null;for(let e=0;e<n._uniforms.length;++e){let t=n._uniforms[e];if(t.name===r||t.name===a){o={size:t.size,type:t.type,name:t.name};break}}o||={name:r,type:0,size:1};let s=new e(t,n,o),c=i.match(/\[(\d+)\]$/),l=c?+c[1]:-1;if(o.name.endsWith(`[0]`)&&(l===-1||l===0)){let e=o.name.replace(/\[0\]$/,``),t=[];this._saveError();for(let r=0;this.getError()===this.NO_ERROR;++r){let i=this._gl.getUniformLocation(n._|0,e+`[`+r+`]`);if(this.getError()!==this.NO_ERROR||i==null||i<0)break;t.push(i)}this._restoreError(this.NO_ERROR),s._array=t}else if(l>0&&l>=o.size)return null;return s}}return null},getProgramInfoLog(e){if(!t(e))throw TypeError(`getProgramInfoLog(WebGLProgram)`);return this._checkWrapper(e,o)?e._linkInfoLog:null},getProgramParameter(e,n=0){if(!t(e))throw TypeError(`getProgramParameter(WebGLProgram, GLenum)`);if(this._checkWrapper(e,o)){switch(n){case this.DELETE_STATUS:return e._pendingDelete;case this.LINK_STATUS:return e._linkStatus;case this.VALIDATE_STATUS:return!!this._gl.getProgramParameter(e._,n);case this.ATTACHED_SHADERS:return this._gl.getProgramParameter(e._,n);case this.ACTIVE_ATTRIBUTES:return e._linkStatus?e._attributes.length:this._gl.getProgramParameter(e._,n);case this.ACTIVE_UNIFORMS:return e._linkStatus?e._uniforms.length:this._gl.getProgramParameter(e._,n)}this.setError(this.INVALID_ENUM)}return null},uniform1f(e,t){this._checkUniformValid(e,t,`uniform1f`,1,`f`)&&this._gl.uniform1f(e?._||0,t)},uniform1i(e,t){this._gl.uniform1i(e?._||0,t)},uniform2f(e,t,n){this._checkUniformValid(e,t,`uniform2f`,2,`f`)&&this._gl.uniform2f(e?._||0,t,n)},uniform2i(e,t,n){this._checkUniformValid(e,t,`uniform2i`,2,`i`)&&this._gl.uniform2i(e?._||0,t,n)},uniform3f(e,t,n,r){this._checkUniformValid(e,t,`uniform3f`,3,`f`)&&this._gl.uniform3f(e?._||0,t,n,r)},uniform3i(e,t,n,r){this._checkUniformValid(e,t,`uniform3i`,3,`i`)&&this._gl.uniform3i(e?._||0,t,n,r)},uniform4f(e,t,n,r,i){if(!this._checkUniformValid(e,t,`uniform4f`,4,`f`)){console.error(`uniform4f is not valid!`);return}this._gl.uniform4f(e?._||0,t,n,r,i)},uniform4i(e,t,n,r,i){this._checkUniformValid(e,t,`uniform4i`,4,`i`)&&this._gl.uniform4i(e?._||0,t,n,r,i)},uniform1fv(e,t){if(!(!e||!this._checkUniformValueValid(e,t,`uniform1fv`,1,`f`))){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1f(r,t[e])}return}this._gl.uniform1f(e?._|0,t[0])}},uniform1iv(e,t){if(this._checkUniformValueValid(e,t,`uniform1iv`,1,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform1i(r,t[e])}return}this.uniform1i(e,t[0])}},uniform2fv(e,t){if(this._checkUniformValueValid(e,t,`uniform2fv`,2,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2f(r,t[2*e],t[2*e+1])}return}this._gl.uniform2f(e?._||0,t[0],t[1])}},uniform2iv(e,t){if(this._checkUniformValueValid(e,t,`uniform2iv`,2,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&2*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform2i(r,t[2*e],t[2*e+1])}return}this.uniform2i(e,t[0],t[1])}},uniform3fv(e,t){if(this._checkUniformValueValid(e,t,`uniform3fv`,3,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3f(r,t[3*e],t[3*e+1],t[3*e+2])}return}this._gl.uniform3f(e?._||0,t[0],t[1],t[2])}},uniform3iv(e,t){if(this._checkUniformValueValid(e,t,`uniform3iv`,3,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&3*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform3i(r,t[3*e],t[3*e+1],t[3*e+2])}return}this.uniform3i(e,t[0],t[1],t[2])}},uniform4fv(e,t){if(this._checkUniformValueValid(e,t,`uniform4fv`,4,`f`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4f(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this._gl.uniform4f(e?._||0,t[0],t[1],t[2],t[3])}},uniform4iv(e,t){if(this._checkUniformValueValid(e,t,`uniform4iv`,4,`i`)){if(e?._array){let n=e._array;for(let e=0;e<n.length&&4*e<t.length;++e){let r=n[e];r!=null&&this._gl.uniform4i(r,t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}return}this.uniform4i(e,t[0],t[1],t[2],t[3])}},uniformMatrix2fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix2fv`,2))return;let r=new Float32Array(n);this._gl.uniformMatrix2fv(e?._||0,!!t,i(r))},uniformMatrix3fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix3fv`,3))return;let r=new Float32Array(n);this._gl.uniformMatrix3fv(e?._||0,!!t,i(r))},uniformMatrix4fv(e,t,n){if(!this._checkUniformMatrix(e,t,n,`uniformMatrix4fv`,4))return;let r=new Float32Array(n);this._gl.uniformMatrix4fv(e?._||0,!!t,i(r))},_checkLocation(t){return t instanceof e?t._program._ctx!==this||t._linkCount!==t._program._linkCount?(this.setError(this.INVALID_OPERATION),!1):!0:(this.setError(this.INVALID_VALUE),!1)},_checkLocationActive(e){return e&&this._checkLocation(e)?e._program===this._activeProgram?!0:(this.setError(this.INVALID_OPERATION),!1):!1},_checkUniformValid(e,n,r,i,o){if(!t(e))throw TypeError(`${r}(WebGLUniformLocation, ...)`);if(!e)return!1;if(this._checkLocationActive(e)){let t=e._activeInfo.type;if(t===this.SAMPLER_2D||t===this.SAMPLER_CUBE){if(i!==1)return this.setError(this.INVALID_VALUE),!1;if(o!==`i`)return this.setError(this.INVALID_OPERATION),!1;if(n<0||n>=this._textureUnits.length)return this.setError(this.INVALID_VALUE),!1}return a(this,t)>i?(this.setError(this.INVALID_OPERATION),!1):!0}return!1},_checkUniformValueValid(e,n,r,i,o){if(!t(e)||!t(n))throw TypeError(`${r}v(WebGLUniformLocation, Array)`);if(!e||!this._checkLocationActive(e))return!1;if(typeof n!=`object`||!n||typeof n.length!=`number`)throw TypeError(`Second argument to ${r} must be array`);return a(this,e._activeInfo.type)>i?(this.setError(this.INVALID_OPERATION),!1):n.length>=i&&n.length%i===0?e._array||n.length===i?!0:(this.setError(this.INVALID_OPERATION),!1):(this.setError(this.INVALID_VALUE),!1)},_checkUniformMatrix(e,n,r,i,a){if(!t(e)||typeof r!=`object`)throw TypeError(i+`(WebGLUniformLocation, Boolean, Array)`);return n||typeof r!=`object`||!r||!r.length||r.length%a*a!==0?(this.setError(this.INVALID_VALUE),!1):!e||!this._checkLocationActive(e)?!1:r.length===a*a||e._array?!0:(this.setError(this.INVALID_VALUE),!1)},_checkShaderSource(e){let t=e._source,n=u(t),r=!1,i=[];for(let e=0;e<n.length;++e){let t=n[e];if(t)switch(t.type){case`ident`:this._validGLSLIdentifier(t.data)||(r=!0,i.push(t.line+`:`+t.column+` invalid identifier - `+t.data));break;case`preprocessor`:{let e=t.data.match(/^\s*#\s*(.*)$/);if(!e||e?.length<2)break;let n=u(e[1]);for(let e=0;e<n.length;++e){let a=n[e];(a.type===`ident`||a.type===void 0)&&(this._validGLSLIdentifier(a.data)||(r=!0,i.push(t.line+`:`+a.column+` invalid identifier - `+a.data)))}break}case`keyword`:switch(t.data){case`do`:r=!0,i.push(t.line+`:`+t.column+` do not supported`);break}break;case`builtin`:switch(t.data){case`dFdx`:case`dFdy`:case`fwidth`:!this._extensions.oes_standard_derivatives&&this._getGlslVersion(!0)===`100`&&(r=!0,i.push(t.line+`:`+t.column+` `+t.data+` not supported`));break}}}return r&&(e._compileInfo=i.join(`
2
- `)),!r},_wrapShader(e,t){let n=t.startsWith(`#version`)||t.includes(`
3
- #version`),r=``;if(!this._extensions.oes_standard_derivatives&&/#ifdef\s+GL_OES_standard_derivatives/.test(t)&&(r+=`#undef GL_OES_standard_derivatives
4
- `),!this._extensions.webgl_draw_buffers&&!n&&(r+=`#define gl_MaxDrawBuffers 1
5
- `),n){if(r){let e=t.indexOf(`
6
- `);t=e===-1?t+`
7
- `+r:t.slice(0,e+1)+r+t.slice(e+1)}}else if(this.canvas){let e=this.canvas.getGlArea().get_use_es(),n=/\b(attribute|varying)\b/.test(t)?e?`100`:`120`:this._getGlslVersion(e);n?t=`#version `+n+`
8
- `+r+t:r&&(t=r+t)}else r&&(t=r+t);return t},_switchActiveProgram(e){e&&(--e._refCount,e._checkDelete())},_fixupLink(e){if(!this._gl.getProgramParameter(e._,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let t=this.getProgramParameter(e,this.ACTIVE_ATTRIBUTES),n=Array.from({length:t});e._attributes.length=t;for(let r=0;r<t;++r)n[r]=this.getActiveAttrib(e,r)?.name,e._attributes[r]=this.getAttribLocation(e,n[r])|0;for(let t=0;t<n.length;++t)if(n[t].length>256)return e._linkInfoLog=`attribute `+n[t]+` is too long`,!1;for(let r=0;r<t;++r)e._attributes[r]<0||this._gl.bindAttribLocation(e._|0,e._attributes[r],n[r]);if(this._gl.linkProgram(e._|0),!this._gl.getProgramParameter(e._|0,this.LINK_STATUS))return e._linkInfoLog=this._gl.getProgramInfoLog(e._),!1;let r=this.getProgramParameter(e,this.ACTIVE_UNIFORMS);e._uniforms.length=r;for(let t=0;t<r;++t){let n=this.getActiveUniform(e,t);n&&(e._uniforms[t]=n)}for(let t=0;t<e._uniforms.length;++t)if(e._uniforms[t].name.length>256)return e._linkInfoLog=`uniform `+e._uniforms[t].name+` is too long`,!1;return e._linkInfoLog=``,!0},_deleteLinkable(e,n,r){if(!t(n))throw TypeError(e+`(`+r.name+`)`);if(n instanceof r&&this._checkOwns(n)){n._pendingDelete=!0,n._checkDelete();return}this.setError(this.INVALID_OPERATION)}};function installShaderProgramMethods(e){Object.assign(e,d)}export{installShaderProgramMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{installShaderLifecycleMethods as e}from"./shader-program/shader-lifecycle.js";import{installProgramLifecycleMethods as t}from"./shader-program/program-lifecycle.js";import{installIntrospectionMethods as n}from"./shader-program/introspection.js";import{installUniformsMethods as r}from"./shader-program/uniforms.js";function installShaderProgramMethods(i){e(i),t(i),n(i),r(i)}export{n as installIntrospectionMethods,t as installProgramLifecycleMethods,e as installShaderLifecycleMethods,installShaderProgramMethods,r as installUniformsMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{Uint8ArrayToVariant as e,arrayToUint8Array as t}from"../../utils.js";import*as n from"bit-twiddle";const r={copyTexImage2D(e=0,t=0,r=0,i=0,a=0,o=0,s=0,c=0){let l=this._getTexImage(e);if(!l){this.setError(this.INVALID_OPERATION);return}if(r!==this.RGBA&&r!==this.RGB&&r!==this.ALPHA&&r!==this.LUMINANCE&&r!==this.LUMINANCE_ALPHA){this.setError(this.INVALID_ENUM);return}if(t<0||o<0||s<0||c!==0){this.setError(this.INVALID_VALUE);return}if(t>0&&!(n.isPow2(o)&&n.isPow2(s))){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.copyTexImage2D(e,t,r,i,a,o,s,c);let u=this.getError();this._restoreError(u),u===this.NO_ERROR&&(l._levelWidth[t]=o,l._levelHeight[t]=s,l._format=this.RGBA,l._type=this.UNSIGNED_BYTE)},copyTexSubImage2D(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0){if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(o<0||s<0||n<0||r<0||t<0){this.setError(this.INVALID_VALUE);return}this._gl.copyTexSubImage2D(e,t,n,r,i,a,o,s)},compressedTexImage2D(n,r,i,a,o,s,c){this._gl.compressedTexImage2D(n,r,i,a,o,s,e(t(c)))},compressedTexSubImage2D(n,r,i,a,o,s,c,l){this._gl.compressedTexSubImage2D(n,r,i,a,o,s,c,e(t(l)))}};function installCopyAndCompressedTextureMethods(e){Object.assign(e,r)}export{installCopyAndCompressedTextureMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{formatSize as e,validCubeTarget as t}from"../../utils.js";const n={_getActiveTextureUnit(){return this._textureUnits[this._activeTextureUnit]},_getActiveTexture(e){let t=this._getActiveTextureUnit();return e===this.TEXTURE_2D?t._bind2D:e===this.TEXTURE_CUBE_MAP?t._bindCube:null},_getTexImage(e){let n=this._getActiveTextureUnit();return e===this.TEXTURE_2D?n._bind2D:t(this,e)?n._bindCube:(this.setError(this.INVALID_ENUM),null)},_checkTextureTarget(e){let t=this._getActiveTextureUnit(),n=null;if(e===this.TEXTURE_2D)n=t._bind2D;else if(e===this.TEXTURE_CUBE_MAP)n=t._bindCube;else return this.setError(this.INVALID_ENUM),!1;return n?!0:(this.setError(this.INVALID_OPERATION),!1)},_validTextureTarget(e){return e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP},_validCubeTarget(e){return e===this.TEXTURE_CUBE_MAP_POSITIVE_X||e===this.TEXTURE_CUBE_MAP_NEGATIVE_X||e===this.TEXTURE_CUBE_MAP_POSITIVE_Y||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Y||e===this.TEXTURE_CUBE_MAP_POSITIVE_Z||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Z},_verifyTextureCompleteness(e,t,n){let r=this._getActiveTextureUnit(),i=null;if(e===this.TEXTURE_2D?i=r._bind2D:this._validCubeTarget(e)&&(i=r._bindCube),this._extensions.oes_texture_float&&!this._extensions.oes_texture_float_linear&&i&&i._type===this.FLOAT&&(t===this.TEXTURE_MAG_FILTER||t===this.TEXTURE_MIN_FILTER)&&(n===this.LINEAR||n===this.LINEAR_MIPMAP_NEAREST||n===this.NEAREST_MIPMAP_LINEAR||n===this.LINEAR_MIPMAP_LINEAR)){i._complete=!1,this.bindTexture(e,i);return}i&&i._complete===!1&&(i._complete=!0,this.bindTexture(e,i))},_computePixelSize(t,n){let r=e(this,n);if(r===0)return this.setError(this.INVALID_ENUM),0;switch(t){case this.UNSIGNED_BYTE:return r;case this.UNSIGNED_SHORT_5_6_5:if(n!==this.RGB){this.setError(this.INVALID_OPERATION);break}return 2;case this.UNSIGNED_SHORT_4_4_4_4:case this.UNSIGNED_SHORT_5_5_5_1:if(n!==this.RGBA){this.setError(this.INVALID_OPERATION);break}return 2;case this.FLOAT:return 1}return this.setError(this.INVALID_ENUM),0},_computeRowStride(e,t){let n=e*t;return n%this._unpackAlignment&&(n+=this._unpackAlignment-n%this._unpackAlignment),n},_checkDimensions(e,t,n,r){if(r<0||t<0||n<0)return this.setError(this.INVALID_VALUE),!1;if(e===this.TEXTURE_2D){if(t>this._maxTextureSize||n>this._maxTextureSize||r>this._maxTextureLevel)return this.setError(this.INVALID_VALUE),!1}else if(this._validCubeTarget(e)){if(t>this._maxCubeMapSize||n>this._maxCubeMapSize||r>this._maxCubeMapLevel)return this.setError(this.INVALID_VALUE),!1}else return this.setError(this.INVALID_ENUM),!1;return!0}};function installTextureIntrospectionMethods(e){Object.assign(e,n)}export{installTextureIntrospectionMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{checkObject as e}from"../../utils.js";import{WebGLTexture as t}from"../../webgl-texture.js";const n={activeTexture(e=0){let t=e-this.TEXTURE0;if(t>=0&&t<this._textureUnits.length){this._activeTextureUnit=t,this._gl.activeTexture(e);return}this.setError(this.INVALID_ENUM)},bindTexture(n=0,r){if(!e(r))throw TypeError(`bindTexture(GLenum, WebGLTexture)`);if(!this._validTextureTarget(n)){this.setError(this.INVALID_ENUM);return}let i=0;if(!r)r=null;else if(r instanceof t&&r._pendingDelete)return;else if(this._checkWrapper(r,t)){if(r._binding&&r._binding!==n){this.setError(this.INVALID_OPERATION);return}r._binding=n,r._complete&&(i=r._|0)}else return;this._saveError(),this._gl.bindTexture(n,i);let a=this.getError();if(this._restoreError(a),a!==this.NO_ERROR)return;let o=this._getActiveTextureUnit(),s=this._getActiveTexture(n);s!==r&&(s&&(--s._refCount,s._checkDelete()),r&&(r._refCount+=1)),n===this.TEXTURE_2D?o._bind2D=r:n===this.TEXTURE_CUBE_MAP&&(o._bindCube=r)},createTexture(){let e=this._gl.createTexture();if(e<=0)return null;let n=new t(e,this);return this._textures[e]=n,n},deleteTexture(n){if(!e(n))throw TypeError(`deleteTexture(WebGLTexture)`);if(n instanceof t){if(!this._checkOwns(n)){this.setError(this.INVALID_OPERATION);return}}else return;let r=this._activeTextureUnit;for(let e=0;e<this._textureUnits.length;++e){let t=this._textureUnits[e];t._bind2D===n?(this.activeTexture(this.TEXTURE0+e),this.bindTexture(this.TEXTURE_2D,null)):t._bindCube===n&&(this.activeTexture(this.TEXTURE0+e),this.bindTexture(this.TEXTURE_CUBE_MAP,null))}this.activeTexture(this.TEXTURE0+r),this._detachTextureFromAllFramebuffers(n),n._pendingDelete=!0,n._checkDelete()},_detachTextureFromAllFramebuffers(e){let t=this._activeFramebuffer,n=this._getAttachments(),r=!1;for(let i in this._framebuffers){let a=this._framebuffers[i];if(!(!a||!a._linked(e))){a!==t&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,a._|0),r=!0);for(let t=0;t<n.length;++t){let r=n[t];a._attachments[r]===e&&(this._gl.framebufferTexture2D(this.FRAMEBUFFER,r,a._attachmentFace[r]||this.TEXTURE_2D,0,a._attachmentLevel[r]||0),a._setAttachment(null,r))}}}r&&this._gl.bindFramebuffer(this.FRAMEBUFFER,t?t._|0:this._gtkFboId)},pixelStorei(e=0,t=0){if(typeof t==`boolean`&&(t=t===!1?0:1),e===this.UNPACK_ALIGNMENT)if(t===1||t===2||t===4||t===8)this._unpackAlignment=t;else{this.setError(this.INVALID_VALUE);return}else if(e===this.PACK_ALIGNMENT)if(t===1||t===2||t===4||t===8)this._packAlignment=t;else{this.setError(this.INVALID_VALUE);return}else if(e===this.UNPACK_COLORSPACE_CONVERSION_WEBGL){if(!(t===this.NONE||t===this.BROWSER_DEFAULT_WEBGL)){this.setError(this.INVALID_VALUE);return}}else if(e===this.UNPACK_FLIP_Y_WEBGL){this._unpackFlipY=!!t;return}else if(e===this.UNPACK_PREMULTIPLY_ALPHA_WEBGL){this._unpackPremultAlpha=!!t;return}this._gl.pixelStorei(e,t)}};function installTextureLifecycleMethods(e){Object.assign(e,n)}export{installTextureLifecycleMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";const e={texParameterf(e=0,t=0,n){if(n=+n,this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,t,n),t){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameterf(e,t,n);return}let r=this._extensions.ext_texture_filter_anisotropic;if(r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameterf(e,t,n);return}this.setError(this.INVALID_ENUM)}},texParameteri(e=0,t=0,n=0){if(this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,t,n),t){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameteri(e,t,n);return}let r=this._extensions.ext_texture_filter_anisotropic;if(r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameteri(e,t,n);return}this.setError(this.INVALID_ENUM)}},getTexParameter(e=0,t=0){if(!this._checkTextureTarget(e))return null;let n=this._getActiveTextureUnit();if(e===this.TEXTURE_2D&&!n._bind2D||e===this.TEXTURE_CUBE_MAP&&!n._bindCube)return this.setError(this.INVALID_OPERATION),null;switch(t){case this.TEXTURE_MAG_FILTER:case this.TEXTURE_MIN_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:return this._getTexParameterDirect(e,t)}let r=this._extensions.ext_texture_filter_anisotropic;return r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT?this._getTexParameterDirect(e,t):(this.setError(this.INVALID_ENUM),null)},_getTexParameterDirect(e=0,t=0){return this._gl.getTexParameterx(e,t)?.unpack()}};function installTextureParameterMethods(t){Object.assign(t,e)}export{installTextureParameterMethods};
@@ -0,0 +1 @@
1
+ import"../../_virtual/_rolldown/runtime.js";import{Uint8ArrayToVariant as e,checkFormat as t,convertPixels as n,extractImageData as r,premultiplyAlpha as i,validCubeTarget as a}from"../../utils.js";import o from"gi://GdkPixbuf?version=2.0";const s={texImage2D(s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h){let g=0,_=0,v=0,y,b,x=0;if(arguments.length===6)if(m=d,v=u,f instanceof o.Pixbuf)b=f,g=b.get_width(),_=b.get_height(),h=b.get_pixels();else{y=f;let e=r(y);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);g=e.width,_=e.height,h=e.data}else arguments.length===9&&(g=u,_=d,x=f,v=p,h=h);if(typeof h!=`object`&&h!==void 0)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!t(this,v)||!t(this,l)){this.setError(this.INVALID_ENUM);return}if(m===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let S=this._getTexImage(s);if(!S||v!==l){this.setError(this.INVALID_OPERATION);return}let C=this._computePixelSize(m,v);if(C===0||!this._checkDimensions(s,g,_,c))return;let w=n(h),T=this._computeRowStride(g,C),E=T*_;if(w&&w.length<E){this.setError(this.INVALID_OPERATION);return}if(x!==0||a(this,s)&&g!==_){this.setError(this.INVALID_VALUE);return}if(this._unpackPremultAlpha&&w&&v===this.RGBA&&(w=i(w)),this._unpackFlipY&&w&&g>0&&_>0){let e=new Uint8Array(w.length);for(let t=0;t<_;t++){let n=t*T,r=(_-1-t)*T;e.set(w.subarray(n,n+T),r)}w=e}this._saveError(),this._gl.texImage2D(s,c,l,g,_,x,v,m,e(w));let D=this.getError();if(this._restoreError(D),D!==this.NO_ERROR)return;S._levelWidth[c]=g,S._levelHeight[c]=_,S._format=v,S._type=m;let O=this._activeFramebuffer;if(O){let e=!1,t=this._getAttachments();for(let n=0;n<t.length;++n)if(O._attachments[t[n]]===S){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}},texSubImage2D(t=0,a=0,s=0,c=0,l=0,u=0,d=0,f=0,p){let m=0,h=0,g=0,_,v;if(arguments.length===7)if(f=u,g=l,d instanceof o.Pixbuf)v=d,m=v.get_width(),h=v.get_height(),p=v.get_pixels();else{_=d;let e=r(_);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);m=e.width,h=e.height,p=e.data}else m=l,h=u,g=d;if(typeof p!=`object`)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!this._getTexImage(t)){this.setError(this.INVALID_OPERATION);return}if(f===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let y=this._computePixelSize(f,g);if(y===0||!this._checkDimensions(t,m,h,a))return;if(s<0||c<0){this.setError(this.INVALID_VALUE);return}let b=n(p),x=this._computeRowStride(m,y),S=x*h;if(!b||b.length<S){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&b&&g===this.RGBA&&(b=i(b)),this._unpackFlipY&&b&&m>0&&h>0){let e=new Uint8Array(b.length);for(let t=0;t<h;t++){let n=t*x,r=(h-1-t)*x;e.set(b.subarray(n,n+x),r)}b=e}this._gl.texSubImage2D(t,a,s,c,m,h,g,f,e(b))}};function installTexImage2DMethods(e){Object.assign(e,s)}export{installTexImage2DMethods};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{Uint8ArrayToVariant as e,arrayToUint8Array as t,checkFormat as n,checkObject as r,convertPixels as i,extractImageData as a,formatSize as o,premultiplyAlpha as s,validCubeTarget as c}from"../utils.js";import{WebGLTexture as l}from"../webgl-texture.js";import*as u from"bit-twiddle";import d from"gi://GdkPixbuf?version=2.0";const f={activeTexture(e=0){let t=e-this.TEXTURE0;if(t>=0&&t<this._textureUnits.length){this._activeTextureUnit=t,this._gl.activeTexture(e);return}this.setError(this.INVALID_ENUM)},bindTexture(e=0,t){if(!r(t))throw TypeError(`bindTexture(GLenum, WebGLTexture)`);if(!this._validTextureTarget(e)){this.setError(this.INVALID_ENUM);return}let n=0;if(!t)t=null;else if(t instanceof l&&t._pendingDelete)return;else if(this._checkWrapper(t,l)){if(t._binding&&t._binding!==e){this.setError(this.INVALID_OPERATION);return}t._binding=e,t._complete&&(n=t._|0)}else return;this._saveError(),this._gl.bindTexture(e,n);let i=this.getError();if(this._restoreError(i),i!==this.NO_ERROR)return;let a=this._getActiveTextureUnit(),o=this._getActiveTexture(e);o!==t&&(o&&(--o._refCount,o._checkDelete()),t&&(t._refCount+=1)),e===this.TEXTURE_2D?a._bind2D=t:e===this.TEXTURE_CUBE_MAP&&(a._bindCube=t)},createTexture(){let e=this._gl.createTexture();if(e<=0)return null;let t=new l(e,this);return this._textures[e]=t,t},deleteTexture(e){if(!r(e))throw TypeError(`deleteTexture(WebGLTexture)`);if(e instanceof l){if(!this._checkOwns(e)){this.setError(this.INVALID_OPERATION);return}}else return;let t=this._activeTextureUnit;for(let t=0;t<this._textureUnits.length;++t){let n=this._textureUnits[t];n._bind2D===e?(this.activeTexture(this.TEXTURE0+t),this.bindTexture(this.TEXTURE_2D,null)):n._bindCube===e&&(this.activeTexture(this.TEXTURE0+t),this.bindTexture(this.TEXTURE_CUBE_MAP,null))}this.activeTexture(this.TEXTURE0+t),this._detachTextureFromAllFramebuffers(e),e._pendingDelete=!0,e._checkDelete()},_detachTextureFromAllFramebuffers(e){let t=this._activeFramebuffer,n=this._getAttachments(),r=!1;for(let i in this._framebuffers){let a=this._framebuffers[i];if(!(!a||!a._linked(e))){a!==t&&(this._gl.bindFramebuffer(this.FRAMEBUFFER,a._|0),r=!0);for(let t=0;t<n.length;++t){let r=n[t];a._attachments[r]===e&&(this._gl.framebufferTexture2D(this.FRAMEBUFFER,r,a._attachmentFace[r]||this.TEXTURE_2D,0,a._attachmentLevel[r]||0),a._setAttachment(null,r))}}}r&&this._gl.bindFramebuffer(this.FRAMEBUFFER,t?t._|0:this._gtkFboId)},pixelStorei(e=0,t=0){if(typeof t==`boolean`&&(t=t===!1?0:1),e===this.UNPACK_ALIGNMENT)if(t===1||t===2||t===4||t===8)this._unpackAlignment=t;else{this.setError(this.INVALID_VALUE);return}else if(e===this.PACK_ALIGNMENT)if(t===1||t===2||t===4||t===8)this._packAlignment=t;else{this.setError(this.INVALID_VALUE);return}else if(e===this.UNPACK_COLORSPACE_CONVERSION_WEBGL){if(!(t===this.NONE||t===this.BROWSER_DEFAULT_WEBGL)){this.setError(this.INVALID_VALUE);return}}else if(e===this.UNPACK_FLIP_Y_WEBGL){this._unpackFlipY=!!t;return}else if(e===this.UNPACK_PREMULTIPLY_ALPHA_WEBGL){this._unpackPremultAlpha=!!t;return}this._gl.pixelStorei(e,t)},texImage2D(t=0,r=0,o=0,l=0,u=0,f=0,p=0,m=0,h){let g=0,_=0,v=0,y,b,x=0;if(arguments.length===6)if(m=u,v=l,f instanceof d.Pixbuf)b=f,g=b.get_width(),_=b.get_height(),h=b.get_pixels();else{y=f;let e=a(y);if(e==null)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);g=e.width,_=e.height,h=e.data}else arguments.length===9&&(g=l,_=u,x=f,v=p,h=h);if(typeof h!=`object`&&h!==void 0)throw TypeError(`texImage2D(GLenum, GLint, GLenum, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!n(this,v)||!n(this,o)){this.setError(this.INVALID_ENUM);return}if(m===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let S=this._getTexImage(t);if(!S||v!==o){this.setError(this.INVALID_OPERATION);return}let C=this._computePixelSize(m,v);if(C===0||!this._checkDimensions(t,g,_,r))return;let w=i(h),T=this._computeRowStride(g,C),E=T*_;if(w&&w.length<E){this.setError(this.INVALID_OPERATION);return}if(x!==0||c(this,t)&&g!==_){this.setError(this.INVALID_VALUE);return}if(this._unpackPremultAlpha&&w&&v===this.RGBA&&(w=s(w)),this._unpackFlipY&&w&&g>0&&_>0){let e=new Uint8Array(w.length);for(let t=0;t<_;t++){let n=t*T,r=(_-1-t)*T;e.set(w.subarray(n,n+T),r)}w=e}this._saveError(),this._gl.texImage2D(t,r,o,g,_,x,v,m,e(w));let D=this.getError();if(this._restoreError(D),D!==this.NO_ERROR)return;S._levelWidth[r]=g,S._levelHeight[r]=_,S._format=v,S._type=m;let O=this._activeFramebuffer;if(O){let e=!1,t=this._getAttachments();for(let n=0;n<t.length;++n)if(O._attachments[t[n]]===S){e=!0;break}e&&this._activeFramebuffer&&this._updateFramebufferAttachments(this._activeFramebuffer)}},texSubImage2D(t=0,n=0,r=0,o=0,c=0,l=0,u=0,f=0,p){let m=0,h=0,g=0,_,v;if(arguments.length===7)if(f=l,g=c,u instanceof d.Pixbuf)v=u,m=v.get_width(),h=v.get_height(),p=v.get_pixels();else{_=u;let e=a(_);if(e==null)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLenum, GLenum, ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement)`);m=e.width,h=e.height,p=e.data}else m=c,h=l,g=u;if(typeof p!=`object`)throw TypeError(`texSubImage2D(GLenum, GLint, GLint, GLint, GLint, GLint, GLenum, GLenum, Uint8Array)`);if(!this._getTexImage(t)){this.setError(this.INVALID_OPERATION);return}if(f===this.FLOAT&&!this._extensions.oes_texture_float){this.setError(this.INVALID_ENUM);return}let y=this._computePixelSize(f,g);if(y===0||!this._checkDimensions(t,m,h,n))return;if(r<0||o<0){this.setError(this.INVALID_VALUE);return}let b=i(p),x=this._computeRowStride(m,y),S=x*h;if(!b||b.length<S){this.setError(this.INVALID_OPERATION);return}if(this._unpackPremultAlpha&&b&&g===this.RGBA&&(b=s(b)),this._unpackFlipY&&b&&m>0&&h>0){let e=new Uint8Array(b.length);for(let t=0;t<h;t++){let n=t*x,r=(h-1-t)*x;e.set(b.subarray(n,n+x),r)}b=e}this._gl.texSubImage2D(t,n,r,o,m,h,g,f,e(b))},copyTexImage2D(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0){let c=this._getTexImage(e);if(!c){this.setError(this.INVALID_OPERATION);return}if(n!==this.RGBA&&n!==this.RGB&&n!==this.ALPHA&&n!==this.LUMINANCE&&n!==this.LUMINANCE_ALPHA){this.setError(this.INVALID_ENUM);return}if(t<0||a<0||o<0||s!==0){this.setError(this.INVALID_VALUE);return}if(t>0&&!(u.isPow2(a)&&u.isPow2(o))){this.setError(this.INVALID_VALUE);return}this._saveError(),this._gl.copyTexImage2D(e,t,n,r,i,a,o,s);let l=this.getError();this._restoreError(l),l===this.NO_ERROR&&(c._levelWidth[t]=a,c._levelHeight[t]=o,c._format=this.RGBA,c._type=this.UNSIGNED_BYTE)},copyTexSubImage2D(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0){if(!this._getTexImage(e)){this.setError(this.INVALID_OPERATION);return}if(o<0||s<0||n<0||r<0||t<0){this.setError(this.INVALID_VALUE);return}this._gl.copyTexSubImage2D(e,t,n,r,i,a,o,s)},compressedTexImage2D(n,r,i,a,o,s,c){this._gl.compressedTexImage2D(n,r,i,a,o,s,e(t(c)))},compressedTexSubImage2D(n,r,i,a,o,s,c,l){this._gl.compressedTexSubImage2D(n,r,i,a,o,s,c,e(t(l)))},texParameterf(e=0,t=0,n){if(n=+n,this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,t,n),t){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameterf(e,t,n);return}let r=this._extensions.ext_texture_filter_anisotropic;if(r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameterf(e,t,n);return}this.setError(this.INVALID_ENUM)}},texParameteri(e=0,t=0,n=0){if(this._checkTextureTarget(e)){switch(this._verifyTextureCompleteness(e,t,n),t){case this.TEXTURE_MIN_FILTER:case this.TEXTURE_MAG_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:this._gl.texParameteri(e,t,n);return}let r=this._extensions.ext_texture_filter_anisotropic;if(r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT){this._gl.texParameteri(e,t,n);return}this.setError(this.INVALID_ENUM)}},getTexParameter(e=0,t=0){if(!this._checkTextureTarget(e))return null;let n=this._getActiveTextureUnit();if(e===this.TEXTURE_2D&&!n._bind2D||e===this.TEXTURE_CUBE_MAP&&!n._bindCube)return this.setError(this.INVALID_OPERATION),null;switch(t){case this.TEXTURE_MAG_FILTER:case this.TEXTURE_MIN_FILTER:case this.TEXTURE_WRAP_S:case this.TEXTURE_WRAP_T:return this._getTexParameterDirect(e,t)}let r=this._extensions.ext_texture_filter_anisotropic;return r&&t===r.TEXTURE_MAX_ANISOTROPY_EXT?this._getTexParameterDirect(e,t):(this.setError(this.INVALID_ENUM),null)},_getTexParameterDirect(e=0,t=0){return this._gl.getTexParameterx(e,t)?.unpack()},_getActiveTextureUnit(){return this._textureUnits[this._activeTextureUnit]},_getActiveTexture(e){let t=this._getActiveTextureUnit();return e===this.TEXTURE_2D?t._bind2D:e===this.TEXTURE_CUBE_MAP?t._bindCube:null},_getTexImage(e){let t=this._getActiveTextureUnit();return e===this.TEXTURE_2D?t._bind2D:c(this,e)?t._bindCube:(this.setError(this.INVALID_ENUM),null)},_checkTextureTarget(e){let t=this._getActiveTextureUnit(),n=null;if(e===this.TEXTURE_2D)n=t._bind2D;else if(e===this.TEXTURE_CUBE_MAP)n=t._bindCube;else return this.setError(this.INVALID_ENUM),!1;return n?!0:(this.setError(this.INVALID_OPERATION),!1)},_validTextureTarget(e){return e===this.TEXTURE_2D||e===this.TEXTURE_CUBE_MAP},_validCubeTarget(e){return e===this.TEXTURE_CUBE_MAP_POSITIVE_X||e===this.TEXTURE_CUBE_MAP_NEGATIVE_X||e===this.TEXTURE_CUBE_MAP_POSITIVE_Y||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Y||e===this.TEXTURE_CUBE_MAP_POSITIVE_Z||e===this.TEXTURE_CUBE_MAP_NEGATIVE_Z},_verifyTextureCompleteness(e,t,n){let r=this._getActiveTextureUnit(),i=null;if(e===this.TEXTURE_2D?i=r._bind2D:this._validCubeTarget(e)&&(i=r._bindCube),this._extensions.oes_texture_float&&!this._extensions.oes_texture_float_linear&&i&&i._type===this.FLOAT&&(t===this.TEXTURE_MAG_FILTER||t===this.TEXTURE_MIN_FILTER)&&(n===this.LINEAR||n===this.LINEAR_MIPMAP_NEAREST||n===this.NEAREST_MIPMAP_LINEAR||n===this.LINEAR_MIPMAP_LINEAR)){i._complete=!1,this.bindTexture(e,i);return}i&&i._complete===!1&&(i._complete=!0,this.bindTexture(e,i))},_computePixelSize(e,t){let n=o(this,t);if(n===0)return this.setError(this.INVALID_ENUM),0;switch(e){case this.UNSIGNED_BYTE:return n;case this.UNSIGNED_SHORT_5_6_5:if(t!==this.RGB){this.setError(this.INVALID_OPERATION);break}return 2;case this.UNSIGNED_SHORT_4_4_4_4:case this.UNSIGNED_SHORT_5_5_5_1:if(t!==this.RGBA){this.setError(this.INVALID_OPERATION);break}return 2;case this.FLOAT:return 1}return this.setError(this.INVALID_ENUM),0},_computeRowStride(e,t){let n=e*t;return n%this._unpackAlignment&&(n+=this._unpackAlignment-n%this._unpackAlignment),n},_checkDimensions(e,t,n,r){if(r<0||t<0||n<0)return this.setError(this.INVALID_VALUE),!1;if(e===this.TEXTURE_2D){if(t>this._maxTextureSize||n>this._maxTextureSize||r>this._maxTextureLevel)return this.setError(this.INVALID_VALUE),!1}else if(this._validCubeTarget(e)){if(t>this._maxCubeMapSize||n>this._maxCubeMapSize||r>this._maxCubeMapLevel)return this.setError(this.INVALID_VALUE),!1}else return this.setError(this.INVALID_ENUM),!1;return!0}};function installTextureManagementMethods(e){Object.assign(e,f)}export{installTextureManagementMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{installTextureLifecycleMethods as e}from"./texture-management/lifecycle.js";import{installTexImage2DMethods as t}from"./texture-management/tex-image.js";import{installCopyAndCompressedTextureMethods as n}from"./texture-management/copy-and-compressed.js";import{installTextureParameterMethods as r}from"./texture-management/parameters.js";import{installTextureIntrospectionMethods as i}from"./texture-management/introspection.js";function installTextureManagementMethods(a){e(a),t(a),n(a),r(a),i(a)}export{installTextureManagementMethods};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{WebGLContextAttributes as e}from"./webgl-context-attributes.js";import{WebGLUniformLocation as t}from"./webgl-uniform-location.js";import{OESElementIndexUint as n,getOESElementIndexUint as r}from"./extensions/oes-element-index-unit.js";import{OESStandardDerivatives as i,getOESStandardDerivatives as a}from"./extensions/oes-standard-derivatives.js";import{OESTextureFloat as o,getOESTextureFloat as s}from"./extensions/oes-texture-float.js";import{OESTextureFloatLinear as c,getOESTextureFloatLinear as l}from"./extensions/oes-texture-float-linear.js";import{STACKGLDestroyContext as u,getSTACKGLDestroyContext as d}from"./extensions/stackgl-destroy-context.js";import{STACKGLResizeDrawingBuffer as f,getSTACKGLResizeDrawingBuffer as p}from"./extensions/stackgl-resize-drawing-buffer.js";import{EXTBlendMinMax as m,getEXTBlendMinMax as h}from"./extensions/ext-blend-minmax.js";import{EXTColorBufferFloat as g,getEXTColorBufferFloat as _}from"./extensions/ext-color-buffer-float.js";import{EXTColorBufferHalfFloat as v,getEXTColorBufferHalfFloat as y}from"./extensions/ext-color-buffer-half-float.js";import{EXTTextureFilterAnisotropic as b,getEXTTextureFilterAnisotropic as x}from"./extensions/ext-texture-filter-anisotropic.js";import{OESTextureHalfFloat as S,getOESTextureHalfFloat as C}from"./extensions/oes-texture-half-float.js";import{WebGLTextureUnit as w}from"./webgl-texture-unit.js";import{WebGLBuffer as T}from"./webgl-buffer.js";import{WebGLVertexArrayGlobalAttribute as E,WebGLVertexArrayGlobalState as D,WebGLVertexArrayObjectAttribute as O,WebGLVertexArrayObjectState as k}from"./webgl-vertex-attribute.js";import{WebGLFramebuffer as A}from"./webgl-framebuffer.js";import{WebGLProgram as j}from"./webgl-program.js";import{WebGLRenderbuffer as M}from"./webgl-renderbuffer.js";import{WebGLShader as N}from"./webgl-shader.js";import{WebGLTexture as P}from"./webgl-texture.js";import{WebGLDrawingBufferWrapper as F}from"./webgl-drawing-buffer-wrapper.js";import{WebGLActiveInfo as I}from"./webgl-active-info.js";import{WebGLShaderPrecisionFormat as L}from"./webgl-shader-precision-format.js";import{WebGLContextBase as R}from"./webgl-context-base.js";import{WebGLRenderingContext as z}from"./webgl-rendering-context.js";import{WebGLQuery as B}from"./webgl-query.js";import{WebGLSampler as V}from"./webgl-sampler.js";import{WebGLSync as H}from"./webgl-sync.js";import{WebGLTransformFeedback as U}from"./webgl-transform-feedback.js";import{WebGLVertexArrayObject as W}from"./webgl-vertex-array-object.js";import{WebGL2RenderingContext as G}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as K}from"./html-canvas-element.js";import{WebGLBridge as q}from"./webgl-bridge.js";import"@girs/gtk-4.0";import"@girs/gjs";import"@girs/gio-2.0";const J=globalThis;J.WebGLRenderingContext=z,J.WebGL2RenderingContext=G;export{m as EXTBlendMinMax,g as EXTColorBufferFloat,v as EXTColorBufferHalfFloat,b as EXTTextureFilterAnisotropic,K as HTMLCanvasElement,n as OESElementIndexUint,i as OESStandardDerivatives,o as OESTextureFloat,c as OESTextureFloatLinear,S as OESTextureHalfFloat,u as STACKGLDestroyContext,f as STACKGLResizeDrawingBuffer,G as WebGL2RenderingContext,I as WebGLActiveInfo,q as WebGLBridge,T as WebGLBuffer,e as WebGLContextAttributes,R as WebGLContextBase,F as WebGLDrawingBufferWrapper,A as WebGLFramebuffer,j as WebGLProgram,B as WebGLQuery,M as WebGLRenderbuffer,z as WebGLRenderingContext,V as WebGLSampler,N as WebGLShader,L as WebGLShaderPrecisionFormat,H as WebGLSync,P as WebGLTexture,w as WebGLTextureUnit,U as WebGLTransformFeedback,t as WebGLUniformLocation,E as WebGLVertexArrayGlobalAttribute,D as WebGLVertexArrayGlobalState,W as WebGLVertexArrayObject,O as WebGLVertexArrayObjectAttribute,k as WebGLVertexArrayObjectState,h as getEXTBlendMinMax,_ as getEXTColorBufferFloat,y as getEXTColorBufferHalfFloat,x as getEXTTextureFilterAnisotropic,r as getOESElementIndexUint,a as getOESStandardDerivatives,s as getOESTextureFloat,l as getOESTextureFloatLinear,C as getOESTextureHalfFloat,d as getSTACKGLDestroyContext,p as getSTACKGLResizeDrawingBuffer};
1
+ import{WebGLContextAttributes as e}from"./webgl-context-attributes.js";import{WebGLUniformLocation as t}from"./webgl-uniform-location.js";import{OESElementIndexUint as n,getOESElementIndexUint as r}from"./extensions/oes-element-index-unit.js";import{OESStandardDerivatives as i,getOESStandardDerivatives as a}from"./extensions/oes-standard-derivatives.js";import{OESTextureFloat as o,getOESTextureFloat as s}from"./extensions/oes-texture-float.js";import{OESTextureFloatLinear as c,getOESTextureFloatLinear as l}from"./extensions/oes-texture-float-linear.js";import{STACKGLDestroyContext as u,getSTACKGLDestroyContext as d}from"./extensions/stackgl-destroy-context.js";import{STACKGLResizeDrawingBuffer as f,getSTACKGLResizeDrawingBuffer as p}from"./extensions/stackgl-resize-drawing-buffer.js";import{EXTBlendMinMax as m,getEXTBlendMinMax as h}from"./extensions/ext-blend-minmax.js";import{EXTColorBufferFloat as g,getEXTColorBufferFloat as _}from"./extensions/ext-color-buffer-float.js";import{EXTColorBufferHalfFloat as v,getEXTColorBufferHalfFloat as y}from"./extensions/ext-color-buffer-half-float.js";import{EXTTextureFilterAnisotropic as b,getEXTTextureFilterAnisotropic as x}from"./extensions/ext-texture-filter-anisotropic.js";import{OESTextureHalfFloat as S,getOESTextureHalfFloat as C}from"./extensions/oes-texture-half-float.js";import{WebGLTextureUnit as w}from"./webgl-texture-unit.js";import{WebGLBuffer as T}from"./webgl-buffer.js";import{WebGLVertexArrayGlobalAttribute as E,WebGLVertexArrayGlobalState as D,WebGLVertexArrayObjectAttribute as O,WebGLVertexArrayObjectState as k}from"./webgl-vertex-attribute.js";import{WebGLFramebuffer as A}from"./webgl-framebuffer.js";import{WebGLProgram as j}from"./webgl-program.js";import{WebGLRenderbuffer as M}from"./webgl-renderbuffer.js";import{WebGLShader as N}from"./webgl-shader.js";import{WebGLTexture as P}from"./webgl-texture.js";import{WebGLDrawingBufferWrapper as F}from"./webgl-drawing-buffer-wrapper.js";import{WebGLShaderPrecisionFormat as I}from"./webgl-shader-precision-format.js";import{WebGLActiveInfo as L}from"./webgl-active-info.js";import{WebGLContextBase as R}from"./webgl-context-base.js";import{WebGLRenderingContext as z}from"./webgl-rendering-context.js";import{WebGLQuery as B}from"./webgl-query.js";import{WebGLSampler as V}from"./webgl-sampler.js";import{WebGLSync as H}from"./webgl-sync.js";import{WebGLTransformFeedback as U}from"./webgl-transform-feedback.js";import{WebGLVertexArrayObject as W}from"./webgl-vertex-array-object.js";import{WebGL2RenderingContext as G}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as K}from"./html-canvas-element.js";import{WebGLBridge as q}from"./webgl-bridge.js";import"@girs/gtk-4.0";import"@girs/gjs";import"@girs/gio-2.0";const J=globalThis;J.WebGLRenderingContext=z,J.WebGL2RenderingContext=G;export{m as EXTBlendMinMax,g as EXTColorBufferFloat,v as EXTColorBufferHalfFloat,b as EXTTextureFilterAnisotropic,K as HTMLCanvasElement,n as OESElementIndexUint,i as OESStandardDerivatives,o as OESTextureFloat,c as OESTextureFloatLinear,S as OESTextureHalfFloat,u as STACKGLDestroyContext,f as STACKGLResizeDrawingBuffer,G as WebGL2RenderingContext,L as WebGLActiveInfo,q as WebGLBridge,T as WebGLBuffer,e as WebGLContextAttributes,R as WebGLContextBase,F as WebGLDrawingBufferWrapper,A as WebGLFramebuffer,j as WebGLProgram,B as WebGLQuery,M as WebGLRenderbuffer,z as WebGLRenderingContext,V as WebGLSampler,N as WebGLShader,I as WebGLShaderPrecisionFormat,H as WebGLSync,P as WebGLTexture,w as WebGLTextureUnit,U as WebGLTransformFeedback,t as WebGLUniformLocation,E as WebGLVertexArrayGlobalAttribute,D as WebGLVertexArrayGlobalState,W as WebGLVertexArrayObject,O as WebGLVertexArrayObjectAttribute,k as WebGLVertexArrayObjectState,h as getEXTBlendMinMax,_ as getEXTColorBufferFloat,y as getEXTColorBufferHalfFloat,x as getEXTTextureFilterAnisotropic,r as getOESElementIndexUint,a as getOESStandardDerivatives,s as getOESTextureFloat,l as getOESTextureFloatLinear,C as getOESTextureHalfFloat,d as getSTACKGLDestroyContext,p as getSTACKGLResizeDrawingBuffer};
@@ -0,0 +1,16 @@
1
+ import { WebGLActiveInfo } from '../../webgl-active-info.js';
2
+ import { WebGLProgram } from '../../webgl-program.js';
3
+ import { WebGLUniformLocation } from '../../webgl-uniform-location.js';
4
+ export interface IntrospectionMethods {
5
+ getActiveAttrib(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null;
6
+ getActiveUniform(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null;
7
+ getAttribLocation(program: WebGLProgram, name: string): GLint;
8
+ getUniform(program: WebGLProgram, location: WebGLUniformLocation): unknown;
9
+ getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation | null;
10
+ }
11
+ declare module '../shader-program.js' {
12
+ interface ShaderProgramMethods extends IntrospectionMethods {
13
+ }
14
+ }
15
+ /** Install program-introspection methods on WebGLContextBase.prototype. */
16
+ export declare function installIntrospectionMethods(proto: object): void;
@@ -0,0 +1,25 @@
1
+ import { WebGLProgram } from '../../webgl-program.js';
2
+ import { WebGLShader } from '../../webgl-shader.js';
3
+ export interface ProgramLifecycleMethods {
4
+ createProgram(): WebGLProgram | null;
5
+ deleteProgram(program: WebGLProgram | null): void;
6
+ useProgram(program: WebGLProgram): void;
7
+ linkProgram(program: WebGLProgram): void;
8
+ validateProgram(program: WebGLProgram): void;
9
+ attachShader(program: WebGLProgram, shader: WebGLShader): void;
10
+ detachShader(program: WebGLProgram, shader: WebGLShader): void;
11
+ bindAttribLocation(program: WebGLProgram, index: GLuint, name: string): void;
12
+ getAttachedShaders(program: WebGLProgram): WebGLShader[] | null;
13
+ getProgramInfoLog(program: WebGLProgram): string | null;
14
+ getProgramParameter(program: WebGLProgram, pname?: GLenum): unknown;
15
+ _switchActiveProgram(active: WebGLProgram | null): void;
16
+ _fixupLink(program: WebGLProgram): boolean;
17
+ _deleteLinkable(name: 'deleteProgram', object: WebGLProgram | null, Type: typeof WebGLProgram): void;
18
+ _deleteLinkable(name: 'deleteShader', object: WebGLShader | null, Type: typeof WebGLShader): void;
19
+ }
20
+ declare module '../shader-program.js' {
21
+ interface ShaderProgramMethods extends ProgramLifecycleMethods {
22
+ }
23
+ }
24
+ /** Install program-object lifecycle methods on WebGLContextBase.prototype. */
25
+ export declare function installProgramLifecycleMethods(proto: object): void;
@@ -0,0 +1,20 @@
1
+ import { WebGLShader } from '../../webgl-shader.js';
2
+ import { WebGLShaderPrecisionFormat } from '../../webgl-shader-precision-format.js';
3
+ export interface ShaderLifecycleMethods {
4
+ createShader(type?: GLenum): WebGLShader | null;
5
+ deleteShader(shader: WebGLShader | null): void;
6
+ compileShader(shader: WebGLShader): void;
7
+ shaderSource(shader: WebGLShader, source: string): void;
8
+ getShaderInfoLog(shader: WebGLShader): string | null;
9
+ getShaderParameter(shader: WebGLShader, pname?: GLenum): unknown;
10
+ getShaderPrecisionFormat(shaderType?: GLenum, precisionType?: GLenum): WebGLShaderPrecisionFormat | null;
11
+ getShaderSource(shader: WebGLShader): string | null;
12
+ _checkShaderSource(shader: WebGLShader): boolean;
13
+ _wrapShader(type: GLenum, source: string): string;
14
+ }
15
+ declare module '../shader-program.js' {
16
+ interface ShaderProgramMethods extends ShaderLifecycleMethods {
17
+ }
18
+ }
19
+ /** Install shader-object lifecycle + source-validation methods on WebGLContextBase.prototype. */
20
+ export declare function installShaderLifecycleMethods(proto: object): void;
@@ -0,0 +1,33 @@
1
+ import { WebGLUniformLocation } from '../../webgl-uniform-location.js';
2
+ export interface UniformsMethods {
3
+ uniform1f(location: WebGLUniformLocation | null, x: GLfloat): void;
4
+ uniform1i(location: WebGLUniformLocation | null, x: GLint): void;
5
+ uniform2f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat): void;
6
+ uniform2i(location: WebGLUniformLocation | null, x: GLint, y: GLint): void;
7
+ uniform3f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat): void;
8
+ uniform3i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint): void;
9
+ uniform4f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void;
10
+ uniform4i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint, w: GLint): void;
11
+ uniform1fv(location: WebGLUniformLocation | null, value: Float32List | Int32List): void;
12
+ uniform1iv(location: WebGLUniformLocation | null, v: Int32List): void;
13
+ uniform2fv(location: WebGLUniformLocation | null, v: Float32List): void;
14
+ uniform2iv(location: WebGLUniformLocation | null, v: Int32List): void;
15
+ uniform3fv(location: WebGLUniformLocation | null, v: Float32List): void;
16
+ uniform3iv(location: WebGLUniformLocation | null, v: Int32List): void;
17
+ uniform4fv(location: WebGLUniformLocation | null, v: Float32List): void;
18
+ uniform4iv(location: WebGLUniformLocation | null, v: Int32List): void;
19
+ uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
20
+ uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
21
+ uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
22
+ _checkLocation(location: WebGLUniformLocation | null): boolean;
23
+ _checkLocationActive(location: WebGLUniformLocation | null): boolean;
24
+ _checkUniformValid(location: WebGLUniformLocation | null, v0: GLfloat, name: string, count: number, type: string): boolean;
25
+ _checkUniformValueValid(location: WebGLUniformLocation | null, value: Float32List | Int32List, name: string, count: number, type: string): boolean;
26
+ _checkUniformMatrix(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List, name: string, count: number): boolean;
27
+ }
28
+ declare module '../shader-program.js' {
29
+ interface ShaderProgramMethods extends UniformsMethods {
30
+ }
31
+ }
32
+ /** Install uniform setter + validation helper methods on WebGLContextBase.prototype. */
33
+ export declare function installUniformsMethods(proto: object): void;
@@ -1,67 +1,22 @@
1
- import { WebGLActiveInfo } from '../webgl-active-info.js';
2
- import { WebGLProgram } from '../webgl-program.js';
3
- import { WebGLShader } from '../webgl-shader.js';
4
- import { WebGLShaderPrecisionFormat } from '../webgl-shader-precision-format.js';
5
- import { WebGLUniformLocation } from '../webgl-uniform-location.js';
1
+ import './shader-program/shader-lifecycle.js';
2
+ import { installShaderLifecycleMethods } from './shader-program/shader-lifecycle.js';
3
+ import './shader-program/program-lifecycle.js';
4
+ import { installProgramLifecycleMethods } from './shader-program/program-lifecycle.js';
5
+ import './shader-program/introspection.js';
6
+ import { installIntrospectionMethods } from './shader-program/introspection.js';
7
+ import './shader-program/uniforms.js';
8
+ import { installUniformsMethods } from './shader-program/uniforms.js';
9
+ /**
10
+ * Aggregate of every method-group interface that contributes to the shader /
11
+ * program surface. Each sub-module extends this interface via `declare module
12
+ * './shader-program.js' { interface ShaderProgramMethods extends <Group>Methods {} }`.
13
+ */
6
14
  export interface ShaderProgramMethods {
7
- createShader(type?: GLenum): WebGLShader | null;
8
- deleteShader(shader: WebGLShader | null): void;
9
- compileShader(shader: WebGLShader): void;
10
- shaderSource(shader: WebGLShader, source: string): void;
11
- getShaderInfoLog(shader: WebGLShader): string | null;
12
- getShaderParameter(shader: WebGLShader, pname?: GLenum): unknown;
13
- getShaderPrecisionFormat(shaderType?: GLenum, precisionType?: GLenum): WebGLShaderPrecisionFormat | null;
14
- getShaderSource(shader: WebGLShader): string | null;
15
- attachShader(program: WebGLProgram, shader: WebGLShader): void;
16
- detachShader(program: WebGLProgram, shader: WebGLShader): void;
17
- bindAttribLocation(program: WebGLProgram, index: GLuint, name: string): void;
18
- createProgram(): WebGLProgram | null;
19
- deleteProgram(program: WebGLProgram | null): void;
20
- useProgram(program: WebGLProgram): void;
21
- linkProgram(program: WebGLProgram): void;
22
- validateProgram(program: WebGLProgram): void;
23
- getActiveAttrib(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null;
24
- getActiveUniform(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null;
25
- getAttachedShaders(program: WebGLProgram): WebGLShader[] | null;
26
- getAttribLocation(program: WebGLProgram, name: string): GLint;
27
- getUniform(program: WebGLProgram, location: WebGLUniformLocation): unknown;
28
- getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation | null;
29
- getProgramInfoLog(program: WebGLProgram): string | null;
30
- getProgramParameter(program: WebGLProgram, pname?: GLenum): unknown;
31
- uniform1f(location: WebGLUniformLocation | null, x: GLfloat): void;
32
- uniform1i(location: WebGLUniformLocation | null, x: GLint): void;
33
- uniform2f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat): void;
34
- uniform2i(location: WebGLUniformLocation | null, x: GLint, y: GLint): void;
35
- uniform3f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat): void;
36
- uniform3i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint): void;
37
- uniform4f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void;
38
- uniform4i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint, w: GLint): void;
39
- uniform1fv(location: WebGLUniformLocation | null, value: Float32List | Int32List): void;
40
- uniform1iv(location: WebGLUniformLocation | null, v: Int32List): void;
41
- uniform2fv(location: WebGLUniformLocation | null, v: Float32List): void;
42
- uniform2iv(location: WebGLUniformLocation | null, v: Int32List): void;
43
- uniform3fv(location: WebGLUniformLocation | null, v: Float32List): void;
44
- uniform3iv(location: WebGLUniformLocation | null, v: Int32List): void;
45
- uniform4fv(location: WebGLUniformLocation | null, v: Float32List): void;
46
- uniform4iv(location: WebGLUniformLocation | null, v: Int32List): void;
47
- uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
48
- uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
49
- uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void;
50
- _checkLocation(location: WebGLUniformLocation | null): boolean;
51
- _checkLocationActive(location: WebGLUniformLocation | null): boolean;
52
- _checkUniformValid(location: WebGLUniformLocation | null, v0: GLfloat, name: string, count: number, type: string): boolean;
53
- _checkUniformValueValid(location: WebGLUniformLocation | null, value: Float32List | Int32List, name: string, count: number, type: string): boolean;
54
- _checkUniformMatrix(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List, name: string, count: number): boolean;
55
- _checkShaderSource(shader: WebGLShader): boolean;
56
- _wrapShader(type: GLenum, source: string): string;
57
- _switchActiveProgram(active: WebGLProgram | null): void;
58
- _fixupLink(program: WebGLProgram): boolean;
59
- _deleteLinkable(name: 'deleteProgram', object: WebGLProgram | null, Type: typeof WebGLProgram): void;
60
- _deleteLinkable(name: 'deleteShader', object: WebGLShader | null, Type: typeof WebGLShader): void;
61
15
  }
62
16
  declare module '../webgl-context-base.js' {
63
17
  interface WebGLContextBase extends ShaderProgramMethods {
64
18
  }
65
19
  }
66
- /** Install shader/program methods on the given prototype. Called from webgl-context-base.ts. */
20
+ /** Install every shader / program method group on the given prototype. */
67
21
  export declare function installShaderProgramMethods(proto: object): void;
22
+ export { installShaderLifecycleMethods, installProgramLifecycleMethods, installIntrospectionMethods, installUniformsMethods, };
@@ -0,0 +1,13 @@
1
+ import type { TypedArray } from '../../types/index.js';
2
+ export interface CopyAndCompressedTextureMethods {
3
+ copyTexImage2D(target?: GLenum, level?: GLint, internalFormat?: GLenum, x?: GLint, y?: GLint, width?: GLsizei, height?: GLsizei, border?: GLint): void;
4
+ copyTexSubImage2D(target?: GLenum, level?: GLint, xoffset?: GLint, yoffset?: GLint, x?: GLint, y?: GLint, width?: GLsizei, height?: GLsizei): void;
5
+ compressedTexImage2D(target: GLenum, level: GLint, internalFormat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: TypedArray): void;
6
+ compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: TypedArray): void;
7
+ }
8
+ declare module '../../webgl-context-base.js' {
9
+ interface WebGLContextBase extends CopyAndCompressedTextureMethods {
10
+ }
11
+ }
12
+ /** Install copy + compressed texture methods on the given prototype. Called from texture-management.ts. */
13
+ export declare function installCopyAndCompressedTextureMethods(proto: object): void;
@@ -0,0 +1,20 @@
1
+ import type { WebGLTexture } from '../../webgl-texture.js';
2
+ import type { WebGLTextureUnit } from '../../webgl-texture-unit.js';
3
+ export interface TextureIntrospectionMethods {
4
+ _getActiveTextureUnit(): WebGLTextureUnit;
5
+ _getActiveTexture(target: GLenum): WebGLTexture | null;
6
+ _getTexImage(target: GLenum): WebGLTexture | null;
7
+ _checkTextureTarget(target: GLenum): boolean;
8
+ _validTextureTarget(target: GLenum): boolean;
9
+ _validCubeTarget(target: GLenum): boolean;
10
+ _verifyTextureCompleteness(target: GLenum, pname: GLenum, param: GLenum): void;
11
+ _computePixelSize(type: GLenum, internalFormat: GLenum): number;
12
+ _computeRowStride(width: number, pixelSize: number): number;
13
+ _checkDimensions(target: GLenum, width: GLsizei, height: GLsizei, level: number): boolean;
14
+ }
15
+ declare module '../../webgl-context-base.js' {
16
+ interface WebGLContextBase extends TextureIntrospectionMethods {
17
+ }
18
+ }
19
+ /** Install internal texture-introspection helpers on the given prototype. Called from texture-management.ts. */
20
+ export declare function installTextureIntrospectionMethods(proto: object): void;
@@ -0,0 +1,15 @@
1
+ import { WebGLTexture } from '../../webgl-texture.js';
2
+ export interface TextureLifecycleMethods {
3
+ activeTexture(texture?: GLenum): void;
4
+ bindTexture(target: GLenum | undefined, texture: WebGLTexture | null): void;
5
+ createTexture(): WebGLTexture | null;
6
+ deleteTexture(texture: WebGLTexture | null): void;
7
+ _detachTextureFromAllFramebuffers(texture: WebGLTexture): void;
8
+ pixelStorei(pname?: GLenum, param?: GLint | GLboolean): void;
9
+ }
10
+ declare module '../../webgl-context-base.js' {
11
+ interface WebGLContextBase extends TextureLifecycleMethods {
12
+ }
13
+ }
14
+ /** Install texture-lifecycle methods on the given prototype. Called from texture-management.ts. */
15
+ export declare function installTextureLifecycleMethods(proto: object): void;
@@ -0,0 +1,12 @@
1
+ export interface TextureParameterMethods {
2
+ texParameterf(target?: GLenum, pname?: GLenum, param?: GLfloat): void;
3
+ texParameteri(target?: GLenum, pname?: GLenum, param?: GLint): void;
4
+ getTexParameter(target?: GLenum, pname?: GLenum): unknown;
5
+ _getTexParameterDirect(target?: GLenum, pname?: GLenum): unknown;
6
+ }
7
+ declare module '../../webgl-context-base.js' {
8
+ interface WebGLContextBase extends TextureParameterMethods {
9
+ }
10
+ }
11
+ /** Install texture-parameter methods on the given prototype. Called from texture-management.ts. */
12
+ export declare function installTextureParameterMethods(proto: object): void;
@@ -0,0 +1,13 @@
1
+ import GdkPixbuf from 'gi://GdkPixbuf?version=2.0';
2
+ export interface TexImage2DMethods {
3
+ texImage2D(target: GLenum, level: GLint, internalFormat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
4
+ texImage2D(target: GLenum, level: GLint, internalFormat: GLint, format: GLenum, type: GLenum, source: TexImageSource | GdkPixbuf.Pixbuf): void;
5
+ texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
6
+ texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource | GdkPixbuf.Pixbuf): void;
7
+ }
8
+ declare module '../../webgl-context-base.js' {
9
+ interface WebGLContextBase extends TexImage2DMethods {
10
+ }
11
+ }
12
+ /** Install 2D texture-upload methods on the given prototype. Called from texture-management.ts. */
13
+ export declare function installTexImage2DMethods(proto: object): void;
@@ -1,40 +1,26 @@
1
- import GdkPixbuf from 'gi://GdkPixbuf?version=2.0';
2
- import { WebGLTexture } from '../webgl-texture.js';
3
- import type { WebGLTextureUnit } from '../webgl-texture-unit.js';
4
- import type { TypedArray } from '../types/index.js';
5
- export interface TextureManagementMethods {
6
- activeTexture(texture?: GLenum): void;
7
- bindTexture(target: GLenum | undefined, texture: WebGLTexture | null): void;
8
- createTexture(): WebGLTexture | null;
9
- deleteTexture(texture: WebGLTexture | null): void;
10
- _detachTextureFromAllFramebuffers(texture: WebGLTexture): void;
11
- pixelStorei(pname?: GLenum, param?: GLint | GLboolean): void;
12
- texImage2D(target: GLenum, level: GLint, internalFormat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
13
- texImage2D(target: GLenum, level: GLint, internalFormat: GLint, format: GLenum, type: GLenum, source: TexImageSource | GdkPixbuf.Pixbuf): void;
14
- texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
15
- texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource | GdkPixbuf.Pixbuf): void;
16
- copyTexImage2D(target?: GLenum, level?: GLint, internalFormat?: GLenum, x?: GLint, y?: GLint, width?: GLsizei, height?: GLsizei, border?: GLint): void;
17
- copyTexSubImage2D(target?: GLenum, level?: GLint, xoffset?: GLint, yoffset?: GLint, x?: GLint, y?: GLint, width?: GLsizei, height?: GLsizei): void;
18
- compressedTexImage2D(target: GLenum, level: GLint, internalFormat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: TypedArray): void;
19
- compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: TypedArray): void;
20
- texParameterf(target?: GLenum, pname?: GLenum, param?: GLfloat): void;
21
- texParameteri(target?: GLenum, pname?: GLenum, param?: GLint): void;
22
- getTexParameter(target?: GLenum, pname?: GLenum): unknown;
23
- _getTexParameterDirect(target?: GLenum, pname?: GLenum): unknown;
24
- _getActiveTextureUnit(): WebGLTextureUnit;
25
- _getActiveTexture(target: GLenum): WebGLTexture | null;
26
- _getTexImage(target: GLenum): WebGLTexture | null;
27
- _checkTextureTarget(target: GLenum): boolean;
28
- _validTextureTarget(target: GLenum): boolean;
29
- _validCubeTarget(target: GLenum): boolean;
30
- _verifyTextureCompleteness(target: GLenum, pname: GLenum, param: GLenum): void;
31
- _computePixelSize(type: GLenum, internalFormat: GLenum): number;
32
- _computeRowStride(width: number, pixelSize: number): number;
33
- _checkDimensions(target: GLenum, width: GLsizei, height: GLsizei, level: number): boolean;
1
+ import './texture-management/lifecycle.js';
2
+ import './texture-management/tex-image.js';
3
+ import './texture-management/copy-and-compressed.js';
4
+ import './texture-management/parameters.js';
5
+ import './texture-management/introspection.js';
6
+ import { type TextureLifecycleMethods } from './texture-management/lifecycle.js';
7
+ import { type TexImage2DMethods } from './texture-management/tex-image.js';
8
+ import { type CopyAndCompressedTextureMethods } from './texture-management/copy-and-compressed.js';
9
+ import { type TextureParameterMethods } from './texture-management/parameters.js';
10
+ import { type TextureIntrospectionMethods } from './texture-management/introspection.js';
11
+ export type { TextureLifecycleMethods } from './texture-management/lifecycle.js';
12
+ export type { TexImage2DMethods } from './texture-management/tex-image.js';
13
+ export type { CopyAndCompressedTextureMethods } from './texture-management/copy-and-compressed.js';
14
+ export type { TextureParameterMethods } from './texture-management/parameters.js';
15
+ export type { TextureIntrospectionMethods } from './texture-management/introspection.js';
16
+ /**
17
+ * Aggregate `WebGLContextBase` augmentation contributed by every sibling
18
+ * `texture-management/<group>.ts` module. Mirrors the per-group `declare
19
+ * module` augmentations they already emit kept as a single re-exported
20
+ * interface so callers depending only on `TextureManagementMethods` keep
21
+ * compiling.
22
+ */
23
+ export interface TextureManagementMethods extends TextureLifecycleMethods, TexImage2DMethods, CopyAndCompressedTextureMethods, TextureParameterMethods, TextureIntrospectionMethods {
34
24
  }
35
- declare module '../webgl-context-base.js' {
36
- interface WebGLContextBase extends TextureManagementMethods {
37
- }
38
- }
39
- /** Install texture-management methods on the given prototype. Called from webgl-context-base.ts. */
25
+ /** Install every texture-management method group on the given prototype. Called from `context/index.ts`. */
40
26
  export declare function installTextureManagementMethods(proto: object): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/webgl",
3
- "version": "0.4.34",
3
+ "version": "0.4.35",
4
4
  "description": "WebGL module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -44,8 +44,8 @@
44
44
  "WebGL"
45
45
  ],
46
46
  "devDependencies": {
47
- "@gjsify/cli": "^0.4.34",
48
- "@gjsify/unit": "^0.4.34",
47
+ "@gjsify/cli": "^0.4.35",
48
+ "@gjsify/unit": "^0.4.35",
49
49
  "@types/bit-twiddle": "^1.0.3",
50
50
  "@types/node": "^25.9.1",
51
51
  "typescript": "^6.0.3"
@@ -54,10 +54,10 @@
54
54
  "@girs/gjs": "4.0.1",
55
55
  "@girs/gtk-4.0": "4.23.0-4.0.1",
56
56
  "@girs/gwebgl-0.1": "0.1.0-4.0.0-rc.5",
57
- "@gjsify/dom-elements": "^0.4.34",
58
- "@gjsify/dom-events": "^0.4.34",
59
- "@gjsify/event-bridge": "^0.4.34",
60
- "@gjsify/utils": "^0.4.34",
57
+ "@gjsify/dom-elements": "^0.4.35",
58
+ "@gjsify/dom-events": "^0.4.35",
59
+ "@gjsify/event-bridge": "^0.4.35",
60
+ "@gjsify/utils": "^0.4.35",
61
61
  "bit-twiddle": "^1.0.2",
62
62
  "glsl-tokenizer": "^2.1.5"
63
63
  }