diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-12-24 14:55:14 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-27 11:58:43 +0100 |
commit | dae63352a3803dbee4d7629921a3531af1a859c1 (patch) | |
tree | e2c0c4eee5956314d25b1787114f3d58159938f6 /Userland | |
parent | d83702cb920fe29bf5efaa48e229ad6a6d9bf90e (diff) | |
download | serenity-dae63352a3803dbee4d7629921a3531af1a859c1.zip |
LibGL: Implement `glGetTexLevelParameteriv`
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGL/GL/gl.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLTexture.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 21 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 1 |
5 files changed, 29 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index e093315851..1d00e98b8b 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -580,6 +580,7 @@ GLAPI void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLAPI void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); GLAPI void glRecti(GLint x1, GLint y1, GLint x2, GLint y2); +GLAPI void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index d52edd1216..cd1c9591db 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -116,6 +116,7 @@ public: virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0; virtual void gl_bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap) = 0; virtual void gl_copy_tex_image_2d(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = 0; + virtual void gl_get_tex_parameter_integerv(GLenum target, GLint level, GLenum pname, GLint* params) = 0; virtual void gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) = 0; virtual void present() = 0; diff --git a/Userland/Libraries/LibGL/GLTexture.cpp b/Userland/Libraries/LibGL/GLTexture.cpp index 60c7ee31bd..354b8be7ae 100644 --- a/Userland/Libraries/LibGL/GLTexture.cpp +++ b/Userland/Libraries/LibGL/GLTexture.cpp @@ -61,3 +61,8 @@ void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x { g_gl_context->gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border); } + +void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params) +{ + g_gl_context->gl_get_tex_parameter_integerv(target, level, pname, params); +} diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 66731b2fcc..997487fdc3 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -2658,6 +2658,27 @@ void SoftwareGLContext::gl_copy_tex_image_2d(GLenum target, GLint level, GLenum target, level, internalformat, x, y, width, height, border); } +void SoftwareGLContext::gl_get_tex_parameter_integerv(GLenum target, GLint level, GLenum pname, GLint* params) +{ + RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); + // FIXME: support targets other than GL_TEXTURE_2D + RETURN_WITH_ERROR_IF(target != GL_TEXTURE_2D, GL_INVALID_ENUM); + // FIXME: support other parameter names + RETURN_WITH_ERROR_IF(pname < GL_TEXTURE_WIDTH || pname > GL_TEXTURE_HEIGHT, GL_INVALID_ENUM); + RETURN_WITH_ERROR_IF(level < 0 || level > Texture2D::LOG2_MAX_TEXTURE_SIZE, GL_INVALID_VALUE); + // FIXME: GL_INVALID_VALUE is generated if target is GL_TEXTURE_BUFFER and level is not zero + // FIXME: GL_INVALID_OPERATION is generated if GL_TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed internal format or on proxy targets + + switch (pname) { + case GL_TEXTURE_HEIGHT: + *params = m_active_texture_unit->bound_texture_2d()->height_at_lod(level); + break; + case GL_TEXTURE_WIDTH: + *params = m_active_texture_unit->bound_texture_2d()->width_at_lod(level); + break; + } +} + void SoftwareGLContext::gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) { APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_rect, x1, y1, x2, y2); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index 6baecd197c..6abec1efbc 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -129,6 +129,7 @@ public: virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override; virtual void gl_bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap) override; virtual void gl_copy_tex_image_2d(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override; + virtual void gl_get_tex_parameter_integerv(GLenum target, GLint level, GLenum pname, GLint* params) override; virtual void gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) override; virtual void present() override; |