mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
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.
This commit is contained in:
parent
4cb5a980e5
commit
1156fe483d
Notes:
github-actions[bot]
2025-01-21 20:38:15 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/1156fe483d1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3239 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/kalenikaliaksandr
1 changed files with 13 additions and 3 deletions
|
@ -13,9 +13,12 @@
|
|||
# include <EGL/egl.h>
|
||||
# include <EGL/eglext.h>
|
||||
# include <EGL/eglext_angle.h>
|
||||
# define GL_GLEXT_PROTOTYPES 1
|
||||
# include <GLES2/gl2.h>
|
||||
# include <GLES2/gl2ext.h>
|
||||
extern "C" {
|
||||
# include <GLES2/gl2ext_angle.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
@ -92,8 +95,12 @@ OwnPtr<OpenGLContext> OpenGLContext::create(NonnullRefPtr<Gfx::SkiaBackendContex
|
|||
auto* config = get_egl_config(display);
|
||||
|
||||
EGLint context_attributes[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
EGL_CONTEXT_CLIENT_VERSION,
|
||||
2,
|
||||
EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE,
|
||||
EGL_TRUE,
|
||||
EGL_NONE,
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attributes);
|
||||
if (context == EGL_NO_CONTEXT) {
|
||||
|
@ -159,6 +166,9 @@ void OpenGLContext::allocate_painting_surface_if_needed()
|
|||
|
||||
eglMakeCurrent(m_impl->display, 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<String> OpenGLContext::get_supported_extensions()
|
|||
#ifdef AK_OS_MACOS
|
||||
make_current();
|
||||
|
||||
auto const* extensions_string = reinterpret_cast<char const*>(glGetString(GL_EXTENSIONS));
|
||||
auto const* extensions_string = reinterpret_cast<char const*>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE));
|
||||
StringView extensions_view(extensions_string, strlen(extensions_string));
|
||||
|
||||
Vector<String> extensions;
|
||||
|
|
Loading…
Reference in a new issue