Change Mipmapping option interaction

Mipmapping only affects downscaling anyway, so by letting it override the interpolation method we enable another useful configuration. (Blocky upscaling, smooth downscaling)

Option documentation updated.
This commit is contained in:
asumface 2019-07-11 23:58:38 +02:00
parent ed74614ff0
commit 08fa54b8e9
No known key found for this signature in database
GPG Key ID: 88BDFBB18D6430AD
1 changed files with 4 additions and 4 deletions

View File

@ -1302,7 +1302,7 @@ public enum NVGImageFlag : uint {
Premultiplied = 1<<4, /// Image data has premultiplied alpha. Premultiplied = 1<<4, /// Image data has premultiplied alpha.
ClampToBorderX = 1<<5, /// Clamp image to border (instead of clamping to edge by default) ClampToBorderX = 1<<5, /// Clamp image to border (instead of clamping to edge by default)
ClampToBorderY = 1<<6, /// Clamp image to border (instead of clamping to edge by default) ClampToBorderY = 1<<6, /// Clamp image to border (instead of clamping to edge by default)
NoFiltering = 1<<8, /// use GL_NEAREST instead of GL_LINEAR NoFiltering = 1<<8, /// use GL_NEAREST instead of GL_LINEAR. Only affects upscaling if GenerateMipmaps is active.
Nearest = NoFiltering, /// compatibility with original NanoVG Nearest = NoFiltering, /// compatibility with original NanoVG
NoDelete = 1<<16,/// Do not delete GL texture handle. NoDelete = 1<<16,/// Do not delete GL texture handle.
} }
@ -13473,12 +13473,12 @@ int glnvg__renderCreateTexture (void* uptr, NVGtexture type, int w, int h, int i
glTexImage2D(GL_TEXTURE_2D, 0, ttype, w, h, 0, ttype, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, ttype, w, h, 0, ttype, GL_UNSIGNED_BYTE, data);
// GL 3.0 and later have support for a dedicated function for generating mipmaps // GL 3.0 and later have support for a dedicated function for generating mipmaps
// it needs to be called after the glTexImage2D call // it needs to be called after the glTexImage2D call
if ((imageFlags&(NVGImageFlag.GenerateMipmaps|NVGImageFlag.NoFiltering)) == NVGImageFlag.GenerateMipmaps) if (imageFlags & NVGImageFlag.GenerateMipmaps)
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
immutable tfmin = immutable tfmin =
(imageFlags&NVGImageFlag.NoFiltering ? GL_NEAREST : (imageFlags & NVGImageFlag.GenerateMipmaps ? GL_LINEAR_MIPMAP_LINEAR :
imageFlags&NVGImageFlag.GenerateMipmaps ? GL_LINEAR_MIPMAP_LINEAR : imageFlags & NVGImageFlag.NoFiltering ? GL_NEAREST :
GL_LINEAR); GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, tfmin); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, tfmin);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (imageFlags&NVGImageFlag.NoFiltering ? GL_NEAREST : GL_LINEAR)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (imageFlags&NVGImageFlag.NoFiltering ? GL_NEAREST : GL_LINEAR));