summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/Texture.cpp
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-09-04 22:18:16 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-11 22:37:07 +0100
commit1540c56e6c82bfbdb1fd9b29c34c7ac1a399a1d3 (patch)
tree656ce8801f6a392f4ba6802702cb7652ca00b7b2 /Userland/Libraries/LibGL/Texture.cpp
parentdda5987684227e31e1d7b2fca749d43f734bfc47 (diff)
downloadserenity-1540c56e6c82bfbdb1fd9b29c34c7ac1a399a1d3.zip
LibGL+LibGPU+LibSoftGPU: Implement `GL_GENERATE_MIPMAP`
We can now generate texture mipmaps on the fly if the client requests it. This fixes the missing textures in our PrBoom+ port.
Diffstat (limited to 'Userland/Libraries/LibGL/Texture.cpp')
-rw-r--r--Userland/Libraries/LibGL/Texture.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGL/Texture.cpp b/Userland/Libraries/LibGL/Texture.cpp
index c8f9ff9d77..6ef6819a9f 100644
--- a/Userland/Libraries/LibGL/Texture.cpp
+++ b/Userland/Libraries/LibGL/Texture.cpp
@@ -582,10 +582,11 @@ void GLContext::gl_tex_parameter(GLenum target, GLenum pname, GLfloat param)
RETURN_WITH_ERROR_IF(target != GL_TEXTURE_2D, GL_INVALID_ENUM);
// FIXME: implement the remaining parameters. (https://docs.gl/gl2/glTexParameter)
- RETURN_WITH_ERROR_IF(!(pname == GL_TEXTURE_MIN_FILTER
- || pname == GL_TEXTURE_MAG_FILTER
- || pname == GL_TEXTURE_WRAP_S
- || pname == GL_TEXTURE_WRAP_T),
+ RETURN_WITH_ERROR_IF(pname != GL_GENERATE_MIPMAP
+ && pname != GL_TEXTURE_MIN_FILTER
+ && pname != GL_TEXTURE_MAG_FILTER
+ && pname != GL_TEXTURE_WRAP_S
+ && pname != GL_TEXTURE_WRAP_T,
GL_INVALID_ENUM);
// We assume GL_TEXTURE_2D (see above)
@@ -593,6 +594,10 @@ void GLContext::gl_tex_parameter(GLenum target, GLenum pname, GLfloat param)
VERIFY(!texture_2d.is_null());
switch (pname) {
+ case GL_GENERATE_MIPMAP:
+ RETURN_WITH_ERROR_IF(param != GL_TRUE && param != GL_FALSE, GL_INVALID_ENUM);
+ texture_2d->set_generate_mipmaps(param == GL_TRUE);
+ break;
case GL_TEXTURE_MIN_FILTER:
RETURN_WITH_ERROR_IF(!(param == GL_NEAREST
|| param == GL_LINEAR
@@ -652,7 +657,7 @@ void GLContext::gl_tex_parameterfv(GLenum target, GLenum pname, GLfloat const* p
RETURN_WITH_ERROR_IF(target != GL_TEXTURE_2D, GL_INVALID_ENUM);
// FIXME: implement the remaining parameters. (https://docs.gl/gl2/glTexParameter)
- RETURN_WITH_ERROR_IF(!(pname == GL_TEXTURE_BORDER_COLOR), GL_INVALID_ENUM);
+ RETURN_WITH_ERROR_IF(pname != GL_TEXTURE_BORDER_COLOR, GL_INVALID_ENUM);
// We assume GL_TEXTURE_2D (see above)
auto texture_2d = m_active_texture_unit->texture_2d_target_texture();