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

@@ -7,6 +7,10 @@ import (
"github.com/inkyblackness/imgui-go/v4"
)
const (
WindowFlagsOverlay imgui.WindowFlags = imgui.WindowFlagsAlwaysAutoResize | imgui.WindowFlagsNoBackground | imgui.WindowFlagsNoNavFocus | imgui.WindowFlagsNoNavInputs | imgui.WindowFlagsNoDecoration | imgui.WindowFlagsNoBringToFrontOnFocus | imgui.WindowFlagsNoSavedSettings | imgui.WindowFlagsNoFocusOnAppearing
)
// MenuItem wraps imgui.MenuItemV to create a
// easy-to-use and intuitive interface.
func MenuItem(name, shortcut string, selected *bool, enabled bool) {
@@ -21,11 +25,18 @@ func Text(format string, a ...interface{}) {
imgui.Text(fmt.Sprintf(format, a...))
}
// TextBackground wraps imgui.Text to create a
// shortcut for fmt.Sprintf.
// TextBackground wraps imgui.Text to create a shortcut for fmt.Sprintf.
//
// It also fills the background of the text with half-transparant black, and takes care of the padding.
func TextBackground(format string, a ...interface{}) {
pad := Vec2f(imgui.CurrentStyle().ItemSpacing())
TextBackgroundV(itype.Vec4f{0, 0, 0, 0.5}, pad, format, a...)
}
// TextBackgroundV wraps imgui.Text to create a shortcut for fmt.Sprintf.
//
// It also fills the background of the text with the given color.
func TextBackground(color itype.Vec4f, padding itype.Vec2f, format string, a ...interface{}) {
func TextBackgroundV(color itype.Vec4f, padding itype.Vec2f, format string, a ...interface{}) {
text := fmt.Sprintf(format, a...)
orig := imgui.CursorScreenPos()
size := imgui.CalcTextSize(text, false, 0)
@@ -35,6 +46,12 @@ func TextBackground(color itype.Vec4f, padding itype.Vec2f, format string, a ...
imgui.Text(text)
}
// TextBlank blanks a line with a nice-looking height (half the font height plus paddings).
func TextBlank() {
fontSize := imgui.FontSize()
imgui.Dummy(imgui.Vec2{X: fontSize / 2, Y: fontSize / 2})
}
// Begin wraps imgui.BeginV to create a
// easy-to-use and intuitive interface.
//