mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LibGL: Generate the API wrappers
We now generate all LibGL API wrappers from a single API method definition list stored in `GLAPI.json`. Since a significant portion of the OpenGL API methods are relatively consistent variants, we take advantage of this to generate a lot of these variants at once. The autogenerated methods check for the non-nullness of the current `GLContext`, and only perform an action if a `GLContext` is present. This prevents a crash in ports like GLTron, who assume you can still call the OpenGL API without an active context. This increases our API wrapper method count from 211 to 356. Fixes #15814.
This commit is contained in:
parent
8c094699db
commit
2da1c1c10e
9 changed files with 1787 additions and 1404 deletions
|
@ -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*);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue