raylib

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_NULL = 0 // Key: NULL, used for no key pressed

	// Alphanumeric keys
	KEY_APOSTROPHE    = 39 // Key: '
	KEY_COMMA         = 44 // Key: ,
	KEY_MINUS         = 45 // Key: -
	KEY_PERIOD        = 46 // Key: .
	KEY_SLASH         = 47 // Key: /
	KEY_ZERO          = 48 // Key: 0
	KEY_ONE           = 49 // Key: 1
	KEY_TWO           = 50 // Key: 2
	KEY_THREE         = 51 // Key: 3
	KEY_FOUR          = 52 // Key: 4
	KEY_FIVE          = 53 // Key: 5
	KEY_SIX           = 54 // Key: 6
	KEY_SEVEN         = 55 // Key: 7
	KEY_EIGHT         = 56 // Key: 8
	KEY_NINE          = 57 // Key: 9
	KEY_SEMICOLON     = 59 // Key: ;
	KEY_EQUAL         = 61 // Key: =
	KEY_A             = 65 // Key: A | a
	KEY_B             = 66 // Key: B | b
	KEY_C             = 67 // Key: C | c
	KEY_D             = 68 // Key: D | d
	KEY_E             = 69 // Key: E | e
	KEY_F             = 70 // Key: F | f
	KEY_G             = 71 // Key: G | g
	KEY_H             = 72 // Key: H | h
	KEY_I             = 73 // Key: I | i
	KEY_J             = 74 // Key: J | j
	KEY_K             = 75 // Key: K | k
	KEY_L             = 76 // Key: L | l
	KEY_M             = 77 // Key: M | m
	KEY_N             = 78 // Key: N | n
	KEY_O             = 79 // Key: O | o
	KEY_P             = 80 // Key: P | p
	KEY_Q             = 81 // Key: Q | q
	KEY_R             = 82 // Key: R | r
	KEY_S             = 83 // Key: S | s
	KEY_T             = 84 // Key: T | t
	KEY_U             = 85 // Key: U | u
	KEY_V             = 86 // Key: V | v
	KEY_W             = 87 // Key: W | w
	KEY_X             = 88 // Key: X | x
	KEY_Y             = 89 // Key: Y | y
	KEY_Z             = 90 // Key: Z | z
	KEY_LEFT_BRACKET  = 91 // Key: [
	KEY_BACKSLASH     = 92 // Key: '\'
	KEY_RIGHT_BRACKET = 93 // Key: ]
	KEY_GRAVE         = 96 // Key: `

	// Function keys
	KEY_SPACE         = 32  // Key: Space
	KEY_ESCAPE        = 256 // Key: Esc
	KEY_ENTER         = 257 // Key: Enter
	KEY_TAB           = 258 // Key: Tab
	KEY_BACKSPACE     = 259 // Key: Backspace
	KEY_INSERT        = 260 // Key: Ins
	KEY_DELETE        = 261 // Key: Del
	KEY_RIGHT         = 262 // Key: Cursor right
	KEY_LEFT          = 263 // Key: Cursor left
	KEY_DOWN          = 264 // Key: Cursor down
	KEY_UP            = 265 // Key: Cursor up
	KEY_PAGE_UP       = 266 // Key: Page up
	KEY_PAGE_DOWN     = 267 // Key: Page down
	KEY_HOME          = 268 // Key: Home
	KEY_END           = 269 // Key: End
	KEY_CAPS_LOCK     = 280 // Key: Caps lock
	KEY_SCROLL_LOCK   = 281 // Key: Scroll down
	KEY_NUM_LOCK      = 282 // Key: Num lock
	KEY_PRINT_SCREEN  = 283 // Key: Print screen
	KEY_PAUSE         = 284 // Key: Pause
	KEY_F1            = 290 // Key: F1
	KEY_F2            = 291 // Key: F2
	KEY_F3            = 292 // Key: F3
	KEY_F4            = 293 // Key: F4
	KEY_F5            = 294 // Key: F5
	KEY_F6            = 295 // Key: F6
	KEY_F7            = 296 // Key: F7
	KEY_F8            = 297 // Key: F8
	KEY_F9            = 298 // Key: F9
	KEY_F10           = 299 // Key: F10
	KEY_F11           = 300 // Key: F11
	KEY_F12           = 301 // Key: F12
	KEY_LEFT_SHIFT    = 340 // Key: Shift left
	KEY_LEFT_CONTROL  = 341 // Key: Control left
	KEY_LEFT_ALT      = 342 // Key: Alt left
	KEY_LEFT_SUPER    = 343 // Key: Super left
	KEY_RIGHT_SHIFT   = 344 // Key: Shift right
	KEY_RIGHT_CONTROL = 345 // Key: Control right
	KEY_RIGHT_ALT     = 346 // Key: Alt right
	KEY_RIGHT_SUPER   = 347 // Key: Super right
	KEY_KB_MENU       = 348 // Key: KB menu

	// Keypad keys
	KEY_KP_0        = 320 // Key: Keypad 0
	KEY_KP_1        = 321 // Key: Keypad 1
	KEY_KP_2        = 322 // Key: Keypad 2
	KEY_KP_3        = 323 // Key: Keypad 3
	KEY_KP_4        = 324 // Key: Keypad 4
	KEY_KP_5        = 325 // Key: Keypad 5
	KEY_KP_6        = 326 // Key: Keypad 6
	KEY_KP_7        = 327 // Key: Keypad 7
	KEY_KP_8        = 328 // Key: Keypad 8
	KEY_KP_9        = 329 // Key: Keypad 9
	KEY_KP_DECIMAL  = 330 // Key: Keypad .
	KEY_KP_DIVIDE   = 331 // Key: Keypad /
	KEY_KP_MULTIPLY = 332 // Key: Keypad *
	KEY_KP_SUBTRACT = 333 // Key: Keypad -
	KEY_KP_ADD      = 334 // Key: Keypad +
	KEY_KP_ENTER    = 335 // Key: Keypad Enter
	KEY_KP_EQUAL    = 336 // Key: Keypad =

	// Android key buttons
	KEY_BACK        = 4  // Key: Android back button
	KEY_MENU        = 82 // Key: Android menu button
	KEY_VOLUME_UP   = 24 // Key: Android volume up button
	KEY_VOLUME_DOWN = 25 // Key: Android volume down button
)

