From 78d5d1e529605410bb6ae67ad9e248eae21703ef Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 26 Oct 2026 08:34:00 +0800 Subject: [PATCH] mv c/raylib => github.com/llarhub/raylib --- c/raylib/README.md | 30 -- c/raylib/_demo/raylibdemo/raydemo.go | 18 - c/raylib/_demo/tetris/tetris.go | 181 ---------- c/raylib/raylib.go | 485 --------------------------- c/raylib/shape.go | 215 ------------ c/raylib/utils.go | 67 ---- 6 files changed, 996 deletions(-) delete mode 100644 c/raylib/README.md delete mode 100644 c/raylib/_demo/raylibdemo/raydemo.go delete mode 100644 c/raylib/_demo/tetris/tetris.go delete mode 100644 c/raylib/raylib.go delete mode 100644 c/raylib/shape.go delete mode 100644 c/raylib/utils.go diff --git a/c/raylib/README.md b/c/raylib/README.md deleted file mode 100644 index f27e06a5..00000000 --- a/c/raylib/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# LLGo wrapper of raysan5/raylib - -## How to install - -### on macOS (Homebrew) - -```sh -brew install raylib -``` - -### on Linux (Debian/Ubuntu) - -```sh -TODO -``` - -## Demos - -The `_demo` directory contains our demos (it start with `_` to prevent the `go` command from compiling it): - -- [tetris](_demo/tetris/tetris.go): tetris powered by raylib - -### How to run demos - -To run the demos in directory `_demo`: - -```sh -cd # eg. cd _demo/tetris -llgo run . -``` diff --git a/c/raylib/_demo/raylibdemo/raydemo.go b/c/raylib/_demo/raylibdemo/raydemo.go deleted file mode 100644 index 160dddac..00000000 --- a/c/raylib/_demo/raylibdemo/raydemo.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "github.com/goplus/lib/c" - "github.com/goplus/lib/c/raylib" -) - -func main() { - const screenWidth = 800 - const screenHeight = 450 - raylib.InitWindow(screenWidth, screenHeight, c.Str("Raylib DEMO")) - for !raylib.WindowShouldClose() { - raylib.BeginDrawing() - raylib.ClearBackground(raylib.RAYWHITE) - raylib.DrawRectangle(screenWidth/2-50, screenHeight/2-50, 100, 100, raylib.BLUE) - raylib.EndDrawing() - } -} diff --git a/c/raylib/_demo/tetris/tetris.go b/c/raylib/_demo/tetris/tetris.go deleted file mode 100644 index 94b551ec..00000000 --- a/c/raylib/_demo/tetris/tetris.go +++ /dev/null @@ -1,181 +0,0 @@ -package main - -import ( - "unsafe" - - "github.com/goplus/lib/c" - "github.com/goplus/lib/c/raylib" -) - -const ( - BOARD_WIDTH = 10 - BOARD_HEIGHT = 20 - BLOCK_SIZE = 30 - - SCREENWIDTH = 300 - SCREENHEIGHT = 600 -) - -const MAX_BLOCKS = 4 - -type Shape struct { - Blocks [MAX_BLOCKS]raylib.Vector2 - Color raylib.Color -} - -var SHAPES = []Shape{ - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 2, Y: 0}, {X: 3, Y: 0}}, Color: raylib.SKYBLUE}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 1}}, Color: raylib.YELLOW}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 1, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 1}, {X: 2, Y: 1}}, Color: raylib.PURPLE}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 1, Y: 0}, {X: 2, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 1}}, Color: raylib.GREEN}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 1, Y: 1}, {X: 2, Y: 1}}, Color: raylib.RED}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 0, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 1}, {X: 2, Y: 1}}, Color: raylib.BLUE}, - {Blocks: [MAX_BLOCKS]raylib.Vector2{{X: 2, Y: 0}, {X: 0, Y: 1}, {X: 1, Y: 1}, {X: 2, Y: 1}}, Color: raylib.ORANGE}, -} - -var board [BOARD_HEIGHT][BOARD_WIDTH]raylib.Color - -var curShape Shape -var curPos raylib.Vector2 - -var fallTime = c.Float(0) -var fallSpeed = c.Float(0.2) -var score = 0 -var scoreText = make([]c.Char, 20) -var gameOver = false - -func genShape() { - curShape = SHAPES[raylib.GetRandomValue(c.Int(0), c.Int(6))] - curPos = raylib.Vector2{BOARD_WIDTH/2 - 1, 0} -} - -func checkCollision() bool { - for i := 0; i < MAX_BLOCKS; i++ { - x := int(curPos.X + curShape.Blocks[i].X) - y := int(curPos.Y + curShape.Blocks[i].Y) - if x < 0 || x >= BOARD_WIDTH || y >= BOARD_HEIGHT || (y >= 0 && board[y][x] != raylib.BLANK) { - return true - } - } - return false -} - -func lockShape() { - for i := 0; i < MAX_BLOCKS; i++ { - x := int(curPos.X + curShape.Blocks[i].X) - y := int(curPos.Y + curShape.Blocks[i].Y) - if y >= 0 { - board[y][x] = curShape.Color - } - } -} - -func rotateShape() { - rotated := curShape - for i := 0; i < MAX_BLOCKS; i++ { - x := rotated.Blocks[i].X - rotated.Blocks[i].X = -rotated.Blocks[i].Y - rotated.Blocks[i].Y = x - } - - temp := curShape - curShape = rotated - if checkCollision() { - curShape = temp - } -} - -func clearLines() int { - linesCleared := 0 - for y := BOARD_HEIGHT - 1; y >= 0; y-- { - lineFull := true - for x := 0; x < BOARD_WIDTH; x++ { - if board[y][x] == raylib.BLANK { - lineFull = false - break - } - } - if lineFull { - for yy := y; yy > 0; yy-- { - for x := 0; x < BOARD_WIDTH; x++ { - board[yy][x] = board[yy-1][x] - } - } - for x := 0; x < BOARD_WIDTH; x++ { - board[0][x] = raylib.BLANK - } - y += 1 - linesCleared += 1 - } - } - return linesCleared -} - -func keyPressed(key c.Int) bool { - return raylib.IsKeyPressed(key) || raylib.IsKeyPressedRepeat(key) -} - -func main() { - raylib.InitWindow(SCREENWIDTH, SCREENHEIGHT, c.Str("tetris (powered by raylib + llgo)")) - raylib.SetTargetFPS(c.Int(60)) - genShape() - for !raylib.WindowShouldClose() && !gameOver { - fallTime += raylib.GetFrameTime() - if fallTime >= fallSpeed { - fallTime = 0 - curPos.Y += 1 - if checkCollision() { - curPos.Y -= 1 - lockShape() - linesCleared := clearLines() - score += linesCleared * 100 - genShape() - if checkCollision() { - gameOver = true - } - } - } - - if keyPressed(raylib.KEY_LEFT) { - curPos.X -= 1 - if checkCollision() { - curPos.X += 1 - } - } - if keyPressed(raylib.KEY_RIGHT) { - curPos.X += 1 - if checkCollision() { - curPos.X -= 1 - } - } - if keyPressed(raylib.KEY_SPACE) || keyPressed(raylib.KEY_UP) || keyPressed(raylib.KEY_DOWN) { - rotateShape() - } - - raylib.BeginDrawing() - raylib.ClearBackground(raylib.RAYWHITE) - for y := 0; y < BOARD_HEIGHT; y++ { - for x := 0; x < BOARD_WIDTH; x++ { - raylib.DrawRectangle(c.Int(x*BLOCK_SIZE), c.Int(y*BLOCK_SIZE), c.Int(BLOCK_SIZE-1), c.Int(BLOCK_SIZE-1), board[y][x]) - } - } - - for i := 0; i < MAX_BLOCKS; i++ { - raylib.DrawRectangle(c.Int((curPos.X+curShape.Blocks[i].X)*BLOCK_SIZE), c.Int((curPos.Y+curShape.Blocks[i].Y)*BLOCK_SIZE), - BLOCK_SIZE-1, BLOCK_SIZE-1, curShape.Color) - } - - c.Sprintf(unsafe.SliceData(scoreText), c.Str("Score:%d"), score) - raylib.DrawText(unsafe.SliceData(scoreText), 10, 10, 20, raylib.BLACK) - - raylib.EndDrawing() - } - - for !raylib.WindowShouldClose() { - raylib.BeginDrawing() - raylib.ClearBackground(raylib.RAYWHITE) - raylib.DrawText(c.Str("Game Over"), SCREENWIDTH/2-50, SCREENHEIGHT/2-10, 20, raylib.RED) - raylib.DrawText(unsafe.SliceData(scoreText), SCREENWIDTH/2-50, SCREENHEIGHT/2+10, 20, raylib.BLACK) - raylib.EndDrawing() - } -} diff --git a/c/raylib/raylib.go b/c/raylib/raylib.go deleted file mode 100644 index ea611cc6..00000000 --- a/c/raylib/raylib.go +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package raylib - -import ( - _ "unsafe" - - "github.com/goplus/lib/c" -) - -const ( - LLGoPackage = "link: $(pkg-config --libs raylib); -lraylib" -) - -// ----------------------------------------------------------------------------- - -// Vector2, 2 components -type Vector2 struct { - X float32 // Vector x component - Y float32 // Vector y component -} - -// Vector3, 3 components -type Vector3 struct { - X float32 // Vector x component - Y float32 // Vector y component - Z float32 // Vector z component -} - -// Vector4, 4 components -type Vector4 struct { - X float32 // Vector x component - Y float32 // Vector y component - Z float32 // Vector z component - W float32 // Vector w component -} - -// Quaternion, 4 components (Vector4 alias) -type Quaternion = Vector4 - -//---------------------------------------------------------------------------------- -// Enumerators Definition - -// System/Window config flags -// By default all flags are set to 0 - -// Trace log level - -// Keyboard keys (US keyboard layout) -// required keys for alternative layouts -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 -) - -// Mouse buttons - -// Mouse cursor - -// Gamepad buttons - -// Gamepad axis - -// Material map index - -// Shader location index - -// Shader uniform data type - -// Shader attribute data types - -// Pixel formats - -// Texture parameters: filter mode - -// Texture parameters: wrap mode - -// Cubemap layouts - -// Font type, defines generation method - -// Color blending modes (pre-defined) - -// Gesture - -// Camera system modes - -// Camera projection - -// N-patch layout - -// ----------------------------------------------------------------------------- -// Window-related functions - -//go:linkname InitWindow C.InitWindow -func InitWindow(width, height c.Int, title *c.Char) - -//go:linkname CloseWindow C.CloseWindow -func CloseWindow() - -//go:linkname WindowShouldClose C.WindowShouldClose -func WindowShouldClose() bool - -//go:linkname IsWindowReady C.IsWindowReady -func IsWindowReady() bool - -//go:linkname IsWindowFullscreen C.IsWindowFullscreen -func IsWindowFullscreen() bool - -//go:linkname IsWindowHidden C.IsWindowHidden -func IsWindowHidden() bool - -//go:linkname IsWindowMinimized C.IsWindowMinimized -func IsWindowMinimized() bool - -//go:linkname IsWindowMaximized C.IsWindowMaximized -func IsWindowMaximized() bool - -//go:linkname IsWindowFocused C.IsWindowFocused -func IsWindowFocused() bool - -//go:linkname IsWindowResized C.IsWindowResized -func IsWindowResized() bool - -//go:linkname IsWindowState C.IsWindowState -func IsWindowState(flag c.Int) bool - -//go:linkname SetWindowState C.SetWindowState -func SetWindowState(flags c.Int) - -//go:linkname ClearWindowState C.ClearWindowState -func ClearWindowState(flags c.Int) - -//go:linkname ToggleFullscreen C.ToggleFullscreen -func ToggleFullscreen() - -//go:linkname MaximizeWindow C.MaximizeWindow -func MaximizeWindow() - -//go:linkname MinimizeWindow C.MinimizeWindow -func MinimizeWindow() - -//go:linkname RestoreWindow C.RestoreWindow -func RestoreWindow() - -//go:linkname SetWindowIcon C.SetWindowIcon -func SetWindowIcon(icon Image) - -//go:linkname SetWindowIcons C.SetWindowIcons -func SetWindowIcons(icons *Image, count c.Int) - -//go:linkname SetWindowTitle C.SetWindowTitle -func SetWindowTitle(title *c.Char) - -//go:linkname SetWindowPosition C.SetWindowPosition -func SetWindowPosition(x, y c.Int) - -//go:linkname SetWindowMonitor C.SetWindowMonitor -func SetWindowMonitor(monitor c.Int) - -//go:linkname SetWindowMinSize C.SetWindowMinSize -func SetWindowMinSize(width, height c.Int) - -//go:linkname SetWindowSize C.SetWindowSize -func SetWindowSize(width, height c.Int) - -//go:linkname SetWindowOpacity C.SetWindowOpacity -func SetWindowOpacity(opacity c.Float) - -//go:linkname SetWindowFocused C.SetWindowFocused -func SetWindowFocused() - -//go:linkname GetWindowHandle C.GetWindowHandle -func GetWindowHandle() c.Pointer - -//go:linkname GetScreenWidth C.GetScreenWidth -func GetScreenWidth() c.Int - -//go:linkname GetScreenHeight C.GetScreenHeight -func GetScreenHeight() c.Int - -// Get current render width (it considers HiDPI) -// -//go:linkname GetRenderWidth C.GetRenderWidth -func GetRenderWidth() c.Int - -// Get current render height (it considers HiDPI) -// -//go:linkname GetRenderHeight C.GetRenderHeight -func GetRenderHeight() c.Int - -// Get number of connected monitors -// -//go:linkname GetMonitorCount C.GetMonitorCount -func GetMonitorCount() c.Int - -// Get current connected monitor -// -//go:linkname GetCurrentMonitor C.GetCurrentMonitor -func GetCurrentMonitor() c.Int - -// Get specified monitor position -// -//go:linkname GetMonitorPosition C.GetMonitorPosition -func GetMonitorPosition(monitor c.Int) Vector2 - -//go:linkname GetMonitorWidth C.GetMonitorWidth -func GetMonitorWidth(monitor c.Int) c.Int - -//go:linkname GetMonitorHeight C.GetMonitorHeight -func GetMonitorHeight(monitor c.Int) c.Int - -//go:linkname GetMonitorPhysicalWidth C.GetMonitorPhysicalWidth -func GetMonitorPhysicalWidth(monitor c.Int) c.Int - -//go:linkname GetMonitorPhysicalHeight C.GetMonitorPhysicalHeight -func GetMonitorPhysicalHeight(monitor c.Int) c.Int - -//go:linkname GetMonitorRefreshRate C.GetMonitorRefreshRate -func GetMonitorRefreshRate(monitor c.Int) c.Int - -//go:linkname GetWindowPosition C.GetWindowPosition -func GetWindowPosition() Vector2 - -//go:linkname GetWindowScaleDPI C.GetWindowScaleDPI -func GetWindowScaleDPI() Vector2 - -//go:linkname GetMonitorName C.GetMonitorName -func GetMonitorName(monitor c.Int) *c.Char - -//go:linkname SetClipboardText C.SetClipboardText -func SetClipboardText(text *c.Char) - -//go:linkname GetClipboardText C.GetClipboardText -func GetClipboardText() *c.Char - -// Enable waiting for events on EndDrawing(), no automatic event polling -// -//go:linkname EnableEventWaiting C.EnableEventWaiting -func EnableEventWaiting() - -// Disable waiting for events on EndDrawing(), automatic events polling -// -//go:linkname DisableEventWaiting C.DisableEventWaiting -func DisableEventWaiting() - -// ----------------------------------------------------------------------------- -// Cursor-related functions - -//go:linkname ShowCursor C.ShowCursor -func ShowCursor() - -//go:linkname HideCursor C.HideCursor -func HideCursor() - -//go:linkname IsCursorHidden C.IsCursorHidden -func IsCursorHidden() bool - -//go:linkname EnableCursor C.EnableCursor -func EnableCursor() - -//go:linkname DisableCursor C.DisableCursor -func DisableCursor() - -//go:linkname IsCursorOnScreen C.IsCursorOnScreen -func IsCursorOnScreen() bool - -// ----------------------------------------------------------------------------- -// Shader management functions - -// ----------------------------------------------------------------------------- -// Screen-space-related functions - -// ----------------------------------------------------------------------------- -// Timing-related functions - -// Set target FPS (maximum) -// -//go:linkname SetTargetFPS C.SetTargetFPS -func SetTargetFPS(fps c.Int) - -// Returns current FPS -// -//go:linkname GetFPS C.GetFPS -func GetFPS() c.Int - -// Returns time in seconds for last frame drawn (delta time) -// -//go:linkname GetFrameTime C.GetFrameTime -func GetFrameTime() c.Float - -// Returns elapsed time in seconds since InitWindow() -// -//go:linkname GetTime C.GetTime -func GetTime() c.Double - -// ----------------------------------------------------------------------------- -// Custom frame control functions - -// NOTE: Those functions are intended for advance users that want full control over the frame processing -// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() -// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL - -// ----------------------------------------------------------------------------- -// Random values generation functions - -//go:linkname SetRandomSeed C.SetRandomSeed -func SetRandomSeed(seed c.Uint) - -//go:linkname GetRandomValue C.GetRandomValue -func GetRandomValue(min c.Int, max c.Int) c.Int - -// ----------------------------------------------------------------------------- -// Misc. functions - -// ----------------------------------------------------------------------------- -// Input-related functions: keyboard - -//go:linkname IsKeyPressed C.IsKeyPressed -func IsKeyPressed(key c.Int) bool - -//go:linkname IsKeyPressedRepeat C.IsKeyPressedRepeat -func IsKeyPressedRepeat(key c.Int) bool - -//go:linkname IsKeyDown C.IsKeyDown -func IsKeyDown(key c.Int) bool - -//go:linkname IsKeyReleased C.IsKeyReleased -func IsKeyReleased(key c.Int) bool - -//go:linkname IsKeyUp C.IsKeyUp -func IsKeyUp(key c.Int) bool - -//go:linkname GetKeyPressed C.GetKeyPressed -func GetKeyPressed() c.Int - -//go:linkname GetCharPressed C.GetCharPressed -func GetCharPressed() c.Int - -//go:linkname SetExitKey C.SetExitKey -func SetExitKey(key c.Int) - -// ----------------------------------------------------------------------------- -// Input-related functions: gamepads - -// ----------------------------------------------------------------------------- -// Input-related functions: mouse - -// ----------------------------------------------------------------------------- -// Input-related functions: touch - -// ----------------------------------------------------------------------------- -// Gestures and Touch Handling Functions (Module: rgestures) - -// ----------------------------------------------------------------------------- diff --git a/c/raylib/shape.go b/c/raylib/shape.go deleted file mode 100644 index 52e698b1..00000000 --- a/c/raylib/shape.go +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package raylib - -import ( - _ "unsafe" - - "github.com/goplus/lib/c" -) - -// ----------------------------------------------------------------------------- - -// Color, 4 components, R8G8B8A8 (32bit) -// R, G, B, A uint8 -type Color uint32 - -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) -) - -// Image, pixel data stored in CPU memory (RAM) -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) -} - -// Camera, defines position/orientation in 3d space -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 -} - -type Camera = Camera3D // Camera type fallback, defaults to Camera3D - -// Camera2D, defines position/orientation in 2d space -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 -} - -// Shader -type Shader struct { - Id c.Uint // Shader program id - Locs *c.Int // Shader locations array (RL_MAX_SHADER_LOCATIONS) -} - -// ----------------------------------------------------------------------------- -// Drawing-related functions - -// Set background color (framebuffer clear color) -// -//go:linkname ClearBackground C.ClearBackground -func ClearBackground(color Color) - -// Begin drawing (call before drawing anything) -// -//go:linkname BeginDrawing C.BeginDrawing -func BeginDrawing() - -// End drawing and swap buffers (call after drawing) -// -//go:linkname EndDrawing C.EndDrawing -func EndDrawing() - -// Begin 2D mode with custom camera (2D) -// -//go:linkname BeginMode2D C.BeginMode2D -func BeginMode2D(camera Camera2D) - -// End mode (2D) -// -//go:linkname EndMode2D C.EndMode2D -func EndMode2D() - -// Begin 3D mode with custom camera (3D) -// -//go:linkname BeginMode3D C.BeginMode3D -func BeginMode3D(camera Camera3D) - -// End mode (3D) -// -//go:linkname EndMode3D C.EndMode3D -func EndMode3D() - -// Begin drawing to render texture -//-go:linkname BeginTextureMode C.BeginTextureMode -//func BeginTextureMode(target RenderTexture2D) - -// End drawing to render texture -// -//go:linkname EndTextureMode C.EndTextureMode -func EndTextureMode() - -// Begin custom shader drawing -// -//go:linkname BeginShaderMode C.BeginShaderMode -func BeginShaderMode(shader Shader) - -// End custom shader drawing (use default shader) -// -//go:linkname EndShaderMode C.EndShaderMode -func EndShaderMode() - -// Color blending modes (pre-defined) -type BlendMode c.Int - -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()) -) - -// Begin blending mode (alpha, additive, multiplied, subtract, custom) -// -//go:linkname BeginBlendMode C.BeginBlendMode -func BeginBlendMode(mode BlendMode) - -// End blending mode (reset to default: alpha blending) -// -//go:linkname EndBlendMode C.EndBlendMode -func EndBlendMode() - -// Begin scissor mode (define screen area for following drawing) -// -//go:linkname BeginScissorMode C.BeginScissorMode -func BeginScissorMode(x, y, width, height c.Int) - -// End scissor mode -// -//go:linkname EndScissorMode C.EndScissorMode -func EndScissorMode() - -// ----------------------------------------------------------------------------- -// VR stereo config functions for VR simulator - -// ----------------------------------------------------------------------------- -// Camera System Functions (Module: rcamera) - -// Update camera position for selected mode -// -//go:linkname UpdateCamera C.UpdateCamera -func UpdateCamera(camera *Camera, mode c.Int) - -// Update camera movement/rotation -// -//go:linkname UpdateCameraPro C.UpdateCameraPro -func UpdateCameraPro(camera *Camera, movement, rotation Vector3, zoom float32) - -// ----------------------------------------------------------------------------- - -// Draw a color-filled rectangle -// -//go:linkname DrawRectangle C.DrawRectangle -func DrawRectangle(posX, posY, width, height c.Int, color Color) - -// Draw text (using default font) -// -//go:linkname DrawText C.DrawText -func DrawText(text *c.Char, posX, posY, fontSize c.Int, color Color) - -// ----------------------------------------------------------------------------- diff --git a/c/raylib/utils.go b/c/raylib/utils.go deleted file mode 100644 index b1a8b5d5..00000000 --- a/c/raylib/utils.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 The XGo Authors (xgo.dev). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package raylib - -import ( - _ "unsafe" - - "github.com/goplus/lib/c" -) - -// ----------------------------------------------------------------------------- - -// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) -// -//go:linkname TraceLog C.TraceLog -func TraceLog(logLevel int, text *c.Char, __llgo_va_list ...any) - -// Set the current threshold (minimum) log level -// -//go:linkname SetTraceLogLevel C.SetTraceLogLevel -func SetTraceLogLevel(logLevel int) - -// ----------------------------------------------------------------------------- -// Set custom callbacks - -// ----------------------------------------------------------------------------- -// Files management functions - -// ----------------------------------------------------------------------------- -// File system functions - -// Check if file exists -// -//go:linkname FileExists C.FileExists -func FileExists(fileName *c.Char) bool - -// Check if a directory path exists -// -//go:linkname DirectoryExists C.DirectoryExists -func DirectoryExists(dirPath *c.Char) bool - -// Check file extension (including point: .png, .wav) -// -//go:linkname IsFileExtension C.IsFileExtension -func IsFileExtension(fileName *c.Char, ext *c.Char) bool - -// ----------------------------------------------------------------------------- -// Compression/Encoding functionality - -// ----------------------------------------------------------------------------- -// Automation events functionality - -// -----------------------------------------------------------------------------