mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibWeb/WebGL: Implement vertex array calls for WebGL2
This commit is contained in:
parent
eec4b71351
commit
86c230cd8e
|
|
@ -845,6 +845,7 @@ class WebGLShader;
|
|||
class WebGLShaderPrecisionFormat;
|
||||
class WebGLTexture;
|
||||
class WebGLUniformLocation;
|
||||
class WebGLVertexArrayObject;
|
||||
}
|
||||
|
||||
namespace Web::WebIDL {
|
||||
|
|
|
|||
|
|
@ -426,8 +426,8 @@ interface mixin WebGL2RenderingContextBase {
|
|||
[FIXME] undefined uniformBlockBinding(WebGLProgram program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
|
||||
|
||||
// Vertex Array Objects
|
||||
[FIXME] WebGLVertexArrayObject createVertexArray();
|
||||
[FIXME] undefined deleteVertexArray(WebGLVertexArrayObject? vertexArray);
|
||||
[FIXME] GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray); // [WebGLHandlesContextLoss]
|
||||
[FIXME] undefined bindVertexArray(WebGLVertexArrayObject? array);
|
||||
WebGLVertexArrayObject createVertexArray();
|
||||
undefined deleteVertexArray(WebGLVertexArrayObject? vertexArray);
|
||||
GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray); // [WebGLHandlesContextLoss]
|
||||
undefined bindVertexArray(WebGLVertexArrayObject? array);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ static bool is_platform_object(Type const& type)
|
|||
"WebGLShaderPrecisionFormat"sv,
|
||||
"WebGLTexture"sv,
|
||||
"WebGLUniformLocation"sv,
|
||||
"WebGLVertexArrayObject"sv,
|
||||
"Window"sv,
|
||||
"WindowProxy"sv,
|
||||
"WritableStream"sv,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ static bool is_webgl_object_type(StringView type_name)
|
|||
|| type_name == "WebGLRenderbuffer"sv
|
||||
|| type_name == "WebGLShader"sv
|
||||
|| type_name == "WebGLTexture"sv
|
||||
|| type_name == "WebGLUniformLocation"sv;
|
||||
|| type_name == "WebGLUniformLocation"sv
|
||||
|| type_name == "WebGLVertexArrayObject"sv;
|
||||
}
|
||||
|
||||
static bool gl_function_modifies_framebuffer(StringView function_name)
|
||||
|
|
@ -325,6 +326,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
SourceGenerator implementation_file_generator { implementation_file_string_builder };
|
||||
implementation_file_generator.set("class_name", class_name);
|
||||
|
||||
auto webgl_version = class_name == "WebGLRenderingContext" ? 1 : 2;
|
||||
if (webgl_version == 1) {
|
||||
implementation_file_generator.append(R"~~~(
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
)~~~");
|
||||
} else {
|
||||
implementation_file_generator.append(R"~~~(
|
||||
#include <GLES3/gl3.h>
|
||||
)~~~");
|
||||
}
|
||||
|
||||
implementation_file_generator.append(R"~~~(
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibJS/Runtime/DataView.h>
|
||||
|
|
@ -345,11 +358,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
#include <LibWeb/WebGL/WebGLShaderPrecisionFormat.h>
|
||||
#include <LibWeb/WebGL/WebGLTexture.h>
|
||||
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
||||
#include <LibWeb/WebGL/WebGLVertexArrayObject.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
||||
static Vector<GLchar> null_terminated_string(StringView string)
|
||||
|
|
@ -488,6 +499,15 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "createVertexArray"sv) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
GLuint handle = 0;
|
||||
glGenVertexArrays(1, &handle);
|
||||
return WebGLVertexArrayObject::create(m_realm, handle);
|
||||
)~~~");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "shaderSource"sv) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
Vector<GLchar*> strings;
|
||||
|
|
@ -783,6 +803,14 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "deleteVertexArray"sv) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
auto handle = vertexArray ? vertexArray->handle() : 0;
|
||||
glDeleteVertexArrays(1, &handle);
|
||||
)~~~");
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector<ByteString> gl_call_arguments;
|
||||
for (size_t i = 0; i < function.parameters.size(); ++i) {
|
||||
auto const& parameter = function.parameters[i];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user