mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibWeb/WebGL: Implement vertex array calls for WebGL2
This commit is contained in:
parent
eec4b71351
commit
86c230cd8e
Notes:
github-actions[bot]
2024-12-06 23:06:25 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 86c230cd8e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2817
Reviewed-by: https://github.com/ADKaster
4 changed files with 38 additions and 8 deletions
|
@ -845,6 +845,7 @@ class WebGLShader;
|
||||||
class WebGLShaderPrecisionFormat;
|
class WebGLShaderPrecisionFormat;
|
||||||
class WebGLTexture;
|
class WebGLTexture;
|
||||||
class WebGLUniformLocation;
|
class WebGLUniformLocation;
|
||||||
|
class WebGLVertexArrayObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::WebIDL {
|
namespace Web::WebIDL {
|
||||||
|
|
|
@ -426,8 +426,8 @@ interface mixin WebGL2RenderingContextBase {
|
||||||
[FIXME] undefined uniformBlockBinding(WebGLProgram program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
|
[FIXME] undefined uniformBlockBinding(WebGLProgram program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
|
||||||
|
|
||||||
// Vertex Array Objects
|
// Vertex Array Objects
|
||||||
[FIXME] WebGLVertexArrayObject createVertexArray();
|
WebGLVertexArrayObject createVertexArray();
|
||||||
[FIXME] undefined deleteVertexArray(WebGLVertexArrayObject? vertexArray);
|
undefined deleteVertexArray(WebGLVertexArrayObject? vertexArray);
|
||||||
[FIXME] GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray); // [WebGLHandlesContextLoss]
|
GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray); // [WebGLHandlesContextLoss]
|
||||||
[FIXME] undefined bindVertexArray(WebGLVertexArrayObject? array);
|
undefined bindVertexArray(WebGLVertexArrayObject? array);
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,6 +117,7 @@ static bool is_platform_object(Type const& type)
|
||||||
"WebGLShaderPrecisionFormat"sv,
|
"WebGLShaderPrecisionFormat"sv,
|
||||||
"WebGLTexture"sv,
|
"WebGLTexture"sv,
|
||||||
"WebGLUniformLocation"sv,
|
"WebGLUniformLocation"sv,
|
||||||
|
"WebGLVertexArrayObject"sv,
|
||||||
"Window"sv,
|
"Window"sv,
|
||||||
"WindowProxy"sv,
|
"WindowProxy"sv,
|
||||||
"WritableStream"sv,
|
"WritableStream"sv,
|
||||||
|
|
|
@ -23,7 +23,8 @@ static bool is_webgl_object_type(StringView type_name)
|
||||||
|| type_name == "WebGLRenderbuffer"sv
|
|| type_name == "WebGLRenderbuffer"sv
|
||||||
|| type_name == "WebGLShader"sv
|
|| type_name == "WebGLShader"sv
|
||||||
|| type_name == "WebGLTexture"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)
|
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 };
|
SourceGenerator implementation_file_generator { implementation_file_string_builder };
|
||||||
implementation_file_generator.set("class_name", class_name);
|
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"~~~(
|
implementation_file_generator.append(R"~~~(
|
||||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||||
#include <LibJS/Runtime/DataView.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/WebGLShaderPrecisionFormat.h>
|
||||||
#include <LibWeb/WebGL/WebGLTexture.h>
|
#include <LibWeb/WebGL/WebGLTexture.h>
|
||||||
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
||||||
|
#include <LibWeb/WebGL/WebGLVertexArrayObject.h>
|
||||||
#include <LibWeb/WebIDL/Buffers.h>
|
#include <LibWeb/WebIDL/Buffers.h>
|
||||||
|
|
||||||
#include <GLES2/gl2.h>
|
|
||||||
#include <GLES2/gl2ext.h>
|
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
|
||||||
static Vector<GLchar> null_terminated_string(StringView string)
|
static Vector<GLchar> null_terminated_string(StringView string)
|
||||||
|
@ -488,6 +499,15 @@ public:
|
||||||
continue;
|
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) {
|
if (function.name == "shaderSource"sv) {
|
||||||
function_impl_generator.append(R"~~~(
|
function_impl_generator.append(R"~~~(
|
||||||
Vector<GLchar*> strings;
|
Vector<GLchar*> strings;
|
||||||
|
@ -783,6 +803,14 @@ public:
|
||||||
continue;
|
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;
|
Vector<ByteString> gl_call_arguments;
|
||||||
for (size_t i = 0; i < function.parameters.size(); ++i) {
|
for (size_t i = 0; i < function.parameters.size(); ++i) {
|
||||||
auto const& parameter = function.parameters[i];
|
auto const& parameter = function.parameters[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue