diff --git a/Tests/LibGL/TestAPI.cpp b/Tests/LibGL/TestAPI.cpp index 7f717db686..b539c5db88 100644 --- a/Tests/LibGL/TestAPI.cpp +++ b/Tests/LibGL/TestAPI.cpp @@ -11,7 +11,7 @@ static NonnullOwnPtr create_testing_context() { auto bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { 1, 1 })); - auto context = GL::create_context(*bitmap); + auto context = MUST(GL::create_context(*bitmap)); GL::make_context_current(context); return context; } diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index f55bbf5371..9b01dfac98 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -24,7 +24,7 @@ static NonnullOwnPtr create_testing_context(int width, int height) { auto bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { width, height })); - auto context = GL::create_context(*bitmap); + auto context = MUST(GL::create_context(*bitmap)); GL::make_context_current(context); // Assume some defaults for our testing contexts diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 431894dc97..ad71c307ef 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -59,7 +59,7 @@ private: constexpr u16 RENDER_WIDTH = 640; constexpr u16 RENDER_HEIGHT = 480; m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { RENDER_WIDTH, RENDER_HEIGHT }).release_value_but_fixme_should_propagate_errors(); - m_context = GL::create_context(*m_bitmap); + m_context = MUST(GL::create_context(*m_bitmap)); start_timer(20); diff --git a/Userland/Demos/Tubes/Tubes.cpp b/Userland/Demos/Tubes/Tubes.cpp index 17713e4b7a..cab53975c5 100644 --- a/Userland/Demos/Tubes/Tubes.cpp +++ b/Userland/Demos/Tubes/Tubes.cpp @@ -125,7 +125,7 @@ void Tubes::choose_new_direction_for_tube(Tube& tube) ErrorOr Tubes::create_buffer(Gfx::IntSize size) { m_bitmap = TRY(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, size)); - m_gl_context = GL::create_context(*m_bitmap); + m_gl_context = TRY(GL::create_context(*m_bitmap)); return {}; } diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index 316f79714c..f71c51a50b 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -921,11 +921,11 @@ void GLContext::build_extension_string() m_extensions = String::join(' ', extensions); } -NonnullOwnPtr create_context(Gfx::Bitmap& bitmap) +ErrorOr> create_context(Gfx::Bitmap& bitmap) { // FIXME: Make driver selectable. This is currently hardcoded to LibSoftGPU - auto driver = MUST(GPU::Driver::try_create("softgpu"sv)); - auto device = MUST(driver->try_create_device(bitmap.size())); + auto driver = TRY(GPU::Driver::try_create("softgpu"sv)); + auto device = TRY(driver->try_create_device(bitmap.size())); auto context = make(driver, move(device), bitmap); dbgln_if(GL_DEBUG, "GL::create_context({}) -> {:p}", bitmap.size(), context.ptr()); diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index a2f6ef7dbf..c8b5bf20f3 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -532,7 +532,7 @@ private: String m_extensions; }; -NonnullOwnPtr create_context(Gfx::Bitmap&); +ErrorOr> create_context(Gfx::Bitmap&); void make_context_current(GLContext*); void present_context(GLContext*); diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 27b0f03bed..824425b668 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -41,18 +41,12 @@ JS::ThrowCompletionOr> WebGLRenderingContext::c return JS::GCPtr { nullptr }; } -#ifndef __serenity__ - // FIXME: Make WebGL work on other platforms. - (void)window; - (void)context_attributes; - dbgln("FIXME: WebGL not supported on the current platform"); - fire_webgl_context_creation_error(canvas_element); - return JS::GCPtr { nullptr }; -#else - // FIXME: LibGL currently doesn't propagate context creation errors. - auto context = GL::create_context(*canvas_element.bitmap()); - return window.heap().allocate(window.realm(), window, canvas_element, move(context), context_attributes, context_attributes); -#endif + auto context_or_error = GL::create_context(*canvas_element.bitmap()); + if (context_or_error.is_error()) { + fire_webgl_context_creation_error(canvas_element); + return JS::GCPtr { nullptr }; + } + return window.heap().allocate(window.realm(), window, canvas_element, context_or_error.release_value(), context_attributes, context_attributes); } WebGLRenderingContext::WebGLRenderingContext(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)