diff options
| author | 3gg <3gg@shellblade.net> | 2025-06-29 16:43:36 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-06-29 16:43:36 -0700 |
| commit | a0bb0d0114c2b228f2f1715b6fc53d99901b0193 (patch) | |
| tree | 2b4b8208b5e03674e24831cb43fd5fe217f996fa /src/core | |
| parent | 8d116c7a402ca413fd12e64406ef27da8f5e6526 (diff) | |
Add support for R8 linear textures to render baked AO
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/texture.c | 10 |
1 files changed, 10 insertions, 0 deletions
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) { | |||
| 37 | gfx_del_texture(texture); | 37 | gfx_del_texture(texture); |
| 38 | return false; | 38 | return false; |
| 39 | } | 39 | } |
| 40 | ASSERT_GL; | ||
| 40 | 41 | ||
| 41 | texture->format = to_GL_format(desc->format); | 42 | texture->format = to_GL_format(desc->format); |
| 42 | texture->type = to_GL_type(desc->format); | 43 | texture->type = to_GL_type(desc->format); |
| @@ -50,6 +51,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { | |||
| 50 | // Mipmaps. | 51 | // Mipmaps. |
| 51 | if (desc->mipmaps) { | 52 | if (desc->mipmaps) { |
| 52 | glGenerateMipmap(texture->target); | 53 | glGenerateMipmap(texture->target); |
| 54 | ASSERT_GL; | ||
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | // Texture filtering. | 57 | // Texture filtering. |
| @@ -60,6 +62,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { | |||
| 60 | GLenum mag = linear ? GL_LINEAR : GL_NEAREST; | 62 | GLenum mag = linear ? GL_LINEAR : GL_NEAREST; |
| 61 | glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, min); | 63 | glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, min); |
| 62 | glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, mag); | 64 | glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, mag); |
| 65 | ASSERT_GL; | ||
| 63 | 66 | ||
| 64 | // Texture wrapping. | 67 | // Texture wrapping. |
| 65 | GLenum wrap = GL_INVALID_ENUM; | 68 | GLenum wrap = GL_INVALID_ENUM; |
| @@ -74,6 +77,7 @@ bool gfx_init_texture(Texture* texture, const TextureDesc* desc) { | |||
| 74 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_R, wrap); | 77 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_R, wrap); |
| 75 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_S, wrap); | 78 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_S, wrap); |
| 76 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_T, wrap); | 79 | glTexParameteri(texture->target, GL_TEXTURE_WRAP_T, wrap); |
| 80 | ASSERT_GL; | ||
| 77 | 81 | ||
| 78 | glBindTexture(texture->target, 0); | 82 | glBindTexture(texture->target, 0); |
| 79 | return true; | 83 | return true; |
| @@ -119,6 +123,7 @@ void gfx_update_texture(Texture* texture, const TextureDataDesc* desc) { | |||
| 119 | FAIL("Unhandled texture dimension"); | 123 | FAIL("Unhandled texture dimension"); |
| 120 | break; | 124 | break; |
| 121 | } | 125 | } |
| 126 | ASSERT_GL; | ||
| 122 | 127 | ||
| 123 | glBindTexture(texture->target, 0); | 128 | glBindTexture(texture->target, 0); |
| 124 | } | 129 | } |
| @@ -139,6 +144,8 @@ GLenum to_GL_internal_format(TextureFormat format) { | |||
| 139 | switch (format) { | 144 | switch (format) { |
| 140 | case TextureDepth: | 145 | case TextureDepth: |
| 141 | return GL_DEPTH_COMPONENT; | 146 | return GL_DEPTH_COMPONENT; |
| 147 | case TextureR8: | ||
| 148 | return GL_R8; | ||
| 142 | case TextureRG16: | 149 | case TextureRG16: |
| 143 | return GL_RG16; | 150 | return GL_RG16; |
| 144 | case TextureRG16F: | 151 | case TextureRG16F: |
| @@ -163,6 +170,8 @@ GLenum to_GL_format(TextureFormat format) { | |||
| 163 | switch (format) { | 170 | switch (format) { |
| 164 | case TextureDepth: | 171 | case TextureDepth: |
| 165 | return GL_DEPTH_COMPONENT; | 172 | return GL_DEPTH_COMPONENT; |
| 173 | case TextureR8: | ||
| 174 | return GL_RED; | ||
| 166 | case TextureRG16: | 175 | case TextureRG16: |
| 167 | case TextureRG16F: | 176 | case TextureRG16F: |
| 168 | return GL_RG; | 177 | return GL_RG; |
| @@ -185,6 +194,7 @@ GLenum to_GL_type(TextureFormat format) { | |||
| 185 | case TextureRG16F: | 194 | case TextureRG16F: |
| 186 | case TextureR11G11B10F: | 195 | case TextureR11G11B10F: |
| 187 | return GL_FLOAT; | 196 | return GL_FLOAT; |
| 197 | case TextureR8: | ||
| 188 | case TextureRG16: | 198 | case TextureRG16: |
| 189 | case TextureRGB8: | 199 | case TextureRGB8: |
| 190 | case TextureRGBA8: | 200 | case TextureRGBA8: |
