MCPcopy Index your code
hub / github.com/processing/p5.js / init

Method init

src/webgl/p5.Texture.js:129–166  ·  view source on GitHub ↗

* Initializes common texture parameters, creates a gl texture, * tries to upload the texture for the first time if data is * already available.

(textureData)

Source from the content-addressed store, hash-verified

127 * already available.
128 */
129 init(textureData) {
130 if (!this.isFramebufferTexture) {
131 this.textureHandle = this._renderer.createTexture({
132 format: this.format,
133 dataType: this.dataType,
134 width: textureData.width,
135 height: textureData.height,
136 });
137 } else {
138 this.textureHandle = this._renderer.createFramebufferTextureHandle(this.src);
139 }
140
141 this._renderer.setTextureParams(this, {
142 minFilter: this.minFilter,
143 magFilter: this.magFilter,
144 wrapS: this.wrapS,
145 wrapT: this.wrapT
146 });
147
148 this.bindTexture();
149
150 if (this._shouldDeferUpload()) {
151 this._renderer.uploadTextureFromData(
152 this.textureHandle,
153 new Uint8Array(1, 1, 1, 1),
154 1,
155 1
156 );
157 } else if (!this.isFramebufferTexture) {
158 // this.update()
159 this._renderer.uploadTextureFromSource(
160 this.textureHandle,
161 textureData
162 );
163 }
164
165 this.unbindTexture();
166 }
167
168 _shouldDeferUpload() {
169 return (

Callers 1

constructorMethod · 0.95

Calls 8

bindTextureMethod · 0.95
_shouldDeferUploadMethod · 0.95
unbindTextureMethod · 0.95
createTextureMethod · 0.45
setTextureParamsMethod · 0.45
uploadTextureFromDataMethod · 0.45

Tested by

no test coverage detected