Keyboard keys (US keyboard layout) required keys for alternative layouts

View Source
const (
	LIGHTGRAY = Color(200 | 200<<8 | 200<<16 | 255<<24) // Light Gray
	GRAY      = Color(130 | 130<<8 | 130<<16 | 255<<24) // Gray
	DARKGRAY  = Color(80 | 80<<8 | 80<<16 | 255<<24)    // Dark Gray
	YELLOW    = Color(253 | 249<<8 | 0<<16 | 255<<24)   // Yellow
	GOLD      = Color(255 | 203<<8 | 0<<16 | 255<<24)   // Gold
	ORANGE    = Color(255 | 161<<8 | 0<<16 | 255<<24)   // Orange
	PINK      = Color(255 | 109<<8 | 194<<16 | 255<<24) // Pink
	RED       = Color(230 | 41<<8 | 55<<16 | 255<<24)   // Red
	MAROON    = Color(190 | 33<<8 | 55<<16 | 255<<24)   // Maroon
	GREEN     = Color(0 | 228<<8 | 48<<16 | 255<<24)    // Green
	LIME      = Color(0 | 158<<8 | 47<<16 | 255<<24)    // Lime
	DARKGREEN = Color(0 | 117<<8 | 44<<16 | 255<<24)    // Dark Green
	SKYBLUE   = Color(102 | 191<<8 | 255<<16 | 255<<24) // Sky Blue
	BLUE      = Color(0 | 121<<8 | 241<<16 | 255<<24)   // Blue

	DARKBLUE   = Color(0 | 82<<8 | 172<<16 | 255<<24)    // Dark Blue
	PURPLE     = Color(200 | 122<<8 | 255<<16 | 255<<24) // Purple
	VIOLET     = Color(135 | 60<<8 | 190<<16 | 255<<24)  // Violet
	DARKPURPLE = Color(112 | 31<<8 | 126<<16 | 255<<24)  // Dark Purple
	BEIGE      = Color(211 | 176<<8 | 131<<16 | 255<<24) // Beige
	BROWN      = Color(127 | 106<<8 | 79<<16 | 255<<24)  // Brown
	DARKBROWN  = Color(76 | 63<<8 | 47<<16 | 255<<24)    // Dark Brown

	WHITE    = Color(255 | 255<<8 | 255<<16 | 255<<24) // White
	BLACK    = Color(0 | 0<<8 | 0<<16 | 255<<24)       // Black
	BLANK    = Color(0 | 0<<8 | 0<<16 | 0<<24)         // Blank (Transparent)
	MAGENTA  = Color(255 | 0<<8 | 255<<16 | 255<<24)   // Magenta
	RAYWHITE = Color(245 | 245<<8 | 245<<16 | 255<<24) // My own White (raylib logo)
)
View Source
const (
	LLGoPackage = "link: $(pkg-config --libs raylib); -lraylib"
)

Variables

This section is empty.

Functions

func BeginBlendMode

func BeginBlendMode(mode BlendMode)

Begin blending mode (alpha, additive, multiplied, subtract, custom)

func BeginDrawing

func BeginDrawing()

Begin drawing (call before drawing anything)

func BeginMode2D

func BeginMode2D(camera Camera2D)

Begin 2D mode with custom camera (2D)

