raylibbackend

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignCursorToFramebufferPixel

func AlignCursorToFramebufferPixel() imgui.Vec2

AlignCursorToFramebufferPixel snaps the current ImGui cursor so items align to framebuffer pixels

func GetPrevTouchDown

func GetPrevTouchDown() bool

GetPrevTouchDown returns whether touch was down in the previous frame

func MapMouseToTexture

func MapMouseToTexture(imgPos, imgSize imgui.Vec2, texW, texH int, flipV bool) (tx, ty float32, hovered bool)

MapMouseToTexture converts current mouse position to texture pixel coords for the given image rect

func PixelAlignedImageSize

func PixelAlignedImageSize(texW, texH int) imgui.Vec2

PixelAlignedImageSize computes an ImGui size with DisplayFramebufferScale applied in pixels

Types

type ImageRTOptions

type ImageRTOptions struct {
	// Align the ImGui cursor to the framebuffer pixel grid before drawing
	AlignCursor bool
	// Flip the image horizontally when drawing
	FlipH bool
	// Flip the image vertically when drawing
	FlipV bool
	// Require app focus for mapping
	RequireAppFocus bool
	// Require the current ImGui window hovered for mapping
	RequireWindowHovered bool
}

ImageRTOptions configures how a RenderTexture2D is rendered and interacted with

type ImageRTResult

type ImageRTResult struct {
	ImagePos  imgui.Vec2
	ImageSize imgui.Vec2
	Hovered   bool
	TexX      float32
	TexY      float32
}

ImageRTResult reports the layout and mouse interaction on the texture

type RaylibBackend

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

RaylibBackend implements the imgui.Backend interface for raylib

func NewRaylibBackend

func NewRaylibBackend() *RaylibBackend

NewRaylibBackend creates a new raylib backend implementation

func (*RaylibBackend) AfterCreateHook

func (r *RaylibBackend) AfterCreateHook() func()

AfterCreateHook returns the after-create-context hook function

func (*RaylibBackend) AfterRenderHook

func (r *RaylibBackend) AfterRenderHook() func()

AfterRenderHook returns the after-render hook function

func (*RaylibBackend) BeforeDestroyHook

func (r *RaylibBackend) BeforeDestroyHook() func()

BeforeDestroyHook returns the before-destroy hook function

func (*RaylibBackend) BeforeRenderHook

func (r *RaylibBackend) BeforeRenderHook() func()

BeforeRenderHook returns the before-render hook function

func (*RaylibBackend) CloseCallback

func (r *RaylibBackend) CloseCallback() func(window unsafe.Pointer)

CloseCallback returns the window close callback

func (*RaylibBackend) ContentScale

func (r *RaylibBackend) ContentScale() (xScale, yScale float32)

ContentScale returns the DPI scale factors for the window

func (*RaylibBackend) CreateTexture

func (r *RaylibBackend) CreateTexture(pixels unsafe.Pointer, width, height int) imgui.TextureRef

CreateTexture creates a new ImGui texture reference.

func (*RaylibBackend) CreateTextureFromTexture2D

func (r *RaylibBackend) CreateTextureFromTexture2D(tex rl.Texture2D) imgui.TextureRef

CreateTextureFromTexture2D registers an existing raylib Texture2D in the ImGui texture cache

func (*RaylibBackend) CreateTextureRgba

func (r *RaylibBackend) CreateTextureRgba(img *image.RGBA, width, height int) imgui.TextureRef

CreateTextureRgba creates an ImGui texture reference from an RGBA image

func (*RaylibBackend) CreateWindow

func (r *RaylibBackend) CreateWindow(title string, width, height int)

CreateWindow creates and initializes the raylib window and ImGui context

func (*RaylibBackend) DeleteTexture

func (r *RaylibBackend) DeleteTexture(id imgui.TextureRef)

DeleteTexture removes a texture from the cache

func (*RaylibBackend) DisableCursor

func (r *RaylibBackend) DisableCursor()

DisableCursor disables the mouse cursor

func (*RaylibBackend) DisplaySize

func (r *RaylibBackend) DisplaySize() (width, height int32)

DisplaySize returns the current display/screen size

func (*RaylibBackend) Dispose

func (r *RaylibBackend) Dispose()

Dispose cleans up resources

func (*RaylibBackend) DrawImageRenderTexture

func (r *RaylibBackend) DrawImageRenderTexture(rt rl.RenderTexture2D, size imgui.Vec2, flipV bool, flipH bool)

DrawImageRenderTexture draws the RenderTexture2D as an ImGui image

func (*RaylibBackend) DropCallback

func (r *RaylibBackend) DropCallback() backend.DropCallback

DropCallback returns the file drop callback

func (*RaylibBackend) EnableCursor

func (r *RaylibBackend) EnableCursor()

EnableCursor enables the mouse cursor

func (*RaylibBackend) GetCharPressed

func (r *RaylibBackend) GetCharPressed() int32

GetCharPressed returns the last character pressed

func (*RaylibBackend) GetClipboardText

func (r *RaylibBackend) GetClipboardText() string

GetClipboardText returns the clipboard text

func (*RaylibBackend) GetCurrentMonitor

func (r *RaylibBackend) GetCurrentMonitor() int

GetCurrentMonitor returns the current monitor index

func (*RaylibBackend) GetFPS

func (r *RaylibBackend) GetFPS() int32

GetFPS returns the current frames per second

func (*RaylibBackend) GetFrameTime

func (r *RaylibBackend) GetFrameTime() float32

GetFrameTime returns the time in seconds for the last frame drawn

func (*RaylibBackend) GetGestureDetected

func (r *RaylibBackend) GetGestureDetected() rl.Gestures

GetGestureDetected returns the latest detected gesture

func (*RaylibBackend) GetKeyPressed

func (r *RaylibBackend) GetKeyPressed() int32

GetKeyPressed returns the last key pressed

func (*RaylibBackend) GetMonitorCount

func (r *RaylibBackend) GetMonitorCount() int

GetMonitorCount returns the number of monitors

func (*RaylibBackend) GetMonitorHeight

func (r *RaylibBackend) GetMonitorHeight(monitor int) int

GetMonitorHeight returns the height of the specified monitor

func (*RaylibBackend) GetMonitorName

func (r *RaylibBackend) GetMonitorName(monitor int) string

GetMonitorName returns the name of the specified monitor

func (*RaylibBackend) GetMonitorPhysicalHeight

func (r *RaylibBackend) GetMonitorPhysicalHeight(monitor int) int

GetMonitorPhysicalHeight returns the physical height of the specified monitor in millimeters

func (*RaylibBackend) GetMonitorPhysicalWidth

func (r *RaylibBackend) GetMonitorPhysicalWidth(monitor int) int

GetMonitorPhysicalWidth returns the physical width of the specified monitor in millimeters

func (*RaylibBackend) GetMonitorPosition

func (r *RaylibBackend) GetMonitorPosition(monitor int) (x, y int32)

GetMonitorPosition returns the position of the specified monitor

func (*RaylibBackend) GetMonitorRefreshRate

func (r *RaylibBackend) GetMonitorRefreshRate(monitor int) int

GetMonitorRefreshRate returns the refresh rate of the specified monitor

func (*RaylibBackend) GetMonitorWidth

func (r *RaylibBackend) GetMonitorWidth(monitor int) int

GetMonitorWidth returns the width of the specified monitor

func (*RaylibBackend) GetMouseDelta

func (r *RaylibBackend) GetMouseDelta() (x, y float32)

GetMouseDelta returns the mouse position delta between frames

func (*RaylibBackend) GetMouseWheelMove

func (r *RaylibBackend) GetMouseWheelMove() float32

GetMouseWheelMove returns the mouse wheel movement for Y axis

func (*RaylibBackend) GetMouseWheelMoveV

func (r *RaylibBackend) GetMouseWheelMoveV() (x, y float32)

GetMouseWheelMoveV returns the mouse wheel movement for both X and Y axes

