Documentation
¶
Overview ¶
Audio subsystem for SDL3 Go bindings
SDL3 constants and type definitions for Go bindings This file provides comprehensive constants and types needed for game development with SDL3, including scancodes, window flags, blend modes, and event constants.
Event handling for SDL3 Go bindings ¶
File I/O and resource management for SDL3 Go bindings
Minimal SDL3 functions for game demo ¶
Rendering functions for SDL3 Go bindings ¶
Package sdl3 provides Go bindings for SDL3 (Simple DirectMedia Layer 3).
This package wraps the SDL3 C library using purego for pure Go bindings without requiring CGO. It provides a complete and idiomatic Go interface to SDL3's multimedia functionality including:
- Window and display management
- Input handling (keyboard, mouse, gamepad, touch)
- Audio recording and playback
- 2D and GPU-accelerated rendering
- File I/O and resource management
- Threading and synchronization
- Platform-specific functionality
Basic usage:
if err := sdl.Init(sdl.INIT_VIDEO); err != nil {
log.Fatal("Failed to initialize SDL:", err)
}
defer sdl.Quit()
window, err := sdl.CreateWindow("My Window", 800, 600, sdl.WINDOW_SHOWN)
if err != nil {
log.Fatal("Failed to create window:", err)
}
defer window.Destroy()
renderer, err := sdl.CreateRenderer(window, nil)
if err != nil {
log.Fatal("Failed to create renderer:", err)
}
defer renderer.Destroy()
// Main loop
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
if event.GetType() == sdl.EVENT_QUIT {
running = false
}
}
renderer.SetDrawColor(0, 0, 0, 255)
renderer.Clear()
renderer.Present()
}
Platform Support:
- Windows (amd64, arm64)
- Linux (amd64, arm64)
- macOS (amd64, arm64)
- WebAssembly (experimental)
Note: SDL3 dynamic library must be available on the system. For Windows: SDL3.dll in PATH or application directory For Linux: libSDL3.so in library path For macOS: libSDL3.dylib in library path
Window management functions for SDL3 Go bindings
Index ¶
- Constants
- func ClearError()
- func CloseAudioDevice(deviceID uint32)
- func ConvertAudioSamples(srcSpec *AudioSpec, srcData []uint8, dstSpec *AudioSpec) ([]uint8, error)
- func CreateWindowAndRenderer(width, height int32, windowFlags uint32) (*Window, *Renderer, error)
- func CreateWindowAndRendererMinimal(title string, width, height int32, windowFlags uint32) (*Window, *Renderer, error)
- func DisableScreenSaver()
- func EnableScreenSaver()
- func FlushEvent(eventType uint32)
- func FlushEvents(minType, maxType uint32)
- func GetAudioDeviceGain(deviceID uint32) float32
- func GetAudioDeviceName(deviceID uint32) string
- func GetAudioDriver(index int32) string
- func GetCurrentAudioDriver() string
- func GetDisplayBounds(displayID uint32) (x, y, w, h int32, err error)
- func GetDisplayContentScale(displayID uint32) (float32, error)
- func GetDisplayName(displayID uint32) string
- func GetDisplayUsableBounds(displayID uint32) (x, y, w, h int32, err error)
- func GetError() string
- func GetNumAudioDrivers() int32
- func GetPrimaryDisplay() uint32
- func GetVersion() (major, minor, patch int)
- func HasEvent(eventType uint32) bool
- func HasEvents(minType, maxType uint32) bool
- func Init(flags uint32) error
- func InitSubSystem(flags uint32) error
- func IsAudioDevicePaused(deviceID uint32) bool
- func IsEventEnabled(eventType uint32) bool
- func IsScreenSaverEnabled() bool
- func LoadFile(filename string) ([]byte, error)
- func LoadFileFromIO(io *IOStream, closeIO bool) ([]byte, error)
- func MixAudio(dst, src []uint8, format uint32, volume float32) error
- func OpenAudioDevice(deviceID uint32, spec *AudioSpec) (uint32, error)
- func PauseAudioDevice(deviceID uint32) error
- func PumpEvents()
- func PushEvent(event *Event) error
- func Quit()
- func QuitSubSystem(flags uint32)
- func RegisterAllFunctions() error
- func RegisterEvents(numevents int32) uint32
- func RegisterMinimalFunctions() error
- func ResumeAudioDevice(deviceID uint32) error
- func SetAudioDeviceGain(deviceID uint32, gain float32) error
- func SetEventEnabled(eventType uint32, enabled bool)
- func WasInit(flags uint32) uint32
- type AudioCallback
- type AudioDevice
- func (d *AudioDevice) Close()
- func (d *AudioDevice) GetFormat() (AudioSpec, int32, error)
- func (d *AudioDevice) GetGain() float32
- func (d *AudioDevice) GetName() string
- func (d *AudioDevice) IsPaused() bool
- func (d *AudioDevice) Open(spec *AudioSpec) (uint32, error)
- func (d *AudioDevice) Pause() error
- func (d *AudioDevice) Resume() error
- func (d *AudioDevice) SetGain(gain float32) error
- type AudioDeviceEvent
- type AudioSpec
- type AudioStream
- func (s *AudioStream) BindToDevice(deviceID uint32) error
- func (s *AudioStream) Clear() error
- func (s *AudioStream) Destroy()
- func (s *AudioStream) Flush() error
- func (s *AudioStream) GetAvailable() int32
- func (s *AudioStream) GetBinding() uint32
- func (s *AudioStream) GetData(buf unsafe.Pointer, length int32) (int32, error)
- func (s *AudioStream) GetFormat() (srcSpec, dstSpec AudioSpec, err error)
- func (s *AudioStream) GetFrequencyRatio() float32
- func (s *AudioStream) GetGain() float32
- func (s *AudioStream) GetQueued() int32
- func (s *AudioStream) Lock() error
- func (s *AudioStream) PutData(buf unsafe.Pointer, length int32) error
- func (s *AudioStream) SetFormat(srcSpec, dstSpec *AudioSpec) error
- func (s *AudioStream) SetFrequencyRatio(ratio float32) error
- func (s *AudioStream) SetGain(gain float32) error
- func (s *AudioStream) Unbind()
- func (s *AudioStream) Unlock() error
- type BlendMode
- type Color
- type Display
- type DisplayMode
- type DropEvent
- type Error
- type Event
- func (e *Event) AsAudioDeviceEvent() *AudioDeviceEvent
- func (e *Event) AsDropEvent() *DropEvent
- func (e *Event) AsGamepadAxisEvent() *GamepadAxisEvent
- func (e *Event) AsGamepadButtonEvent() *GamepadButtonEvent
- func (e *Event) AsGamepadDeviceEvent() *GamepadDeviceEvent
- func (e *Event) AsJoyAxisEvent() *JoyAxisEvent
- func (e *Event) AsJoyBallEvent() *JoyBallEvent
- func (e *Event) AsJoyButtonEvent() *JoyButtonEvent
- func (e *Event) AsJoyDeviceEvent() *JoyDeviceEvent
- func (e *Event) AsJoyHatEvent() *JoyHatEvent
- func (e *Event) AsKeyboardEvent() *KeyboardEvent
- func (e *Event) AsMouseButtonEvent() *MouseButtonEvent
- func (e *Event) AsMouseMotionEvent() *MouseMotionEvent
- func (e *Event) AsMouseWheelEvent() *MouseWheelEvent
- func (e *Event) AsQuitEvent() *QuitEvent
- func (e *Event) AsSensorEvent() *SensorEvent
- func (e *Event) AsTextEditingEvent() *TextEditingEvent
- func (e *Event) AsTextInputEvent() *TextInputEvent
- func (e *Event) AsTouchFingerEvent() *TouchFingerEvent
- func (e *Event) AsUserEvent() *UserEvent
- func (e *Event) AsWindowEvent() *WindowEvent
- func (e *Event) GetTimestamp() uint64
- func (e *Event) GetType() uint32
- type EventFilter
- type EventWatchFunc
- type FPoint
- type FRect
- type GamepadAxisEvent
- type GamepadButtonEvent
- type GamepadDeviceEvent
- type IOStream
- func (io *IOStream) Close() error
- func (io *IOStream) Flush() error
- func (io *IOStream) GetStatus() int32
- func (io *IOStream) Printf(format string, args ...interface{}) (int64, error)
- func (io *IOStream) Read(buffer []byte) (int64, error)
- func (io *IOStream) ReadS8() (int8, error)
- func (io *IOStream) ReadS16BE() (int16, error)
- func (io *IOStream) ReadS16LE() (int16, error)
- func (io *IOStream) ReadS32BE() (int32, error)
- func (io *IOStream) ReadS32LE() (int32, error)
- func (io *IOStream) ReadS64BE() (int64, error)
- func (io *IOStream) ReadS64LE() (int64, error)
- func (io *IOStream) ReadU8() (uint8, error)
- func (io *IOStream) ReadU16BE() (uint16, error)
- func (io *IOStream) ReadU16LE() (uint16, error)
- func (io *IOStream) ReadU32BE() (uint32, error)
- func (io *IOStream) ReadU32LE() (uint32, error)
- func (io *IOStream) ReadU64BE() (uint64, error)
- func (io *IOStream) ReadU64LE() (uint64, error)
- func (io *IOStream) Seek(offset int64, whence int32) (int64, error)
- func (io *IOStream) Size() int64
- func (io *IOStream) Tell() (int64, error)
- func (io *IOStream) Write(buffer []byte) (int64, error)
- func (io *IOStream) WriteS8(value int8) error
- func (io *IOStream) WriteS16BE(value int16) error
- func (io *IOStream) WriteS16LE(value int16) error
- func (io *IOStream) WriteS32BE(value int32) error
- func (io *IOStream) WriteS32LE(value int32) error
- func (io *IOStream) WriteS64BE(value int64) error
- func (io *IOStream) WriteS64LE(value int64) error
- func (io *IOStream) WriteU8(value uint8) error
- func (io *IOStream) WriteU16BE(value uint16) error
- func (io *IOStream) WriteU16LE(value uint16) error
- func (io *IOStream) WriteU32BE(value uint32) error
- func (io *IOStream) WriteU32LE(value uint32) error
- func (io *IOStream) WriteU64BE(value uint64) error
- func (io *IOStream) WriteU64LE(value uint64) error
- type JoyAxisEvent
- type JoyBallEvent
- type JoyButtonEvent
- type JoyDeviceEvent
- type JoyHatEvent
- type KeyboardEvent
- type Keymod
- type Keysym
- type MouseButtonEvent
- type MouseMotionEvent
- type MouseWheelEvent
- type Point
- type QuitEvent
- type Rect
- type Renderer
- func (r *Renderer) Clear() error
- func (r *Renderer) ClearMinimal() error
- func (r *Renderer) CreateTexture(format uint32, access int32, w, h int32) (*Texture, error)
- func (r *Renderer) Destroy()
- func (r *Renderer) DrawLine(x1, y1, x2, y2 float32) error
- func (r *Renderer) DrawPoint(x, y float32) error
- func (r *Renderer) DrawRect(rect *FRect) error
- func (r *Renderer) DrawRectMinimal(rect *FRect) error
- func (r *Renderer) FillRect(rect *FRect) error
- func (r *Renderer) FillRectMinimal(rect *FRect) error
- func (r *Renderer) GetBlendMode() (int32, error)
- func (r *Renderer) GetDrawColor() (red, green, blue, alpha uint8, err error)
- func (r *Renderer) GetName() string
- func (r *Renderer) GetOutputSize() (width, height int32, err error)
- func (r *Renderer) GetVSync() (int32, error)
- func (r *Renderer) Present() error
- func (r *Renderer) PresentMinimal() error
- func (r *Renderer) SetBlendMode(blendMode int32) error
- func (r *Renderer) SetDrawColor(red, green, blue, alpha uint8) error
- func (r *Renderer) SetDrawColorFloat(red, green, blue, alpha float32) error
- func (r *Renderer) SetDrawColorMinimal(red, green, blue, alpha uint8) error
- func (r *Renderer) SetVSync(vsync int32) error
- type Scancode
- type SensorEvent
- type Surface
- type TextEditingEvent
- type TextInputEvent
- type Texture
- func (t *Texture) Destroy()
- func (t *Texture) GetAlphaMod() (uint8, error)
- func (t *Texture) GetBlendMode() (int32, error)
- func (t *Texture) GetColorMod() (red, green, blue uint8, err error)
- func (t *Texture) GetSize() (width, height float32, err error)
- func (t *Texture) SetAlphaMod(alpha uint8) error
- func (t *Texture) SetBlendMode(blendMode int32) error
- func (t *Texture) SetColorMod(red, green, blue uint8) error
- type TouchFingerEvent
- type UserEvent
- type Window
- func (w *Window) CreateRenderer() (*Renderer, error)
- func (w *Window) CreateRendererWithDriver(driverName string) (*Renderer, error)
- func (w *Window) Destroy()
- func (w *Window) Flash(operation int32) error
- func (w *Window) FlashBriefly() error
- func (w *Window) FlashUntilFocused() error
- func (w *Window) GetFlags() uint32
- func (w *Window) GetGrab() bool
- func (w *Window) GetID() uint32
- func (w *Window) GetKeyboardGrab() bool
- func (w *Window) GetMaximumSize() (maxWidth, maxHeight int32, err error)
- func (w *Window) GetMinimumSize() (minWidth, minHeight int32, err error)
- func (w *Window) GetMouseGrab() bool
- func (w *Window) GetOpacity() float32
- func (w *Window) GetPosition() (x, y int32, err error)
- func (w *Window) GetSize() (width, height int32, err error)
- func (w *Window) GetSizeInPixels() (width, height int32, err error)
- func (w *Window) GetTitle() string
- func (w *Window) Hide() error
- func (w *Window) Maximize() error
- func (w *Window) Minimize() error
- func (w *Window) Raise() error
- func (w *Window) Restore() error
- func (w *Window) SetAlwaysOnTop(onTop bool)
- func (w *Window) SetBordered(bordered bool)
- func (w *Window) SetFullscreen(fullscreen bool) error
- func (w *Window) SetGrab(grabbed bool)
- func (w *Window) SetInputFocus() error
- func (w *Window) SetKeyboardGrab(grabbed bool)
- func (w *Window) SetMaximumSize(maxWidth, maxHeight int32) error
- func (w *Window) SetMinimumSize(minWidth, minHeight int32) error
- func (w *Window) SetModalFor(parent *Window) error
- func (w *Window) SetMouseGrab(grabbed bool)
- func (w *Window) SetOpacity(opacity float32) error
- func (w *Window) SetPosition(x, y int32) error
- func (w *Window) SetResizable(resizable bool)
- func (w *Window) SetSize(width, height int32) error
- func (w *Window) SetTitle(title string)
- func (w *Window) Show() error
- func (w *Window) StopFlashing() error
- func (w *Window) Sync() error
- type WindowEvent
- type WindowFlags
Constants ¶
const ( AUDIO_U8 = 0x0008 // Unsigned 8-bit samples AUDIO_S8 = 0x8008 // Signed 8-bit samples AUDIO_U16LSB = 0x0010 // Unsigned 16-bit samples (little endian) AUDIO_S16LSB = 0x8010 // Signed 16-bit samples (little endian) AUDIO_U16MSB = 0x1010 // Unsigned 16-bit samples (big endian) AUDIO_S16MSB = 0x9010 // Signed 16-bit samples (big endian) AUDIO_U16 = AUDIO_U16LSB AUDIO_S16 = AUDIO_S16LSB AUDIO_S32LSB = 0x8020 // 32-bit integer samples (little endian) AUDIO_S32MSB = 0x9020 // 32-bit integer samples (big endian) AUDIO_S32 = AUDIO_S32LSB AUDIO_F32LSB = 0x8120 // 32-bit floating point samples (little endian) AUDIO_F32MSB = 0x9120 // 32-bit floating point samples (big endian) AUDIO_F32 = AUDIO_F32LSB )
Audio format constants
const ( RENDERER_SOFTWARE = 0x00000001 RENDERER_ACCELERATED = 0x00000002 RENDERER_PRESENTVSYNC = 0x00000004 RENDERER_TARGETTEXTURE = 0x00000008 )
Renderer flags
const ( TEXTUREACCESS_STATIC = 0 // Changes rarely, not lockable TEXTUREACCESS_STREAMING = 1 // Changes frequently, lockable TEXTUREACCESS_TARGET = 2 // Can be used as a render target )
Texture access patterns
const ( PIXELFORMAT_UNKNOWN = 0 PIXELFORMAT_INDEX1LSB = 0x11100100 PIXELFORMAT_INDEX1MSB = 0x11200100 PIXELFORMAT_INDEX4LSB = 0x12100400 PIXELFORMAT_INDEX4MSB = 0x12200400 PIXELFORMAT_INDEX8 = 0x13000801 PIXELFORMAT_RGB332 = 0x14110801 PIXELFORMAT_RGB444 = 0x15120C02 PIXELFORMAT_RGB555 = 0x15130F02 PIXELFORMAT_BGR555 = 0x15530F02 PIXELFORMAT_ARGB4444 = 0x15321002 PIXELFORMAT_RGBA4444 = 0x15421002 PIXELFORMAT_ABGR4444 = 0x15721002 PIXELFORMAT_BGRA4444 = 0x15821002 PIXELFORMAT_ARGB1555 = 0x15331002 PIXELFORMAT_RGBA5551 = 0x15441002 PIXELFORMAT_ABGR1555 = 0x15731002 PIXELFORMAT_BGRA5551 = 0x15841002 PIXELFORMAT_RGB565 = 0x15151002 PIXELFORMAT_BGR565 = 0x15551002 PIXELFORMAT_RGB24 = 0x17101803 PIXELFORMAT_BGR24 = 0x17401803 PIXELFORMAT_RGB888 = 0x16161804 PIXELFORMAT_RGBX8888 = 0x16261804 PIXELFORMAT_BGR888 = 0x16561804 PIXELFORMAT_BGRX8888 = 0x16661804 PIXELFORMAT_ARGB8888 = 0x16362004 PIXELFORMAT_RGBA8888 = 0x16462004 PIXELFORMAT_ABGR8888 = 0x16762004 PIXELFORMAT_BGRA8888 = 0x16862004 PIXELFORMAT_ARGB2101010 = 0x16372004 PIXELFORMAT_RGBA32 = PIXELFORMAT_ABGR8888 PIXELFORMAT_ARGB32 = PIXELFORMAT_BGRA8888 PIXELFORMAT_BGRA32 = PIXELFORMAT_ARGB8888 PIXELFORMAT_ABGR32 = PIXELFORMAT_RGBA8888 )
Pixel format constants (commonly used in games)
const ( AUDIO_MASK_BITSIZE = 0xFF AUDIO_MASK_FLOAT = 1 << 8 AUDIO_MASK_BIG_ENDIAN = 1 << 12 AUDIO_MASK_SIGNED = 1 << 15 )
Audio format mask constants (for games with sound - specific formats defined in audio.go)
const ( GAMEPAD_AXIS_INVALID = -1 GAMEPAD_AXIS_LEFTX = 0 GAMEPAD_AXIS_LEFTY = 1 GAMEPAD_AXIS_RIGHTX = 2 GAMEPAD_AXIS_RIGHTY = 3 GAMEPAD_AXIS_LEFT_TRIGGER = 4 GAMEPAD_AXIS_RIGHT_TRIGGER = 5 GAMEPAD_AXIS_MAX = 6 GAMEPAD_BUTTON_INVALID = -1 GAMEPAD_BUTTON_A = 0 GAMEPAD_BUTTON_B = 1 GAMEPAD_BUTTON_X = 2 GAMEPAD_BUTTON_Y = 3 GAMEPAD_BUTTON_BACK = 4 GAMEPAD_BUTTON_GUIDE = 5 GAMEPAD_BUTTON_START = 6 GAMEPAD_BUTTON_LEFT_STICK = 7 GAMEPAD_BUTTON_RIGHT_STICK = 8 GAMEPAD_BUTTON_LEFT_SHOULDER = 9 GAMEPAD_BUTTON_RIGHT_SHOULDER = 10 GAMEPAD_BUTTON_DPAD_UP = 11 GAMEPAD_BUTTON_DPAD_DOWN = 12 GAMEPAD_BUTTON_DPAD_LEFT = 13 GAMEPAD_BUTTON_DPAD_RIGHT = 14 GAMEPAD_BUTTON_MISC1 = 15 GAMEPAD_BUTTON_PADDLE1 = 16 GAMEPAD_BUTTON_PADDLE2 = 17 GAMEPAD_BUTTON_PADDLE3 = 18 GAMEPAD_BUTTON_PADDLE4 = 19 GAMEPAD_BUTTON_TOUCHPAD = 20 GAMEPAD_BUTTON_MAX = 21 )
Game controller constants
const ( RELEASED = 0 PRESSED = 1 )
Button state constants
const ( BUTTON_LEFT = 1 BUTTON_MIDDLE = 2 BUTTON_RIGHT = 3 BUTTON_X1 = 4 BUTTON_X2 = 5 )
Mouse button constants
const ( HAT_CENTERED = 0x00 HAT_UP = 0x01 HAT_RIGHT = 0x02 HAT_DOWN = 0x04 HAT_LEFT = 0x08 HAT_RIGHTUP = HAT_RIGHT | HAT_UP HAT_RIGHTDOWN = HAT_RIGHT | HAT_DOWN HAT_LEFTUP = HAT_LEFT | HAT_UP HAT_LEFTDOWN = HAT_LEFT | HAT_DOWN )
Hat position constants
const ( IO_SEEK_SET = 0 // Seek from the beginning of data IO_SEEK_CUR = 1 // Seek relative to current read point IO_SEEK_END = 2 // Seek relative to the end of data )
IOWhence constants for seeking
const ( IO_STATUS_READY = 0 IO_STATUS_ERROR = 1 IO_STATUS_EOF = 2 IO_STATUS_NOT_READY = 3 IO_STATUS_READONLY = 4 IO_STATUS_WRITEONLY = 5 )
IOStatus constants
const ( BLENDMODE_NONE = 0x00000000 BLENDMODE_BLEND = 0x00000001 BLENDMODE_ADD = 0x00000002 BLENDMODE_MOD = 0x00000004 BLENDMODE_MUL = 0x00000008 BLENDMODE_INVALID = 0x7FFFFFFF )
Blend modes
const ( SCALEMODE_NEAREST = 0 SCALEMODE_LINEAR = 1 SCALEMODE_BEST = 2 )
Scale modes
const ( FLIP_NONE = 0x00000000 FLIP_HORIZONTAL = 0x00000001 FLIP_VERTICAL = 0x00000002 )
Flip constants
const ( MAJOR_VERSION = 3 MINOR_VERSION = 2 PATCHLEVEL = 0 )
Version information
const ( INIT_TIMER = 0x00000001 INIT_AUDIO = 0x00000010 INIT_VIDEO = 0x00000020 INIT_JOYSTICK = 0x00000200 INIT_HAPTIC = 0x00001000 INIT_GAMEPAD = 0x00002000 INIT_EVENTS = 0x00004000 INIT_SENSOR = 0x00008000 INIT_CAMERA = 0x00010000 INIT_EVERYTHING = INIT_TIMER | INIT_AUDIO | INIT_VIDEO | INIT_EVENTS | INIT_JOYSTICK | INIT_HAPTIC | INIT_GAMEPAD | INIT_SENSOR | INIT_CAMERA )
Init flags for SDL_Init
const ( WINDOW_FULLSCREEN = 0x00000001 WINDOW_OPENGL = 0x00000002 WINDOW_OCCLUDED = 0x00000004 WINDOW_SHOWN = 0x00000008 WINDOW_HIDDEN = 0x00000010 WINDOW_BORDERLESS = 0x00000020 WINDOW_RESIZABLE = 0x00000040 WINDOW_MINIMIZED = 0x00000080 WINDOW_MAXIMIZED = 0x00000100 WINDOW_MOUSE_GRABBED = 0x00000200 WINDOW_INPUT_FOCUS = 0x00000400 WINDOW_MOUSE_FOCUS = 0x00000800 WINDOW_EXTERNAL = 0x00001000 WINDOW_MODAL = 0x00002000 WINDOW_HIGH_PIXEL_DENSITY = 0x00004000 WINDOW_MOUSE_CAPTURE = 0x00008000 WINDOW_ALWAYS_ON_TOP = 0x00010000 WINDOW_UTILITY = 0x00020000 WINDOW_TOOLTIP = 0x00040000 WINDOW_POPUP_MENU = 0x00080000 WINDOW_KEYBOARD_GRABBED = 0x00100000 WINDOW_VULKAN = 0x10000000 WINDOW_METAL = 0x20000000 WINDOW_TRANSPARENT = 0x40000000 WINDOW_NOT_FOCUSABLE = 0x80000000 )
Window flags
const ( EVENT_FIRST = 0 EVENT_QUIT = 0x100 EVENT_TERMINATING = 0x101 EVENT_LOW_MEMORY = 0x102 EVENT_WILL_ENTER_BACKGROUND = 0x103 EVENT_DID_ENTER_BACKGROUND = 0x104 EVENT_WILL_ENTER_FOREGROUND = 0x105 EVENT_DID_ENTER_FOREGROUND = 0x106 EVENT_LOCALE_CHANGED = 0x107 EVENT_SYSTEM_THEME_CHANGED = 0x108 EVENT_DISPLAY_ORIENTATION = 0x151 EVENT_DISPLAY_ADDED = 0x152 EVENT_DISPLAY_REMOVED = 0x153 EVENT_DISPLAY_MOVED = 0x154 EVENT_DISPLAY_DESKTOP_MODE_CHANGED = 0x155 EVENT_DISPLAY_CURRENT_MODE_CHANGED = 0x156 EVENT_DISPLAY_CONTENT_SCALE_CHANGED = 0x157 EVENT_WINDOW_SHOWN = 0x202 EVENT_WINDOW_HIDDEN = 0x203 EVENT_WINDOW_EXPOSED = 0x204 EVENT_WINDOW_MOVED = 0x205 EVENT_WINDOW_RESIZED = 0x206 EVENT_WINDOW_PIXEL_SIZE_CHANGED = 0x207 EVENT_WINDOW_METAL_VIEW_RESIZED = 0x208 EVENT_WINDOW_MINIMIZED = 0x209 EVENT_WINDOW_MAXIMIZED = 0x20A EVENT_WINDOW_RESTORED = 0x20B EVENT_WINDOW_MOUSE_ENTER = 0x20C EVENT_WINDOW_MOUSE_LEAVE = 0x20D EVENT_WINDOW_FOCUS_GAINED = 0x20E EVENT_WINDOW_FOCUS_LOST = 0x20F EVENT_WINDOW_CLOSE_REQUESTED = 0x210 EVENT_WINDOW_HIT_TEST = 0x211 EVENT_WINDOW_ICCPROF_CHANGED = 0x212 EVENT_WINDOW_DISPLAY_CHANGED = 0x213 EVENT_WINDOW_DISPLAY_SCALE_CHANGED = 0x214 EVENT_WINDOW_SAFE_AREA_CHANGED = 0x215 EVENT_WINDOW_OCCLUDED = 0x216 EVENT_WINDOW_ENTER_FULLSCREEN = 0x217 EVENT_WINDOW_LEAVE_FULLSCREEN = 0x218 EVENT_WINDOW_DESTROYED = 0x219 EVENT_WINDOW_HDR_STATE_CHANGED = 0x21A EVENT_KEY_DOWN = 0x300 EVENT_KEY_UP = 0x301 EVENT_TEXT_EDITING = 0x302 EVENT_TEXT_INPUT = 0x303 EVENT_KEYMAP_CHANGED = 0x304 EVENT_KEYBOARD_ADDED = 0x305 EVENT_KEYBOARD_REMOVED = 0x306 EVENT_TEXT_EDITING_CANDIDATES = 0x307 EVENT_MOUSE_BUTTON_DOWN = 0x400 EVENT_MOUSE_BUTTON_UP = 0x401 EVENT_MOUSE_MOTION = 0x402 EVENT_MOUSE_WHEEL = 0x403 EVENT_MOUSE_ADDED = 0x404 EVENT_MOUSE_REMOVED = 0x405 EVENT_JOYSTICK_AXIS_MOTION = 0x600 EVENT_JOYSTICK_BALL_MOTION = 0x601 EVENT_JOYSTICK_HAT_MOTION = 0x602 EVENT_JOYSTICK_BUTTON_DOWN = 0x603 EVENT_JOYSTICK_BUTTON_UP = 0x604 EVENT_JOYSTICK_ADDED = 0x605 EVENT_JOYSTICK_REMOVED = 0x606 EVENT_JOYSTICK_BATTERY_UPDATED = 0x607 EVENT_JOYSTICK_UPDATE_COMPLETE = 0x608 EVENT_GAMEPAD_AXIS_MOTION = 0x650 EVENT_GAMEPAD_BUTTON_DOWN = 0x651 EVENT_GAMEPAD_BUTTON_UP = 0x652 EVENT_GAMEPAD_ADDED = 0x653 EVENT_GAMEPAD_REMOVED = 0x654 EVENT_GAMEPAD_REMAPPED = 0x655 EVENT_GAMEPAD_TOUCHPAD_DOWN = 0x656 EVENT_GAMEPAD_TOUCHPAD_MOTION = 0x657 EVENT_GAMEPAD_TOUCHPAD_UP = 0x658 EVENT_GAMEPAD_SENSOR_UPDATE = 0x659 EVENT_GAMEPAD_UPDATE_COMPLETE = 0x65A EVENT_GAMEPAD_STEAM_HANDLE_UPDATED = 0x65B EVENT_FINGER_DOWN = 0x700 EVENT_FINGER_UP = 0x701 EVENT_FINGER_MOTION = 0x702 EVENT_CLIPBOARD_UPDATE = 0x900 EVENT_DROP_FILE = 0x1000 EVENT_DROP_TEXT = 0x1001 EVENT_DROP_BEGIN = 0x1002 EVENT_DROP_COMPLETE = 0x1003 EVENT_DROP_POSITION = 0x1004 EVENT_AUDIO_DEVICE_ADDED = 0x1100 EVENT_AUDIO_DEVICE_REMOVED = 0x1101 EVENT_AUDIO_DEVICE_FORMAT_CHANGED = 0x1102 EVENT_SENSOR_UPDATE = 0x1200 EVENT_PEN_PROXIMITY_IN = 0x1300 EVENT_PEN_PROXIMITY_OUT = 0x1301 EVENT_PEN_DOWN = 0x1302 EVENT_PEN_UP = 0x1303 EVENT_PEN_MOTION = 0x1304 EVENT_PEN_BUTTON_DOWN = 0x1305 EVENT_PEN_BUTTON_UP = 0x1306 EVENT_CAMERA_DEVICE_ADDED = 0x1400 EVENT_CAMERA_DEVICE_REMOVED = 0x1401 EVENT_CAMERA_DEVICE_APPROVED = 0x1402 EVENT_CAMERA_DEVICE_DENIED = 0x1403 EVENT_RENDER_TARGETS_RESET = 0x2000 EVENT_RENDER_DEVICE_RESET = 0x2001 EVENT_POLL_SENTINEL = 0x7F00 EVENT_USER = 0x8000 EVENT_LAST = 0xFFFF )
Event types
const ( WINDOWPOS_UNDEFINED = 0x1FFF0000 WINDOWPOS_CENTERED = 0x2FFF0000 )
Window position constants
const ( HITTEST_NORMAL = 0 HITTEST_DRAGGABLE = 1 HITTEST_RESIZE_TOPLEFT = 2 HITTEST_RESIZE_TOP = 3 HITTEST_RESIZE_TOPRIGHT = 4 HITTEST_RESIZE_RIGHT = 5 HITTEST_RESIZE_BOTTOMRIGHT = 6 HITTEST_RESIZE_BOTTOM = 7 HITTEST_RESIZE_BOTTOMLEFT = 8 HITTEST_RESIZE_LEFT = 9 )
Window hit test results
const ( FLASH_CANCEL = 0 FLASH_BRIEFLY = 1 FLASH_UNTIL_FOCUSED = 2 )
Flash operation constants
Variables ¶
This section is empty.
Functions ¶
func CloseAudioDevice ¶
func CloseAudioDevice(deviceID uint32)
CloseAudioDevice closes an opened audio device.
func ConvertAudioSamples ¶
ConvertAudioSamples converts audio samples to a different format.
func CreateWindowAndRenderer ¶
CreateWindowAndRenderer creates a window and default renderer.
func CreateWindowAndRendererMinimal ¶
func CreateWindowAndRendererMinimal(title string, width, height int32, windowFlags uint32) (*Window, *Renderer, error)
CreateWindowAndRendererMinimal creates both window and renderer in one call (more reliable)
func FlushEvent ¶
func FlushEvent(eventType uint32)
FlushEvent clears events of a specific type from the event queue.
func FlushEvents ¶
func FlushEvents(minType, maxType uint32)
FlushEvents clears events within a range of types from the event queue.
func GetAudioDeviceGain ¶
GetAudioDeviceGain gets the gain of an audio device.
func GetAudioDeviceName ¶
GetAudioDeviceName returns the human-readable name of a specific audio device.
func GetAudioDriver ¶
GetAudioDriver returns the name of a built-in audio driver.
func GetCurrentAudioDriver ¶
func GetCurrentAudioDriver() string
GetCurrentAudioDriver returns the name of the current audio driver.
func GetDisplayBounds ¶
GetDisplayBounds returns the desktop area represented by a display.
func GetDisplayContentScale ¶
GetDisplayContentScale returns the content scale of a display.
func GetDisplayName ¶
GetDisplayName returns the name of a display.
func GetDisplayUsableBounds ¶
GetDisplayUsableBounds returns the usable desktop area represented by a display.
func GetNumAudioDrivers ¶
func GetNumAudioDrivers() int32
GetNumAudioDrivers returns the number of built-in audio drivers.
func GetPrimaryDisplay ¶
func GetPrimaryDisplay() uint32
GetPrimaryDisplay returns the instance ID of the primary display.
func GetVersion ¶
func GetVersion() (major, minor, patch int)
GetVersion returns the SDL version information.
func Init ¶
Init initializes SDL with the specified subsystems. Pass INIT_EVERYTHING to initialize all subsystems.
func InitSubSystem ¶
InitSubSystem initializes specific SDL subsystems.
func IsAudioDevicePaused ¶
IsAudioDevicePaused checks if an audio device is paused.
func IsEventEnabled ¶
IsEventEnabled checks if processing of a certain event type is enabled.
func IsScreenSaverEnabled ¶
func IsScreenSaverEnabled() bool
IsScreenSaverEnabled returns whether the screen saver is currently enabled.
func LoadFileFromIO ¶
LoadFileFromIO loads an entire file from an I/O stream into memory.
func OpenAudioDevice ¶
OpenAudioDevice opens a specific audio device.
func PauseAudioDevice ¶
PauseAudioDevice pauses audio playback on the specified device.
func PumpEvents ¶
func PumpEvents()
PumpEvents pumps the event loop, gathering events from the input devices.
func QuitSubSystem ¶
func QuitSubSystem(flags uint32)
QuitSubSystem shuts down specific SDL subsystems.
func RegisterAllFunctions ¶
func RegisterAllFunctions() error
RegisterAllFunctions registers all SDL3 function pointers
func RegisterEvents ¶
RegisterEvents allocates a set of user-defined events.
func RegisterMinimalFunctions ¶
func RegisterMinimalFunctions() error
Register minimal functions needed for the game
func ResumeAudioDevice ¶
ResumeAudioDevice resumes audio playback on the specified device.
func SetAudioDeviceGain ¶
SetAudioDeviceGain sets the gain of an audio device.
func SetEventEnabled ¶
SetEventEnabled enables or disables processing of certain event types.
Types ¶
type AudioCallback ¶
Audio callback function type
type AudioDevice ¶
type AudioDevice struct {
ID uint32
}
AudioDevice represents an SDL audio device
func GetAudioPlaybackDevices ¶
func GetAudioPlaybackDevices() ([]AudioDevice, error)
GetAudioPlaybackDevices returns a list of available audio playback devices.
func GetAudioRecordingDevices ¶
func GetAudioRecordingDevices() ([]AudioDevice, error)
GetAudioRecordingDevices returns a list of available audio recording devices.
func (*AudioDevice) GetFormat ¶
func (d *AudioDevice) GetFormat() (AudioSpec, int32, error)
GetFormat gets the preferred audio format of the audio device.
func (*AudioDevice) GetGain ¶
func (d *AudioDevice) GetGain() float32
GetGain gets the gain of the audio device.
func (*AudioDevice) GetName ¶
func (d *AudioDevice) GetName() string
GetName returns the human-readable name of the audio device.
func (*AudioDevice) IsPaused ¶
func (d *AudioDevice) IsPaused() bool
IsPaused checks if the audio device is paused.
func (*AudioDevice) Open ¶
func (d *AudioDevice) Open(spec *AudioSpec) (uint32, error)
Open opens the audio device.
func (*AudioDevice) Pause ¶
func (d *AudioDevice) Pause() error
Pause pauses audio playback on the device.
func (*AudioDevice) Resume ¶
func (d *AudioDevice) Resume() error
Resume resumes audio playback on the device.
func (*AudioDevice) SetGain ¶
func (d *AudioDevice) SetGain(gain float32) error
SetGain sets the gain of the audio device.
type AudioDeviceEvent ¶
type AudioDeviceEvent struct {
Type uint32
Timestamp uint64
Which uint32
Recording uint8
Padding1 uint8
Padding2 uint8
Padding3 uint8
}
AudioDeviceEvent represents audio device connection/disconnection event
type AudioSpec ¶
AudioSpec represents audio format specification
func GetAudioDeviceFormat ¶
GetAudioDeviceFormat gets the preferred audio format of a specific audio device.
type AudioStream ¶
type AudioStream struct {
// contains filtered or unexported fields
}
AudioStream represents an audio stream
func CreateAudioStream ¶
func CreateAudioStream(srcSpec, dstSpec *AudioSpec) (*AudioStream, error)
CreateAudioStream creates a new audio stream.
func (*AudioStream) BindToDevice ¶
func (s *AudioStream) BindToDevice(deviceID uint32) error
BindToDevice binds an audio stream to an audio device.
func (*AudioStream) Clear ¶
func (s *AudioStream) Clear() error
Clear clears any pending data in the stream.
func (*AudioStream) Flush ¶
func (s *AudioStream) Flush() error
Flush tells the stream that you're done sending data.
func (*AudioStream) GetAvailable ¶
func (s *AudioStream) GetAvailable() int32
GetAvailable gets the number of converted/resampled bytes available.
func (*AudioStream) GetBinding ¶
func (s *AudioStream) GetBinding() uint32
GetBinding gets the audio device bound to an audio stream.
func (*AudioStream) GetFormat ¶
func (s *AudioStream) GetFormat() (srcSpec, dstSpec AudioSpec, err error)
GetFormat gets the format of an audio stream.
func (*AudioStream) GetFrequencyRatio ¶
func (s *AudioStream) GetFrequencyRatio() float32
GetFrequencyRatio gets the frequency ratio of an audio stream.
func (*AudioStream) GetGain ¶
func (s *AudioStream) GetGain() float32
GetGain gets the gain of an audio stream.
func (*AudioStream) GetQueued ¶
func (s *AudioStream) GetQueued() int32
GetQueued gets the number of bytes currently queued.
func (*AudioStream) Lock ¶
func (s *AudioStream) Lock() error
Lock locks an audio stream for serialized access.
func (*AudioStream) PutData ¶
func (s *AudioStream) PutData(buf unsafe.Pointer, length int32) error
PutData adds data to be converted/resampled to the stream.
func (*AudioStream) SetFormat ¶
func (s *AudioStream) SetFormat(srcSpec, dstSpec *AudioSpec) error
SetFormat sets the format of an audio stream.
func (*AudioStream) SetFrequencyRatio ¶
func (s *AudioStream) SetFrequencyRatio(ratio float32) error
SetFrequencyRatio sets the frequency ratio of an audio stream.
func (*AudioStream) SetGain ¶
func (s *AudioStream) SetGain(gain float32) error
SetGain sets the gain of an audio stream.
func (*AudioStream) Unbind ¶
func (s *AudioStream) Unbind()
Unbind unbinds an audio stream from its audio device.
func (*AudioStream) Unlock ¶
func (s *AudioStream) Unlock() error
Unlock unlocks an audio stream for serialized access.
type BlendMode ¶
type BlendMode uint32
BlendMode represents different blending modes for rendering operations
const ( // Pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) BLENDMODE_BLEND_PREMULTIPLIED BlendMode = 0x00000010 // Pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA BLENDMODE_ADD_PREMULTIPLIED BlendMode = 0x00000020 )
Note: Basic BLENDMODE_ constants already defined in renderer.go - BlendMode type provided here for type safety Additional blend modes for advanced rendering
type Display ¶
Display represents display information
func GetDisplays ¶
GetDisplays returns information about available displays.
type DisplayMode ¶
type DisplayMode struct {
DisplayID uint32
Format uint32
W int32
H int32
PixelDensity float32
RefreshRate float32
}
DisplayMode represents a display mode
type DropEvent ¶
type DropEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
X float32
Y float32
Source *byte
Data *byte
}
DropEvent represents file drop event
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an SDL error
type Event ¶
Event represents an SDL event
func PollEventMinimal ¶
func PollEventMinimal() *Event
func WaitEventTimeout ¶
WaitEventTimeout waits until the specified timeout for the next available event.
func (*Event) AsAudioDeviceEvent ¶
func (e *Event) AsAudioDeviceEvent() *AudioDeviceEvent
AsAudioDeviceEvent converts the event to an AudioDeviceEvent.
func (*Event) AsDropEvent ¶
AsDropEvent converts the event to a DropEvent.
func (*Event) AsGamepadAxisEvent ¶
func (e *Event) AsGamepadAxisEvent() *GamepadAxisEvent
AsGamepadAxisEvent converts the event to a GamepadAxisEvent.
func (*Event) AsGamepadButtonEvent ¶
func (e *Event) AsGamepadButtonEvent() *GamepadButtonEvent
AsGamepadButtonEvent converts the event to a GamepadButtonEvent.
func (*Event) AsGamepadDeviceEvent ¶
func (e *Event) AsGamepadDeviceEvent() *GamepadDeviceEvent
AsGamepadDeviceEvent converts the event to a GamepadDeviceEvent.
func (*Event) AsJoyAxisEvent ¶
func (e *Event) AsJoyAxisEvent() *JoyAxisEvent
AsJoyAxisEvent converts the event to a JoyAxisEvent.
func (*Event) AsJoyBallEvent ¶
func (e *Event) AsJoyBallEvent() *JoyBallEvent
AsJoyBallEvent converts the event to a JoyBallEvent.
func (*Event) AsJoyButtonEvent ¶
func (e *Event) AsJoyButtonEvent() *JoyButtonEvent
AsJoyButtonEvent converts the event to a JoyButtonEvent.
func (*Event) AsJoyDeviceEvent ¶
func (e *Event) AsJoyDeviceEvent() *JoyDeviceEvent
AsJoyDeviceEvent converts the event to a JoyDeviceEvent.
func (*Event) AsJoyHatEvent ¶
func (e *Event) AsJoyHatEvent() *JoyHatEvent
AsJoyHatEvent converts the event to a JoyHatEvent.
func (*Event) AsKeyboardEvent ¶
func (e *Event) AsKeyboardEvent() *KeyboardEvent
AsKeyboardEvent converts the event to a KeyboardEvent.
func (*Event) AsMouseButtonEvent ¶
func (e *Event) AsMouseButtonEvent() *MouseButtonEvent
AsMouseButtonEvent converts the event to a MouseButtonEvent.
func (*Event) AsMouseMotionEvent ¶
func (e *Event) AsMouseMotionEvent() *MouseMotionEvent
AsMouseMotionEvent converts the event to a MouseMotionEvent.
func (*Event) AsMouseWheelEvent ¶
func (e *Event) AsMouseWheelEvent() *MouseWheelEvent
AsMouseWheelEvent converts the event to a MouseWheelEvent.
func (*Event) AsQuitEvent ¶
AsQuitEvent converts the event to a QuitEvent.
func (*Event) AsSensorEvent ¶
func (e *Event) AsSensorEvent() *SensorEvent
AsSensorEvent converts the event to a SensorEvent.
func (*Event) AsTextEditingEvent ¶
func (e *Event) AsTextEditingEvent() *TextEditingEvent
AsTextEditingEvent converts the event to a TextEditingEvent.
func (*Event) AsTextInputEvent ¶
func (e *Event) AsTextInputEvent() *TextInputEvent
AsTextInputEvent converts the event to a TextInputEvent.
func (*Event) AsTouchFingerEvent ¶
func (e *Event) AsTouchFingerEvent() *TouchFingerEvent
AsTouchFingerEvent converts the event to a TouchFingerEvent.
func (*Event) AsUserEvent ¶
AsUserEvent converts the event to a UserEvent.
func (*Event) AsWindowEvent ¶
func (e *Event) AsWindowEvent() *WindowEvent
AsWindowEvent converts the event to a WindowEvent.
func (*Event) GetTimestamp ¶
GetTimestamp returns the event timestamp.
type EventFilter ¶
Event filter function type
type EventWatchFunc ¶
Event watch function type
type GamepadAxisEvent ¶
type GamepadAxisEvent struct {
Type uint32
Timestamp uint64
Which uint32
Axis uint8
Padding1 uint8
Padding2 uint8
Padding3 uint8
Value int16
Padding4 uint16
}
GamepadAxisEvent represents gamepad axis motion event
type GamepadButtonEvent ¶
type GamepadButtonEvent struct {
Type uint32
Timestamp uint64
Which uint32
Button uint8
State uint8
Padding1 uint8
Padding2 uint8
}
GamepadButtonEvent represents gamepad button press or release event
type GamepadDeviceEvent ¶
GamepadDeviceEvent represents gamepad device connection/disconnection event
type IOStream ¶
type IOStream struct {
// contains filtered or unexported fields
}
IOStream represents an SDL I/O stream
func IOFromConstMemory ¶
IOFromConstMemory creates a read-only I/O stream from memory.
func IOFromDynamicMemory ¶
IOFromDynamicMemory creates an I/O stream from dynamic memory.
func IOFromFile ¶
IOFromFile creates an I/O stream from a file path.
func IOFromMemory ¶
IOFromMemory creates an I/O stream from memory.
func (*IOStream) WriteS16BE ¶
WriteS16BE writes a signed 16-bit big-endian value.
func (*IOStream) WriteS16LE ¶
WriteS16LE writes a signed 16-bit little-endian value.
func (*IOStream) WriteS32BE ¶
WriteS32BE writes a signed 32-bit big-endian value.
func (*IOStream) WriteS32LE ¶
WriteS32LE writes a signed 32-bit little-endian value.
func (*IOStream) WriteS64BE ¶
WriteS64BE writes a signed 64-bit big-endian value.
func (*IOStream) WriteS64LE ¶
WriteS64LE writes a signed 64-bit little-endian value.
func (*IOStream) WriteU16BE ¶
WriteU16BE writes an unsigned 16-bit big-endian value.
func (*IOStream) WriteU16LE ¶
WriteU16LE writes an unsigned 16-bit little-endian value.
func (*IOStream) WriteU32BE ¶
WriteU32BE writes an unsigned 32-bit big-endian value.
func (*IOStream) WriteU32LE ¶
WriteU32LE writes an unsigned 32-bit little-endian value.
func (*IOStream) WriteU64BE ¶
WriteU64BE writes an unsigned 64-bit big-endian value.
func (*IOStream) WriteU64LE ¶
WriteU64LE writes an unsigned 64-bit little-endian value.
type JoyAxisEvent ¶
type JoyAxisEvent struct {
Type uint32
Timestamp uint64
Which uint32
Axis uint8
Padding1 uint8
Padding2 uint8
Padding3 uint8
Value int16
Padding4 uint16
}
JoyAxisEvent represents joystick axis motion event
type JoyBallEvent ¶
type JoyBallEvent struct {
Type uint32
Timestamp uint64
Which uint32
Ball uint8
Padding1 uint8
Padding2 uint8
Padding3 uint8
XRel int16
YRel int16
}
JoyBallEvent represents joystick ball motion event
type JoyButtonEvent ¶
type JoyButtonEvent struct {
Type uint32
Timestamp uint64
Which uint32
Button uint8
State uint8
Padding1 uint8
Padding2 uint8
}
JoyButtonEvent represents joystick button press or release event
type JoyDeviceEvent ¶
JoyDeviceEvent represents joystick device connection/disconnection event
type JoyHatEvent ¶
type JoyHatEvent struct {
Type uint32
Timestamp uint64
Which uint32
Hat uint8
Value uint8
Padding1 uint8
Padding2 uint8
}
JoyHatEvent represents joystick hat position change event
type KeyboardEvent ¶
type KeyboardEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Which uint32
State uint8
Repeat uint8
Padding2 uint8
Padding3 uint8
Keysym Keysym
}
KeyboardEvent represents a keyboard key press or release event
type Keymod ¶
type Keymod uint16
Keymod represents key modifier flags
const ( KMOD_NONE Keymod = 0x0000 KMOD_LSHIFT Keymod = 0x0001 KMOD_RSHIFT Keymod = 0x0002 KMOD_LCTRL Keymod = 0x0040 KMOD_RCTRL Keymod = 0x0080 KMOD_LALT Keymod = 0x0100 KMOD_RALT Keymod = 0x0200 KMOD_LGUI Keymod = 0x0400 KMOD_RGUI Keymod = 0x0800 KMOD_NUM Keymod = 0x1000 KMOD_CAPS Keymod = 0x2000 KMOD_MODE Keymod = 0x4000 KMOD_SCROLL Keymod = 0x8000 // Convenience constants KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT KMOD_ALT = KMOD_LALT | KMOD_RALT KMOD_GUI = KMOD_LGUI | KMOD_RGUI )
type MouseButtonEvent ¶
type MouseButtonEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Which uint32
Button uint8
State uint8
Clicks uint8
Padding uint8
X float32
Y float32
}
MouseButtonEvent represents mouse button press or release event
type MouseMotionEvent ¶
type MouseMotionEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Which uint32
State uint32
X float32
Y float32
XRel float32
YRel float32
}
MouseMotionEvent represents mouse motion event
type MouseWheelEvent ¶
type MouseWheelEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Which uint32
X float32
Y float32
Direction uint32
MouseX float32
MouseY float32
}
MouseWheelEvent represents mouse wheel event
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer represents an SDL renderer
func CreateRenderer ¶
CreateRenderer creates a 2D rendering context for a window.
func CreateRendererMinimal ¶
func (*Renderer) ClearMinimal ¶
func (*Renderer) CreateTexture ¶
CreateTexture creates a texture for a rendering context.
func (*Renderer) DrawRectMinimal ¶
func (*Renderer) FillRect ¶
FillRect fills a rectangle on the current rendering target with the drawing color.
func (*Renderer) FillRectMinimal ¶
func (*Renderer) GetBlendMode ¶
GetBlendMode gets the blend mode used for drawing operations.
func (*Renderer) GetDrawColor ¶
GetDrawColor gets the color used for drawing operations.
func (*Renderer) GetOutputSize ¶
GetOutputSize returns the output size in pixels of a rendering context.
func (*Renderer) Present ¶
Present updates the screen with any rendering performed since the previous call.
func (*Renderer) PresentMinimal ¶
func (*Renderer) SetBlendMode ¶
SetBlendMode sets the blend mode used for drawing operations.
func (*Renderer) SetDrawColor ¶
SetDrawColor sets the color used for drawing operations.
func (*Renderer) SetDrawColorFloat ¶
SetDrawColorFloat sets the color used for drawing operations (floating point).
func (*Renderer) SetDrawColorMinimal ¶
type Scancode ¶
type Scancode uint32
Scancode represents a physical key position on the keyboard Based on the USB keyboard usage page standard
const ( // Unknown scancode SCANCODE_UNKNOWN Scancode = 0 // Letters (A-Z) - based on USB HID usage page SCANCODE_A Scancode = 4 SCANCODE_B Scancode = 5 SCANCODE_C Scancode = 6 SCANCODE_D Scancode = 7 SCANCODE_E Scancode = 8 SCANCODE_F Scancode = 9 SCANCODE_G Scancode = 10 SCANCODE_H Scancode = 11 SCANCODE_I Scancode = 12 SCANCODE_J Scancode = 13 SCANCODE_K Scancode = 14 SCANCODE_L Scancode = 15 SCANCODE_M Scancode = 16 SCANCODE_N Scancode = 17 SCANCODE_O Scancode = 18 SCANCODE_P Scancode = 19 SCANCODE_Q Scancode = 20 SCANCODE_R Scancode = 21 SCANCODE_S Scancode = 22 SCANCODE_T Scancode = 23 SCANCODE_U Scancode = 24 SCANCODE_V Scancode = 25 SCANCODE_W Scancode = 26 SCANCODE_X Scancode = 27 SCANCODE_Y Scancode = 28 SCANCODE_Z Scancode = 29 // Numbers (1-0) SCANCODE_1 Scancode = 30 SCANCODE_2 Scancode = 31 SCANCODE_3 Scancode = 32 SCANCODE_4 Scancode = 33 SCANCODE_5 Scancode = 34 SCANCODE_6 Scancode = 35 SCANCODE_7 Scancode = 36 SCANCODE_8 Scancode = 37 SCANCODE_9 Scancode = 38 SCANCODE_0 Scancode = 39 // Common keys SCANCODE_RETURN Scancode = 40 SCANCODE_ESCAPE Scancode = 41 SCANCODE_BACKSPACE Scancode = 42 SCANCODE_TAB Scancode = 43 SCANCODE_SPACE Scancode = 44 // Punctuation SCANCODE_MINUS Scancode = 45 SCANCODE_EQUALS Scancode = 46 SCANCODE_LEFTBRACKET Scancode = 47 SCANCODE_RIGHTBRACKET Scancode = 48 SCANCODE_BACKSLASH Scancode = 49 SCANCODE_NONUSHASH Scancode = 50 // ISO USB keyboards have \| key SCANCODE_SEMICOLON Scancode = 51 SCANCODE_APOSTROPHE Scancode = 52 SCANCODE_GRAVE Scancode = 53 // Located in the top left corner (grave accent and tilde) SCANCODE_COMMA Scancode = 54 SCANCODE_PERIOD Scancode = 55 SCANCODE_SLASH Scancode = 56 // Lock keys SCANCODE_CAPSLOCK Scancode = 57 // Function keys (F1-F24) SCANCODE_F1 Scancode = 58 SCANCODE_F2 Scancode = 59 SCANCODE_F3 Scancode = 60 SCANCODE_F4 Scancode = 61 SCANCODE_F5 Scancode = 62 SCANCODE_F6 Scancode = 63 SCANCODE_F7 Scancode = 64 SCANCODE_F8 Scancode = 65 SCANCODE_F9 Scancode = 66 SCANCODE_F10 Scancode = 67 SCANCODE_F11 Scancode = 68 SCANCODE_F12 Scancode = 69 // Screen control keys SCANCODE_PRINTSCREEN Scancode = 70 SCANCODE_SCROLLLOCK Scancode = 71 SCANCODE_PAUSE Scancode = 72 // Navigation cluster SCANCODE_INSERT Scancode = 73 SCANCODE_HOME Scancode = 74 SCANCODE_PAGEUP Scancode = 75 SCANCODE_DELETE Scancode = 76 SCANCODE_END Scancode = 77 SCANCODE_PAGEDOWN Scancode = 78 // Arrow keys (critical for games) SCANCODE_RIGHT Scancode = 79 SCANCODE_LEFT Scancode = 80 SCANCODE_DOWN Scancode = 81 SCANCODE_UP Scancode = 82 // Keypad SCANCODE_NUMLOCKCLEAR Scancode = 83 // NumLock on PC, Clear on Mac SCANCODE_KP_DIVIDE Scancode = 84 SCANCODE_KP_MULTIPLY Scancode = 85 SCANCODE_KP_MINUS Scancode = 86 SCANCODE_KP_PLUS Scancode = 87 SCANCODE_KP_ENTER Scancode = 88 SCANCODE_KP_1 Scancode = 89 SCANCODE_KP_2 Scancode = 90 SCANCODE_KP_3 Scancode = 91 SCANCODE_KP_4 Scancode = 92 SCANCODE_KP_5 Scancode = 93 SCANCODE_KP_6 Scancode = 94 SCANCODE_KP_7 Scancode = 95 SCANCODE_KP_8 Scancode = 96 SCANCODE_KP_9 Scancode = 97 SCANCODE_KP_0 Scancode = 98 SCANCODE_KP_PERIOD Scancode = 99 // International keys SCANCODE_NONUSBACKSLASH Scancode = 100 // This is the additional key that ISO keyboards have over ANSI SCANCODE_APPLICATION Scancode = 101 // Windows contextual menu, compose SCANCODE_POWER Scancode = 102 // The USB document says this is a status flag, not a physical key // Keypad equals SCANCODE_KP_EQUALS Scancode = 103 // Extended function keys SCANCODE_F13 Scancode = 104 SCANCODE_F14 Scancode = 105 SCANCODE_F15 Scancode = 106 SCANCODE_F16 Scancode = 107 SCANCODE_F17 Scancode = 108 SCANCODE_F18 Scancode = 109 SCANCODE_F19 Scancode = 110 SCANCODE_F20 Scancode = 111 SCANCODE_F21 Scancode = 112 SCANCODE_F22 Scancode = 113 SCANCODE_F23 Scancode = 114 SCANCODE_F24 Scancode = 115 // Additional keys SCANCODE_EXECUTE Scancode = 116 SCANCODE_HELP Scancode = 117 SCANCODE_MENU Scancode = 118 SCANCODE_SELECT Scancode = 119 SCANCODE_STOP Scancode = 120 SCANCODE_AGAIN Scancode = 121 // Redo SCANCODE_UNDO Scancode = 122 SCANCODE_CUT Scancode = 123 SCANCODE_COPY Scancode = 124 SCANCODE_PASTE Scancode = 125 SCANCODE_FIND Scancode = 126 SCANCODE_MUTE Scancode = 127 SCANCODE_VOLUMEUP Scancode = 128 SCANCODE_VOLUMEDOWN Scancode = 129 SCANCODE_KP_COMMA Scancode = 133 SCANCODE_KP_EQUALSAS400 Scancode = 134 // International keys 2 SCANCODE_INTERNATIONAL1 Scancode = 135 SCANCODE_INTERNATIONAL2 Scancode = 136 SCANCODE_INTERNATIONAL3 Scancode = 137 // Yen SCANCODE_INTERNATIONAL4 Scancode = 138 SCANCODE_INTERNATIONAL5 Scancode = 139 SCANCODE_INTERNATIONAL6 Scancode = 140 SCANCODE_INTERNATIONAL7 Scancode = 141 SCANCODE_INTERNATIONAL8 Scancode = 142 SCANCODE_INTERNATIONAL9 Scancode = 143 // Language keys SCANCODE_LANG1 Scancode = 144 // Hangul/English toggle SCANCODE_LANG2 Scancode = 145 // Hanja conversion SCANCODE_LANG3 Scancode = 146 // Katakana SCANCODE_LANG4 Scancode = 147 // Hiragana SCANCODE_LANG5 Scancode = 148 // Zenkaku/Hankaku SCANCODE_LANG6 Scancode = 149 SCANCODE_LANG7 Scancode = 150 SCANCODE_LANG8 Scancode = 151 SCANCODE_LANG9 Scancode = 152 // Modifier keys - Left side SCANCODE_LCTRL Scancode = 224 SCANCODE_LSHIFT Scancode = 225 SCANCODE_LALT Scancode = 226 SCANCODE_LGUI Scancode = 227 // Windows/Cmd key // Modifier keys - Right side SCANCODE_RCTRL Scancode = 228 SCANCODE_RSHIFT Scancode = 229 SCANCODE_RALT Scancode = 230 // Alt Gr key SCANCODE_RGUI Scancode = 231 // Windows/Cmd key // Mobile phone keys SCANCODE_MODE Scancode = 257 // ModeSwitch key SCANCODE_SLEEP Scancode = 258 SCANCODE_WAKE Scancode = 259 SCANCODE_CHANNEL_INCREMENT Scancode = 260 SCANCODE_CHANNEL_DECREMENT Scancode = 261 // Media keys SCANCODE_MEDIA_PLAY Scancode = 262 SCANCODE_MEDIA_PAUSE Scancode = 263 SCANCODE_MEDIA_RECORD Scancode = 264 SCANCODE_MEDIA_FAST_FORWARD Scancode = 265 SCANCODE_MEDIA_REWIND Scancode = 266 SCANCODE_MEDIA_NEXT_TRACK Scancode = 267 SCANCODE_MEDIA_PREVIOUS_TRACK Scancode = 268 SCANCODE_MEDIA_STOP Scancode = 269 SCANCODE_MEDIA_EJECT Scancode = 270 // Phone keys SCANCODE_SOFTLEFT Scancode = 287 // Usually situated below the display on phones SCANCODE_SOFTRIGHT Scancode = 288 SCANCODE_CALL Scancode = 289 // The "Answer" key SCANCODE_ENDCALL Scancode = 290 // The "Hang up" key // Reserved range for dynamic keycodes SCANCODE_RESERVED Scancode = 400 // Scancode count (for array bounds) SCANCODE_COUNT Scancode = 512 )
func (Scancode) IsArrowKey ¶
IsArrowKey returns true if the scancode represents an arrow key
func (Scancode) IsFunctionKey ¶
IsFunctionKey returns true if the scancode represents a function key
func (Scancode) IsModifier ¶
IsModifier returns true if the scancode represents a modifier key
func (Scancode) IsPrintable ¶
IsPrintable returns true if the scancode represents a printable character
type SensorEvent ¶
type SensorEvent struct {
Type uint32
Timestamp uint64
Which int32
Data [6]float32
Timestamp_us uint64
}
SensorEvent represents sensor update event
type Surface ¶
type Surface struct {
// contains filtered or unexported fields
}
Surface represents an SDL surface
type TextEditingEvent ¶
type TextEditingEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Text [32]byte
Start int32
Length int32
}
TextEditingEvent represents keyboard text editing event
func (*TextEditingEvent) GetText ¶
func (t *TextEditingEvent) GetText() string
Helper methods for TextEditingEvent
type TextInputEvent ¶
TextInputEvent represents keyboard text input event
func (*TextInputEvent) GetText ¶
func (t *TextInputEvent) GetText() string
Helper methods for TextInputEvent
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents an SDL texture
func (*Texture) GetAlphaMod ¶
GetAlphaMod gets the additional alpha value multiplied into render copy operations.
func (*Texture) GetBlendMode ¶
GetBlendMode gets the blend mode for a texture.
func (*Texture) GetColorMod ¶
GetColorMod gets the additional color value multiplied into render copy operations.
func (*Texture) SetAlphaMod ¶
SetAlphaMod sets an additional alpha value multiplied into render copy operations.
func (*Texture) SetBlendMode ¶
SetBlendMode sets the blend mode for a texture.
func (*Texture) SetColorMod ¶
SetColorMod sets an additional color value multiplied into render copy operations.
type TouchFingerEvent ¶
type TouchFingerEvent struct {
Type uint32
Timestamp uint64
TouchID int64
FingerID int64
X float32
Y float32
DX float32
DY float32
Pressure float32
WindowID uint32
}
TouchFingerEvent represents touch finger motion event
type UserEvent ¶
type UserEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Code int32
Data1 unsafe.Pointer
Data2 unsafe.Pointer
}
UserEvent represents user-defined event
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents an SDL window
func CreateWindow ¶
CreateWindow creates a window with the specified dimensions and flags.
func CreateWindowMinimal ¶
Minimal versions of the functions for the demo
func GetGrabbedWindow ¶
func GetGrabbedWindow() *Window
GetGrabbedWindow returns the window that currently has grabbed input.
func GetWindowFromEvent ¶
GetWindowFromEvent gets the window associated with an event.
func GetWindowFromID ¶
GetWindowFromID returns the window associated with an ID.
func (*Window) CreateRenderer ¶
CreateRenderer creates a renderer for the window using the best available rendering driver.
func (*Window) CreateRendererWithDriver ¶
CreateRendererWithDriver creates a renderer for the window using the specified driver.
func (*Window) FlashBriefly ¶
FlashBriefly flashes the window briefly to get attention.
func (*Window) FlashUntilFocused ¶
FlashUntilFocused flashes the window until it receives focus.
func (*Window) GetKeyboardGrab ¶
GetKeyboardGrab returns the window's keyboard grab mode.
func (*Window) GetMaximumSize ¶
GetMaximumSize returns the maximum size of the window.
func (*Window) GetMinimumSize ¶
GetMinimumSize returns the minimum size of the window.
func (*Window) GetMouseGrab ¶
GetMouseGrab returns the window's mouse grab mode.
func (*Window) GetOpacity ¶
GetOpacity returns the window's opacity.
func (*Window) GetPosition ¶
GetPosition returns the window's position.
func (*Window) GetSizeInPixels ¶
GetSizeInPixels returns the window's size in pixels.
func (*Window) SetAlwaysOnTop ¶
SetAlwaysOnTop sets whether the window should always be on top.
func (*Window) SetBordered ¶
SetBordered sets whether the window has a border.
func (*Window) SetFullscreen ¶
SetFullscreen sets the window's fullscreen state.
func (*Window) SetInputFocus ¶
SetInputFocus explicitly sets input focus to this window.
func (*Window) SetKeyboardGrab ¶
SetKeyboardGrab sets the window's keyboard grab mode.
func (*Window) SetMaximumSize ¶
SetMaximumSize sets the maximum size of the window.
func (*Window) SetMinimumSize ¶
SetMinimumSize sets the minimum size of the window.
func (*Window) SetModalFor ¶
SetModalFor makes this window a modal dialog for another window.
func (*Window) SetMouseGrab ¶
SetMouseGrab sets the window's mouse grab mode.
func (*Window) SetOpacity ¶
SetOpacity sets the window's opacity.
func (*Window) SetPosition ¶
SetPosition sets the window's position.
func (*Window) SetResizable ¶
SetResizable sets whether the window is resizable.
func (*Window) StopFlashing ¶
StopFlashing stops the window from flashing.
type WindowEvent ¶
type WindowEvent struct {
Type uint32
Timestamp uint64
WindowID uint32
Event int32
Data1 int32
Data2 int32
}
WindowEvent represents a window state change event
type WindowFlags ¶
type WindowFlags uint64
WindowFlags represents window creation and state flags
func (WindowFlags) HasFlag ¶
func (f WindowFlags) HasFlag(flag WindowFlags) bool
HasFlag checks if a window has a specific flag set