1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibGL: Implement very basic version of glGetFloatv

This is a very basic implementation of glGetfloatv. It will only give a
result when used with GL_MODELVIEW_MATRIX. In the future
 we can update and extend it's functionality.
This commit is contained in:
Erik Biederstadt 2021-06-08 21:34:50 -06:00 committed by Andreas Kling
parent 99ffcc28c2
commit 61bd1890d2
5 changed files with 43 additions and 0 deletions

View file

@ -1291,6 +1291,38 @@ void SoftwareGLContext::gl_active_texture(GLenum texture)
m_active_texture_unit = &m_texture_units.at(texture - GL_TEXTURE0);
}
void SoftwareGLContext::gl_get_floatv(GLenum pname, GLfloat* params)
{
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
auto flatten_and_assign_matrix = [&params](const FloatMatrix4x4& matrix) {
auto elements = matrix.elements();
for (size_t i = 0; i < 4; ++i) {
for (size_t j = 0; j < 4; ++j) {
params[i * 4 + j] = elements[i][j];
}
}
};
switch (pname) {
case GL_MODELVIEW_MATRIX:
if (m_current_matrix_mode == GL_MODELVIEW)
flatten_and_assign_matrix(m_model_view_matrix);
else {
if (m_model_view_matrix_stack.is_empty())
flatten_and_assign_matrix(FloatMatrix4x4::identity());
else
flatten_and_assign_matrix(m_model_view_matrix_stack.last());
}
break;
default:
// FIXME: Because glQuake only requires GL_MODELVIEW_MATRIX, that is the only parameter
// that we currently support. More parameters should be supported.
TODO();
}
}
void SoftwareGLContext::present()
{
m_rasterizer.blit_to(*m_frontbuffer);