func (*RaylibBackend) GetMouseX

func (r *RaylibBackend) GetMouseX() int32

GetMouseX returns the mouse X position

func (*RaylibBackend) GetMouseY

func (r *RaylibBackend) GetMouseY() int32

GetMouseY returns the mouse Y position

func (*RaylibBackend) GetRandomValue

func (r *RaylibBackend) GetRandomValue(min, max int32) int32

GetRandomValue generates a random integer between min and max

func (*RaylibBackend) GetRenderHeight

func (r *RaylibBackend) GetRenderHeight() int

GetRenderHeight returns the render height (framebuffer height)

func (*RaylibBackend) GetRenderWidth

func (r *RaylibBackend) GetRenderWidth() int

GetRenderWidth returns the render width (framebuffer width)

func (*RaylibBackend) GetTime

func (r *RaylibBackend) GetTime() float64

GetTime returns the elapsed time in seconds since initialization

func (*RaylibBackend) GetWindowPos

func (r *RaylibBackend) GetWindowPos() (x, y int32)

GetWindowPos returns the current window position

func (*RaylibBackend) HideCursor

func (r *RaylibBackend) HideCursor()

HideCursor hides the mouse cursor

func (*RaylibBackend) ImageRenderTexture

func (r *RaylibBackend) ImageRenderTexture(rt rl.RenderTexture2D, opts *ImageRTOptions) ImageRTResult

ImageRenderTexture prepares then draws the image, and returns the result

func (*RaylibBackend) IsCursorHidden

func (r *RaylibBackend) IsCursorHidden() bool

IsCursorHidden checks if the cursor is hidden

func (*RaylibBackend) IsCursorOnScreen

func (r *RaylibBackend) IsCursorOnScreen() bool

IsCursorOnScreen checks if the cursor is on screen

func (*RaylibBackend) IsGestureDetected

func (r *RaylibBackend) IsGestureDetected(gesture rl.Gestures) bool

IsGestureDetected checks if a specific gesture was detected

func (*RaylibBackend) IsKeyDown

func (r *RaylibBackend) IsKeyDown(key int32) bool

IsKeyDown checks if a key is currently down

func (*RaylibBackend) IsKeyPressed

func (r *RaylibBackend) IsKeyPressed(key int32) bool

IsKeyPressed checks if a key was pressed once

func (*RaylibBackend) IsKeyReleased

func (r *RaylibBackend) IsKeyReleased(key int32) bool

IsKeyReleased checks if a key was released once

func (*RaylibBackend) IsKeyUp

func (r *RaylibBackend) IsKeyUp(key int32) bool

IsKeyUp checks if a key is currently up

func (*RaylibBackend) IsWindowFocused

func (r *RaylibBackend) IsWindowFocused() bool

IsWindowFocused checks if the window has focus

func (*RaylibBackend) IsWindowFullscreen

func (r *RaylibBackend) IsWindowFullscreen() bool

IsWindowFullscreen checks if the window is in fullscreen mode

func (*RaylibBackend) IsWindowHidden

func (r *RaylibBackend) IsWindowHidden() bool

IsWindowHidden checks if the window is hidden

func (*RaylibBackend) IsWindowMaximized

func (r *RaylibBackend) IsWindowMaximized() bool

IsWindowMaximized checks if the window is maximized

func (*RaylibBackend) IsWindowMinimized

func (r *RaylibBackend) IsWindowMinimized() bool

IsWindowMinimized checks if the window is minimized

func (*RaylibBackend) IsWindowResized

func (r *RaylibBackend) IsWindowResized() bool

IsWindowResized checks if the window was resized

func (*RaylibBackend) IsWindowState

func (r *RaylibBackend) IsWindowState(flag uint32) bool

IsWindowState checks if a window state flag is set

func (*RaylibBackend) KeyCallback

func (r *RaylibBackend) KeyCallback() backend.KeyCallback

KeyCallback returns the keyboard callback

func (*RaylibBackend) LoopFunc

func (r *RaylibBackend) LoopFunc() func()

LoopFunc returns the main loop function

func (*RaylibBackend) MaximizeWindow

func (r *RaylibBackend) MaximizeWindow()

MaximizeWindow maximizes the window

func (*RaylibBackend) MinimizeWindow

func (r *RaylibBackend) MinimizeWindow()

MinimizeWindow minimizes the window

func (*RaylibBackend) NewFrame

func (r *RaylibBackend) NewFrame()

NewFrame is called by at the start of each frame

func (*RaylibBackend) OpenURL

func (r *RaylibBackend) OpenURL(url string)

OpenURL opens a URL in the default browser

func (*RaylibBackend) PrepareImageRenderTexture

func (r *RaylibBackend) PrepareImageRenderTexture(rt rl.RenderTexture2D, opts *ImageRTOptions) ImageRTResult

PrepareImageRenderTexture computes size/pos and optional mouse mapping for a RenderTexture2D

func (*RaylibBackend) Refresh

func (r *RaylibBackend) Refresh()

Refresh does nothing as raylib draws each frame in Run loop

func (*RaylibBackend) Render

func (r *RaylibBackend) Render(drawData imgui.DrawData)

Render is the core drawing logic

func (*RaylibBackend) RestoreWindow

func (r *RaylibBackend) RestoreWindow()

RestoreWindow restores the window from a minimized or maximized state

func (*RaylibBackend) Run

func (r *RaylibBackend) Run(f func())

Run starts the main loop of the backend

func (*RaylibBackend) SetAfterCreateContextHook

func (r *RaylibBackend) SetAfterCreateContextHook(f func())

SetAfterCreateContextHook sets the callback to run after ImGui context is created

func (*RaylibBackend) SetAfterRenderHook

func (r *RaylibBackend) SetAfterRenderHook(f func())

SetAfterRenderHook sets the callback to run after rendering

func (*RaylibBackend) SetBeforeDestroyContextHook

func (r *RaylibBackend) SetBeforeDestroyContextHook(f func())

SetBeforeDestroyContextHook sets the callback to run before ImGui context is destroyed

func (*RaylibBackend) SetBeforeImGuiRenderHook

func (r *RaylibBackend) SetBeforeImGuiRenderHook(f func())

SetBeforeImGuiRenderHook sets the callback to run before ImGui rendering begins

func (*RaylibBackend) SetBeforeRenderHook

func (r *RaylibBackend) SetBeforeRenderHook(f func())

SetBeforeRenderHook sets the callback to run before rendering

func (*RaylibBackend) SetBgColor

func (r *RaylibBackend) SetBgColor(color imgui.Vec4)

SetBgColor sets the background color for the window

func (*RaylibBackend) SetClipboardText

func (r *RaylibBackend) SetClipboardText(text string)

SetClipboardText sets the clipboard text

func (*RaylibBackend) SetCloseCallback

func (r *RaylibBackend) SetCloseCallback(callback backend.WindowCloseCallback)

SetCloseCallback sets the callback for window close events

func (*RaylibBackend) SetConfigFlags

func (r *RaylibBackend) SetConfigFlags(flags ...RaylibBackendFlags)

SetConfigFlags sets raylib config flags

func (*RaylibBackend) SetCursorPos

func (r *RaylibBackend) SetCursorPos(x, y float64)

SetCursorPos sets the mouse cursor position

func (*RaylibBackend) SetCustomContext

func (r *RaylibBackend) SetCustomContext(ctx *imgui.Context)

SetCustomContext allows setting a custom ImGui context before CreateWindow

func (*RaylibBackend) SetCustomFontAtlas

func (r *RaylibBackend) SetCustomFontAtlas(atlas *imgui.FontAtlas)

SetCustomFontAtlas allows setting a custom font atlas before CreateWindow

func (*RaylibBackend) SetDropCallback

func (r *RaylibBackend) SetDropCallback(callback backend.DropCallback)

SetDropCallback sets the callback for file drop events

func (*RaylibBackend) SetExitKey

func (r *RaylibBackend) SetExitKey(key int32)

