Skip to content

WebGL extension properties should not be static #201

Open
@CEksal

Description

@CEksal

As the title states. Example:

import 'dart:js_interop';
import 'package:web/web.dart' hide WEBGL_compressed_texture_astc;

// Proper type for WEBGL_debug_renderer_info extension
// Note that the getters are not marked as `static`, because there is no global `WebGLDebugRendererInfo` object,
// nor is there one named `WEBGL_debug_renderer_info`.
extension type WebGLDebugRendererInfo._(JSObject _) implements JSObject {
  external int get UNMASKED_RENDERER_WEBGL;
  external int get UNMASKED_VENDOR_WEBGL;
}

void main() {
  final canvas = HTMLCanvasElement();
  final renderingContext = canvas.getContext('webgl')! as WebGLRenderingContext;
  final ext = renderingContext.getExtension('WEBGL_debug_renderer_info') as WebGLDebugRendererInfo?;

  print(ext?.UNMASKED_RENDERER_WEBGL); // prints 37446 (0x9246)
  print(WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL); // throws JavaScript TypeError
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-api-bugtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions