func (ui *UI) update() {
}
update Handles general update type things and handle inputs. Called from ui.Draw.
package pixelui
import (
	"C"
	"github.com/faiface/pixel"
	"github.com/inkyblackness/imgui-go"
)
import (
	"image/color"
	"time"
	"unsafe"
	"github.com/dusk125/pixelutils/packer"
	"github.com/faiface/mainthread"
	"github.com/faiface/pixel/pixelgl"
)
const uiShader = `
#version 330 core
in vec4  vColor;
in vec2  vTexCoords;
in float vIntensity;
in vec4  vClipRect;
out vec4 fragColor;
uniform vec4 uColorMask;
uniform vec4 uTexBounds;
uniform sampler2D uTexture;
uniform vec4 uClipRect;
void main() {
	if ((vClipRect != vec4(0,0,0,0)) && (gl_FragCoord.x < vClipRect.x || gl_FragCoord.y < vClipRect.y || gl_FragCoord.x > vClipRect.z || gl_FragCoord.y > vClipRect.w))
		discard;
	fragColor = vColor;
	if (vIntensity == 0) {
		fragColor *= vColor * texture(uTexture, vTexCoords).a;
		fragColor *= uColorMask;
	} else {
		fragColor *= vColor * texture(uTexture, vTexCoords);
		fragColor *= uColorMask;
	}
}
`
type UI struct {
	win        *pixelgl.Window
	context    *imgui.Context
	io         imgui.IO
	fonts      imgui.FontAtlas
	timer      time.Time
	fontAtlas  pixel.TargetPicture
	shader     *pixelgl.GLShader
	matrix     pixel.Matrix
	shaderTris *pixelgl.GLTriangles
	packer     *packer.AliasPacker
	fontId     int
}
var CurrentUI *UI
const (
	NO_DEFAULT_FONT uint8 = 1 << iota
)
func NewUI(win *pixelgl.Window, flags uint8) *UI {
	var context *imgui.Context
	mainthread.Call(func() {
		context = imgui.CreateContext(nil)
	})
	ui := &UI{
		win:     win,
		context: context,
	}
	CurrentUI = ui
	ui.packer = packer.NewAliasPacker(0, 0, packer.AllowGrowth)
	ui.io = imgui.CurrentIO()
	ui.io.SetDisplaySize(IVec(win.Bounds().Size()))
	ui.io.SetClipboard(Clipboard{win: win})
	ui.fonts = ui.io.Fonts()
	ui.shader = pixelgl.NewGLShader(uiShader)
	ui.shaderTris = pixelgl.NewGLTriangles(ui.shader, pixel.MakeTrianglesData(0))
	if flags&NO_DEFAULT_FONT == 0 {
		ui.loadDefaultFont()
	}
	ui.setKeyMapping()
	return ui
}
func (ui UI) GetPacker() *packer.AliasPacker {
	return ui.packer
}
func (ui *UI) Destroy() {
	ui.context.Destroy()
}
func (ui *UI) NewFrame() {
	if !ui.timer.IsZero() {
		ui.io.SetDeltaTime(float32(time.Since(ui.timer).Seconds()))
	}
	ui.timer = time.Now()
	ui.prepareIO()
	imgui.NewFrame()
}