SetExitKey sets the key to exit the application

func (*RaylibBackend) SetGesturesEnabled

func (r *RaylibBackend) SetGesturesEnabled(flags uint32)

SetGesturesEnabled enables gesture detection for specific gesture types

func (*RaylibBackend) SetIcons

func (r *RaylibBackend) SetIcons(icons ...image.Image)

SetIcons sets the window icon (uses the first icon if multiple is provided)

func (*RaylibBackend) SetInputMode

func (r *RaylibBackend) SetInputMode(mode, value RaylibBackendFlags)

SetInputMode sets the input mode for cursor visibility and enabling

func (*RaylibBackend) SetKeyCallback

func (r *RaylibBackend) SetKeyCallback(callback backend.KeyCallback)

SetKeyCallback sets the callback for keyboard events

func (*RaylibBackend) SetMouseCursor

func (r *RaylibBackend) SetMouseCursor(cursor int32)

SetMouseCursor sets the mouse cursor style

func (*RaylibBackend) SetShouldClose

func (r *RaylibBackend) SetShouldClose(b bool)

SetShouldClose sets whether the window should close

func (*RaylibBackend) SetSizeChangeCallback

func (r *RaylibBackend) SetSizeChangeCallback(callback backend.SizeChangeCallback)

SetSizeChangeCallback sets the callback for window size change events

func (*RaylibBackend) SetSwapInterval

func (r *RaylibBackend) SetSwapInterval(interval RaylibBackendFlags) error

SetSwapInterval sets the swap interval for VSync (RaylibSwapIntervalDisabled = off, RaylibSwapIntervalEnabled = on)

func (*RaylibBackend) SetTargetFPS

func (r *RaylibBackend) SetTargetFPS(fps uint)

SetTargetFPS sets the target frames per second

func (*RaylibBackend) SetTextureFilterForRef

func (r *RaylibBackend) SetTextureFilterForRef(id imgui.TextureRef, filter rl.TextureFilterMode)

SetTextureFilterForRef sets the texture filter mode for a texture reference

func (*RaylibBackend) SetTextureWrapForRef

func (r *RaylibBackend) SetTextureWrapForRef(id imgui.TextureRef, wrap rl.TextureWrapMode)

SetTextureWrapForRef sets the texture wrap mode for a texture reference

func (*RaylibBackend) SetWindowFlags

func (r *RaylibBackend) SetWindowFlags(flag RaylibBackendFlags, value int)

SetWindowFlags sets or clears a window flag

func (*RaylibBackend) SetWindowMonitor

func (r *RaylibBackend) SetWindowMonitor(monitor int)

SetWindowMonitor sets the monitor that the window should use

func (*RaylibBackend) SetWindowOpacity

func (r *RaylibBackend) SetWindowOpacity(opacity float32)

SetWindowOpacity sets the window opacity

func (*RaylibBackend) SetWindowPos

func (r *RaylibBackend) SetWindowPos(x, y int)

SetWindowPos sets the window position

func (*RaylibBackend) SetWindowSize

func (r *RaylibBackend) SetWindowSize(width, height int)

SetWindowSize sets the window size

func (*RaylibBackend) SetWindowSizeLimits

func (r *RaylibBackend) SetWindowSizeLimits(minWidth, minHeight, maxWidth, maxHeight int)

SetWindowSizeLimits sets the minimum and maximum window size limits

func (*RaylibBackend) SetWindowTitle

func (r *RaylibBackend) SetWindowTitle(title string)

SetWindowTitle sets the window title

func (*RaylibBackend) ShowCursor

func (r *RaylibBackend) ShowCursor()

ShowCursor shows the mouse cursor

func (*RaylibBackend) SizeCallback

func (r *RaylibBackend) SizeCallback() backend.SizeChangeCallback

SizeCallback returns the size change callback

func (*RaylibBackend) TakeScreenshot

func (r *RaylibBackend) TakeScreenshot(filename string)

TakeScreenshot takes a screenshot and saves it to the specified file

