ebitenbackend

package module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 9 Imported by: 0

README

cimgui-go-ebiten

Ebiten backend for cimgui-go!

WIP

This is a work in progress!

Credit for rendering code goes to https://github.com/gabstv/ebiten-imgui. Unfortunately the ebiten-imgui repository hasn't been updated in a while and the version of imgui is forked and outdated. This implementation uses the new backend abstraction to allow it to work with the latest versions of imgui, from the cimgui-go repository.

Important!

This repository is designed to work with https://github.com/AllenDang/cimgui-go; however, the cimgui-go repository has their own sdl and glfw implementations. Luckly,these can be disabled at build that we can use ebiten's window by supplying the following build tags:

  • exclude_cimgui_sdl
  • exclude_cimgui_glfw

example:

go run -tags exclude_cimgui_glfw,exclude_cimgui_sdl examples/ui_over_game/main.go

Trying to build without the cimgui exclude build tags will cause the compiler to throw a bunch of ld errors.

TODO

  • Add gamepad support

Documentation

Index

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 DropCallback

type DropCallback func([]string)

type EbitenBackend

type EbitenBackend struct {
	// contains filtered or unexported fields
}

func NewEbitenBackend

func NewEbitenBackend() *EbitenBackend

func (*EbitenBackend) ContentScale

func (b *EbitenBackend) ContentScale() (xScale, yScale float32)

func (*EbitenBackend) CreateTexture

func (b *EbitenBackend) CreateTexture(pixels unsafe.Pointer, width, height int) imgui.TextureID

func (*EbitenBackend) CreateTextureRgba

func (b *EbitenBackend) CreateTextureRgba(img *image.RGBA, width, height int) imgui.TextureID

func (*EbitenBackend) CreateWindow

func (b *EbitenBackend) CreateWindow(title string, width, height int)

func (*EbitenBackend) DeleteTexture

func (b *EbitenBackend) DeleteTexture(id imgui.TextureID)

func (*EbitenBackend) DisplaySize

func (b *EbitenBackend) DisplaySize() (width, height int32)

func (*EbitenBackend) Game

func (b *EbitenBackend) Game() *GameProxy

func (*EbitenBackend) GetWindowPos

func (b *EbitenBackend) GetWindowPos() (x, y int32)

func (*EbitenBackend) Refresh

func (b *EbitenBackend) Refresh()

func (*EbitenBackend) Run

func (b *EbitenBackend) Run(f func())

func (*EbitenBackend) SetAfterCreateContextHook

func (b *EbitenBackend) SetAfterCreateContextHook(hook func())

func (*EbitenBackend) SetAfterRenderHook

func (b *EbitenBackend) SetAfterRenderHook(hook func())

func (*EbitenBackend) SetBeforeDestroyContextHook

func (b *EbitenBackend) SetBeforeDestroyContextHook(hook func())

func (*EbitenBackend) SetBeforeRenderHook

func (b *EbitenBackend) SetBeforeRenderHook(hook func())

func (*EbitenBackend) SetBgColor

func (b *EbitenBackend) SetBgColor(color imgui.Vec4)

func (*EbitenBackend) SetCloseCallback

func (b *EbitenBackend) SetCloseCallback(cb imgui.WindowCloseCallback[EbitenWindowFlags])

func (b *GLFWBackend) SetCloseCallback(cbfun WindowCloseCallback[GLFWWindowFlags]) {

func (*EbitenBackend) SetCursorPos

func (b *EbitenBackend) SetCursorPos(x, y float64)

func (*EbitenBackend) SetDropCallback

func (b *EbitenBackend) SetDropCallback(callback imgui.DropCallback)

func (*EbitenBackend) SetGame

func (b *EbitenBackend) SetGame(game ebiten.Game)

func (*EbitenBackend) SetGameRenderDestination

func (b *EbitenBackend) SetGameRenderDestination(dest *ebiten.Image)

func (*EbitenBackend) SetGameScreenSize

func (b *EbitenBackend) SetGameScreenSize(size imgui.Vec2)

func (*EbitenBackend) SetIcons

func (b *EbitenBackend) SetIcons(icons ...image.Image)

func (*EbitenBackend) SetInputMode

func (b *EbitenBackend) SetInputMode(mode EbitenWindowFlags, value EbitenWindowFlags)

func (*EbitenBackend) SetKeyCallback

func (b *EbitenBackend) SetKeyCallback(callback imgui.KeyCallback)

func (*EbitenBackend) SetShouldClose

func (b *EbitenBackend) SetShouldClose(shouldClose bool)

func (*EbitenBackend) SetSizeChangeCallback

func (b *EbitenBackend) SetSizeChangeCallback(callback imgui.SizeChangeCallback)

func (*EbitenBackend) SetSwapInterval

func (b *EbitenBackend) SetSwapInterval(interval EbitenWindowFlags) error

func (*EbitenBackend) SetTargetFPS

func (b *EbitenBackend) SetTargetFPS(fps uint)

func (*EbitenBackend) SetWindowFlags

func (b *EbitenBackend) SetWindowFlags(flag EbitenWindowFlags, 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)

type EbitenWindowFlags

type EbitenWindowFlags int
const (
	EbitenWindowFlagsCursorMode EbitenWindowFlags = iota
	EbitenWindowFlagsCursorShape
	EbitenWindowFlagsResizingMode
	EbitenWindowFlagsFPSMode
	EbitenWindowFlagsDecorated
	EbitenWindowFlagsFloating
	EbitenWindowFlagsMaximized
	EbitenWindowFlagsMinimized
	EbitenWindowFlagsClosingHandled
	EbitenWindowFlagsMousePassthrough
)

type GameProxy

type GameProxy struct {
	Resizeable bool
	// contains filtered or unexported fields
}

func (*GameProxy) Draw

func (g *GameProxy) Draw(screen *ebiten.Image)

func (*GameProxy) Game

func (g *GameProxy) Game() ebiten.Game

func (*GameProxy) Layout

func (g *GameProxy) Layout(outsideWidth, outsideHeight int) (int, int)

func (*GameProxy) Screen

func (g *GameProxy) Screen() *ebiten.Image

func (*GameProxy) ScreenTextureID

func (g *GameProxy) ScreenTextureID() imgui.TextureID

func (*GameProxy) SetGameScreenSize

func (g *GameProxy) SetGameScreenSize(v imgui.Vec2)

func (*GameProxy) Update

func (g *GameProxy) Update() error

Update - Update UI and proxy in tandem. Handle inputs

type KeyCallback

type KeyCallback func(key, scanCode, action, mods int)

type SizeChangeCallback

type SizeChangeCallback func(w, h int)

type TextureCache

type TextureCache interface {
	FontAtlasTextureID() imgui.TextureID
	SetFontAtlasTextureID(id imgui.TextureID)
	GetTexture(id imgui.TextureID) *ebiten.Image
	SetTexture(id imgui.TextureID, img *ebiten.Image)
	RemoveTexture(id imgui.TextureID)
	ResetFontAtlasCache(filter ebiten.Filter)
	NextId() int
}
var Cache TextureCache

func NewCache

func NewCache() TextureCache

type WindowCloseCallback

type WindowCloseCallback[B ~int] func(b imgui.Backend[B])

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL