Skip to content

Commit 38d1cdb

Browse files
authored
Merge pull request #13574 from bghgary/wrap-texture
Update wrapNativeTexture and wrapWebGLTexture with explicit hasMipMaps and samplingMode
2 parents 3f0a628 + c1ac334 commit 38d1cdb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/dev/core/src/Engines/engine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,13 +1686,17 @@ export class Engine extends ThinEngine {
16861686
/**
16871687
* Wraps an external web gl texture in a Babylon texture.
16881688
* @param texture defines the external texture
1689+
* @param hasMipMaps defines whether the external texture has mip maps (default: false)
1690+
* @param samplingMode defines the sampling mode for the external texture (default: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE)
16891691
* @returns the babylon internal texture
16901692
*/
1691-
public wrapWebGLTexture(texture: WebGLTexture): InternalTexture {
1693+
public wrapWebGLTexture(texture: WebGLTexture, hasMipMaps: boolean = false, samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE): InternalTexture {
16921694
const hardwareTexture = new WebGLHardwareTexture(texture, this._gl);
16931695
const internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
16941696
internalTexture._hardwareTexture = hardwareTexture;
16951697
internalTexture.isReady = true;
1698+
internalTexture.useMipMaps = hasMipMaps;
1699+
this.updateTextureSamplingMode(samplingMode, internalTexture);
16961700
return internalTexture;
16971701
}
16981702

packages/dev/core/src/Engines/nativeEngine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,13 +1779,17 @@ export class NativeEngine extends Engine {
17791779
/**
17801780
* Wraps an external native texture in a Babylon texture.
17811781
* @param texture defines the external texture
1782+
* @param hasMipMaps defines whether the external texture has mip maps
1783+
* @param samplingMode defines the sampling mode for the external texture (default: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE)
17821784
* @returns the babylon internal texture
17831785
*/
1784-
public wrapNativeTexture(texture: any): InternalTexture {
1786+
public wrapNativeTexture(texture: any, hasMipMaps: boolean = false, samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE): InternalTexture {
17851787
const hardwareTexture = new NativeHardwareTexture(texture, this._engine);
17861788
const internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
17871789
internalTexture._hardwareTexture = hardwareTexture;
17881790
internalTexture.isReady = true;
1791+
internalTexture.useMipMaps = hasMipMaps;
1792+
this.updateTextureSamplingMode(samplingMode, internalTexture);
17891793
return internalTexture;
17901794
}
17911795

0 commit comments

Comments
 (0)