mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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:
parent
99ffcc28c2
commit
61bd1890d2
Notes:
sideshowbarker
2024-07-18 12:35:15 +09:00
Author: https://github.com/ebiederstadt Commit: https://github.com/SerenityOS/serenity/commit/61bd1890d21 Pull-request: https://github.com/SerenityOS/serenity/pull/7936 Reviewed-by: https://github.com/sunverwerth ✅
5 changed files with 43 additions and 0 deletions
|
@ -201,6 +201,9 @@ extern "C" {
|
|||
#define GL_NEAREST_MIPMAP_LINEAR 0x2602
|
||||
#define GL_REPEAT 0x2603
|
||||
|
||||
// OpenGL State & GLGet
|
||||
#define GL_MODELVIEW_MATRIX 0x0BA6
|
||||
|
||||
//
|
||||
// OpenGL typedefs
|
||||
//
|
||||
|
@ -294,6 +297,7 @@ GLAPI void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsize
|
|||
GLAPI void glTexCoord2f(GLfloat s, GLfloat t);
|
||||
GLAPI void glBindTexture(GLenum target, GLuint texture);
|
||||
GLAPI void glActiveTexture(GLenum texture);
|
||||
GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = 0;
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
|
||||
virtual void gl_active_texture(GLenum texture) = 0;
|
||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
|
|
@ -84,3 +84,8 @@ void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format
|
|||
{
|
||||
g_gl_context->gl_read_pixels(x, y, width, height, format, type, pixels);
|
||||
}
|
||||
|
||||
void glGetFloatv(GLenum pname, GLfloat* params)
|
||||
{
|
||||
g_gl_context->gl_get_floatv(pname, params);
|
||||
}
|
||||
|
|
|
@ -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 = [¶ms](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);
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) override;
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) override;
|
||||
virtual void gl_active_texture(GLenum texture) override;
|
||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) override;
|
||||
|
||||
virtual void present() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue