From a0bb0d0114c2b228f2f1715b6fc53d99901b0193 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 29 Jun 2025 16:43:36 -0700 Subject: Add support for R8 linear textures to render baked AO --- src/core/texture.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/core/texture.c') diff --git a/src/core/texture.c b/src/core/texture.c index 89f7ec0..372f9e6 100644 --- a/src/core/texture.c +++ b/src/core/texture.c @@ -37,6 +37,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { gfx_del_texture(texture); return false; } + ASSERT_GL; texture->format = to_GL_format(desc->format); texture->type = to_GL_type(desc->format); @@ -50,6 +51,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { // Mipmaps. if (desc->mipmaps) { glGenerateMipmap(texture->target); + ASSERT_GL; } // Texture filtering. @@ -60,6 +62,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { GLenum mag = linear ? GL_LINEAR : GL_NEAREST; glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, min); glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, mag); + ASSERT_GL; // Texture wrapping. GLenum wrap = GL_INVALID_ENUM; @@ -74,6 +77,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { glTexParameteri(texture->target, GL_TEXTURE_WRAP_R, wrap); glTexParameteri(texture->target, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(texture->target, GL_TEXTURE_WRAP_T, wrap); + ASSERT_GL; glBindTexture(texture->target, 0); return true; @@ -119,6 +123,7 @@ void gfx_update_texture(Texture* texture, const TextureDataDesc* desc) { FAIL("Unhandled texture dimension"); break; } + ASSERT_GL; glBindTexture(texture->target, 0); } @@ -139,6 +144,8 @@ GLenum to_GL_internal_format(TextureFormat format) { switch (format) { case TextureDepth: return GL_DEPTH_COMPONENT; + case TextureR8: + return GL_R8; case TextureRG16: return GL_RG16; case TextureRG16F: @@ -163,6 +170,8 @@ GLenum to_GL_format(TextureFormat format) { switch (format) { case TextureDepth: return GL_DEPTH_COMPONENT; + case TextureR8: + return GL_RED; case TextureRG16: case TextureRG16F: return GL_RG; @@ -185,6 +194,7 @@ GLenum to_GL_type(TextureFormat format) { case TextureRG16F: case TextureR11G11B10F: return GL_FLOAT; + case TextureR8: case TextureRG16: case TextureRGB8: case TextureRGBA8: -- cgit v1.2.3