瀏覽代碼

LibWeb/WebGL: Implement WebGLRenderingContextBase.lineWidth()

Luke Wilde 3 年之前
父節點
當前提交
d9ef228c76

+ 13 - 0
Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp

@@ -242,6 +242,19 @@ GLenum WebGLRenderingContextBase::get_error()
     return m_context->gl_get_error();
     return m_context->gl_get_error();
 }
 }
 
 
+void WebGLRenderingContextBase::line_width(GLfloat width)
+{
+    if (m_context_lost)
+        return;
+
+    dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContextBase::line_width(width={})", width);
+
+    // https://www.khronos.org/registry/webgl/specs/latest/1.0/#NAN_LINE_WIDTH
+    // "In the WebGL API, if the width parameter passed to lineWidth is set to NaN, an INVALID_VALUE error is generated and the line width is not changed."
+    RETURN_WITH_WEBGL_ERROR_IF(isnan(width), GL_INVALID_VALUE);
+    m_context->gl_line_width(width);
+}
+
 void WebGLRenderingContextBase::polygon_offset(GLfloat factor, GLfloat units)
 void WebGLRenderingContextBase::polygon_offset(GLfloat factor, GLfloat units)
 {
 {
     if (m_context_lost)
     if (m_context_lost)

+ 1 - 0
Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h

@@ -48,6 +48,7 @@ public:
 
 
     GLenum get_error();
     GLenum get_error();
 
 
+    void line_width(GLfloat width);
     void polygon_offset(GLfloat factor, GLfloat units);
     void polygon_offset(GLfloat factor, GLfloat units);
 
 
     void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
     void scissor(GLint x, GLint y, GLsizei width, GLsizei height);

+ 1 - 0
Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl

@@ -43,6 +43,7 @@ interface mixin WebGLRenderingContextBase {
 
 
     GLenum getError();
     GLenum getError();
 
 
+    undefined lineWidth(GLfloat width);
     undefined polygonOffset(GLfloat factor, GLfloat units);
     undefined polygonOffset(GLfloat factor, GLfloat units);
 
 
     undefined scissor(GLint x, GLint y, GLsizei width, GLsizei height);
     undefined scissor(GLint x, GLint y, GLsizei width, GLsizei height);