From 1156fe483d1078818b77b587c17255de263fb69f Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 10 Jan 2025 12:52:47 +0000 Subject: [PATCH] LibWeb/WebGL: Tell ANGLE to create a WebGL compatible EGL context This causes it to enforce the sections "Differences Between WebGL and OpenGL ES 2.0" from the WebGL 1 specification and "Differences Between WebGL and OpenGL ES 3.0" from the WebGL 2 specification. It also disables a bunch of extensions by default, which we must now request with glRequestExtensionANGLE. --- Libraries/LibWeb/WebGL/OpenGLContext.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/WebGL/OpenGLContext.cpp b/Libraries/LibWeb/WebGL/OpenGLContext.cpp index b50962221ac..133c2e1ec83 100644 --- a/Libraries/LibWeb/WebGL/OpenGLContext.cpp +++ b/Libraries/LibWeb/WebGL/OpenGLContext.cpp @@ -13,9 +13,12 @@ # include # include # include +# define GL_GLEXT_PROTOTYPES 1 # include # include +extern "C" { # include +} #endif namespace Web::WebGL { @@ -92,8 +95,12 @@ OwnPtr OpenGLContext::create(NonnullRefPtrdisplay, m_impl->surface, m_impl->surface, m_impl->context); + // This extension is not enabled by default in WebGL compatibility mode, so we need to request it. + glRequestExtensionANGLE("GL_ANGLE_texture_rectangle"); + EGLint texture_target_angle = 0; eglGetConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_TARGET_ANGLE, &texture_target_angle); VERIFY(texture_target_angle == EGL_TEXTURE_RECTANGLE_ANGLE); @@ -285,7 +295,7 @@ Vector OpenGLContext::get_supported_extensions() #ifdef AK_OS_MACOS make_current(); - auto const* extensions_string = reinterpret_cast(glGetString(GL_EXTENSIONS)); + auto const* extensions_string = reinterpret_cast(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)); StringView extensions_view(extensions_string, strlen(extensions_string)); Vector extensions;