Documentation
¶
Overview ¶
Package ebitenbackend contains a renderer of ImGui for Ebitengine along with cimgui.Backend implementation.
Index ¶
- func Render(target *ebiten.Image, drawData *imgui.DrawData, txcache TextureCache, ...)
- func RenderMasked(target *ebiten.Image, mask *ebiten.Image, drawData *imgui.DrawData, ...)
- type EbitenBackend
- func (b *EbitenBackend) AttachToExistingWindow(window *glfw.Window, instance vk.Instance, device vk.Device, ...)
- func (e *EbitenBackend) BeginFrame()
- func (e *EbitenBackend) ClipMask() bool
- func (b *EbitenBackend) ContentScale() (xScale, yScale float32)
- func (e *EbitenBackend) CreateTexture(pixels unsafe.Pointer, width, height int) imgui.TextureRef
- func (e *EbitenBackend) CreateTextureFromGame(game ebiten.Game, width, height int) imgui.TextureRef
- func (b *EbitenBackend) CreateTextureRgba(img *image.RGBA, width, height int) imgui.TextureRef
- func (e *EbitenBackend) CreateWindow(title string, width, height int)
- func (e *EbitenBackend) DeleteTexture(id imgui.TextureRef)
- func (b *EbitenBackend) DisplaySize() (width, height int32)
- func (e *EbitenBackend) Draw(screen *ebiten.Image)
- func (e *EbitenBackend) EndFrame()
- func (b *EbitenBackend) GetWindowPos() (x, y int32)
- func (e *EbitenBackend) Layout(outsideWidth, outsideHeight int) (int, int)
- func (b *EbitenBackend) Refresh()
- func (b *EbitenBackend) Run(loop func())
- func (b *EbitenBackend) SetAfterCreateContextHook(fn func())
- func (b *EbitenBackend) SetAfterRenderHook(fn func())
- func (b *EbitenBackend) SetBeforeDestroyContextHook(fn func())
- func (b *EbitenBackend) SetBeforeRenderHook(fn func())
- func (b *EbitenBackend) SetBgColor(col imgui.Vec4)
- func (e *EbitenBackend) SetClipMask(value bool)
- func (b *EbitenBackend) SetCloseCallback(cb backend.WindowCloseCallback)
- func (e *EbitenBackend) SetContext(ctx *imgui.Context) *EbitenBackend
- func (b *EbitenBackend) SetCursorPos(x, y float64)
- func (b *EbitenBackend) SetDropCallback(backend.DropCallback)
- func (e *EbitenBackend) SetFontAtlas(fa *imgui.FontAtlas) *EbitenBackend
- func (b *EbitenBackend) SetIcons(icons ...image.Image)
- func (b *EbitenBackend) SetInputMode(mode, value EbitenBackendFlags)
- func (b *EbitenBackend) SetKeyCallback(backend.KeyCallback)
- func (b *EbitenBackend) SetShouldClose(sc bool)
- func (b *EbitenBackend) SetSizeChangeCallback(cb backend.SizeChangeCallback)
- func (b *EbitenBackend) SetSwapInterval(interval EbitenBackendFlags) error
- func (e *EbitenBackend) SetTargetFPS(fps uint)
- func (e *EbitenBackend) SetText(text string)
- func (b *EbitenBackend) SetWindowFlags(flag EbitenBackendFlags, value int)
- func (b *EbitenBackend) SetWindowPos(x, y int)
- func (b *EbitenBackend) SetWindowSize(width, height int)
- func (b *EbitenBackend) SetWindowSizeLimits(minWidth, minHeight, maxWidth, maxHeight int)
- func (b *EbitenBackend) SetWindowTitle(title string)
- func (e *EbitenBackend) Text() (string, error)
- func (e *EbitenBackend) Update() error
- type EbitenBackendFlags
- type TextureCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EbitenBackend ¶
type EbitenBackend struct {
// contains filtered or unexported fields
}
EbitenBackend implements imgui.Backend and ebiten.Game. It allows to render imgui UI using ebitengine (https://github.com/hajimehoshi/ebiten).
func NewEbitenBackend ¶
func NewEbitenBackend() *EbitenBackend
NewEbitenBackend creates a new Ebiten backend. it takes font atlas which could be nil
func (*EbitenBackend) AttachToExistingWindow ¶
func (b *EbitenBackend) AttachToExistingWindow(window *glfw.Window, instance vk.Instance, device vk.Device, physical_device vk.PhysicalDevice, graphics_queue vk.Queue, pipeline_cache vk.PipelineCache, graphics_queue_family uint32, swapchainImageResources []*as.SwapchainImageResources, swapchainDimensions *as.SwapchainDimensions)
func (*EbitenBackend) BeginFrame ¶
func (e *EbitenBackend) BeginFrame()
BeginFrame needs to be called on every frame, before cimgui-go calls. This is usually called inside the game's Update() function.
func (*EbitenBackend) ClipMask ¶
func (e *EbitenBackend) ClipMask() bool
ClipMask returns if clipmask is enabled or not.
func (*EbitenBackend) ContentScale ¶
func (b *EbitenBackend) ContentScale() (xScale, yScale float32)
func (*EbitenBackend) CreateTexture ¶
func (e *EbitenBackend) CreateTexture(pixels unsafe.Pointer, width, height int) imgui.TextureRef
func (*EbitenBackend) CreateTextureFromGame ¶
func (e *EbitenBackend) CreateTextureFromGame(game ebiten.Game, width, height int) imgui.TextureRef
func (*EbitenBackend) CreateTextureRgba ¶
func (b *EbitenBackend) CreateTextureRgba(img *image.RGBA, width, height int) imgui.TextureRef
func (*EbitenBackend) CreateWindow ¶
func (e *EbitenBackend) CreateWindow(title string, width, height int)
func (*EbitenBackend) DeleteTexture ¶
func (e *EbitenBackend) DeleteTexture(id imgui.TextureRef)
func (*EbitenBackend) DisplaySize ¶
func (b *EbitenBackend) DisplaySize() (width, height int32)
func (*EbitenBackend) Draw ¶
func (e *EbitenBackend) Draw(screen *ebiten.Image)
Draw draws the generated imgui frame to the screen. This is usually called inside the game's Draw() function.
func (*EbitenBackend) EndFrame ¶
func (e *EbitenBackend) EndFrame()
EndFrame needs to be called on every frame, after cimgui-go calls. This is usually called inside the game's Update() function.
func (*EbitenBackend) GetWindowPos ¶
func (b *EbitenBackend) GetWindowPos() (x, y int32)
func (*EbitenBackend) Layout ¶
func (e *EbitenBackend) Layout(outsideWidth, outsideHeight int) (int, int)
func (*EbitenBackend) Refresh ¶
func (b *EbitenBackend) Refresh()
Because Ebiten refreshes continuously anyway, Refresh has nothing to do here.
func (*EbitenBackend) Run ¶
func (b *EbitenBackend) Run(loop func())
func (*EbitenBackend) SetAfterCreateContextHook ¶
func (b *EbitenBackend) SetAfterCreateContextHook(fn func())
func (*EbitenBackend) SetAfterRenderHook ¶
func (b *EbitenBackend) SetAfterRenderHook(fn func())
func (*EbitenBackend) SetBeforeDestroyContextHook ¶
func (b *EbitenBackend) SetBeforeDestroyContextHook(fn func())
func (*EbitenBackend) SetBeforeRenderHook ¶
func (b *EbitenBackend) SetBeforeRenderHook(fn func())
func (*EbitenBackend) SetBgColor ¶
func (b *EbitenBackend) SetBgColor(col imgui.Vec4)
func (*EbitenBackend) SetClipMask ¶
func (e *EbitenBackend) SetClipMask(value bool)
SetClipMask sets if clipmask is enabled or not. This is usually called for debugging purposes.
func (*EbitenBackend) SetCloseCallback ¶
func (b *EbitenBackend) SetCloseCallback(cb backend.WindowCloseCallback)
func (*EbitenBackend) SetContext ¶
func (e *EbitenBackend) SetContext(ctx *imgui.Context) *EbitenBackend
SetContext sets imgui.Context (if not set, CreateWindow will create one)
func (*EbitenBackend) SetCursorPos ¶
func (b *EbitenBackend) SetCursorPos(x, y float64)
TODO: Not implemented
func (*EbitenBackend) SetDropCallback ¶
func (b *EbitenBackend) SetDropCallback(backend.DropCallback)
TODO: Not implemented
func (*EbitenBackend) SetFontAtlas ¶
func (e *EbitenBackend) SetFontAtlas(fa *imgui.FontAtlas) *EbitenBackend
SetFontAtlas sets custom font atlas * do not use SetContext along with this * if not called, CreateWindow will create new context with nil font atlas
func (*EbitenBackend) SetIcons ¶
func (b *EbitenBackend) SetIcons(icons ...image.Image)
func (*EbitenBackend) SetInputMode ¶
func (b *EbitenBackend) SetInputMode(mode, value EbitenBackendFlags)
TODO: Not implemented
func (*EbitenBackend) SetKeyCallback ¶
func (b *EbitenBackend) SetKeyCallback(backend.KeyCallback)
func (*EbitenBackend) SetShouldClose ¶
func (b *EbitenBackend) SetShouldClose(sc bool)
SetShouldClose asks to close the window and stop the game loop. WIll call CloseCallback if set.
func (*EbitenBackend) SetSizeChangeCallback ¶
func (b *EbitenBackend) SetSizeChangeCallback(cb backend.SizeChangeCallback)
func (*EbitenBackend) SetSwapInterval ¶
func (b *EbitenBackend) SetSwapInterval(interval EbitenBackendFlags) error
TODO: Not implemented
func (*EbitenBackend) SetTargetFPS ¶
func (e *EbitenBackend) SetTargetFPS(fps uint)
func (*EbitenBackend) SetText ¶
func (e *EbitenBackend) SetText(text string)
SetText implements imgui clipboard
func (*EbitenBackend) SetWindowFlags ¶
func (b *EbitenBackend) SetWindowFlags(flag EbitenBackendFlags, value int)
func (*EbitenBackend) SetWindowPos ¶
func (b *EbitenBackend) SetWindowPos(x, y int)
func (*EbitenBackend) SetWindowSize ¶
func (b *EbitenBackend) SetWindowSize(width, height int)
func (*EbitenBackend) SetWindowSizeLimits ¶
func (b *EbitenBackend) SetWindowSizeLimits(minWidth, minHeight, maxWidth, maxHeight int)
func (*EbitenBackend) SetWindowTitle ¶
func (b *EbitenBackend) SetWindowTitle(title string)
func (*EbitenBackend) Text ¶
func (e *EbitenBackend) Text() (string, error)
Text implements imgui clipboard
func (*EbitenBackend) Update ¶
func (e *EbitenBackend) Update() error
Update needs to be called on every frame, before cimgui-go calls. This is usually called inside the game's Update() function. delta is the time in seconds since the last frame.
type EbitenBackendFlags ¶
type EbitenBackendFlags int
const ( // EbitenBackendFlagsCursorMode sets the cursor mode. // refer ebiten.CursorModeType // CursorModeVisible, CursorModeHidden, CursorModeCaptured EbitenBackendFlagsCursorMode EbitenBackendFlags = iota // EbitenBackendFlagsCursorShape sets the cursor shape. // refer ebiten.CursorShapeType // CursorShapeDefault, CursorShapeText, CursorShapeCrosshair, CursorShapePointer, // CursorShapeEWResize, CursorShapeNSResize, CursorShapeNESWResize, CursorShapeNWSEResize, // CursorShapeMove, CursorShapeNotAllowed CursorShapeType, EbitenBackendFlagsCursorShape EbitenBackendFlagsCursorShape // EbitenBackendFlagsResizingMode sets the resizing mode. // Possible values: WindowResizingModeDisabled, WindowResizingModeOnlyFullscreenEnabled, WindowResizingModeEnabled EbitenBackendFlagsResizingMode // EbitenBackendFlagsFPSMode if 0 set enables vsync. See also: ebiten.SetVsyncEnabled EbitenBackendFlagsFPSMode // EbitenBackendFlagsDecorated sets the window decoration if != 0. EbitenBackendFlagsDecorated EbitenBackendFlagsFloating EbitenBackendFlagsMaximized EbitenBackendFlagsMinimized EbitenBackendFlagsClosingHandled EbitenBackendFlagsMousePassthrough // EbitenBackendFlagsDebug is a flag to enable debug mode. It will show FPS, TPS, ClipMask and enable ClipMask shortcut. // 0 (default) disabled, 1 (or anything else) enabled // The following keys are bound to the following actions: // - C: Toggle ClipMask // - I: Toggle input sync (if disabled no input will be handled) // - S: Toggle cursor shape sync EbitenBackendFlagsDebug // EbitenBackendFlagsTransparent sets whether window is transparent. See also: ebiten.RunGameOptions.ScreenTransparent EbitenBackendFlagsTransparent )
type TextureCache ¶
type TextureCache interface {
UpdateTexture(tex imgui.TextureData)
GetTexture(id imgui.TextureID) *ebiten.Image
GetGameTexture(id imgui.TextureID) (ebiten.Game, bool)
ForEachGame(f func(id imgui.TextureID, game ebiten.Game, target *ebiten.Image))
SetTexture(id imgui.TextureID, img *ebiten.Image)
SetGameTexture(id imgui.TextureID, img ebiten.Game)
RemoveTexture(id imgui.TextureID)
NextId() int
}
func NewCache ¶
func NewCache() TextureCache