mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
LibWeb: Use platform's OpenGL in WebGL when it is available
This change makes WebGL to use LibGL only in SerenityOS, and the platform's OpenGL driver in Ladybird if it is available. This is implemented by introducing wrapper class between WebGL and OpenGL calls. This way it will also be possible to provide more complete support in Ladybird even if we don't yet have all needed calls implemented in LibGL. For now, the wrapper class makes all GL calls virtual. However, we can get rid of this and implement it at compile time in case of performance problems.
This commit is contained in:
parent
c6289fad49
commit
271c9d1ae9
9 changed files with 449 additions and 37 deletions
|
@ -44,15 +44,18 @@ JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::c
|
|||
return JS::GCPtr<WebGLRenderingContext> { nullptr };
|
||||
}
|
||||
|
||||
auto context_or_error = GL::create_context(*canvas_element.bitmap());
|
||||
if (context_or_error.is_error()) {
|
||||
VERIFY(canvas_element.bitmap());
|
||||
auto context = OpenGLContext::create(*canvas_element.bitmap());
|
||||
|
||||
if (!context) {
|
||||
fire_webgl_context_creation_error(canvas_element);
|
||||
return JS::GCPtr<WebGLRenderingContext> { nullptr };
|
||||
}
|
||||
return realm.heap().allocate<WebGLRenderingContext>(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes);
|
||||
|
||||
return realm.heap().allocate<WebGLRenderingContext>(realm, realm, canvas_element, context.release_nonnull(), context_attributes, context_attributes);
|
||||
}
|
||||
|
||||
WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
|
||||
WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<OpenGLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
|
||||
: WebGLRenderingContextBase(realm, canvas_element, move(context), move(context_creation_parameters), move(actual_context_parameters))
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue