mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibWeb/WebGL: Implement getBufferParameter
This commit is contained in:
parent
a65a981a6b
commit
4c0872ea1b
Notes:
github-actions[bot]
2024-12-05 20:43:05 +00:00
Author: https://github.com/Lubrsi
Commit: 4c0872ea1b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2791
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/shannonbooth
2 changed files with 48 additions and 9 deletions
|
@ -109,7 +109,7 @@ interface mixin WebGLRenderingContextBase {
|
||||||
|
|
||||||
GLint getAttribLocation(WebGLProgram program, DOMString name);
|
GLint getAttribLocation(WebGLProgram program, DOMString name);
|
||||||
|
|
||||||
[FIXME] any getBufferParameter(GLenum target, GLenum pname);
|
any getBufferParameter(GLenum target, GLenum pname);
|
||||||
any getParameter(GLenum pname);
|
any getParameter(GLenum pname);
|
||||||
|
|
||||||
GLenum getError();
|
GLenum getError();
|
||||||
|
|
|
@ -63,16 +63,16 @@ static ByteString idl_to_gl_function_name(StringView function_name)
|
||||||
return gl_function_name_builder.to_byte_string();
|
return gl_function_name_builder.to_byte_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NameAndType {
|
||||||
|
StringView name;
|
||||||
|
struct {
|
||||||
|
StringView type;
|
||||||
|
int element_count { 0 };
|
||||||
|
} return_type;
|
||||||
|
};
|
||||||
|
|
||||||
static void generate_get_parameter(SourceGenerator& generator)
|
static void generate_get_parameter(SourceGenerator& generator)
|
||||||
{
|
{
|
||||||
struct NameAndType {
|
|
||||||
StringView name;
|
|
||||||
struct {
|
|
||||||
StringView type;
|
|
||||||
int element_count { 0 };
|
|
||||||
} return_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector<NameAndType> const name_to_type = {
|
Vector<NameAndType> const name_to_type = {
|
||||||
{ "ACTIVE_TEXTURE"sv, { "GLenum"sv } },
|
{ "ACTIVE_TEXTURE"sv, { "GLenum"sv } },
|
||||||
{ "ALIASED_LINE_WIDTH_RANGE"sv, { "Float32Array"sv, 2 } },
|
{ "ALIASED_LINE_WIDTH_RANGE"sv, { "Float32Array"sv, 2 } },
|
||||||
|
@ -232,6 +232,40 @@ static void generate_get_parameter(SourceGenerator& generator)
|
||||||
})~~~");
|
})~~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void generate_get_buffer_parameter(SourceGenerator& generator)
|
||||||
|
{
|
||||||
|
Vector<NameAndType> const name_to_type = {
|
||||||
|
{ "BUFFER_SIZE"sv, { "GLint"sv } },
|
||||||
|
{ "BUFFER_USAGE"sv, { "GLenum"sv } },
|
||||||
|
};
|
||||||
|
|
||||||
|
generator.append(" switch (pname) {");
|
||||||
|
|
||||||
|
for (auto const& name_and_type : name_to_type) {
|
||||||
|
auto const& parameter_name = name_and_type.name;
|
||||||
|
auto const& type_name = name_and_type.return_type.type;
|
||||||
|
|
||||||
|
StringBuilder string_builder;
|
||||||
|
SourceGenerator impl_generator { string_builder };
|
||||||
|
impl_generator.set("parameter_name", parameter_name);
|
||||||
|
impl_generator.set("type_name", type_name);
|
||||||
|
impl_generator.append(R"~~~(
|
||||||
|
case GL_@parameter_name@: {
|
||||||
|
GLint result;
|
||||||
|
glGetBufferParameteriv(target, GL_@parameter_name@, &result);
|
||||||
|
return JS::Value(result);
|
||||||
|
}
|
||||||
|
)~~~");
|
||||||
|
|
||||||
|
generator.append(string_builder.string_view());
|
||||||
|
}
|
||||||
|
|
||||||
|
generator.appendln(R"~~~(
|
||||||
|
default:
|
||||||
|
TODO();
|
||||||
|
})~~~");
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
StringView generated_header_path;
|
StringView generated_header_path;
|
||||||
|
@ -604,6 +638,11 @@ public:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (function.name == "getBufferParameter"sv) {
|
||||||
|
generate_get_buffer_parameter(function_impl_generator);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (function.name == "getActiveUniform"sv) {
|
if (function.name == "getActiveUniform"sv) {
|
||||||
function_impl_generator.append(R"~~~(
|
function_impl_generator.append(R"~~~(
|
||||||
GLint size = 0;
|
GLint size = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue