summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Meta/CMake/libgl_generators.cmake14
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/CMakeLists.txt1
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibGL/CMakeLists.txt1
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp570
-rw-r--r--Userland/Libraries/LibGL/CMakeLists.txt8
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h228
-rw-r--r--Userland/Libraries/LibGL/GLAPI.cpp1177
-rw-r--r--Userland/Libraries/LibGL/GLAPI.json1162
-rw-r--r--Userland/Libraries/LibGL/GLContext.h30
9 files changed, 1787 insertions, 1404 deletions
diff --git a/Meta/CMake/libgl_generators.cmake b/Meta/CMake/libgl_generators.cmake
new file mode 100644
index 0000000000..f9b73838d4
--- /dev/null
+++ b/Meta/CMake/libgl_generators.cmake
@@ -0,0 +1,14 @@
+function (generate_libgl_implementation)
+ set(LIBGL_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
+
+ invoke_generator(
+ "GLAPI.cpp"
+ Lagom::GenerateGLAPIWrapper
+ "${LIBGL_INPUT_FOLDER}/GLAPI.json"
+ "GL/glapi.h"
+ "GLAPI.cpp"
+ arguments -j "${LIBGL_INPUT_FOLDER}/GLAPI.json"
+ )
+
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/GL/glapi.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGL/GL/")
+endfunction()
diff --git a/Meta/Lagom/Tools/CodeGenerators/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/CMakeLists.txt
index 5461e96e91..c391d6e8b7 100644
--- a/Meta/Lagom/Tools/CodeGenerators/CMakeLists.txt
+++ b/Meta/Lagom/Tools/CodeGenerators/CMakeLists.txt
@@ -1,5 +1,6 @@
add_subdirectory(IPCCompiler)
add_subdirectory(LibEDID)
+add_subdirectory(LibGL)
add_subdirectory(LibLocale)
add_subdirectory(LibTimeZone)
add_subdirectory(LibUnicode)
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibGL/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/LibGL/CMakeLists.txt
new file mode 100644
index 0000000000..682d056e3b
--- /dev/null
+++ b/Meta/Lagom/Tools/CodeGenerators/LibGL/CMakeLists.txt
@@ -0,0 +1 @@
+lagom_tool(GenerateGLAPIWrapper SOURCES GenerateGLAPIWrapper.cpp LIBS LibMain)
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp
new file mode 100644
index 0000000000..8c4ceb11c7
--- /dev/null
+++ b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2022, Jelle Raaijmakers <jelle@gmta.nl>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/Array.h>
+#include <AK/DeprecatedString.h>
+#include <AK/JsonObject.h>
+#include <AK/NumericLimits.h>
+#include <AK/Optional.h>
+#include <AK/SourceGenerator.h>
+#include <AK/StringBuilder.h>
+#include <AK/StringView.h>
+#include <AK/Vector.h>
+#include <LibCore/ArgsParser.h>
+#include <LibCore/Stream.h>
+#include <LibMain/Main.h>
+
+struct ArgumentDefinition {
+ Optional<DeprecatedString> name;
+ Optional<DeprecatedString> cpp_type;
+ DeprecatedString expression;
+ Optional<DeprecatedString> cast_to;
+};
+
+struct FunctionDefinition {
+ DeprecatedString name;
+ DeprecatedString return_type;
+ Vector<ArgumentDefinition> arguments;
+ DeprecatedString implementation;
+ bool unimplemented;
+ DeprecatedString variant_gl_type;
+};
+
+struct VariantType {
+ DeprecatedString encoded_type;
+ Optional<DeprecatedString> implementation;
+ bool unimplemented;
+};
+
+struct Variants {
+ Vector<DeprecatedString> api_suffixes { "" };
+ Vector<u32> argument_counts { NumericLimits<u32>::max() };
+ Vector<DeprecatedString> argument_defaults { "" };
+ bool convert_range { false };
+ Vector<VariantType> types {
+ {
+ .encoded_type = "",
+ .implementation = Optional<DeprecatedString> {},
+ .unimplemented = false,
+ }
+ };
+ DeprecatedString pointer_argument { "" };
+};
+
+struct EncodedTypeEntry {
+ StringView encoded_type;
+ StringView cpp_type;
+ StringView gl_type;
+};
+
+// clang-format off
+constexpr static Array<EncodedTypeEntry, 9> type_definitions = {
+ EncodedTypeEntry { "b"sv, "GLbyte"sv, "GL_BYTE"sv },
+ EncodedTypeEntry { "d"sv, "GLdouble"sv, "GL_DOUBLE"sv },
+ EncodedTypeEntry { "f"sv, "GLfloat"sv, "GL_FLOAT"sv },
+ EncodedTypeEntry { "i"sv, "GLint"sv, "GL_INT"sv },
+ EncodedTypeEntry { "s"sv, "GLshort"sv, "GL_SHORT"sv },
+ EncodedTypeEntry { "ub"sv, "GLubyte"sv, "GL_UNSIGNED_BYTE"sv },
+ EncodedTypeEntry { "ui"sv, "GLuint"sv, "GL_UNSIGNED_INT"sv },
+ EncodedTypeEntry { "us"sv, "GLushort"sv, "GL_UNSIGNED_SHORT"sv },
+ EncodedTypeEntry { "x"sv, "GLfixed"sv, "GL_INT"sv },
+};
+// clang-format on
+
+struct EncodedType {
+ EncodedTypeEntry type_entry;
+ DeprecatedString cpp_type;
+ DeprecatedString function_name_suffix;
+ bool is_pointer;
+ bool is_const_pointer;
+};
+
+Vector<DeprecatedString> get_name_list(JsonValue const& name_definition)
+{
+ if (name_definition.is_null())
+ return {};
+
+ Vector<DeprecatedString, 1> names;
+ if (name_definition.is_string()) {
+ names.append(name_definition.as_string());
+ } else if (name_definition.is_array()) {
+ name_definition.as_array().for_each([&names](auto& value) {
+ VERIFY(value.is_string());
+ names.append(value.as_string());
+ });
+ } else {
+ VERIFY_NOT_REACHED();
+ }
+ return names;
+}
+
+Optional<EncodedType> get_encoded_type(DeprecatedString encoded_type)
+{
+ bool is_const_pointer = !encoded_type.ends_with('!');
+ if (!is_const_pointer)
+ encoded_type = encoded_type.substring_view(0, encoded_type.length() - 1);
+ DeprecatedString function_name_suffix = encoded_type;
+
+ bool is_pointer = encoded_type.ends_with('v');
+ if (is_pointer)
+ encoded_type = encoded_type.substring_view(0, encoded_type.length() - 1);
+
+ VERIFY(is_const_pointer || is_pointer);
+
+ Optional<EncodedTypeEntry> type_definition;
+ for (size_t i = 0; i < type_definitions.size(); ++i) {
+ if (type_definitions[i].encoded_type == encoded_type) {
+ type_definition = type_definitions[i];
+ break;
+ }
+ }
+
+ if (!type_definition.has_value())
+ return {};
+
+ return EncodedType {
+ .type_entry = type_definition.value(),
+ .cpp_type = DeprecatedString::formatted(
+ "{}{}{}",
+ type_definition->cpp_type,
+ is_pointer && is_const_pointer ? " const" : "",
+ is_pointer ? "*" : ""),
+ .function_name_suffix = function_name_suffix,
+ .is_pointer = is_pointer,
+ .is_const_pointer = is_const_pointer,
+ };
+}
+
+DeprecatedString wrap_expression_in_range_conversion(DeprecatedString source_type, DeprecatedString target_type, DeprecatedString expression)
+{
+ VERIFY(target_type == "GLfloat" || target_type == "GLdouble");
+
+ // No range conversion required
+ if (source_type == target_type || source_type == "GLdouble")
+ return expression;
+
+ if (source_type == "GLbyte")
+ return DeprecatedString::formatted("({} + 128.) / 127.5 - 1.", expression);
+ else if (source_type == "GLfloat")
+ return DeprecatedString::formatted("static_cast<GLdouble>({})", expression);
+ else if (source_type == "GLint")
+ return DeprecatedString::formatted("({} + 2147483648.) / 2147483647.5 - 1.", expression);
+ else if (source_type == "GLshort")
+ return DeprecatedString::formatted("({} + 32768.) / 32767.5 - 1.", expression);
+ else if (source_type == "GLubyte")
+ return DeprecatedString::formatted("{} / 255.", expression);
+ else if (source_type == "GLuint")
+ return DeprecatedString::formatted("{} / 4294967296.", expression);
+ else if (source_type == "GLushort")
+ return DeprecatedString::formatted("{} / 65536.", expression);
+ VERIFY_NOT_REACHED();
+}
+
+Variants read_variants_settings(JsonObject const& variants_obj)
+{
+ Variants variants;
+
+ if (variants_obj.has("argument_counts"sv)) {
+ variants.argument_counts.clear_with_capacity();
+ variants_obj.get("argument_counts"sv).as_array().for_each([&](auto const& argument_count_value) {
+ variants.argument_counts.append(argument_count_value.to_u32());
+ });
+ }
+ if (variants_obj.has("argument_defaults"sv)) {
+ variants.argument_defaults.clear_with_capacity();
+ variants_obj.get("argument_defaults"sv).as_array().for_each([&](auto const& argument_default_value) {
+ variants.argument_defaults.append(argument_default_value.as_string());
+ });
+ }
+ if (variants_obj.has("convert_range"sv)) {
+ variants.convert_range = variants_obj.get("convert_range"sv).to_bool();
+ }
+ if (variants_obj.has("api_suffixes"sv)) {
+ variants.api_suffixes.clear_with_capacity();
+ variants_obj.get("api_suffixes"sv).as_array().for_each([&](auto const& suffix_value) {
+ variants.api_suffixes.append(suffix_value.as_string());
+ });
+ }
+ if (variants_obj.has("pointer_argument"sv)) {
+ variants.pointer_argument = variants_obj.get("pointer_argument"sv).as_string();
+ }
+ if (variants_obj.has("types"sv)) {
+ variants.types.clear_with_capacity();
+ variants_obj.get("types"sv).as_object().for_each_member([&](auto const& key, auto const& type_value) {
+ auto const& type = type_value.as_object();
+ variants.types.append(VariantType {
+ .encoded_type = key,
+ .implementation = type.has("implementation"sv) ? type.get("implementation"sv).as_string() : Optional<DeprecatedString> {},
+ .unimplemented = type.get("unimplemented"sv).to_bool(false),
+ });
+ });
+ }
+
+ return variants;
+}
+
+Vector<ArgumentDefinition> copy_arguments_for_variant(Vector<ArgumentDefinition> arguments, Variants variants,
+ u32 argument_count, EncodedType encoded_type)
+{
+ Vector<ArgumentDefinition> variant_arguments = arguments;
+ auto base_cpp_type = encoded_type.type_entry.cpp_type;
+
+ size_t variadic_index = 0;
+ for (size_t i = 0; i < variant_arguments.size(); ++i) {
+ // Skip arguments with a fixed type
+ if (variant_arguments[i].cpp_type.has_value())
+ continue;
+
+ variant_arguments[i].cpp_type = encoded_type.cpp_type;
+ auto cast_to = variant_arguments[i].cast_to;
+
+ // Pointer argument
+ if (encoded_type.is_pointer) {
+ variant_arguments[i].name = (variadic_index == 0) ? variants.pointer_argument : Optional<DeprecatedString> {};
+
+ if (variadic_index >= argument_count) {
+ // If this variable argument is past the argument count, fall back to the defaults
+ variant_arguments[i].expression = variants.argument_defaults[variadic_index];
+ variant_arguments[i].cast_to = Optional<DeprecatedString> {};
+
+ } else if (argument_count == 1 && variants.argument_counts.size() == 1) {
+ // Otherwise, if the pointer is the only variadic argument, pass it through unchanged
+ variant_arguments[i].cast_to = Optional<DeprecatedString> {};
+
+ } else {
+ // Otherwise, index into the pointer argument
+ auto indexed_expression = DeprecatedString::formatted("{}[{}]", variants.pointer_argument, variadic_index);
+ if (variants.convert_range && cast_to.has_value())
+ indexed_expression = wrap_expression_in_range_conversion(base_cpp_type, cast_to.value(), indexed_expression);
+ variant_arguments[i].expression = indexed_expression;
+ }
+
+ } else {
+ // Regular argument
+ if (variadic_index >= argument_count) {
+ // If the variable argument is past the argument count, fall back to the defaults
+ variant_arguments[i].name = Optional<DeprecatedString> {};
+ variant_arguments[i].expression = variants.argument_defaults[variadic_index];
+ variant_arguments[i].cast_to = Optional<DeprecatedString> {};
+
+ } else if (variants.convert_range && cast_to.has_value()) {
+ // Otherwise, if we need to convert the input values, wrap the expression in a range conversion
+ variant_arguments[i].expression = wrap_expression_in_range_conversion(
+ base_cpp_type,
+ cast_to.value(),
+ variant_arguments[i].expression);
+ }
+ }
+
+ // Determine if we can skip casting to the target type
+ if (cast_to == base_cpp_type || (variants.convert_range && cast_to == "GLdouble"))
+ variant_arguments[i].cast_to = Optional<DeprecatedString> {};
+
+ variadic_index++;
+ }
+
+ return variant_arguments;
+}
+
+Vector<FunctionDefinition> create_function_definitions(DeprecatedString function_name, JsonObject const& function_definition)
+{
+ // A single function definition can expand to multiple generated functions by way of:
+ // - differing API suffices (ARB, EXT, etc.);
+ // - differing argument counts;
+ // - differing argument types.
+ // These can all be combined.
+
+ // Parse base argument definitions first; these may later be modified by variants
+ Vector<ArgumentDefinition> argument_definitions;
+ JsonArray const& arguments = function_definition.has("arguments"sv)
+ ? function_definition.get("arguments"sv).as_array()
+ : JsonArray {};
+ arguments.for_each([&argument_definitions](auto const& argument_value) {
+ VERIFY(argument_value.is_object());
+ auto const& argument = argument_value.as_object();
+
+ auto type = argument.has("type"sv) ? argument.get("type"sv).as_string() : Optional<DeprecatedString> {};
+ auto argument_names = get_name_list(argument.get("name"sv));
+ auto expression = argument.get("expression"sv).as_string_or("@argument_name@");
+ auto cast_to = argument.has("cast_to"sv) ? argument.get("cast_to"sv).as_string() : Optional<DeprecatedString> {};
+
+ // Add an empty dummy name when all we have is an expression
+ if (argument_names.is_empty() && !expression.is_empty())
+ argument_names.append("");
+
+ for (auto const& argument_name : argument_names) {
+ argument_definitions.append({ .name = argument_name.is_empty() ? Optional<DeprecatedString> {} : argument_name,
+ .cpp_type = type,
+ .expression = expression,
+ .cast_to = cast_to });
+ }
+ });
+
+ // Create functions for each name and/or variant
+ Vector<FunctionDefinition> functions;
+
+ auto return_type = function_definition.get("return_type"sv).as_string_or("void"sv);
+ auto function_implementation = function_definition.get("implementation"sv).as_string_or(function_name.to_snakecase());
+ auto function_unimplemented = function_definition.get("unimplemented"sv).to_bool(false);
+
+ if (!function_definition.has("variants"sv)) {
+ functions.append({
+ .name = function_name,
+ .return_type = return_type,
+ .arguments = argument_definitions,
+ .implementation = function_implementation,
+ .unimplemented = function_unimplemented,
+ .variant_gl_type = "",
+ });
+ return functions;
+ }
+
+ // Read variants settings for this function
+ auto variants_obj = function_definition.get("variants"sv).as_object();
+ auto variants = read_variants_settings(variants_obj);
+
+ for (auto argument_count : variants.argument_counts) {
+ for (auto const& variant_type : variants.types) {
+ auto encoded_type = get_encoded_type(variant_type.encoded_type);
+ auto variant_arguments = encoded_type.has_value()
+ ? copy_arguments_for_variant(argument_definitions, variants, argument_count, encoded_type.value())
+ : argument_definitions;
+ auto variant_type_implementation = variant_type.implementation.has_value()
+ ? variant_type.implementation.value()
+ : function_implementation;
+
+ for (auto const& api_suffix : variants.api_suffixes) {
+ functions.append({
+ .name = DeprecatedString::formatted(
+ "{}{}{}{}",
+ function_name,
+ variants.argument_counts.size() > 1 ? DeprecatedString::formatted("{}", argument_count) : "",
+ encoded_type.has_value() && variants.types.size() > 1 ? encoded_type->function_name_suffix : "",
+ api_suffix),
+ .return_type = return_type,
+ .arguments = variant_arguments,
+ .implementation = variant_type_implementation,
+ .unimplemented = variant_type.unimplemented || function_unimplemented,
+ .variant_gl_type = encoded_type.has_value() ? encoded_type->type_entry.gl_type : ""sv,
+ });
+ }
+ }
+ }
+
+ return functions;
+}
+
+ErrorOr<void> generate_header_file(JsonObject& api_data, Core::Stream::File& file)
+{
+ StringBuilder builder;
+ SourceGenerator generator { builder };
+
+ generator.appendln("#pragma once");
+ generator.append("\n");
+ generator.appendln("#include <LibGL/GL/glplatform.h>");
+ generator.append("\n");
+ generator.appendln("#ifdef __cplusplus");
+ generator.appendln("extern \"C\" {");
+ generator.appendln("#endif");
+ generator.append("\n");
+
+ api_data.for_each_member([&](auto& function_name, auto& value) {
+ VERIFY(value.is_object());
+ auto const& function = value.as_object();
+ auto function_definitions = create_function_definitions(function_name, function);
+
+ for (auto const& function_definition : function_definitions) {
+ auto function_generator = generator.fork();
+
+ function_generator.set("name", function_definition.name);
+ function_generator.set("return_type", function_definition.return_type);
+
+ function_generator.append("GLAPI @return_type@ gl@name@(");
+
+ bool first = true;
+ for (auto const& argument_definition : function_definition.arguments) {
+ if (!argument_definition.name.has_value() || !argument_definition.cpp_type.has_value())
+ continue;
+
+ auto argument_generator = function_generator.fork();
+ argument_generator.set("argument_type", argument_definition.cpp_type.value());
+ argument_generator.set("argument_name", argument_definition.name.value());
+
+ if (!first)
+ argument_generator.append(", ");
+ first = false;
+ argument_generator.append("@argument_type@ @argument_name@");
+ }
+
+ function_generator.appendln(");");
+ }
+ });
+
+ generator.appendln("#ifdef __cplusplus");
+ generator.appendln("}");
+ generator.appendln("#endif");
+
+ TRY(file.write(generator.as_string_view().bytes()));
+ return {};
+}
+
+ErrorOr<void> generate_implementation_file(JsonObject& api_data, Core::Stream::File& file)
+{
+ StringBuilder builder;
+ SourceGenerator generator { builder };
+
+ generator.appendln("#include <LibGL/GL/glapi.h>");
+ generator.appendln("#include <LibGL/GLContext.h>");
+ generator.append("\n");
+ generator.appendln("extern GL::GLContext* g_gl_context;");
+ generator.append("\n");
+
+ api_data.for_each_member([&](auto& function_name, auto& value) {
+ VERIFY(value.is_object());
+ JsonObject const& function = value.as_object();
+ auto function_definitions = create_function_definitions(function_name, function);
+
+ for (auto const& function_definition : function_definitions) {
+ auto function_generator = generator.fork();
+ auto return_type = function_definition.return_type;
+
+ function_generator.set("name"sv, function_definition.name);
+ function_generator.set("return_type"sv, return_type);
+ function_generator.set("implementation"sv, function_definition.implementation);
+ function_generator.set("variant_gl_type"sv, function_definition.variant_gl_type);
+
+ function_generator.append("@return_type@ gl@name@(");
+
+ bool first = true;
+ for (auto const& argument_definition : function_definition.arguments) {
+ if (!argument_definition.name.has_value() || !argument_definition.cpp_type.has_value())
+ continue;
+
+ auto argument_generator = function_generator.fork();
+ argument_generator.set("argument_type", argument_definition.cpp_type.value());
+ argument_generator.set("argument_name", argument_definition.name.value());
+
+ if (!first)
+ argument_generator.append(", ");
+ first = false;
+ argument_generator.append("@argument_type@ @argument_name@");
+ }
+ function_generator.appendln(")");
+ function_generator.appendln("{");
+
+ if (function_definition.unimplemented) {
+ function_generator.append(" dbgln(\"gl@name@(");
+
+ first = true;
+ for (auto const& argument_definition : function_definition.arguments) {
+ if (!argument_definition.name.has_value())
+ continue;
+ if (!first)
+ function_generator.append(", ");
+ first = false;
+ if (argument_definition.cpp_type.value().ends_with('*'))
+ function_generator.append("{:p}");
+ else if (argument_definition.cpp_type.value() == "GLenum")
+ function_generator.append("{:#x}");
+ else
+ function_generator.append("{}");
+ }
+
+ function_generator.append("): unimplemented\"");
+
+ for (auto const& argument_definition : function_definition.arguments) {
+ if (!argument_definition.name.has_value())
+ continue;
+
+ function_generator.append(", ");
+ function_generator.append(argument_definition.name.value());
+ }
+
+ function_generator.appendln(");");
+ function_generator.appendln(" TODO();");
+ } else {
+ function_generator.appendln(" if (!g_gl_context)");
+ if (return_type.ends_with('*'))
+ function_generator.appendln(" return nullptr;");
+ else if (return_type == "GLboolean"sv)
+ function_generator.appendln(" return GL_FALSE;");
+ else if (return_type == "GLenum"sv)
+ function_generator.appendln(" return GL_INVALID_OPERATION;");
+ else if (return_type == "GLuint"sv)
+ function_generator.appendln(" return 0;");
+ else if (return_type == "void"sv)
+ function_generator.appendln(" return;");
+ else
+ VERIFY_NOT_REACHED();
+ function_generator.append(" ");
+ if (return_type != "void"sv)
+ function_generator.append("return ");
+ function_generator.append("g_gl_context->gl_@implementation@(");
+
+ first = true;
+ for (auto const& argument_definition : function_definition.arguments) {
+ auto argument_generator = function_generator.fork();
+
+ auto cast_to = argument_definition.cast_to;
+ argument_generator.set("argument_name", argument_definition.name.value_or(""));
+ argument_generator.set("cast_to", cast_to.value_or(""));
+
+ if (!first)
+ argument_generator.append(", ");
+ first = false;
+
+ if (cast_to.has_value())
+ argument_generator.append("static_cast<@cast_to@>(");
+ argument_generator.append(argument_definition.expression);
+ if (cast_to.has_value())
+ argument_generator.append(")");
+ }
+
+ function_generator.appendln(");");
+ }
+
+ function_generator.appendln("}");
+ function_generator.append("\n");
+ }
+ });
+
+ TRY(file.write(generator.as_string_view().bytes()));
+ return {};
+}
+
+ErrorOr<JsonValue> read_entire_file_as_json(StringView filename)
+{
+ auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
+ auto json_size = TRY(file->size());
+ auto json_data = TRY(ByteBuffer::create_uninitialized(json_size));
+ TRY(file->read_entire_buffer(json_data.bytes()));
+ return JsonValue::from_string(json_data);
+}
+
+ErrorOr<int> serenity_main(Main::Arguments arguments)
+{
+ StringView generated_header_path;
+ StringView generated_implementation_path;
+ StringView api_json_path;
+
+ Core::ArgsParser args_parser;
+ args_parser.add_option(generated_header_path, "Path to the OpenGL API header file to generate", "generated-header-path", 'h', "generated-header-path");
+ args_parser.add_option(generated_implementation_path, "Path to the OpenGL API implementation file to generate", "generated-implementation-path", 'c', "generated-implementation-path");
+ args_parser.add_option(api_json_path, "Path to the JSON file to read from", "json-path", 'j', "json-path");
+ args_parser.parse(arguments);
+
+ auto json = TRY(read_entire_file_as_json(api_json_path));
+ VERIFY(json.is_object());
+ auto api_data = json.as_object();
+
+ auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write));
+ auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write));
+
+ TRY(generate_header_file(api_data, *generated_header_file));
+ TRY(generate_implementation_file(api_data, *generated_implementation_file));
+
+ return 0;
+}
diff --git a/Userland/Libraries/LibGL/CMakeLists.txt b/Userland/Libraries/LibGL/CMakeLists.txt
index 88bd390fe9..d9235adb54 100644
--- a/Userland/Libraries/LibGL/CMakeLists.txt
+++ b/Userland/Libraries/LibGL/CMakeLists.txt
@@ -1,9 +1,10 @@
+include(libgl_generators)
+
set(SOURCES
Buffer/Buffer.cpp
Buffer.cpp
ClipPlane.cpp
ContextParameter.cpp
- GLAPI.cpp
GLContext.cpp
Image.cpp
Lighting.cpp
@@ -19,5 +20,10 @@ set(SOURCES
Vertex.cpp
)
+generate_libgl_implementation()
+
+set(GENERATED_SOURCES
+ GLAPI.cpp)
+
serenity_lib(LibGL gl)
target_link_libraries(LibGL PRIVATE LibCore LibGfx LibGLSL LibGPU)
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 0cfe285af4..56f617ef1a 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -1,13 +1,14 @@
/*
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
- * Copyright (c) 2021, Jelle Raaijmakers <jelle@gmta.nl>
+ * Copyright (c) 2021-2022, Jelle Raaijmakers <jelle@gmta.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
+#include <LibGL/GL/glapi.h>
#include <LibGL/GL/glplatform.h>
#ifdef __cplusplus
@@ -610,231 +611,6 @@ extern "C" {
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
-GLAPI void glBegin(GLenum mode);
-GLAPI void glClear(GLbitfield mask);
-GLAPI void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-GLAPI void glClearDepth(GLdouble depth);
-GLAPI void glClearDepthf(GLfloat depth);
-GLAPI void glClearStencil(GLint s);
-GLAPI void glColor3d(GLdouble r, GLdouble g, GLdouble b);
-GLAPI void glColor3dv(GLdouble const* v);
-GLAPI void glColor3f(GLfloat r, GLfloat g, GLfloat b);
-GLAPI void glColor3fv(GLfloat const* v);
-GLAPI void glColor3ub(GLubyte r, GLubyte g, GLubyte b);
-GLAPI void glColor3ubv(GLubyte const* v);
-GLAPI void glColor4b(GLbyte r, GLbyte g, GLbyte b, GLbyte a);
-GLAPI void glColor4dv(GLdouble const* v);
-GLAPI void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
-GLAPI void glColor4fv(GLfloat const* v);
-GLAPI void glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a);
-GLAPI void glColor4ubv(GLubyte const* v);
-GLAPI void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-GLAPI void glColorMaterial(GLenum face, GLenum mode);
-GLAPI void glDeleteTextures(GLsizei n, GLuint const* textures);
-GLAPI void glEnd();
-GLAPI void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
-GLAPI void glGenTextures(GLsizei n, GLuint* textures);
-GLAPI GLenum glGetError();
-GLAPI GLubyte const* glGetString(GLenum name);
-GLAPI void glLoadIdentity();
-GLAPI void glLoadMatrixd(GLdouble const* matrix);
-GLAPI void glLoadMatrixf(GLfloat const* matrix);
-GLAPI void glMatrixMode(GLenum mode);
-GLAPI void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
-GLAPI void glPushMatrix();
-GLAPI void glPopMatrix();
-GLAPI void glMultMatrixd(GLdouble const* matrix);
-GLAPI void glMultMatrixf(GLfloat const* matrix);
-GLAPI void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void glScaled(GLdouble x, GLdouble y, GLdouble z);
-GLAPI void glScalef(GLfloat x, GLfloat y, GLfloat z);
-GLAPI void glTranslated(GLdouble x, GLdouble y, GLdouble z);
-GLAPI void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
-GLAPI void glVertex2d(GLdouble x, GLdouble y);
-GLAPI void glVertex2dv(GLdouble const* v);
-GLAPI void glVertex2f(GLfloat x, GLfloat y);
-GLAPI void glVertex2fv(GLfloat const* v);
-GLAPI void glVertex2i(GLint x, GLint y);
-GLAPI void glVertex2iv(GLint const* v);
-GLAPI void glVertex2s(GLshort x, GLshort y);
-GLAPI void glVertex2sv(GLshort const* v);
-GLAPI void glVertex3d(GLdouble x, GLdouble y, GLdouble z);
-GLAPI void glVertex3dv(GLdouble const* v);
-GLAPI void glVertex3f(GLfloat x, GLfloat y, GLfloat z);
-GLAPI void glVertex3fv(GLfloat const* v);
-GLAPI void glVertex3i(GLint x, GLint y, GLint z);
-GLAPI void glVertex3iv(GLint const* v);
-GLAPI void glVertex3s(GLshort x, GLshort y, GLshort z);
-GLAPI void glVertex3sv(GLshort const* v);
-GLAPI void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void glVertex4dv(GLdouble const* v);
-GLAPI void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void glVertex4fv(GLfloat const* v);
-GLAPI void glVertex4i(GLint x, GLint y, GLint z, GLint w);
-GLAPI void glVertex4iv(GLint const* v);
-GLAPI void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void glVertex4sv(GLshort const* v);
-GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void glEnable(GLenum cap);
-GLAPI void glDisable(GLenum cap);
-GLAPI GLboolean glIsEnabled(GLenum cap);
-GLAPI void glCullFace(GLenum mode);
-GLAPI void glFrontFace(GLenum mode);
-GLAPI GLuint glGenLists(GLsizei range);
-GLAPI void glCallList(GLuint list);
-GLAPI void glCallLists(GLsizei n, GLenum type, void const* lists);
-GLAPI void glDeleteLists(GLuint list, GLsizei range);
-GLAPI void glListBase(GLuint base);
-GLAPI void glEndList(void);
-GLAPI void glNewList(GLuint list, GLenum mode);
-GLAPI GLboolean glIsList(GLuint list);
-GLAPI void glFlush();
-GLAPI void glFinish();
-GLAPI void glBlendFunc(GLenum sfactor, GLenum dfactor);
-GLAPI void glShadeModel(GLenum mode);
-GLAPI void glAlphaFunc(GLenum func, GLclampf ref);
-GLAPI void glHint(GLenum target, GLenum mode);
-GLAPI void glReadBuffer(GLenum mode);
-GLAPI void glDrawBuffer(GLenum buffer);
-GLAPI void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
-GLAPI void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid const* data);
-GLAPI void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data);
-GLAPI void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid const* data);
-GLAPI void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid const* data);
-GLAPI void glTexCoord1f(GLfloat s);
-GLAPI void glTexCoord1fv(GLfloat const* v);
-GLAPI void glTexCoord2d(GLdouble s, GLdouble t);
-GLAPI void glTexCoord2dv(GLdouble const* v);
-GLAPI void glTexCoord2f(GLfloat s, GLfloat t);
-GLAPI void glTexCoord2fv(GLfloat const* v);
-GLAPI void glTexCoord2i(GLint s, GLint t);
-GLAPI void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r);
-GLAPI void glTexCoord3fv(GLfloat const* v);
-GLAPI void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-GLAPI void glTexCoord4fv(GLfloat const* v);
-GLAPI void glMultiTexCoord1f(GLenum target, GLfloat s);
-GLAPI void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
-GLAPI void glMultiTexCoord2fvARB(GLenum target, GLfloat const* v);
-GLAPI void glMultiTexCoord2fv(GLenum target, GLfloat const* v);
-GLAPI void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t);
-GLAPI void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r);
-GLAPI void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-GLAPI void glTexParameteri(GLenum target, GLenum pname, GLint param);
-GLAPI void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
-GLAPI void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
-GLAPI void glTexEnvi(GLenum target, GLenum pname, GLint param);
-GLAPI void glBindTexture(GLenum target, GLuint texture);
-GLAPI GLboolean glIsTexture(GLuint texture);
-GLAPI void glActiveTextureARB(GLenum texture);
-GLAPI void glActiveTexture(GLenum texture);
-GLAPI void glGetBooleanv(GLenum pname, GLboolean* data);
-GLAPI void glGetDoublev(GLenum pname, GLdouble* params);
-GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
-GLAPI void glGetIntegerv(GLenum pname, GLint* data);
-GLAPI void glGetLightfv(GLenum light, GLenum pname, GLfloat* params);
-GLAPI void glGetLightiv(GLenum light, GLenum pname, GLint* params);
-GLAPI void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params);
-GLAPI void glGetMaterialiv(GLenum face, GLenum pname, GLint* params);
-GLAPI void glDepthMask(GLboolean flag);
-GLAPI void glEnableClientState(GLenum cap);
-GLAPI void glDisableClientState(GLenum cap);
-GLAPI void glClientActiveTextureARB(GLenum target);
-GLAPI void glClientActiveTexture(GLenum target);
-GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer);
-GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer);
-GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer);
-GLAPI void glDrawArrays(GLenum mode, GLint first, GLsizei count);
-GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, void const* indices);
-GLAPI void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data);
-GLAPI void glDepthRange(GLdouble nearVal, GLdouble farVal);
-GLAPI void glDepthFunc(GLenum func);
-GLAPI void glPolygonMode(GLenum face, GLenum mode);
-GLAPI void glPolygonOffset(GLfloat factor, GLfloat units);
-GLAPI void glFogfv(GLenum mode, GLfloat const* params);
-GLAPI void glFogf(GLenum pname, GLfloat param);
-GLAPI void glFogi(GLenum pname, GLint param);
-GLAPI void glPixelStorei(GLenum pname, GLint param);
-GLAPI void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void glLightf(GLenum light, GLenum pname, GLfloat param);
-GLAPI void glLightfv(GLenum light, GLenum pname, GLfloat const* params);
-GLAPI void glLighti(GLenum light, GLenum pname, GLint param);
-GLAPI void glLightiv(GLenum light, GLenum pname, GLint const* params);
-GLAPI void glLightModelf(GLenum pname, GLfloat param);
-GLAPI void glLightModelfv(GLenum pname, GLfloat const* params);
-GLAPI void glLightModeli(GLenum pname, GLint param);
-GLAPI void glLightModeliv(GLenum pname, GLint const* params);
-GLAPI void glStencilFunc(GLenum func, GLint ref, GLuint mask);
-GLAPI void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
-GLAPI void glStencilMask(GLuint mask);
-GLAPI void glStencilMaskSeparate(GLenum face, GLuint mask);
-GLAPI void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI void glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz);
-GLAPI void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
-GLAPI void glNormal3fv(GLfloat const* v);
-GLAPI void glNormalPointer(GLenum type, GLsizei stride, void const* pointer);
-GLAPI void glRasterPos2d(GLdouble x, GLdouble y);
-GLAPI void glRasterPos2f(GLfloat x, GLfloat y);
-GLAPI void glRasterPos2i(GLint x, GLint y);
-GLAPI void glRasterPos2s(GLshort x, GLshort y);
-GLAPI void glMaterialf(GLenum face, GLenum pname, GLfloat param);
-GLAPI void glMaterialfv(GLenum face, GLenum pname, GLfloat const* params);
-GLAPI void glMateriali(GLenum face, GLenum pname, GLint param);
-GLAPI void glMaterialiv(GLenum face, GLenum pname, GLint const* params);
-GLAPI void glLineWidth(GLfloat width);
-GLAPI void glPushAttrib(GLbitfield mask);
-GLAPI void glPopAttrib();
-GLAPI void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap);
-GLAPI void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, GLdouble const* points);
-GLAPI void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, GLfloat const* points);
-GLAPI void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble const* points);
-GLAPI void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat const* points);
-GLAPI void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
-GLAPI void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2);
-GLAPI void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
-GLAPI void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
-GLAPI void glEvalCoord1d(GLdouble u);
-GLAPI void glEvalCoord1f(GLfloat u);
-GLAPI void glEvalCoord2d(GLdouble u, GLdouble v);
-GLAPI void glEvalCoord2f(GLfloat u, GLfloat v);
-GLAPI void glEvalMesh1(GLenum mode, GLint i1, GLint i2);
-GLAPI void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
-GLAPI void glEvalPoint1(GLint i);
-GLAPI void glEvalPoint2(GLint i, GLint j);
-GLAPI void glTexGend(GLenum coord, GLenum pname, GLdouble param);
-GLAPI void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
-GLAPI void glTexGenfv(GLenum coord, GLenum pname, GLfloat const* params);
-GLAPI void glTexGeni(GLenum coord, GLenum pname, GLint param);
-GLAPI void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
-GLAPI void glRecti(GLint x1, GLint y1, GLint x2, GLint y2);
-GLAPI void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void* pixels);
-GLAPI void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params);
-GLAPI void glPointSize(GLfloat size);
-GLAPI void glClipPlane(GLenum plane, GLdouble const* equation);
-GLAPI void glGetClipPlane(GLenum plane, GLdouble* equation);
-GLAPI void glArrayElement(GLint i);
-GLAPI void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void glBindBuffer(GLenum target, GLuint buffer);
-GLAPI void glBufferData(GLenum target, GLsizeiptr size, void const* data, GLenum usage);
-GLAPI void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void const* data);
-GLAPI void glDeleteBuffers(GLsizei n, GLuint const* buffers);
-GLAPI void glGenBuffers(GLsizei n, GLuint* buffers);
-
-GLAPI GLuint glCreateShader(GLenum shader_type);
-GLAPI void glDeleteShader(GLuint shader);
-GLAPI void glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length);
-GLAPI void glCompileShader(GLuint shader);
-GLAPI void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
-
-GLAPI GLuint glCreateProgram();
-GLAPI void glDeleteProgram(GLuint program);
-GLAPI void glAttachShader(GLuint program, GLuint shader);
-GLAPI void glLinkProgram(GLuint program);
-GLAPI void glUseProgram(GLuint program);
-GLAPI void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
-
#ifdef __cplusplus
}
#endif
diff --git a/Userland/Libraries/LibGL/GLAPI.cpp b/Userland/Libraries/LibGL/GLAPI.cpp
deleted file mode 100644
index 4790934a07..0000000000
--- a/Userland/Libraries/LibGL/GLAPI.cpp
+++ /dev/null
@@ -1,1177 +0,0 @@
-/*
- * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
- * Copyright (c) 2021-2022, Jelle Raaijmakers <jelle@gmta.nl>
- * Copyright (c) 2021-2022, Jesse Buhagiar <jooster669@gmail.com>
- * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <AK/Array.h>
-#include <AK/Debug.h>
-#include <LibGL/GL/gl.h>
-#include <LibGL/GLContext.h>
-
-extern GL::GLContext* g_gl_context;
-
-// Transposes input matrices (column-major) to our Matrix (row-major).
-template<typename I>
-constexpr FloatMatrix4x4 transpose_input_matrix(I const* matrix)
-{
- Array<float, 16> elements;
- for (size_t i = 0; i < 16; ++i)
- elements[i] = static_cast<float>(matrix[i]);
- // clang-format off
- return {
- elements[0], elements[4], elements[8], elements[12],
- elements[1], elements[5], elements[9], elements[13],
- elements[2], elements[6], elements[10], elements[14],
- elements[3], elements[7], elements[11], elements[15],
- };
- // clang-format on
-}
-
-template<>
-constexpr FloatMatrix4x4 transpose_input_matrix(float const* matrix)
-{
- // clang-format off
- return {
- matrix[0], matrix[4], matrix[8], matrix[12],
- matrix[1], matrix[5], matrix[9], matrix[13],
- matrix[2], matrix[6], matrix[10], matrix[14],
- matrix[3], matrix[7], matrix[11], matrix[15],
- };
- // clang-format on
-}
-
-void glActiveTexture(GLenum texture)
-{
- g_gl_context->gl_active_texture(texture);
-}
-
-void glActiveTextureARB(GLenum texture)
-{
- glActiveTexture(texture);
-}
-
-void glAlphaFunc(GLenum func, GLclampf ref)
-{
- return g_gl_context->gl_alpha_func(func, ref);
-}
-
-void glArrayElement(GLint i)
-{
- g_gl_context->gl_array_element(i);
-}
-
-void glAttachShader(GLuint program, GLuint shader)
-{
- g_gl_context->gl_attach_shader(program, shader);
-}
-
-void glBegin(GLenum mode)
-{
- g_gl_context->gl_begin(mode);
-}
-
-void glBindBuffer(GLenum target, GLuint buffer)
-{
- g_gl_context->gl_bind_buffer(target, buffer);
-}
-
-void glBindTexture(GLenum target, GLuint texture)
-{
- g_gl_context->gl_bind_texture(target, texture);
-}
-
-void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap)
-{
- g_gl_context->gl_bitmap(width, height, xorig, yorig, xmove, ymove, bitmap);
-}
-
-void glBlendFunc(GLenum sfactor, GLenum dfactor)
-{
- return g_gl_context->gl_blend_func(sfactor, dfactor);
-}
-
-void glBufferData(GLenum target, GLsizeiptr size, void const* data, GLenum usage)
-{
- g_gl_context->gl_buffer_data(target, size, data, usage);
-}
-
-void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void const* data)
-{
- g_gl_context->gl_buffer_sub_data(target, offset, size, data);
-}
-
-void glCallList(GLuint list)
-{
- return g_gl_context->gl_call_list(list);
-}
-
-void glCallLists(GLsizei n, GLenum type, void const* lists)
-{
- return g_gl_context->gl_call_lists(n, type, lists);
-}
-
-void glClear(GLbitfield mask)
-{
- g_gl_context->gl_clear(mask);
-}
-
-void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-{
- g_gl_context->gl_clear_color(red, green, blue, alpha);
-}
-
-void glClearDepth(GLdouble depth)
-{
- g_gl_context->gl_clear_depth(depth);
-}
-
-void glClearDepthf(GLfloat depth)
-{
- g_gl_context->gl_clear_depth(static_cast<double>(depth));
-}
-
-void glClearStencil(GLint s)
-{
- g_gl_context->gl_clear_stencil(s);
-}
-
-void glClientActiveTexture(GLenum target)
-{
- g_gl_context->gl_client_active_texture(target);
-}
-
-void glClientActiveTextureARB(GLenum target)
-{
- glClientActiveTexture(target);
-}
-
-void glClipPlane(GLenum plane, GLdouble const* equation)
-{
- g_gl_context->gl_clip_plane(plane, equation);
-}
-
-void glColor3d(GLdouble r, GLdouble g, GLdouble b)
-{
- g_gl_context->gl_color(r, g, b, 1.0);
-}
-
-void glColor3dv(GLdouble const* v)
-{
- g_gl_context->gl_color(v[0], v[1], v[2], 1.0);
-}
-
-void glColor3f(GLfloat r, GLfloat g, GLfloat b)
-{
- g_gl_context->gl_color(r, g, b, 1.0);
-}
-
-void glColor3fv(GLfloat const* v)
-{
- g_gl_context->gl_color(v[0], v[1], v[2], 1.0);
-}
-
-void glColor3ub(GLubyte r, GLubyte g, GLubyte b)
-{
- g_gl_context->gl_color(r / 255.0, g / 255.0, b / 255.0, 1.0);
-}
-
-void glColor3ubv(GLubyte const* v)
-{
- g_gl_context->gl_color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, 1.0);
-}
-
-void glColor4b(GLbyte r, GLbyte g, GLbyte b, GLbyte a)
-{
- g_gl_context->gl_color(
- (static_cast<double>(r) + 128) / 127.5 - 1,
- (static_cast<double>(g) + 128) / 127.5 - 1,
- (static_cast<double>(b) + 128) / 127.5 - 1,
- (static_cast<double>(a) + 128) / 127.5 - 1);
-}
-
-void glColor4dv(GLdouble const* v)
-{
- g_gl_context->gl_color(v[0], v[1], v[2], v[3]);
-}
-
-void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
-{
- g_gl_context->gl_color(r, g, b, a);
-}
-
-void glColor4fv(GLfloat const* v)
-{
- g_gl_context->gl_color(v[0], v[1], v[2], v[3]);
-}
-
-void glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
-{
- g_gl_context->gl_color(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
-}
-
-void glColor4ubv(GLubyte const* v)
-{
- g_gl_context->gl_color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
-}
-
-void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
-{
- g_gl_context->gl_color_mask(red, green, blue, alpha);
-}
-
-void glColorMaterial(GLenum face, GLenum mode)
-{
- g_gl_context->gl_color_material(face, mode);
-}
-
-void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
-{
- g_gl_context->gl_color_pointer(size, type, stride, pointer);
-}
-
-void glCompileShader(GLuint shader)
-{
- g_gl_context->gl_compile_shader(shader);
-}
-
-void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
-{
- g_gl_context->gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border);
-}
-
-void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
-{
- g_gl_context->gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height);
-}
-
-GLuint glCreateProgram()
-{
- return g_gl_context->gl_create_program();
-}
-
-GLuint glCreateShader(GLenum shader_type)
-{
- return g_gl_context->gl_create_shader(shader_type);
-}
-
-void glCullFace(GLenum mode)
-{
- g_gl_context->gl_cull_face(mode);
-}
-
-void glDeleteBuffers(GLsizei n, GLuint const* buffers)
-{
- g_gl_context->gl_delete_buffers(n, buffers);
-}
-
-void glDepthFunc(GLenum func)
-{
- g_gl_context->gl_depth_func(func);
-}
-
-void glDepthMask(GLboolean flag)
-{
- g_gl_context->gl_depth_mask(flag);
-}
-
-void glDepthRange(GLdouble min, GLdouble max)
-{
- g_gl_context->gl_depth_range(min, max);
-}
-
-void glDeleteLists(GLuint list, GLsizei range)
-{
- return g_gl_context->gl_delete_lists(list, range);
-}
-
-void glDeleteProgram(GLuint program)
-{
- g_gl_context->gl_delete_program(program);
-}
-
-void glDeleteShader(GLuint shader)
-{
- g_gl_context->gl_delete_shader(shader);
-}
-
-void glDeleteTextures(GLsizei n, GLuint const* textures)
-{
- g_gl_context->gl_delete_textures(n, textures);
-}
-
-void glDisable(GLenum cap)
-{
- g_gl_context->gl_disable(cap);
-}
-
-void glDisableClientState(GLenum cap)
-{
- g_gl_context->gl_disable_client_state(cap);
-}
-
-void glDrawArrays(GLenum mode, GLint first, GLsizei count)
-{
- g_gl_context->gl_draw_arrays(mode, first, count);
-}
-
-void glDrawBuffer(GLenum buffer)
-{
- g_gl_context->gl_draw_buffer(buffer);
-}
-
-void glDrawElements(GLenum mode, GLsizei count, GLenum type, void const* indices)
-{
- g_gl_context->gl_draw_elements(mode, count, type, indices);
-}
-
-void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data)
-{
- g_gl_context->gl_draw_pixels(width, height, format, type, data);
-}
-
-void glEnable(GLenum cap)
-{
- g_gl_context->gl_enable(cap);
-}
-
-void glEnableClientState(GLenum cap)
-{
- g_gl_context->gl_enable_client_state(cap);
-}
-
-void glEnd()
-{
- g_gl_context->gl_end();
-}
-
-void glEndList(void)
-{
- return g_gl_context->gl_end_list();
-}
-
-void glEvalCoord1d(GLdouble u)
-{
- dbgln("glEvalCoord1d({}): unimplemented", u);
- TODO();
-}
-
-void glEvalCoord1f(GLfloat u)
-{
- dbgln("glEvalCoord1f({}): unimplemented", u);
- TODO();
-}
-
-void glEvalCoord2d(GLdouble u, GLdouble v)
-{
- dbgln("glEvalCoord2d({}, {}): unimplemented", u, v);
- TODO();
-}
-
-void glEvalCoord2f(GLfloat u, GLfloat v)
-{
- dbgln("glEvalCoord2f({}, {}): unimplemented", u, v);
- TODO();
-}
-
-void glEvalMesh1(GLenum mode, GLint i1, GLint i2)
-{
- dbgln("glEvalMesh1({:#x}, {}, {}): unimplemented", mode, i1, i2);
- TODO();
-}
-
-void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
-{
- dbgln("glEvalMesh2({:#x}, {}, {}, {}, {}): unimplemented", mode, i1, i2, j1, j2);
- TODO();
-}
-
-void glEvalPoint1(GLint i)
-{
- dbgln("glEvalPoint1({}): unimplemented", i);
- TODO();
-}
-
-void glEvalPoint2(GLint i, GLint j)
-{
- dbgln("glEvalPoint2({}, {}): unimplemented", i, j);
- TODO();
-}
-
-void glFinish()
-{
- g_gl_context->gl_finish();
-}
-
-void glFogfv(GLenum pname, GLfloat const* params)
-{
- g_gl_context->gl_fogfv(pname, params);
-}
-
-void glFogf(GLenum pname, GLfloat param)
-{
- g_gl_context->gl_fogf(pname, param);
-}
-
-void glFogi(GLenum pname, GLint param)
-{
- g_gl_context->gl_fogi(pname, param);
-}
-
-void glFlush()
-{
- g_gl_context->gl_flush();
-}
-
-void glFrontFace(GLenum mode)
-{
- g_gl_context->gl_front_face(mode);
-}
-
-void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)
-{
- g_gl_context->gl_frustum(left, right, bottom, top, nearVal, farVal);
-}
-
-void glGenBuffers(GLsizei n, GLuint* buffers)
-{
- g_gl_context->gl_gen_buffers(n, buffers);
-}
-
-GLuint glGenLists(GLsizei range)
-{
- return g_gl_context->gl_gen_lists(range);
-}
-
-void glGenTextures(GLsizei n, GLuint* textures)
-{
- g_gl_context->gl_gen_textures(n, textures);
-}
-
-void glGetBooleanv(GLenum pname, GLboolean* data)
-{
- g_gl_context->gl_get_booleanv(pname, data);
-}
-
-void glGetClipPlane(GLenum plane, GLdouble* equation)
-{
- g_gl_context->gl_get_clip_plane(plane, equation);
-}
-
-void glGetDoublev(GLenum pname, GLdouble* params)
-{
- g_gl_context->gl_get_doublev(pname, params);
-}
-
-GLenum glGetError()
-{
- return g_gl_context->gl_get_error();
-}
-
-void glGetFloatv(GLenum pname, GLfloat* params)
-{
- g_gl_context->gl_get_floatv(pname, params);
-}
-
-void glGetIntegerv(GLenum pname, GLint* data)
-{
- g_gl_context->gl_get_integerv(pname, data);
-}
-
-void glGetLightfv(GLenum light, GLenum pname, GLfloat* params)
-{
- g_gl_context->gl_get_light(light, pname, params, GL_FLOAT);
-}
-
-void glGetLightiv(GLenum light, GLenum pname, GLint* params)
-{
- g_gl_context->gl_get_light(light, pname, params, GL_INT);
-}
-
-void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params)
-{
- g_gl_context->gl_get_material(face, pname, params, GL_FLOAT);
-}
-
-void glGetMaterialiv(GLenum face, GLenum pname, GLint* params)
-{
- g_gl_context->gl_get_material(face, pname, params, GL_INT);
-}
-
-void glGetProgramiv(GLuint program, GLenum pname, GLint* params)
-{
- g_gl_context->gl_get_program(program, pname, params);
-}
-
-GLubyte const* glGetString(GLenum name)
-{
- return g_gl_context->gl_get_string(name);
-}
-
-void glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
-{
- g_gl_context->gl_get_shader(shader, pname, params);
-}
-
-void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void* pixels)
-{
- g_gl_context->gl_get_tex_image(target, level, format, type, pixels);
-}
-
-void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params)
-{
- g_gl_context->gl_get_tex_parameter_integerv(target, level, pname, params);
-}
-
-void glHint(GLenum target, GLenum mode)
-{
- g_gl_context->gl_hint(target, mode);
-}
-
-GLboolean glIsEnabled(GLenum cap)
-{
- return g_gl_context->gl_is_enabled(cap);
-}
-
-GLboolean glIsList(GLuint list)
-{
- return g_gl_context->gl_is_list(list);
-}
-
-GLboolean glIsTexture(GLuint texture)
-{
- return g_gl_context->gl_is_texture(texture);
-}
-
-void glLightf(GLenum light, GLenum pname, GLfloat param)
-{
- g_gl_context->gl_lightf(light, pname, param);
-}
-
-void glLightfv(GLenum light, GLenum pname, GLfloat const* param)
-{
- g_gl_context->gl_lightfv(light, pname, param);
-}
-
-void glLighti(GLenum light, GLenum pname, GLint param)
-{
- g_gl_context->gl_lightf(light, pname, param);
-}
-
-void glLightiv(GLenum light, GLenum pname, GLint const* params)
-{
- g_gl_context->gl_lightiv(light, pname, params);
-}
-
-void glLightModelf(GLenum pname, GLfloat param)
-{
- g_gl_context->gl_light_model(pname, param, 0.f, 0.f, 0.f);
-}
-
-void glLightModelfv(GLenum pname, GLfloat const* params)
-{
- g_gl_context->gl_light_modelv(pname, params, GL_FLOAT);
-}
-
-void glLightModeliv(GLenum pname, GLint const* params)
-{
- g_gl_context->gl_light_modelv(pname, params, GL_INT);
-}
-
-void glLightModeli(GLenum pname, GLint param)
-{
- g_gl_context->gl_light_model(pname, static_cast<float>(param), 0.f, 0.f, 0.f);
-}
-
-void glLineWidth(GLfloat width)
-{
- g_gl_context->gl_line_width(width);
-}
-
-void glLinkProgram(GLuint program)
-{
- g_gl_context->gl_link_program(program);
-}
-
-void glListBase(GLuint base)
-{
- return g_gl_context->gl_list_base(base);
-}
-
-void glLoadIdentity()
-{
- g_gl_context->gl_load_identity();
-}
-
-void glLoadMatrixd(GLdouble const* matrix)
-{
- g_gl_context->gl_load_matrix(transpose_input_matrix(matrix));
-}
-
-void glLoadMatrixf(GLfloat const* matrix)
-{
- g_gl_context->gl_load_matrix(transpose_input_matrix(matrix));
-}
-
-void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, GLdouble const* points)
-{
- dbgln("glMap1d({:#x}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, stride, order, points);
- TODO();
-}
-
-void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, GLfloat const* points)
-{
- dbgln("glMap1f({:#x}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, stride, order, points);
- TODO();
-}
-
-void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble const* points)
-{
- dbgln("glMap2d({:#x}, {}, {}, {}, {}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
- TODO();
-}
-
-void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat const* points)
-{
- dbgln("glMap2f({:#x}, {}, {}, {}, {}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
- TODO();
-}
-
-void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
-{
- dbgln("glMapGrid1d({}, {}, {}): unimplemented", un, u1, u2);
- TODO();
-}
-
-void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
-{
- dbgln("glMapGrid1f({}, {}, {}): unimplemented", un, u1, u2);
- TODO();
-}
-
-void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
-{
- dbgln("glMapGrid2d({}, {}, {}, {}, {}, {}): unimplemented", un, u1, u2, vn, v1, v2);
- TODO();
-}
-
-void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
-{
- dbgln("glMapGrid2f({}, {}, {}, {}, {}, {}): unimplemented", un, u1, u2, vn, v1, v2);
- TODO();
-}
-
-void glMaterialf(GLenum face, GLenum pname, GLfloat param)
-{
- g_gl_context->gl_materialf(face, pname, param);
-}
-
-void glMaterialfv(GLenum face, GLenum pname, GLfloat const* params)
-{
- g_gl_context->gl_materialfv(face, pname, params);
-}
-
-void glMateriali(GLenum face, GLenum pname, GLint param)
-{
- g_gl_context->gl_materialf(face, pname, param);
-}
-
-void glMaterialiv(GLenum face, GLenum pname, GLint const* params)
-{
- g_gl_context->gl_materialiv(face, pname, params);
-}
-
-void glMatrixMode(GLenum mode)
-{
- g_gl_context->gl_matrix_mode(mode);
-}
-
-void glMultiTexCoord1f(GLenum target, GLfloat s)
-{
- g_gl_context->gl_multi_tex_coord(target, s, 0.f, 0.f, 1.f);
-}
-
-void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
-{
- glMultiTexCoord2f(target, s, t);
-}
-
-void glMultiTexCoord2fvARB(GLenum target, GLfloat const* v)
-{
- glMultiTexCoord2fv(target, v);
-}
-
-void glMultiTexCoord2fv(GLenum target, GLfloat const* v)
-{
- g_gl_context->gl_multi_tex_coord(target, v[0], v[1], 0.f, 1.f);
-}
-
-void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t)
-{
- g_gl_context->gl_multi_tex_coord(target, s, t, 0.f, 1.f);
-}
-
-void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r)
-{
- g_gl_context->gl_multi_tex_coord(target, s, t, r, 1.f);
-}
-
-void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
-{
- g_gl_context->gl_multi_tex_coord(target, s, t, r, q);
-}
-
-void glMultMatrixd(GLdouble const* matrix)
-{
- g_gl_context->gl_mult_matrix(transpose_input_matrix(matrix));
-}
-
-void glMultMatrixf(GLfloat const* matrix)
-{
- g_gl_context->gl_mult_matrix(transpose_input_matrix(matrix));
-}
-
-void glNewList(GLuint list, GLenum mode)
-{
- return g_gl_context->gl_new_list(list, mode);
-}
-
-void glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)
-{
- g_gl_context->gl_normal(nx, ny, nz);
-}
-
-void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
-{
- g_gl_context->gl_normal(nx, ny, nz);
-}
-
-void glNormal3fv(GLfloat const* v)
-{
- g_gl_context->gl_normal(v[0], v[1], v[2]);
-}
-
-void glNormalPointer(GLenum type, GLsizei stride, void const* pointer)
-{
- g_gl_context->gl_normal_pointer(type, stride, pointer);
-}
-
-void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)
-{
- g_gl_context->gl_ortho(left, right, bottom, top, nearVal, farVal);
-}
-
-void glPixelStorei(GLenum pname, GLint param)
-{
- g_gl_context->gl_pixel_storei(pname, param);
-}
-
-void glPointSize(GLfloat size)
-{
- g_gl_context->gl_point_size(size);
-}
-
-void glPolygonMode(GLenum face, GLenum mode)
-{
- g_gl_context->gl_polygon_mode(face, mode);
-}
-
-void glPolygonOffset(GLfloat factor, GLfloat units)
-{
- g_gl_context->gl_polygon_offset(factor, units);
-}
-
-void glPopAttrib()
-{
- g_gl_context->gl_pop_attrib();
-}
-
-void glPopMatrix()
-{
- g_gl_context->gl_pop_matrix();
-}
-
-void glPushAttrib(GLbitfield mask)
-{
- g_gl_context->gl_push_attrib(mask);
-}
-
-void glPushMatrix()
-{
- g_gl_context->gl_push_matrix();
-}
-
-void glRasterPos2d(GLdouble x, GLdouble y)
-{
- g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
-}
-
-void glRasterPos2f(GLfloat x, GLfloat y)
-{
- g_gl_context->gl_raster_pos(x, y, 0.f, 1.f);
-}
-
-void glRasterPos2i(GLint x, GLint y)
-{
- g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
-}
-
-void glRasterPos2s(GLshort x, GLshort y)
-{
- g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
-}
-
-void glReadBuffer(GLenum mode)
-{
- g_gl_context->gl_read_buffer(mode);
-}
-
-void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
-{
- g_gl_context->gl_read_pixels(x, y, width, height, format, type, pixels);
-}
-
-void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
-{
- g_gl_context->gl_rect(x1, y1, x2, y2);
-}
-
-void glRecti(GLint x1, GLint y1, GLint x2, GLint y2)
-{
- g_gl_context->gl_rect(x1, y1, x2, y2);
-}
-
-void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
-{
- g_gl_context->gl_rotate(angle, x, y, z);
-}
-
-void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
-{
- g_gl_context->gl_rotate(angle, x, y, z);
-}
-
-void glScaled(GLdouble x, GLdouble y, GLdouble z)
-{
- g_gl_context->gl_scale(x, y, z);
-}
-
-void glScalef(GLfloat x, GLfloat y, GLfloat z)
-{
- g_gl_context->gl_scale(x, y, z);
-}
-
-void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- g_gl_context->gl_scissor(x, y, width, height);
-}
-
-void glShadeModel(GLenum mode)
-{
- g_gl_context->gl_shade_model(mode);
-}
-
-void glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length)
-{
- g_gl_context->gl_shader_source(shader, count, string, length);
-}
-
-void glStencilFunc(GLenum func, GLint ref, GLuint mask)
-{
- g_gl_context->gl_stencil_func_separate(GL_FRONT_AND_BACK, func, ref, mask);
-}
-
-void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
-{
- g_gl_context->gl_stencil_func_separate(face, func, ref, mask);
-}
-
-void glStencilMask(GLuint mask)
-{
- g_gl_context->gl_stencil_mask_separate(GL_FRONT_AND_BACK, mask);
-}
-
-void glStencilMaskSeparate(GLenum face, GLuint mask)
-{
- g_gl_context->gl_stencil_mask_separate(face, mask);
-}
-
-void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
-{
- g_gl_context->gl_stencil_op_separate(GL_FRONT_AND_BACK, sfail, dpfail, dppass);
-}
-
-void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
-{
- g_gl_context->gl_stencil_op_separate(face, sfail, dpfail, dppass);
-}
-
-void glTexCoord1f(GLfloat s)
-{
- g_gl_context->gl_tex_coord(s, 0.0f, 0.0f, 1.0f);
-}
-
-void glTexCoord1fv(GLfloat const* v)
-{
- g_gl_context->gl_tex_coord(v[0], 0.0f, 0.0f, 1.0f);
-}
-
-void glTexCoord2d(GLdouble s, GLdouble t)
-{
- g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
-}
-
-void glTexCoord2dv(GLdouble const* v)
-{
- g_gl_context->gl_tex_coord(v[0], v[1], 0.0f, 1.0f);
-}
-
-void glTexCoord2f(GLfloat s, GLfloat t)
-{
- g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
-}
-
-void glTexCoord2fv(GLfloat const* v)
-{
- g_gl_context->gl_tex_coord(v[0], v[1], 0.0f, 1.0f);
-}
-
-void glTexCoord2i(GLint s, GLint t)
-{
- g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
-}
-
-void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r)
-{
- g_gl_context->gl_tex_coord(s, t, r, 1.0f);
-}
-
-void glTexCoord3fv(GLfloat const* v)
-{
- g_gl_context->gl_tex_coord(v[0], v[1], v[2], 1.0f);
-}
-
-void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
-{
- g_gl_context->gl_tex_coord(s, t, r, q);
-}
-
-void glTexCoord4fv(GLfloat const* v)
-{
- g_gl_context->gl_tex_coord(v[0], v[1], v[2], v[3]);
-}
-
-void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
-{
- g_gl_context->gl_tex_coord_pointer(size, type, stride, pointer);
-}
-
-void glTexEnvf(GLenum target, GLenum pname, GLfloat param)
-{
- g_gl_context->gl_tex_env(target, pname, param);
-}
-
-void glTexEnvi(GLenum target, GLenum pname, GLint param)
-{
- g_gl_context->gl_tex_env(target, pname, param);
-}
-
-void glTexGend(GLenum coord, GLenum pname, GLdouble param)
-{
- g_gl_context->gl_tex_gen(coord, pname, param);
-}
-
-void glTexGenf(GLenum coord, GLenum pname, GLfloat param)
-{
- g_gl_context->gl_tex_gen(coord, pname, param);
-}
-
-void glTexGenfv(GLenum coord, GLenum pname, GLfloat const* params)
-{
- g_gl_context->gl_tex_gen_floatv(coord, pname, params);
-}
-
-void glTexGeni(GLenum coord, GLenum pname, GLint param)
-{
- g_gl_context->gl_tex_gen(coord, pname, param);
-}
-
-void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid const* data)
-{
- dbgln("glTexImage1D({:#x}, {}, {:#x}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, border, format, type, data);
- TODO();
-}
-
-void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data)
-{
- g_gl_context->gl_tex_image_2d(target, level, internalFormat, width, height, border, format, type, data);
-}
-
-void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid const* data)
-{
- dbgln("glTexImage3D({:#x}, {}, {:#x}, {}, {}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, height, depth, border, format, type, data);
- TODO();
-}
-
-void glTexParameteri(GLenum target, GLenum pname, GLint param)
-{
- g_gl_context->gl_tex_parameter(target, pname, param);
-}
-
-void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
-{
- g_gl_context->gl_tex_parameter(target, pname, param);
-}
-
-void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid const* data)
-{
- g_gl_context->gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, data);
-}
-
-void glTranslated(GLdouble x, GLdouble y, GLdouble z)
-{
- g_gl_context->gl_translate(x, y, z);
-}
-
-void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
-{
- g_gl_context->gl_translate(x, y, z);
-}
-
-void glUseProgram(GLuint program)
-{
- g_gl_context->gl_use_program(program);
-}
-
-void glVertex2d(GLdouble x, GLdouble y)
-{
- g_gl_context->gl_vertex(x, y, 0.0, 1.0);
-}
-
-void glVertex2dv(GLdouble const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
-}
-
-void glVertex2f(GLfloat x, GLfloat y)
-{
- g_gl_context->gl_vertex(x, y, 0.0, 1.0);
-}
-
-void glVertex2fv(GLfloat const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
-}
-
-void glVertex2i(GLint x, GLint y)
-{
- g_gl_context->gl_vertex(x, y, 0.0, 1.0);
-}
-
-void glVertex2iv(GLint const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
-}
-
-void glVertex2s(GLshort x, GLshort y)
-{
- g_gl_context->gl_vertex(x, y, 0.0, 1.0);
-}
-
-void glVertex2sv(GLshort const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
-}
-
-void glVertex3d(GLdouble x, GLdouble y, GLdouble z)
-{
- g_gl_context->gl_vertex(x, y, z, 1.0);
-}
-
-void glVertex3dv(GLdouble const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
-}
-
-void glVertex3f(GLfloat x, GLfloat y, GLfloat z)
-{
- g_gl_context->gl_vertex(x, y, z, 1.0);
-}
-
-void glVertex3fv(GLfloat const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
-}
-
-void glVertex3i(GLint x, GLint y, GLint z)
-{
- g_gl_context->gl_vertex(x, y, z, 1.0);
-}
-
-void glVertex3iv(GLint const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
-}
-
-void glVertex3s(GLshort x, GLshort y, GLshort z)
-{
- g_gl_context->gl_vertex(x, y, z, 1.0);
-}
-
-void glVertex3sv(GLshort const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
-}
-
-void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
- g_gl_context->gl_vertex(x, y, z, w);
-}
-
-void glVertex4dv(GLdouble const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
-}
-
-void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- g_gl_context->gl_vertex(x, y, z, w);
-}
-
-void glVertex4fv(GLfloat const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
-}
-
-void glVertex4i(GLint x, GLint y, GLint z, GLint w)
-{
- g_gl_context->gl_vertex(x, y, z, w);
-}
-
-void glVertex4iv(GLint const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
-}
-
-void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
-{
- g_gl_context->gl_vertex(x, y, z, w);
-}
-
-void glVertex4sv(GLshort const* v)
-{
- g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
-}
-
-void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
-{
- g_gl_context->gl_vertex_pointer(size, type, stride, pointer);
-}
-
-void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- g_gl_context->gl_viewport(x, y, width, height);
-}
diff --git a/Userland/Libraries/LibGL/GLAPI.json b/Userland/Libraries/LibGL/GLAPI.json
new file mode 100644
index 0000000000..82c812512c
--- /dev/null
+++ b/Userland/Libraries/LibGL/GLAPI.json
@@ -0,0 +1,1162 @@
+{
+ "ActiveTexture": {
+ "arguments": [
+ {"type": "GLenum", "name": "texture"}
+ ],
+ "variants": {
+ "api_suffixes": ["", "ARB"]
+ }
+ },
+ "AlphaFunc": {
+ "arguments": [
+ {"type": "GLenum", "name": "func"},
+ {"type": "GLclampf", "name": "ref"}
+ ]
+ },
+ "ArrayElement": {
+ "arguments": [
+ {"type": "GLint", "name": "i"}
+ ]
+ },
+ "AttachShader": {
+ "arguments": [
+ {"type": "GLuint", "name": "program"},
+ {"type": "GLuint", "name": "shader"}
+ ]
+ },
+ "Begin": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "BindBuffer": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLuint", "name": "buffer"}
+ ]
+ },
+ "BindTexture": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLuint", "name": "texture"}
+ ]
+ },
+ "Bitmap": {
+ "arguments": [
+ {"type": "GLsizei", "name": ["width", "height"]},
+ {"type": "GLfloat", "name": ["xorig", "yorig", "xmove", "ymove"]},
+ {"type": "GLubyte const*", "name": "bitmap"}
+ ]
+ },
+ "BlendFunc": {
+ "arguments": [
+ {"type": "GLenum", "name": ["sfactor", "dfactor"]}
+ ]
+ },
+ "BufferData": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLsizeiptr", "name": "size"},
+ {"type": "void const*", "name": "data"},
+ {"type": "GLenum", "name": "usage"}
+ ]
+ },
+ "BufferSubData": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLintptr", "name": "offset"},
+ {"type": "GLsizeiptr", "name": "size"},
+ {"type": "void const*", "name": "data"}
+ ]
+ },
+ "CallList": {
+ "arguments": [
+ {"type": "GLuint", "name": "list"}
+ ]
+ },
+ "CallLists": {
+ "arguments": [
+ {"type": "GLsizei", "name": "n"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "lists"}
+ ]
+ },
+ "Clear": {
+ "arguments": [
+ {"type": "GLbitfield", "name": "mask"}
+ ]
+ },
+ "ClearColor": {
+ "arguments": [
+ {"type": "GLclampf", "name": ["red", "green", "blue", "alpha"]}
+ ]
+ },
+ "ClearDepth": {
+ "arguments": [
+ {"type": "GLdouble", "name": "depth"}
+ ]
+ },
+ "ClearDepthf": {
+ "arguments": [
+ {"type": "GLfloat", "name": "depth", "cast_to": "GLdouble"}
+ ],
+ "implementation": "clear_depth"
+ },
+ "ClearStencil": {
+ "arguments": [
+ {"type": "GLint", "name": "s"}
+ ]
+ },
+ "ClientActiveTexture": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"}
+ ],
+ "variants": {
+ "api_suffixes": ["", "ARB"]
+ }
+ },
+ "ClipPlane": {
+ "arguments": [
+ {"type": "GLenum", "name": "plane"},
+ {"type": "GLdouble const*", "name": "equation"}
+ ]
+ },
+ "Color": {
+ "arguments": [
+ {"name": ["red", "green", "blue", "alpha"], "cast_to": "GLdouble"}
+ ],
+ "variants": {
+ "argument_counts": [3, 4],
+ "argument_defaults": ["0.", "0.", "0.", "1."],
+ "convert_range": true,
+ "pointer_argument": "v",
+ "types": {
+ "b": {},
+ "bv": {},
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {},
+ "ub": {},
+ "ubv": {},
+ "ui": {},
+ "uiv": {},
+ "us": {},
+ "usv": {}
+ }
+ }
+ },
+ "ColorMask": {
+ "arguments": [
+ {"type": "GLboolean", "name": ["red", "green", "blue", "alpha"]}
+ ]
+ },
+ "ColorMaterial": {
+ "arguments": [
+ {"type": "GLenum", "name": "face"},
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "ColorPointer": {
+ "arguments": [
+ {"type": "GLint", "name": "size"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "GLsizei", "name": "stride"},
+ {"type": "void const*", "name": "pointer"}
+ ]
+ },
+ "CompileShader": {
+ "arguments": [
+ {"type": "GLuint", "name": "shader"}
+ ]
+ },
+ "CopyTexImage2D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLenum", "name": "internalformat"},
+ {"type": "GLint", "name": ["x", "y"]},
+ {"type": "GLsizei", "name": ["width", "height"]},
+ {"type": "GLint", "name": "border"}
+ ],
+ "implementation": "copy_tex_image_2d"
+ },
+ "CopyTexSubImage2D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": ["level", "xoffset", "yoffset", "x", "y"]},
+ {"type": "GLsizei", "name": ["width", "height"]}
+ ],
+ "implementation": "copy_tex_sub_image_2d"
+ },
+ "CreateProgram": {
+ "return_type": "GLuint"
+ },
+ "CreateShader": {
+ "arguments": [
+ {"type": "GLenum", "name": "shader_type"}
+ ],
+ "return_type": "GLuint"
+ },
+ "CullFace": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "DeleteBuffers": {
+ "arguments": [
+ {"type": "GLsizei", "name": "n"},
+ {"type": "GLuint const*", "name": "buffers"}
+ ]
+ },
+ "DeleteLists": {
+ "arguments": [
+ {"type": "GLuint", "name": "list"},
+ {"type": "GLsizei", "name": "range"}
+ ]
+ },
+ "DeleteProgram": {
+ "arguments": [
+ {"type": "GLuint", "name": "program"}
+ ]
+ },
+ "DeleteShader": {
+ "arguments": [
+ {"type": "GLuint", "name": "shader"}
+ ]
+ },
+ "DeleteTextures": {
+ "arguments": [
+ {"type": "GLsizei", "name": "n"},
+ {"type": "GLuint const*", "name": "textures"}
+ ]
+ },
+ "DepthFunc": {
+ "arguments": [
+ {"type": "GLenum", "name": "func"}
+ ]
+ },
+ "DepthMask": {
+ "arguments": [
+ {"type": "GLboolean", "name": "flag"}
+ ]
+ },
+ "DepthRange": {
+ "arguments": [
+ {"type": "GLdouble", "name": ["nearVal", "farVal"]}
+ ]
+ },
+ "DepthRangef": {
+ "arguments": [
+ {"type": "GLfloat", "name": ["nearVal", "farVal"], "cast_to": "GLdouble"}
+ ],
+ "implementation": "depth_range"
+ },
+ "Disable": {
+ "arguments": [
+ {"type": "GLenum", "name": "cap"}
+ ]
+ },
+ "DisableClientState": {
+ "arguments": [
+ {"type": "GLenum", "name": "cap"}
+ ]
+ },
+ "DrawArrays": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"},
+ {"type": "GLint", "name": "first"},
+ {"type": "GLsizei", "name": "count"}
+ ]
+ },
+ "DrawBuffer": {
+ "arguments": [
+ {"type": "GLenum", "name": "buffer"}
+ ]
+ },
+ "DrawElements": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"},
+ {"type": "GLsizei", "name": "count"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "indices"}
+ ]
+ },
+ "DrawPixels": {
+ "arguments": [
+ {"type": "GLsizei", "name": ["width", "height"]},
+ {"type": "GLenum", "name": ["format", "type"]},
+ {"type": "void const*", "name": "data"}
+ ]
+ },
+ "Enable": {
+ "arguments": [
+ {"type": "GLenum", "name": "cap"}
+ ]
+ },
+ "EnableClientState": {
+ "arguments": [
+ {"type": "GLenum", "name": "cap"}
+ ]
+ },
+ "End": {},
+ "EndList": {},
+ "EvalCoord": {
+ "arguments": [
+ {"name": ["u", "v"]}
+ ],
+ "unimplemented": true,
+ "variants": {
+ "argument_counts": [1, 2],
+ "argument_defaults": ["0.", "0."],
+ "pointer_argument": "u",
+ "types": {
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {}
+ }
+ }
+ },
+ "EvalMesh1": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"},
+ {"type": "GLint", "name": ["i1", "i2"]}
+ ],
+ "unimplemented": true
+ },
+ "EvalMesh2": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"},
+ {"type": "GLint", "name": ["i1", "i2", "j1", "j2"]}
+ ],
+ "unimplemented": true
+ },
+ "EvalPoint": {
+ "arguments": [
+ {"name": ["i", "j"]}
+ ],
+ "unimplemented": true,
+ "variants": {
+ "argument_counts": [1, 2],
+ "argument_defaults": ["0", "0"],
+ "types": {
+ "i": {}
+ }
+ }
+ },
+ "Finish": {},
+ "Flush": {},
+ "Fog": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "f": {"implementation": "fogf"},
+ "fv": {"implementation": "fogfv"},
+ "i": {"implementation": "fogi"},
+ "iv": {"unimplemented": true}
+ }
+ }
+ },
+ "FrontFace": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "Frustum": {
+ "arguments": [
+ {"type": "GLdouble", "name": ["left", "right", "bottom", "top", "nearVal", "farVal"]}
+ ]
+ },
+ "GenBuffers": {
+ "arguments": [
+ {"type": "GLsizei", "name": "n"},
+ {"type": "GLuint*", "name": "buffers"}
+ ]
+ },
+ "GenLists": {
+ "arguments": [
+ {"type": "GLsizei", "name": "range"}
+ ],
+ "return_type": "GLuint"
+ },
+ "GenTextures": {
+ "arguments": [
+ {"type": "GLsizei", "name": "n"},
+ {"type": "GLuint*", "name": "textures"}
+ ]
+ },
+ "GetBooleanv": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLboolean*", "name": "data"}
+ ]
+ },
+ "GetClipPlane": {
+ "arguments": [
+ {"type": "GLenum", "name": "plane"},
+ {"type": "GLdouble*", "name": "equation"}
+ ]
+ },
+ "GetDoublev": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLdouble*", "name": "data"}
+ ]
+ },
+ "GetError": {
+ "return_type": "GLenum"
+ },
+ "GetFloatv": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLfloat*", "name": "data"}
+ ]
+ },
+ "GetIntegerv": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLint*", "name": "data"}
+ ]
+ },
+ "GetLight": {
+ "arguments": [
+ {"type": "GLenum", "name": "light"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "params"},
+ {"type": "GLenum", "expression": "@variant_gl_type@"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "fv!": {},
+ "iv!": {}
+ }
+ }
+ },
+ "GetMaterial": {
+ "arguments": [
+ {"type": "GLenum", "name": "face"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "params"},
+ {"type": "GLenum", "expression": "@variant_gl_type@"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "fv!": {},
+ "iv!": {}
+ }
+ }
+ },
+ "GetProgramiv": {
+ "arguments": [
+ {"type": "GLuint", "name": "program"},
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLint*", "name": "params"}
+ ],
+ "implementation": "get_program"
+ },
+ "GetShaderiv": {
+ "arguments": [
+ {"type": "GLuint", "name": "shader"},
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLint*", "name": "params"}
+ ],
+ "implementation": "get_shader"
+ },
+ "GetString": {
+ "arguments": [
+ {"type": "GLenum", "name": "name"}
+ ],
+ "return_type": "GLubyte const*"
+ },
+ "GetTexImage": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLenum", "name": ["format", "type"]},
+ {"type": "void*", "name": "pixels"}
+ ]
+ },
+ "GetTexLevelParameter": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "params"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "fv!": {"unimplemented": true},
+ "iv!": {"implementation": "get_tex_parameter_integerv"}
+ }
+ }
+ },
+ "Hint": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "IsEnabled": {
+ "arguments": [
+ {"type": "GLenum", "name": "cap"}
+ ],
+ "return_type": "GLboolean"
+ },
+ "IsList": {
+ "arguments": [
+ {"type": "GLuint", "name": "list"}
+ ],
+ "return_type": "GLboolean"
+ },
+ "IsTexture": {
+ "arguments": [
+ {"type": "GLuint", "name": "texture"}
+ ],
+ "return_type": "GLboolean"
+ },
+ "Light": {
+ "arguments": [
+ {"type": "GLenum", "name": "light"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param", "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "f": {},
+ "fv": {"implementation": "lightfv"},
+ "i": {},
+ "iv": {"implementation": "lightiv"},
+ "x": {},
+ "xv": {"implementation": "lightiv"}
+ }
+ },
+ "implementation": "lightf"
+ },
+ "LightModel": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param"},
+ {"type": "GLenum", "expression": "@variant_gl_type@"}
+ ],
+ "implementation": "light_modelv",
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "fv": {},
+ "iv": {}
+ }
+ }
+ },
+ "LightModelf": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLfloat", "name": "x"},
+ {"name": ["y", "z", "w"], "expression": "0.f"}
+ ],
+ "implementation": "light_model"
+ },
+ "LightModeli": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"type": "GLint", "name": "x", "cast_to": "GLfloat"},
+ {"name": ["y", "z", "w"], "expression": "0.f"}
+ ],
+ "implementation": "light_model"
+ },
+ "LineWidth": {
+ "arguments": [
+ {"type": "GLfloat", "name": "width"}
+ ]
+ },
+ "LinkProgram": {
+ "arguments": [
+ {"type": "GLuint", "name": "program"}
+ ]
+ },
+ "ListBase": {
+ "arguments": [
+ {"type": "GLuint", "name": "base"}
+ ]
+ },
+ "LoadIdentity": {},
+ "LoadMatrixd": {
+ "arguments": [
+ {"type": "GLdouble const*", "name": "m", "expression": "GL::transpose_input_matrix(@argument_name@)"}
+ ],
+ "implementation": "load_matrix"
+ },
+ "LoadMatrixf": {
+ "arguments": [
+ {"type": "GLfloat const*", "name": "m", "expression": "GL::transpose_input_matrix(@argument_name@)"}
+ ],
+ "implementation": "load_matrix"
+ },
+ "Map1d": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLdouble","name": ["u1", "u2"]},
+ {"type": "GLint", "name": ["stride", "order"]},
+ {"type": "GLdouble const*", "name": "points"}
+ ],
+ "unimplemented": true
+ },
+ "Map1f": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLfloat","name": ["u1", "u2"]},
+ {"type": "GLint", "name": ["stride", "order"]},
+ {"type": "GLfloat const*", "name": "points"}
+ ],
+ "unimplemented": true
+ },
+ "Map2d": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLdouble","name": ["u1", "u2"]},
+ {"type": "GLint", "name": ["ustride", "uorder"]},
+ {"type": "GLdouble","name": ["v1", "v2"]},
+ {"type": "GLint", "name": ["vstride", "vorder"]},
+ {"type": "GLdouble const*", "name": "points"}
+ ],
+ "unimplemented": true
+ },
+ "Map2f": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLfloat","name": ["u1", "u2"]},
+ {"type": "GLint", "name": ["ustride", "uorder"]},
+ {"type": "GLfloat","name": ["v1", "v2"]},
+ {"type": "GLint", "name": ["vstride", "vorder"]},
+ {"type": "GLfloat const*", "name": "points"}
+ ],
+ "unimplemented": true
+ },
+ "MapGrid1": {
+ "arguments": [
+ {"type": "GLint", "name": "un"},
+ {"name": ["u1", "u2"]}
+ ],
+ "unimplemented": true,
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {}
+ }
+ }
+ },
+ "MapGrid2": {
+ "arguments": [
+ {"type": "GLint", "name": "un"},
+ {"name": ["u1", "u2"]},
+ {"type": "GLint", "name": "vn"},
+ {"name": ["v1", "v2"]}
+ ],
+ "unimplemented": true,
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {}
+ }
+ }
+ },
+ "Material": {
+ "arguments": [
+ {"type": "GLenum", "name": "face"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param", "cast_to": "GLfloat"}
+ ],
+ "implementation": "materialf",
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "f": {},
+ "fv": {
+ "implementation": "materialfv"
+ },
+ "i": {},
+ "iv": {
+ "implementation": "materialiv"
+ }
+ }
+ }
+ },
+ "MatrixMode": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "MultiTexCoord": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"name": ["s", "t", "r", "q"], "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "api_suffixes": ["", "ARB"],
+ "argument_counts": [1, 2, 3, 4],
+ "argument_defaults": ["0.f", "0.f", "0.f", "1.f"],
+ "pointer_argument": "v",
+ "types": {
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {}
+ }
+ }
+ },
+ "MultMatrixd": {
+ "arguments": [
+ {"type": "GLdouble const*", "name": "m", "expression": "GL::transpose_input_matrix(@argument_name@)"}
+ ],
+ "implementation": "mult_matrix"
+ },
+ "MultMatrixf": {
+ "arguments": [
+ {"type": "GLfloat const*", "name": "m", "expression": "GL::transpose_input_matrix(@argument_name@)"}
+ ],
+ "implementation": "mult_matrix"
+ },
+ "NewList": {
+ "arguments": [
+ {"type": "GLuint", "name": "list"},
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "Normal3": {
+ "arguments": [
+ {"name": ["nx", "ny", "nz"], "cast_to": "GLfloat"}
+ ],
+ "implementation": "normal",
+ "variants": {
+ "convert_range": true,
+ "pointer_argument": "v",
+ "types": {
+ "b": {},
+ "bv": {},
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {}
+ }
+ }
+ },
+ "NormalPointer": {
+ "arguments": [
+ {"type": "GLenum", "name": "type"},
+ {"type": "GLsizei", "name": "stride"},
+ {"type": "void const*", "name": "pointer"}
+ ]
+ },
+ "Ortho": {
+ "arguments": [
+ {"type": "GLdouble", "name": ["left", "right", "bottom", "top", "nearVal", "farVal"]}
+ ]
+ },
+ "PixelStore": {
+ "arguments": [
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param", "cast_to": "GLint"}
+ ],
+ "implementation": "pixel_storei",
+ "variants": {
+ "types": {
+ "f": {},
+ "i": {}
+ }
+ }
+ },
+ "PointSize": {
+ "arguments": [
+ {"type": "GLfloat", "name": "size"}
+ ]
+ },
+ "PolygonMode": {
+ "arguments": [
+ {"type": "GLenum", "name": ["face", "mode"]}
+ ]
+ },
+ "PolygonOffset": {
+ "arguments": [
+ {"type": "GLfloat", "name": ["factor", "units"]}
+ ]
+ },
+ "PopAttrib": {},
+ "PopMatrix": {},
+ "PushAttrib": {
+ "arguments": [
+ {"type": "GLbitfield", "name": "mask"}
+ ]
+ },
+ "PushMatrix": {},
+ "RasterPos": {
+ "arguments": [
+ {"name": ["x", "y", "z", "w"], "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "argument_counts": [2, 3, 4],
+ "argument_defaults": ["0.f", "0.f", "0.f", "1.f"],
+ "pointer_argument": "v",
+ "types": {
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {}
+ }
+ }
+ },
+ "ReadBuffer": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "ReadPixels": {
+ "arguments": [
+ {"type": "GLint", "name": "x"},
+ {"type": "GLint", "name": "y"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLsizei", "name": "height"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void*", "name": "data"}
+ ]
+ },
+ "Rect": {
+ "arguments": [
+ {"name": ["x1", "y1", "x2", "y2"], "cast_to": "GLdouble"}
+ ],
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {},
+ "i": {},
+ "s": {}
+ }
+ }
+ },
+ "Rotate": {
+ "arguments": [
+ {"name": ["angle", "x", "y", "z"], "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {}
+ }
+ }
+ },
+ "Scale": {
+ "arguments": [
+ {"name": ["x", "y", "z"], "cast_to": "GLdouble"}
+ ],
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {}
+ }
+ }
+ },
+ "Scissor": {
+ "arguments": [
+ {"type": "GLint", "name": ["x", "y"]},
+ {"type": "GLsizei", "name": ["width", "height"]}
+ ]
+ },
+ "ShadeModel": {
+ "arguments": [
+ {"type": "GLenum", "name": "mode"}
+ ]
+ },
+ "ShaderSource": {
+ "arguments": [
+ {"type": "GLuint", "name": "shader"},
+ {"type": "GLsizei", "name": "count"},
+ {"type": "GLchar const**", "name": "string"},
+ {"type": "GLint const*", "name": "length"}
+ ]
+ },
+ "StencilFunc": {
+ "arguments": [
+ {"expression": "GL_FRONT_AND_BACK"},
+ {"type": "GLenum", "name": "func"},
+ {"type": "GLint", "name": "ref"},
+ {"type": "GLuint", "name": "mask"}
+ ],
+ "implementation": "stencil_func_separate"
+ },
+ "StencilFuncSeparate": {
+ "arguments": [
+ {"type": "GLenum", "name": ["face", "func"]},
+ {"type": "GLint", "name": "ref"},
+ {"type": "GLuint", "name": "mask"}
+ ]
+ },
+ "StencilMask": {
+ "arguments": [
+ {"expression": "GL_FRONT_AND_BACK"},
+ {"type": "GLuint", "name": "mask"}
+ ],
+ "implementation": "stencil_mask_separate"
+ },
+ "StencilMaskSeparate": {
+ "arguments": [
+ {"type": "GLenum", "name": "face"},
+ {"type": "GLuint", "name": "mask"}
+ ]
+ },
+ "StencilOp": {
+ "arguments": [
+ {"expression": "GL_FRONT_AND_BACK"},
+ {"type": "GLenum", "name": ["sfail", "dpfail", "dppass"]}
+ ],
+ "implementation": "stencil_op_separate"
+ },
+ "StencilOpSeparate": {
+ "arguments": [
+ {"type": "GLenum", "name": ["face", "sfail", "dpfail", "dppass"]}
+ ]
+ },
+ "TexCoord": {
+ "arguments": [
+ {"name": ["s", "t", "r", "q"], "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "argument_counts": [1, 2, 3, 4],
+ "argument_defaults": ["0.f", "0.f", "0.f", "1.f"],
+ "pointer_argument": "v",
+ "types": {
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {}
+ }
+ }
+ },
+ "TexCoordPointer": {
+ "arguments": [
+ {"type": "GLint", "name": "size"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "GLsizei", "name": "stride"},
+ {"type": "void const*", "name": "pointer"}
+ ]
+ },
+ "TexEnv": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param", "cast_to": "GLfloat"}
+ ],
+ "variants": {
+ "pointer_argument": "params",
+ "types": {
+ "f": {},
+ "fv": {"unimplemented": true},
+ "i": {},
+ "iv": {"unimplemented": true}
+ }
+ }
+ },
+ "TexGen": {
+ "arguments": [
+ {"type": "GLenum", "name": "coord"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param", "cast_to": "GLint"}
+ ],
+ "variants": {
+ "argument_counts": [1],
+ "pointer_argument": "params",
+ "types": {
+ "d": {},
+ "dv": {"unimplemented": true},
+ "f": {},
+ "fv": {"implementation": "tex_gen_floatv"},
+ "i": {},
+ "iv": {"unimplemented": true}
+ }
+ }
+ },
+ "TexImage1D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "internalFormat"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLint", "name": "border"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "data"}
+ ],
+ "unimplemented": true
+ },
+ "TexImage2D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "internalFormat"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLsizei", "name": "height"},
+ {"type": "GLint", "name": "border"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "data"}
+ ],
+ "implementation": "tex_image_2d"
+ },
+ "TexImage3D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "internalFormat"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLsizei", "name": "height"},
+ {"type": "GLsizei", "name": "depth"},
+ {"type": "GLint", "name": "border"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "data"}
+ ],
+ "unimplemented": true
+ },
+ "TexParameter": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLenum", "name": "pname"},
+ {"name": "param"}
+ ],
+ "variants": {
+ "pointer_argument": "params",
+ "types": {
+ "f": {},
+ "fv": {"unimplemented": true},
+ "i": {},
+ "iv": {"unimplemented": true}
+ }
+ }
+ },
+ "TexSubImage1D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "xoffset"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "pixels"}
+ ],
+ "unimplemented": true
+ },
+ "TexSubImage2D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "xoffset"},
+ {"type": "GLint", "name": "yoffset"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLsizei", "name": "height"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "pixels"}
+ ],
+ "implementation": "tex_sub_image_2d"
+ },
+ "TexSubImage3D": {
+ "arguments": [
+ {"type": "GLenum", "name": "target"},
+ {"type": "GLint", "name": "level"},
+ {"type": "GLint", "name": "xoffset"},
+ {"type": "GLint", "name": "yoffset"},
+ {"type": "GLint", "name": "zoffset"},
+ {"type": "GLsizei", "name": "width"},
+ {"type": "GLsizei", "name": "height"},
+ {"type": "GLsizei", "name": "depth"},
+ {"type": "GLenum", "name": "format"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "void const*", "name": "pixels"}
+ ],
+ "unimplemented": true
+ },
+ "Translate": {
+ "arguments": [
+ {"name": ["x", "y", "z"], "cast_to": "GLdouble"}
+ ],
+ "variants": {
+ "types": {
+ "d": {},
+ "f": {}
+ }
+ }
+ },
+ "UseProgram": {
+ "arguments": [
+ {"type": "GLuint", "name": "program"}
+ ]
+ },
+ "Vertex": {
+ "arguments": [
+ {"name": ["x", "y", "z", "w"], "cast_to": "GLdouble"}
+ ],
+ "variants": {
+ "argument_counts": [2, 3, 4],
+ "argument_defaults": ["0.", "0.", "0.", "1."],
+ "pointer_argument": "v",
+ "types": {
+ "d": {},
+ "dv": {},
+ "f": {},
+ "fv": {},
+ "i": {},
+ "iv": {},
+ "s": {},
+ "sv": {}
+ }
+ }
+ },
+ "VertexPointer": {
+ "arguments": [
+ {"type": "GLint", "name": "size"},
+ {"type": "GLenum", "name": "type"},
+ {"type": "GLsizei", "name": "stride"},
+ {"type": "void const*", "name": "pointer"}
+ ]
+ },
+ "Viewport": {
+ "arguments": [
+ {"type": "GLint", "name": ["x", "y"]},
+ {"type": "GLsizei", "name": ["width", "height"]}
+ ]
+ }
+}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 259f4d88bc..3b1b1b27d1 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -574,6 +574,36 @@ private:
RefPtr<Buffer> m_element_array_buffer;
};
+// Transposes input matrices (column-major) to our Matrix (row-major).
+template<typename I>
+constexpr FloatMatrix4x4 transpose_input_matrix(I const* matrix)
+{
+ Array<float, 16> elements;
+ for (size_t i = 0; i < 16; ++i)
+ elements[i] = static_cast<float>(matrix[i]);
+ // clang-format off
+ return {
+ elements[0], elements[4], elements[8], elements[12],
+ elements[1], elements[5], elements[9], elements[13],
+ elements[2], elements[6], elements[10], elements[14],
+ elements[3], elements[7], elements[11], elements[15],
+ };
+ // clang-format on
+}
+
+template<>
+constexpr FloatMatrix4x4 transpose_input_matrix(float const* matrix)
+{
+ // clang-format off
+ return {
+ matrix[0], matrix[4], matrix[8], matrix[12],
+ matrix[1], matrix[5], matrix[9], matrix[13],
+ matrix[2], matrix[6], matrix[10], matrix[14],
+ matrix[3], matrix[7], matrix[11], matrix[15],
+ };
+ // clang-format on
+}
+
ErrorOr<NonnullOwnPtr<GLContext>> create_context(Gfx::Bitmap&);
void make_context_current(GLContext*);