func BeginMode3D

func BeginMode3D(camera Camera3D)

Begin 3D mode with custom camera (3D)

func BeginScissorMode

func BeginScissorMode(x, y, width, height c.Int)

Begin scissor mode (define screen area for following drawing)

func BeginShaderMode

func BeginShaderMode(shader Shader)

Begin custom shader drawing

func ClearBackground

func ClearBackground(color Color)

Set background color (framebuffer clear color)

func ClearWindowState

func ClearWindowState(flags c.Int)

func CloseWindow

func CloseWindow()

func DirectoryExists

func DirectoryExists(dirPath *c.Char) bool

Check if a directory path exists

func DisableCursor

func DisableCursor()

func DisableEventWaiting

func DisableEventWaiting()

Disable waiting for events on EndDrawing(), automatic events polling

func DrawRectangle

func DrawRectangle(posX, posY, width, height c.Int, color Color)

Draw a color-filled rectangle

func DrawText

func DrawText(text *c.Char, posX, posY, fontSize c.Int, color Color)

Draw text (using default font)

func EnableCursor

func EnableCursor()

func EnableEventWaiting

func EnableEventWaiting()

Enable waiting for events on EndDrawing(), no automatic event polling

func EndBlendMode

func EndBlendMode()

End blending mode (reset to default: alpha blending)

func EndDrawing

func EndDrawing()

End drawing and swap buffers (call after drawing)

func EndMode2D

func EndMode2D()

End mode (2D)

func EndMode3D

func EndMode3D()

End mode (3D)

func EndScissorMode

func EndScissorMode()

End scissor mode

func EndShaderMode

func EndShaderMode()

End custom shader drawing (use default shader)

func EndTextureMode

func EndTextureMode()

End drawing to render texture

func FileExists

func FileExists(fileName *c.Char) bool

Check if file exists

func GetCharPressed

func GetCharPressed() c.Int

func GetClipboardText

func GetClipboardText() *c.Char

func GetCurrentMonitor

func GetCurrentMonitor() c.Int

Get current connected monitor

func GetFPS

func GetFPS() c.Int

Returns current FPS

func GetFrameTime

func GetFrameTime() c.Float

Returns time in seconds for last frame drawn (delta time)

func GetKeyPressed

func GetKeyPressed() c.Int

func GetMonitorCount

func GetMonitorCount() c.Int

Get number of connected monitors

func GetMonitorHeight

func GetMonitorHeight(monitor c.Int) c.Int

func GetMonitorName

func GetMonitorName(monitor c.Int) *c.Char

func GetMonitorPhysicalHeight

func GetMonitorPhysicalHeight(monitor c.Int) c.Int

func GetMonitorPhysicalWidth

func GetMonitorPhysicalWidth(monitor c.Int) c.Int

func GetMonitorRefreshRate

func GetMonitorRefreshRate(monitor c.Int) c.Int

func GetMonitorWidth

func GetMonitorWidth(monitor c.Int) c.Int

func GetRandomValue

func GetRandomValue(min c.Int, max c.Int) c.Int

func GetRenderHeight

func GetRenderHeight() c.Int

Get current render height (it considers HiDPI)

func GetRenderWidth

func GetRenderWidth() c.Int

Get current render width (it considers HiDPI)

func GetScreenHeight

func GetScreenHeight() c.Int

func GetScreenWidth

func GetScreenWidth() c.Int

func GetTime

func GetTime() c.Double

Returns elapsed time in seconds since InitWindow()

func GetWindowHandle

func GetWindowHandle() c.Pointer

func HideCursor

func HideCursor()

func InitWindow

func InitWindow(width, height c.Int, title *c.Char)

func IsCursorHidden

func IsCursorHidden() bool

func IsCursorOnScreen

func IsCursorOnScreen() bool

func IsFileExtension

func IsFileExtension(fileName *c.Char, ext *c.Char) bool

Check file extension (including point: .png, .wav)

func IsKeyDown

func IsKeyDown(key c.Int) bool

func IsKeyPressed

func IsKeyPressed(key c.Int) bool

func IsKeyPressedRepeat

func IsKeyPressedRepeat(key c.Int) bool

func IsKeyReleased

func IsKeyReleased(key c.Int) bool

func IsKeyUp

func IsKeyUp(key c.Int) bool

func IsWindowFocused

func IsWindowFocused() bool

func IsWindowFullscreen

func IsWindowFullscreen() bool

func IsWindowHidden

func IsWindowHidden() bool

func IsWindowMaximized

func IsWindowMaximized() bool

func IsWindowMinimized

func IsWindowMinimized() bool

func IsWindowReady

func IsWindowReady() bool

func IsWindowResized

func IsWindowResized() bool

func IsWindowState

func IsWindowState(flag c.Int) bool

func MaximizeWindow

func MaximizeWindow()

