Skip to content

Commit

Permalink
LibWeb/WebGL: Don't crash on unknown getParameter on the context
Browse files Browse the repository at this point in the history
And allow the implementation to set the error code.
  • Loading branch information
ADKaster committed Dec 6, 2024
1 parent 9becc62 commit aa5f94c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Libraries/LibWeb/WebGL/WebGL2RenderingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class WebGL2RenderingContext : public Bindings::PlatformObject

GLenum m_error { 0 };

void set_error(GLenum error);
virtual void set_error(GLenum error) override;
};

}
2 changes: 1 addition & 1 deletion Libraries/LibWeb/WebGL/WebGLRenderingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class WebGLRenderingContext : public Bindings::PlatformObject

GLenum m_error { 0 };

void set_error(GLenum error);
virtual void set_error(GLenum error) override;
};

void fire_webgl_context_event(HTML::HTMLCanvasElement& canvas_element, FlyString const& type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ static void generate_get_parameter(SourceGenerator& generator)

generator.appendln(R"~~~(
default:
TODO();
dbgln("Unknown WebGL parameter name: {:x}", pname);
set_error(GL_INVALID_ENUM);
return JS::js_null();
})~~~");
}

Expand Down Expand Up @@ -389,6 +391,7 @@ class @class_name@ {
virtual void present() = 0;
virtual void needs_to_present() = 0;
virtual void set_error(GLenum) = 0;
)~~~");

for (auto const& function : interface.functions) {
Expand Down

0 comments on commit aa5f94c

Please sign in to comment.