diff --git a/src/browser/canvas/WebGLRenderingContext.zig b/src/browser/canvas/WebGLRenderingContext.zig index 688376c4..47f9df20 100644 --- a/src/browser/canvas/WebGLRenderingContext.zig +++ b/src/browser/canvas/WebGLRenderingContext.zig @@ -61,7 +61,7 @@ pub const Extension = union(enum) { WEBGL_debug_shaders: void, WEBGL_depth_texture: void, WEBGL_draw_buffers: void, - WEBGL_lose_context: void, + WEBGL_lose_context: Type.WEBGL_lose_context, WEBGL_multi_draw: void, WEBGL_polygon_mode: void, @@ -117,6 +117,12 @@ pub const Extension = union(enum) { return UNMASKED_RENDERER_WEBGL; } }; + + pub const WEBGL_lose_context = struct { + _: u8 = 0, + pub fn _loseContext(_: *const WEBGL_lose_context) void {} + pub fn _restoreContext(_: *const WEBGL_lose_context) void {} + }; }; }; @@ -128,6 +134,7 @@ pub fn _getExtension(self: *const WebGLRenderingContext, name: []const u8) ?Exte return switch (tag) { .WEBGL_debug_renderer_info => @unionInit(Extension, "WEBGL_debug_renderer_info", .{}), + .WEBGL_lose_context => @unionInit(Extension, "WEBGL_lose_context", .{}), inline else => |comptime_enum| @unionInit(Extension, @tagName(comptime_enum), {}), }; } diff --git a/src/browser/canvas/root.zig b/src/browser/canvas/root.zig index 1d3f62b0..fbb51caa 100644 --- a/src/browser/canvas/root.zig +++ b/src/browser/canvas/root.zig @@ -9,4 +9,5 @@ pub const Interfaces = .{ CanvasRenderingContext2D, WebGLRenderingContext, Extension.Type.WEBGL_debug_renderer_info, + Extension.Type.WEBGL_lose_context, }; diff --git a/src/tests/html/canvas.html b/src/tests/html/canvas.html index 8c82d0e8..529813f4 100644 --- a/src/tests/html/canvas.html +++ b/src/tests/html/canvas.html @@ -102,4 +102,15 @@ testing.expectEqual(rendererInfo.UNMASKED_VENDOR_WEBGL, 0x9245); testing.expectEqual(rendererInfo.UNMASKED_RENDERER_WEBGL, 0x9246); } + +// WEBGL_lose_context +{ + const element = document.createElement("canvas"); + const ctx = element.getContext("webgl"); + const loseContext = ctx.getExtension("WEBGL_lose_context"); + testing.expectEqual(true, loseContext instanceof WEBGL_lose_context); + + loseContext.loseContext(); + loseContext.restoreContext(); +}