func MinimizeWindow

func MinimizeWindow()

func RestoreWindow

func RestoreWindow()

func SetClipboardText

func SetClipboardText(text *c.Char)

func SetExitKey

func SetExitKey(key c.Int)

func SetRandomSeed

func SetRandomSeed(seed c.Uint)

func SetTargetFPS

func SetTargetFPS(fps c.Int)

Set target FPS (maximum)

func SetTraceLogLevel

func SetTraceLogLevel(logLevel int)

Set the current threshold (minimum) log level

func SetWindowFocused

func SetWindowFocused()

func SetWindowIcon

func SetWindowIcon(icon Image)

func SetWindowIcons

func SetWindowIcons(icons *Image, count c.Int)

func SetWindowMinSize

func SetWindowMinSize(width, height c.Int)

func SetWindowMonitor

func SetWindowMonitor(monitor c.Int)

func SetWindowOpacity

func SetWindowOpacity(opacity c.Float)

func SetWindowPosition

func SetWindowPosition(x, y c.Int)

func SetWindowSize

func SetWindowSize(width, height c.Int)

func SetWindowState

func SetWindowState(flags c.Int)

func SetWindowTitle

func SetWindowTitle(title *c.Char)

func ShowCursor

func ShowCursor()

func ToggleFullscreen

func ToggleFullscreen()

func TraceLog

func TraceLog(logLevel int, text *c.Char, __llgo_va_list ...any)

Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)

func UpdateCamera

func UpdateCamera(camera *Camera, mode c.Int)

Update camera position for selected mode

func UpdateCameraPro

func UpdateCameraPro(camera *Camera, movement, rotation Vector3, zoom float32)

Update camera movement/rotation

func WindowShouldClose

func WindowShouldClose() bool

Types

type BlendMode

type BlendMode c.Int

Color blending modes (pre-defined)

const (
	BLEND_ALPHA             BlendMode = iota // Blend textures considering alpha (default)
	BLEND_ADDITIVE                           // Blend textures adding colors
	BLEND_MULTIPLIED                         // Blend textures multiplying colors
	BLEND_ADD_COLORS                         // Blend textures adding colors (alternative)
	BLEND_SUBTRACT_COLORS                    // Blend textures subtracting colors (alternative)
	BLEND_ALPHA_PREMULTIPLY                  // Blend premultiplied textures considering alpha
	BLEND_CUSTOM                             // Blend textures using custom src/dst factors (use rlSetBlendFactors())
	BLEND_CUSTOM_SEPARATE                    // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
)

type Camera

type Camera = Camera3D // Camera type fallback, defaults to Camera3D

type Camera2D

type Camera2D struct {
	Offset   Vector2 // Camera offset (displacement from target)
	Target   Vector2 // Camera target (rotation and zoom origin)
	Rotation float32 // Camera rotation in degrees
	Zoom     float32 // Camera zoom (scaling), should be 1.0f by default
}

Camera2D, defines position/orientation in 2d space

type Camera3D

type Camera3D struct {
	Position   Vector3 // Camera position
	Target     Vector3 // Camera target it looks-at
	Up         Vector3 // Camera up vector (rotation over its axis)
	Fovy       float32 // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic
	Projection c.Int   // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
}

Camera, defines position/orientation in 3d space

type Color

type Color uint32

Color, 4 components, R8G8B8A8 (32bit) R, G, B, A uint8

type Image

type Image struct {
	Data    c.Pointer // Image raw data
	Width   c.Int     // Image base width
	Height  c.Int     // Image base height
	Mipmaps c.Int     // Mipmap levels, 1 by default
	Format  c.Int     // Data format (PixelFormat type)
}

Image, pixel data stored in CPU memory (RAM)

type Quaternion

type Quaternion = Vector4

Quaternion, 4 components (Vector4 alias)

type Shader

type Shader struct {
	Id   c.Uint // Shader program id
	Locs *c.Int // Shader locations array (RL_MAX_SHADER_LOCATIONS)
}

Shader

type Vector2

type Vector2 struct {
	X float32 // Vector x component
	Y float32 // Vector y component
}

Vector2, 2 components

func GetMonitorPosition

func GetMonitorPosition(monitor c.Int) Vector2

Get specified monitor position

func GetWindowPosition

func GetWindowPosition() Vector2

func GetWindowScaleDPI

func GetWindowScaleDPI() Vector2

type Vector3

type Vector3 struct {
	X float32 // Vector x component
	Y float32 // Vector y component
	Z float32 // Vector z component
}

Vector3, 3 components

type Vector4

type Vector4 struct {
	X float32 // Vector x component
	Y float32 // Vector y component
	Z float32 // Vector z component
	W float32 // Vector w component
}

Vector4, 4 components

Directories

Path Synopsis
_demo

Jump to

Keyboard shortcuts

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