FlipY texture flag, display world texture atlas

This commit is contained in:
2022-02-16 00:29:34 +08:00
parent 326253a73b
commit 565e0390f3
6 changed files with 86 additions and 17 deletions

View File

@@ -38,6 +38,7 @@ func ImageV(tex uint32, size itype.Vec2f, texRange itype.Rectf, texColor itype.V
)
}
// Per-texture flags. This is passed to the shader as-is and handled only there.
type TextureFlag int
const (
@@ -48,6 +49,7 @@ const (
TextureFlag_Linear // Linear source data, requires gamma correction.
TextureFlag_ImGUIFont // This is a font texture from ImGUI, with a single red channel.
TextureFlag_FlipY // The render should flip the Y axis of the texture. By default ImageXXX()s render textures with (0,0) at the bottom left, and this is for in case you want to flip them.
TextureFlag_RGB = TextureFlag_Red | TextureFlag_Green | TextureFlag_Blue
TextureFlag_RGBA = TextureFlag_Red | TextureFlag_Green | TextureFlag_Blue | TextureFlag_Alpha
@@ -70,6 +72,18 @@ func SetTextureFlag(tex uint32, flags ...TextureFlag) {
texflags[tex] = f
}
// AddTextureFlag adds the given flags to the texture.
func AddTextureFlag(tex uint32, flags ...TextureFlag) {
var f TextureFlag
for _, f0 := range flags {
f |= f0
}
texflagslock.Lock()
defer texflagslock.Unlock()
texflags[tex] |= f
}
// TextureFlag returns the flags of a given texture.
func GetTextureFlag(tex uint32) TextureFlag {
texflagslock.RLock()