Skip to content

Commit 50d66ba

Browse files
cqundefinegmta
authored andcommitted
LibWeb: Implement WebGL getVertexAttribOffset
1 parent 1bc7e9d commit 50d66ba

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

Libraries/LibWeb/WebGL/WebGL2RenderingContextImpl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,6 +3193,18 @@ JS::Value WebGL2RenderingContextImpl::get_vertex_attrib(WebIDL::UnsignedLong ind
31933193
}
31943194
}
31953195

3196+
WebIDL::LongLong WebGL2RenderingContextImpl::get_vertex_attrib_offset(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname)
3197+
{
3198+
if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
3199+
set_error(GL_INVALID_ENUM);
3200+
return 0;
3201+
}
3202+
3203+
GLintptr result { 0 };
3204+
glGetVertexAttribPointervRobustANGLE(index, GL_VERTEX_ATTRIB_ARRAY_POINTER, 1, nullptr, reinterpret_cast<void**>(&result));
3205+
return result;
3206+
}
3207+
31963208
void WebGL2RenderingContextImpl::hint(WebIDL::UnsignedLong target, WebIDL::UnsignedLong mode)
31973209
{
31983210
m_context->make_current();

Libraries/LibWeb/WebGL/WebGL2RenderingContextImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class WebGL2RenderingContextImpl : public WebGLRenderingContextBase {
200200
JS::Value get_uniform(GC::Root<WebGLProgram> program, GC::Root<WebGLUniformLocation> location);
201201
GC::Root<WebGLUniformLocation> get_uniform_location(GC::Root<WebGLProgram> program, String name);
202202
JS::Value get_vertex_attrib(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname);
203+
WebIDL::LongLong get_vertex_attrib_offset(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname);
203204
void hint(WebIDL::UnsignedLong target, WebIDL::UnsignedLong mode);
204205
bool is_buffer(GC::Root<WebGLBuffer> buffer);
205206
bool is_enabled(WebIDL::UnsignedLong cap);

Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ interface mixin WebGLRenderingContextBase {
133133

134134
any getVertexAttrib(GLuint index, GLenum pname);
135135

136-
[FIXME] GLintptr getVertexAttribOffset(GLuint index, GLenum pname);
136+
GLintptr getVertexAttribOffset(GLuint index, GLenum pname);
137137

138138
undefined hint(GLenum target, GLenum mode);
139139
GLboolean isBuffer(WebGLBuffer? buffer);

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,18 @@ JS::Value WebGLRenderingContextImpl::get_vertex_attrib(WebIDL::UnsignedLong inde
17571757
}
17581758
}
17591759

1760+
WebIDL::LongLong WebGLRenderingContextImpl::get_vertex_attrib_offset(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname)
1761+
{
1762+
if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
1763+
set_error(GL_INVALID_ENUM);
1764+
return 0;
1765+
}
1766+
1767+
GLintptr result { 0 };
1768+
glGetVertexAttribPointervRobustANGLE(index, GL_VERTEX_ATTRIB_ARRAY_POINTER, 1, nullptr, reinterpret_cast<void**>(&result));
1769+
return result;
1770+
}
1771+
17601772
void WebGLRenderingContextImpl::hint(WebIDL::UnsignedLong target, WebIDL::UnsignedLong mode)
17611773
{
17621774
m_context->make_current();

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class WebGLRenderingContextImpl : public WebGLRenderingContextBase {
115115
JS::Value get_uniform(GC::Root<WebGLProgram> program, GC::Root<WebGLUniformLocation> location);
116116
GC::Root<WebGLUniformLocation> get_uniform_location(GC::Root<WebGLProgram> program, String name);
117117
JS::Value get_vertex_attrib(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname);
118+
WebIDL::LongLong get_vertex_attrib_offset(WebIDL::UnsignedLong index, WebIDL::UnsignedLong pname);
118119
void hint(WebIDL::UnsignedLong target, WebIDL::UnsignedLong mode);
119120
bool is_buffer(GC::Root<WebGLBuffer> buffer);
120121
bool is_enabled(WebIDL::UnsignedLong cap);

0 commit comments

Comments
 (0)