func (*RaylibBackend) ToggleBorderlessWindowed

func (r *RaylibBackend) ToggleBorderlessWindowed()

ToggleBorderlessWindowed toggles borderless windowed mode

func (*RaylibBackend) ToggleFullscreen

func (r *RaylibBackend) ToggleFullscreen()

ToggleFullscreen toggles fullscreen mode

type RaylibBackendFlags

type RaylibBackendFlags int
const (
	// RaylibBackendFlagsVsyncHint sets VSync hint for the GPU
	RaylibBackendFlagsVsyncHint RaylibBackendFlags = iota

	// RaylibBackendFlagsFullscreen sets fullscreen mode
	RaylibBackendFlagsFullscreen

	// RaylibBackendFlagsResizable sets window resizable
	RaylibBackendFlagsResizable

	// RaylibBackendFlagsUndecorated sets window without decorations
	RaylibBackendFlagsUndecorated

	// RaylibBackendFlagsHidden sets window hidden on initialization
	RaylibBackendFlagsHidden

	// RaylibBackendFlagsMinimized sets window minimized
	RaylibBackendFlagsMinimized

	// RaylibBackendFlagsMaximized sets window maximized
	RaylibBackendFlagsMaximized

	// RaylibBackendFlagsUnfocused sets window without focus on initialization
	RaylibBackendFlagsUnfocused

	// RaylibBackendFlagsTopmost sets window always on top
	RaylibBackendFlagsTopmost

	// RaylibBackendFlagsAlwaysRun sets window to keep running while minimized
	RaylibBackendFlagsAlwaysRun

	// RaylibBackendFlagsTransparent sets transparent framebuffer
	RaylibBackendFlagsTransparent

	// RaylibBackendFlagsHighDPI sets HighDPI support
	RaylibBackendFlagsHighDPI

	// RaylibBackendFlagsMousePassthrough sets mouse passthrough
	RaylibBackendFlagsMousePassthrough

	// RaylibBackendFlagsBorderlessWindowed sets borderless windowed mode
	RaylibBackendFlagsBorderlessWindowed

	// RaylibBackendFlagsMSAA4X sets MSAA 4X hint (antialiasing)
	RaylibBackendFlagsMSAA4X

	// RaylibBackendFlagsInterlaced sets interlaced hint for V3D (Raspberry Pi)
	RaylibBackendFlagsInterlaced

	// RaylibInputModeCursorVisible is the mode flag for cursor visibility
	RaylibInputModeCursorVisible

	// RaylibInputModeCursorEnabled is the mode flag for cursor enable/disable
	RaylibInputModeCursorEnabled

	// RaylibInputModeDisabled represents a disabled input mode
	RaylibInputModeDisabled

	// RaylibInputModeEnabled represents an enabled input mode
	RaylibInputModeEnabled

	// RaylibSwapIntervalDisabled disables VSync (swap interval = 0)
	RaylibSwapIntervalDisabled

	// RaylibSwapIntervalEnabled enables VSync (swap interval = 1)
	RaylibSwapIntervalEnabled
)

type RenderTransform

type RenderTransform struct {
	DisplayPos imgui.Vec2
	Scale      imgui.Vec2
	UVScale    imgui.Vec2
	FlipV      bool
}

RenderTransform holds the current coordinate and scaling info

type TextureCache

type TextureCache interface {
	UpdateTexture(tex imgui.TextureData)
	GetTexture(id imgui.TextureID) rl.Texture2D
	HasTexture(id imgui.TextureID) bool
	SetTexture(id imgui.TextureID, img rl.Texture2D)
	RemoveTexture(id imgui.TextureID)
	NextId() int
}

TextureCache interface defines methods for managing textures in Raylib

func NewTextureCache

func NewTextureCache() TextureCache

NewTextureCache creates a new texture cache instance

type VertexLayout

type VertexLayout struct {
	Stride int
	PosOff int
	UVOff  int
	ColOff int
}

VertexLayout defines the ImGui vertex buffer

Jump to

Keyboard shortcuts

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