summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h4
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLUtils.cpp5
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp32
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 43 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 62af06aab0..5b63250616 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -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
}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 7f0279f8bd..a352ef8596 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -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;
};
diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp
index 46ccd7f1dc..732315fdd0 100644
--- a/Userland/Libraries/LibGL/GLUtils.cpp
+++ b/Userland/Libraries/LibGL/GLUtils.cpp
@@ -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);
+}
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index c26e462d82..ec5c9dad33 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -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);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 40ab70c0ed..d41d92fbd7 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -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;