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 (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.TextureID
- func (e *EbitenBackend) CreateTextureFromGame(game ebiten.Game, width, height int) imgui.TextureID
- func (b *EbitenBackend) CreateTextureRgba(img *image.RGBA, width, height int) imgui.TextureID
- func (e *EbitenBackend) CreateWindow(title string, width, height int)
- func (e *EbitenBackend) DeleteTexture(id imgui.TextureID)
- 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[EbitenBackendFlags])
- 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(bool)
- func (b *EbitenBackend) SetSizeChangeCallback(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 ¶
func Render ¶
func Render(target *ebiten.Image, drawData *imgui.DrawData, txcache TextureCache, dfilter ebiten.Filter, )
Render the ImGui drawData into the target *ebiten.Image
func RenderMasked ¶
func RenderMasked(target *ebiten.Image, mask *ebiten.Image, drawData *imgui.DrawData, txcache TextureCache, dfilter ebiten.Filter, )
RenderMasked renders the ImGui drawData into the target *ebiten.Image
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) 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 (*EbitenBackend) CreateTextureFromGame ¶ added in v1.0.2
func (e *EbitenBackend) CreateTextureFromGame(game ebiten.Game, width, height int) imgui.TextureID
func (*EbitenBackend) CreateTextureRgba ¶
func (*EbitenBackend) CreateWindow ¶
func (e *EbitenBackend) CreateWindow(title string, width, height int)
func (*EbitenBackend) DeleteTexture ¶
func (e *EbitenBackend) DeleteTexture(id imgui.TextureID)
func (*EbitenBackend) DisplaySize ¶
func (b *EbitenBackend) DisplaySize() (width, height int32)
TODO: Not implemented
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) 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[EbitenBackendFlags])
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(bool)
TODO: Not implemented
func (*EbitenBackend) SetSizeChangeCallback ¶
func (b *EbitenBackend) SetSizeChangeCallback(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 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 EbitenBackendFlagsDebug )
type TextureCache ¶
type TextureCache interface { FontAtlasTextureID() imgui.TextureID SetFontAtlasTextureID(id imgui.TextureID) 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) ResetFontAtlasCache(filter ebiten.Filter) NextId() int }
func NewCache ¶
func NewCache() TextureCache