{"record":{"id":"81101ebe64b29426","repo":"BabylonJS/Babylon.js","slug":"wrapwebgltexture-is-not-supported-use-wrapnativet","errorCode":null,"errorMessage":"wrapWebGLTexture is not supported, use wrapNativeTexture instead.","messagePattern":"wrapWebGLTexture is not supported, use wrapNativeTexture instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/nativeEngine.pure.ts","lineNumber":37,"sourceCode":"     * Will be overriden by the Thin Native engine implementation\r\n     * No code should be placed here\r\n     */\r\n    protected _initializeNativeEngine(_adaptToDeviceRatio: boolean): void {}\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public constructor(options: NativeEngineOptions = {}) {\r\n        super(null, false, undefined, options.adaptToDeviceRatio);\r\n\r\n        this._initializeNativeEngine(options.adaptToDeviceRatio ?? false);\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public override wrapWebGLTexture(): InternalTexture {\r\n        throw new Error(\"wrapWebGLTexture is not supported, use wrapNativeTexture instead.\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public override updateWrappedWebGLTexture(): void {\r\n        throw new Error(\"updateWrappedWebGLTexture is not supported, use updateWrappedNativeTexture instead.\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public override _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, _faceIndex: number = 0, _lod: number = 0) {\r\n        throw new Error(\"_uploadArrayBufferViewToTexture not implemented.\");\r\n    }\r\n}\r\n\r\n/**\r","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/nativeEngine.pure.ts#L19-L55","documentation":"NativeEngine (Babylon Native) does not consume WebGL handles, so wrapWebGLTexture() — which wraps an existing WebGL texture into an InternalTexture — is intentionally unimplemented and always throws. The Native equivalent is wrapNativeTexture().","triggerScenarios":"Calling engine.wrapWebGLTexture(...) on a NativeEngine instance (Babylon Native / react-native-babylon / Node native build).","commonSituations":"Code shared between the web and native builds that assumes a WebGL engine, accidentally running the WebGL wrapping path under Babylon Native.","solutions":["On native, call wrapNativeTexture() with the platform-native texture handle instead.","Branch on engine capabilities: if ((engine as any).wrapNativeTexture) use it, else use wrapWebGLTexture().","Remove the WebGL-only wrapping code from the native path."],"exampleFix":"// before\nconst tex = engine.wrapWebGLTexture(glTexture);\n// after\nconst tex = \"wrapNativeTexture\" in engine\n  ? engine.wrapNativeTexture(nativeTexture)\n  : engine.wrapWebGLTexture(glTexture);","handlingStrategy":"type-guard","validationCode":"const isNative = typeof (engine as any).wrapNativeTexture === \"function\";\nif (!isNative) engine.wrapWebGLTexture(handle);","typeGuard":"function isNativeEngine(e) {\n  return \"wrapNativeTexture\" in e;\n}","tryCatchPattern":"try {\n  return engine.wrapWebGLTexture(handle);\n} catch (e) {\n  if (/use wrapNativeTexture/.test(e.message)) {\n    return (engine as any).wrapNativeTexture(nativeHandle);\n  }\n  throw e;\n}","preventionTips":["Abstract texture wrapping behind a platform helper.","Test shared render code on Babylon Native builds early.","Grep for wrapWebGLTexture in shared modules and guard them."],"tags":["babylon-native","textures","unsupported-api","platform"],"backgroundTag":"api-not-supported-on-platform","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}