summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-06-04 04:37:10 +0100
committerLinus Groh <mail@linusgroh.de>2022-06-13 21:45:27 +0100
commit39a212b54fcbc8cb2b051fcbef497b1fa020b718 (patch)
tree2e1e7aa2b860dbb61d3068ff0216b4764f0ded70 /Userland/Libraries/LibWeb
parentaa77c26b60b54cbc5099dc94491288c9c6804d63 (diff)
downloadserenity-39a212b54fcbc8cb2b051fcbef497b1fa020b718.zip
LibWeb/WebGL: Add a bunch of simple forwarding functions
This collection of functions simply check if the context is still alive, then forward the call to the GL context.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp135
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h24
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl24
3 files changed, 183 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
index 28c2d0d1d0..e0594ace41 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
@@ -93,6 +93,15 @@ JS::Object* WebGLRenderingContextBase::get_extension(String const& name) const
return nullptr;
}
+void WebGLRenderingContextBase::active_texture(GLenum texture)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::active_texture(texture=0x{:08x})", texture);
+ m_context->gl_active_texture(texture);
+}
+
void WebGLRenderingContextBase::clear(GLbitfield mask)
{
if (m_context_lost)
@@ -114,4 +123,130 @@ void WebGLRenderingContextBase::clear_color(GLclampf red, GLclampf green, GLclam
m_context->gl_clear_color(red, green, blue, alpha);
}
+void WebGLRenderingContextBase::clear_depth(GLclampf depth)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::clear_depth(depth={})", depth);
+ m_context->gl_clear_depth(depth);
+}
+
+void WebGLRenderingContextBase::clear_stencil(GLint s)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::clear_stencil(s=0x{:08x})", s);
+ m_context->gl_clear_stencil(s);
+}
+
+void WebGLRenderingContextBase::color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::color_mask(red={}, green={}, blue={}, alpha={})", red, green, blue, alpha);
+ m_context->gl_color_mask(red, green, blue, alpha);
+}
+
+void WebGLRenderingContextBase::cull_face(GLenum mode)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::cull_face(mode=0x{:08x})", mode);
+ m_context->gl_cull_face(mode);
+}
+
+void WebGLRenderingContextBase::depth_func(GLenum func)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::depth_func(func=0x{:08x})", func);
+ m_context->gl_depth_func(func);
+}
+
+void WebGLRenderingContextBase::depth_mask(GLboolean mask)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::depth_mask(mask={})", mask);
+ m_context->gl_depth_mask(mask);
+}
+
+void WebGLRenderingContextBase::finish()
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::finish()");
+ m_context->gl_finish();
+}
+
+void WebGLRenderingContextBase::flush()
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::flush()");
+ m_context->gl_flush();
+}
+
+void WebGLRenderingContextBase::front_face(GLenum mode)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::front_face(mode=0x{:08x})", mode);
+ m_context->gl_front_face(mode);
+}
+
+void WebGLRenderingContextBase::polygon_offset(GLfloat factor, GLfloat units)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::polygon_offset(factor={}, units={})", factor, units);
+ m_context->gl_polygon_offset(factor, units);
+}
+
+void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::scissor(x={}, y={}, width={}, height={})", x, y, width, height);
+ m_context->gl_scissor(x, y, width, height);
+}
+
+void WebGLRenderingContextBase::stencil_op(GLenum fail, GLenum zfail, GLenum zpass)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::stencil_op(fail=0x{:08x}, zfail=0x{:08x}, zpass=0x{:08x})", fail, zfail, zpass);
+ m_context->gl_stencil_op_separate(GL_FRONT_AND_BACK, fail, zfail, zpass);
+}
+
+void WebGLRenderingContextBase::stencil_op_separate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::stencil_op_separate(face=0x{:08x}, fail=0x{:08x}, zfail=0x{:08x}, zpass=0x{:08x})", face, fail, zfail, zpass);
+ m_context->gl_stencil_op_separate(face, fail, zfail, zpass);
+}
+
+void WebGLRenderingContextBase::viewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ if (m_context_lost)
+ return;
+
+ dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::viewport(x={}, y={}, width={}, height={})", x, y, width, height);
+ m_context->gl_viewport(x, y, width, height);
+}
+
}
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
index 2942133cb5..9ad28aacbc 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
@@ -26,8 +26,32 @@ public:
Optional<Vector<String>> get_supported_extensions() const;
JS::Object* get_extension(String const& name) const;
+ void active_texture(GLenum texture);
+
void clear(GLbitfield mask);
void clear_color(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ void clear_depth(GLclampf depth);
+ void clear_stencil(GLint s);
+ void color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+
+ void cull_face(GLenum mode);
+
+ void depth_func(GLenum func);
+ void depth_mask(GLboolean mask);
+
+ void finish();
+ void flush();
+
+ void front_face(GLenum mode);
+
+ void polygon_offset(GLfloat factor, GLfloat units);
+
+ void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
+
+ void stencil_op(GLenum fail, GLenum zfail, GLenum zpass);
+ void stencil_op_separate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+
+ void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
protected:
WebGLRenderingContextBase(HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl
index caf0647372..49069332d1 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl
@@ -21,8 +21,32 @@ interface mixin WebGLRenderingContextBase {
sequence<DOMString>? getSupportedExtensions();
object? getExtension(DOMString name);
+ undefined activeTexture(GLenum texture);
+
undefined clear(GLbitfield mask);
undefined clearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ undefined clearDepth(GLclampf depth);
+ undefined clearStencil(GLint s);
+ undefined colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+
+ undefined cullFace(GLenum mode);
+
+ undefined depthFunc(GLenum func);
+ undefined depthMask(GLboolean flag);
+
+ undefined finish();
+ undefined flush();
+
+ undefined frontFace(GLenum mode);
+
+ undefined polygonOffset(GLfloat factor, GLfloat units);
+
+ undefined scissor(GLint x, GLint y, GLsizei width, GLsizei height);
+
+ undefined stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+ undefined stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+
+ undefined viewport(GLint x, GLint y, GLsizei width, GLsizei height);
// Enums
// ClearBufferMask