Browse Source

initial commit

master
Wesley Kerfoot 3 years ago
commit
5e0340ed03
  1. 1
      compile_raygui.sh
  2. 3
      config.nims
  3. 18
      game.nimble
  4. 5
      src/game.nim
  5. 345
      src/gamepkg/gui.nim
  6. 354
      src/gamepkg/raygui.nim
  7. 1291
      src/gamepkg/raylib.nim
  8. 270
      src/gamepkg/raymath.nim
  9. 318
      src/gamepkg/rlgl.nim
  10. 36
      styles/README.md
  11. 16
      styles/ashes/README.md
  12. 24
      styles/ashes/ashes.rgs
  13. 51
      styles/ashes/font_readme.txt
  14. BIN
      styles/ashes/screenshot.png
  15. BIN
      styles/ashes/style_table.png
  16. BIN
      styles/ashes/v5loxical.ttf
  17. 16
      styles/bluish/README.md
  18. 24
      styles/bluish/bluish.rgs
  19. 76
      styles/bluish/font_readme.txt
  20. BIN
      styles/bluish/homespun.ttf
  21. BIN
      styles/bluish/screenshot.png
  22. BIN
      styles/bluish/style_table.png
  23. 16
      styles/candy/README.md
  24. 24
      styles/candy/candy.rgs
  25. 27
      styles/candy/font_readme.txt
  26. BIN
      styles/candy/screenshot.png
  27. BIN
      styles/candy/style_table.png
  28. BIN
      styles/candy/v5easter.ttf
  29. 16
      styles/cherry/README.md
  30. BIN
      styles/cherry/Westington.ttf
  31. 24
      styles/cherry/cherry.rgs
  32. BIN
      styles/cherry/screenshot.png
  33. BIN
      styles/cherry/style_table.png
  34. BIN
      styles/cyber/Kyrou 7 Wide.ttf
  35. 16
      styles/cyber/README.md
  36. 24
      styles/cyber/cyber.rgs
  37. 36
      styles/cyber/font_readme.txt
  38. BIN
      styles/cyber/screenshot.png
  39. BIN
      styles/cyber/style_table.png
  40. 14
      styles/default/README.md
  41. 69
      styles/default/default.rgs
  42. BIN
      styles/default/screenshot.png
  43. BIN
      styles/default/style_table.png
  44. BIN
      styles/jungle/Pixel Intv.otf
  45. 16
      styles/jungle/README.md
  46. 47
      styles/jungle/font_readme.txt
  47. 24
      styles/jungle/jungle.rgs
  48. BIN
      styles/jungle/screenshot.png
  49. BIN
      styles/jungle/style_table.png
  50. BIN
      styles/lavanda/Cartridge.ttf
  51. 16
      styles/lavanda/README.md
  52. 6
      styles/lavanda/font_readme.txt
  53. 24
      styles/lavanda/lavanda.rgs
  54. BIN
      styles/lavanda/screenshot.png
  55. BIN
      styles/lavanda/style_table.png
  56. BIN
      styles/terminal/Mecha.ttf
  57. 16
      styles/terminal/README.md
  58. BIN
      styles/terminal/screenshot.png
  59. BIN
      styles/terminal/style_table.png
  60. 24
      styles/terminal/terminal.rgs
  61. 1
      tests/config.nims
  62. 12
      tests/test1.nim

1
compile_raygui.sh

@ -0,0 +1 @@
gcc -shared -fPIC -DRAYGUIDEF -DRAYGUI_IMPLEMENTATION -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 raygui.h -o raygui.so

3
config.nims

@ -0,0 +1,3 @@
switch("define", "ssl")
switch("threads", "on")
switch("passL", "-lraylib ")

18
game.nimble

@ -0,0 +1,18 @@
# Package
version = "0.11.0"
author = "Wesley Kerfoot"
description = "Turn Your Tweets Into Blog Posts"
license = "MIT"
srcDir = "src"
installExt = @["nim"]
bin = @["game"]
# Dependencies
requires "nim >= 1.0"
requires "https://github.com/GULPF/timezones"
requires "https://github.com/cheatfate/nimcrypto"
task bookmark, "Builds the minified bookmarklet":
"echo -n 'javascript:' > ./bookmarklet.min.js".exec
"uglifyjs bookmarklet.js >> ./bookmarklet.min.js".exec

5
src/game.nim

@ -0,0 +1,5 @@
import gamepkg/gui
import threadpool
when isMainModule:
guiLoop()

345
src/gamepkg/gui.nim

@ -0,0 +1,345 @@
import algorithm, heapqueue, random, options, sequtils, sugar, tables
import raylib, raygui
from times import getTime, toUnix, nanosecond
# Seed rng
let now = getTime()
randomize(now.toUnix * 1_000_000_000 + now.nanosecond)
# constants
const rowSize = 20 # How many tiles per row of the board
const boardOffset: int = 50 # How far is the board from the top of the window
const boxStride: int = 40 # How much space does a tile take up
const borderWidth: float32 = 6.float32 # How wide are the borders between tiles
const sideSize = (boxStride-borderWidth.int).float32 # How long is a side of a tile
const boardLength = (boxStride+borderWidth.int) * rowSize # How long is a side of the board
const infinity = (1.0/0.0).float32
const averageMineCount = ((rowSize*rowSize) * 0.10).int # How many mines should be placed on average?
type GameState = enum
unfinished,
lost,
won
type TileState = object
mine: bool # is it a mine?
marked: bool # have we marked it as a mine?
revealed: bool # has it been revealed?, implies the search algorithm ran
mineNeighbours: int
type Tile = ref object of RootObj
state: TileState
pos: Rectangle
x: int
y: int
proc `$` (t: Tile): string =
return "state = " & $t.state & ", " & "x = " & $t.x & ", " & "y = " & $t.y
type Board = ref object of RootObj
tiles: seq[Tile]
xIntervals: seq[tuple[l: float32, h: float32]]
yIntervals: seq[tuple[l: float32, h: float32]]
proc isWinning(board: Board): bool =
# If All tiles are either revealed or mines (but not both), you won
board.tiles.all((tile) => (tile.state.mine and (not tile.state.revealed)) or tile.state.revealed)
proc getTile(board: Board, x: int, y: int): Option[Tile] =
# Given x, y coords, get tile if it exists
if x > (rowSize - 1) or y > (rowSize - 1) or x < 0 or y < 0:
return none(Tile)
let l = board.tiles.len
let pos = (rowSize * y) + x
if pos >= 0 and pos < l:
return some(board.tiles[pos])
none(Tile)
proc getNeighbours(board: Board, tile: Tile): seq[Tile] =
let x = tile.x
let y = tile.y
let positions = @[
@[x+1, y],
@[x+1, y+1],
@[x+1, y-1],
@[x, y+1],
@[x, y-1],
@[x-1, y+1],
@[x-1, y],
@[x-1, y-1]
] # neighboring coordinates to check
let filteredPositions = filterIt(positions, getTile(board, it[0], it[1]).isSome)
assert(filteredPositions.len >= 3 and filteredPositions.len <= 8)
return map(filteredPositions, (pos) => getTile(board, pos[0], pos[1]).get)
proc revealBoard(board: Board, tile: Tile) =
# Recursively reveal neighbours unless one of them is a mine
var q = initHeapQueue[Tile]()
q.push(tile)
var processed = initTable[string, bool]()
while q.len > 0:
var skip: bool = false
let t = q.pop()
let k = $t.x & "," & $t.y
if processed.contains(k):
continue
processed[k] = true
# If it's not a mine, reveal it
t.state.revealed = true
# If any of the neighbours are mines, stop
let neighbours = getNeighbours(board, t)
if anyIt(neighbours, it.state.mine):
t.state.mineNeighbours = filterIt(neighbours, it.state.mine).len
continue
# Add all the neighbours to the queue to be processed
for neighbour in neighbours:
if processed.contains(($neighbour.x & "," & $neighbour.y)):
continue
# Must not add mines to the queue
assert(not neighbour.state.mine)
q.push(neighbour)
proc setMine(numMines: int): bool =
let maxR: float = rowSize*rowSize
return rand(max_r) < (numMines.float)
proc comparator(a: tuple[l: float32, h: float32], k: int): int =
if k.float32 < a.l:
return 1
if k.float32 > a.h:
return -1
else:
return 0
proc getTilePos(mouseX: int, mouseY: int, board: Board): int =
# Take x, y coordinates of cursor
# Do search for the tile x and y coordinates using intervals
# Return position in the set of tiles
if mouseX.float32 > boardLength or mouseY.float32 > boardLength:
return -1
let x: int = board.xIntervals.binarySearch(mouseX, comparator) - 1
let y: int = board.yIntervals.binarySearch(mouseY, comparator) - 1
return (y*rowSize) + x
proc drawTile(heightPos: int, widthPos: int, state: TileState, reveal: bool = false): Tile =
let edge = 1.float32
let y = boardOffset+(boxStride*heightPos)
let x = boardOffset+(boxStride*widthPos)
let boxRect = Rectangle(x: x.float32, y: y.float32, width: sideSize, height: sideSize)
let c1 = Color(r: 2, g: 91, b: 36, a: 255)
let c2 = Color(r: 0, g: 0, b: 0, a: 255)
let c3 = Color(r: 0, g: 91, b: 109, a: 255)
let c4 = Color(r: 0, g: 212, b: 255, a: 255)
if state.mine and reveal:
DrawRectangleRec(boxRect, RED)
elif state.revealed:
DrawRectangleRec(boxRect, GREEN)
if state.mineNeighbours > 0:
DrawText($state.mineNeighbours, x+(sideSize/4).int, y, sideSize.int, BLACK)
# show everything if `reveal` is true
elif reveal:
DrawRectangleRec(boxRect, GREEN)
else:
DrawRectangleGradientEx(boxRect, c1, c2, c3, c4)
let start1 = Vector2(x: x.float32+edge, y: y.float32+edge)
let end1 = Vector2(x: (x+boxStride).float32-borderWidth-edge, y: (y+boxStride).float32-borderWidth-edge)
let start2 = Vector2(x: (x).float32+edge,
y: (y+boxStride).float32-borderWidth-edge)
let end2 = Vector2(x: (x+boxStride).float32-borderWidth-edge,
y: y.float32+edge)
if state.marked:
DrawLineEx(start1, end1, 3, WHITE)
DrawLineEx(start2, end2, 3, WHITE)
return Tile(state: state, x: widthPos, y: heightPos, pos: boxRect)
proc drawBoardWindow() =
DrawRectangle(boardOffset, boardOffset, boardLength, boardLength, BLACK)
proc generateBoard(screenWidth: int, screenHeight: int, rowSize: int): Board =
# Draw the initial board
drawBoardWindow()
var tiles: seq[Tile]
var xIntervals: seq[tuple[l: float32, h: float32]] = @[]
var yIntervals: seq[tuple[l: float32, h: float32]] = @[]
for heightPos in countup(0, rowSize-1, 1):
xIntervals = @[]
for widthPos in countup(0, rowSize-1, 1):
var state: TileState
state.marked = false
state.revealed = false
state.mine = setMine(averageMineCount) # average number of mines
state.mineNeighbours = 0
let tile = drawTile(heightPos, widthPos, state)
tiles &= @[tile]
# FIXME ugly shit, encapsulate it into a function or make it more terse
if xIntervals.len > 0:
xIntervals &= @[(l: xIntervals[xIntervals.high].h, h: tile.pos.x.float32)]
else:
xIntervals &= @[(l: 0.float32, h: tile.pos.x.float32)]
if yIntervals.len > 0:
yIntervals &= @[(l: yIntervals[yIntervals.high].h, h: tiles[tiles.high].pos.y.float32)]
else:
yIntervals &= @[(l: 0.float32, h: tiles[tiles.high].pos.y.float32)]
# Required for fencepost cases
xIntervals &= (l: xIntervals[xIntervals.high].h, h: infinity)
yIntervals &= (l: yIntervals[yIntervals.high].h, h: infinity)
result = Board(tiles: tiles, xIntervals: xIntervals, yIntervals: yIntervals)
proc drawBoard(screenWidth: int, screenHeight: int, board: Board) =
drawBoardWindow()
for tile in board.tiles:
discard drawTile(tile.y, tile.x, tile.state)
proc showBoard(screenWidth: int, screenHeight: int, board: Board) =
# Show the entire board
drawBoardWindow()
for tile in board.tiles:
discard drawTile(tile.y, tile.x, tile.state, reveal=true)
proc guiLoop*() =
echo "gui loop starting"
# TODO get from xlib
var screenWidth: int = 100
var screenHeight: int = 100
SetConfigFlags(ord(ConfigFlags.FLAG_WINDOW_UNDECORATED))
InitWindow(screenWidth, screenHeight, "Minesweeper")
let monitor = GetCurrentMonitor()
screenWidth = (monitor.GetMonitorWidth() / 2).int
screenHeight = (monitor.GetMonitorHeight() / 2).int
SetWindowSize(screenWidth, screenHeight)
SetWindowTitle("Minesweeper")
MaximizeWindow()
GuiLoadStyle("styles/terminal/terminal.rgs")
#echo GetScreenWidth()
#echo GetScreenHeight()
var mousePos = Vector2(x: 0, y: 0)
var windowPos = Vector2(x: screenWidth.float32, y: screenHeight.float32)
var panOffset = mousePos
var dragWindow = false
var exitWindow = false
var board: Option[Board] = none(Board)
var gameState: GameState = unfinished
SetTargetFPS(60)
while not exitWindow and not WindowShouldClose():
screenWidth = (monitor.GetMonitorWidth()).int
screenHeight = (monitor.GetMonitorHeight()).int
mousePos = GetMousePosition()
if IsMouseButtonPressed(MOUSE_LEFT_BUTTON):
if CheckCollisionPointRec(mousePos, Rectangle(x: 0.float32, y: 0.float32, width: screenWidth.float32, height: 20.float32)):
dragWindow = true
panOffset = mousePos
else:
# Check if we're clicking a minefield tile
if board.isSome and gameState == unfinished:
echo isWinning(board.get)
let tilePos = getTilePos(mousePos.x.int, mousePos.y.int, board.get) # TODO make this take vector2 instead ?
if tilePos >= 0:
let tile = board.get.tiles[tilePos]
if tile.state.mine and not tile.state.marked:
echo "boom!"
gameState = lost
if tile.state.marked:
echo "do nothing"
else:
echo "reveal it"
revealBoard(board.get, tile)
if isWinning(board.get):
echo "You won!"
gameState = won
if IsMouseButtonPressed(MOUSE_RIGHT_BUTTON):
if board.isSome:
let tilePos = getTilePos(mousePos.x.int, mousePos.y.int, board.get)
if tilePos >= 0:
let tile = board.get.tiles[tilePos]
if not tile.state.revealed:
board.get.tiles[tilePos].state.marked = not tile.state.marked
if dragWindow:
windowPos.x += (mousePos.x - panOffset.x)
windowPos.y += (mousePos.y - panOffset.y)
if IsMouseButtonReleased(MOUSE_LEFT_BUTTON):
dragWindow = false
SetWindowPosition(windowPos.x.int, windowPos.y.int)
BeginDrawing()
# This must come before anything else!
ClearBackground(RAYWHITE)
exitWindow = GuiWindowBox(Rectangle(x: 0.float32, y: 0.float32, width: screenWidth.float32, height: screenHeight.float32),
"#198# Minesweeper".cstring)
if board.isNone:
# Generate the initial board if there isn't one
board = some(generateBoard(screenWidth, screenHeight, rowSize))
else:
if gameState == won and board.isSome:
showBoard(screenWidth, screenHeight, board.get)
DrawText("You won!", (screenWidth/2).int, (screenHeight/2).int, 30, GREEN)
elif gameState == lost and board.isSome:
showBoard(screenWidth, screenHeight, board.get)
DrawText("You lost! :(", (screenWidth/2).int, (screenHeight/2).int, 30, RED)
# Otherwise update the state of the abstract board with the window
else:
drawBoard(screenWidth, screenHeight, board.get)
EndDrawing()
CloseWindow()

354
src/gamepkg/raygui.nim

@ -0,0 +1,354 @@
#
# raygui v2.9-dev - A simple and easy-to-use immediate-mode gui library
#
# DESCRIPTION:
#
# raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
# available as a standalone library, as long as input and drawing functions are provided.
#
# Controls provided:
#
# # Container/separators Controls
# - WindowBox
# - GroupBox
# - Line
# - Panel
#
# # Basic Controls
# - Label
# - Button
# - LabelButton --> Label
# - ImageButton --> Button
# - ImageButtonEx --> Button
# - Toggle
# - ToggleGroup --> Toggle
# - CheckBox
# - ComboBox
# - DropdownBox
# - TextBox
# - TextBoxMulti
# - ValueBox --> TextBox
# - Spinner --> Button, ValueBox
# - Slider
# - SliderBar --> Slider
# - ProgressBar
# - StatusBar
# - ScrollBar
# - ScrollPanel
# - DummyRec
# - Grid
#
# # Advance Controls
# - ListView
# - ColorPicker --> ColorPanel, ColorBarHue
# - MessageBox --> Window, Label, Button
# - TextInputBox --> Window, Label, TextBox, Button
#
# It also provides a set of functions for styling the controls based on its properties (size, color).
#
# CONFIGURATION:
#
# #define RAYGUI_IMPLEMENTATION
# Generates the implementation of the library into the included file.
# If not defined, the library is in header only mode and can be included in other headers
# or source files without problems. But only ONE file should hold the implementation.
#
# #define RAYGUI_STATIC (defined by default)
# The generated implementation will stay private inside implementation file and all
# internal symbols and functions will only be visible inside that file.
#
# #define RAYGUI_STANDALONE
# Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
# internally in the library and input management and drawing functions must be provided by
# the user (check library implementation for further details).
#
# #define RAYGUI_SUPPORT_ICONS
# Includes riconsdata.h header defining a set of 128 icons (binary format) to be used on
# multiple controls and following raygui styles
#
#
# VERSIONS HISTORY:
# 2.9 (17-Mar-2021) Removed tooltip API
# 2.8 (03-May-2020) Centralized rectangles drawing to GuiDrawRectangle()
# 2.7 (20-Feb-2020) Added possible tooltips API
# 2.6 (09-Sep-2019) ADDED: GuiTextInputBox()
# REDESIGNED: GuiListView*(), GuiDropdownBox(), GuiSlider*(), GuiProgressBar(), GuiMessageBox()
# REVIEWED: GuiTextBox(), GuiSpinner(), GuiValueBox(), GuiLoadStyle()
# Replaced property INNER_PADDING by TEXT_PADDING, renamed some properties
# Added 8 new custom styles ready to use
# Multiple minor tweaks and bugs corrected
# 2.5 (28-May-2019) Implemented extended GuiTextBox(), GuiValueBox(), GuiSpinner()
# 2.3 (29-Apr-2019) Added rIcons auxiliar library and support for it, multiple controls reviewed
# Refactor all controls drawing mechanism to use control state
# 2.2 (05-Feb-2019) Added GuiScrollBar(), GuiScrollPanel(), reviewed GuiListView(), removed Gui*Ex() controls
# 2.1 (26-Dec-2018) Redesign of GuiCheckBox(), GuiComboBox(), GuiDropdownBox(), GuiToggleGroup() > Use combined text string
# Complete redesign of style system (breaking change)
# 2.0 (08-Nov-2018) Support controls guiLock and custom fonts, reviewed GuiComboBox(), GuiListView()...
# 1.9 (09-Oct-2018) Controls review: GuiGrid(), GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()...
# 1.8 (01-May-2018) Lot of rework and redesign to align with rGuiStyler and rGuiLayout
# 1.5 (21-Jun-2017) Working in an improved styles system
# 1.4 (15-Jun-2017) Rewritten all GUI functions (removed useless ones)
# 1.3 (12-Jun-2017) Redesigned styles system
# 1.1 (01-Jun-2017) Complete review of the library
# 1.0 (07-Jun-2016) Converted to header-only by Ramon Santamaria.
# 0.9 (07-Mar-2016) Reviewed and tested by Albert Martos, Ian Eito, Sergio Martinez and Ramon Santamaria.
# 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria.
#
# CONTRIBUTORS:
# Ramon Santamaria: Supervision, review, redesign, update and maintenance...
# Vlad Adrian: Complete rewrite of GuiTextBox() to support extended features (2019)
# Sergio Martinez: Review, testing (2015) and redesign of multiple controls (2018)
# Adria Arranz: Testing and Implementation of additional controls (2018)
# Jordi Jorba: Testing and Implementation of additional controls (2018)
# Albert Martos: Review and testing of the library (2015)
# Ian Eito: Review and testing of the library (2015)
# Kevin Gato: Initial implementation of basic components (2014)
# Daniel Nicolas: Initial implementation of basic components (2014)
#
#
# LICENSE: zlib/libpng
#
# Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose, including commercial
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not claim that you
# wrote the original software. If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
# as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
#
template RAYGUI_H*(): auto = RAYGUI_H
template RAYGUI_VERSION*(): auto = "2.9-dev"
import raylib
# Define functions scope to be used internally (static) or externally (extern) to the module including this file
{.pragma: RAYGUIDEF, cdecl, discardable, dynlib: "raygui" & LEXT.}
# Allow custom memory allocators
# ----------------------------------------------------------------------------------
# Defines and Macros
# ----------------------------------------------------------------------------------
template NUM_CONTROLS*(): auto = 16
template NUM_PROPS_DEFAULT*(): auto = 16
template NUM_PROPS_EXTENDED*(): auto = 8
template TEXTEDIT_CURSOR_BLINK_FRAMES*(): auto = 20
# ----------------------------------------------------------------------------------
# Types and Structures Definition
# NOTE: Some types are required for RAYGUI_STANDALONE usage
# ----------------------------------------------------------------------------------
# Style property
type GuiStyleProp* {.bycopy.} = object
controlId*: uint16
propertyId*: uint16
propertyValue*: int32
# Gui control state
type GuiControlState* = enum
GUI_STATE_NORMAL = 0
GUI_STATE_FOCUSED
GUI_STATE_PRESSED
GUI_STATE_DISABLED
converter GuiControlState2int32* (self: GuiControlState): int32 = self.int32
# Gui control text alignment
type GuiTextAlignment* = enum
GUI_TEXT_ALIGN_LEFT = 0
GUI_TEXT_ALIGN_CENTER
GUI_TEXT_ALIGN_RIGHT
converter GuiTextAlignment2int32* (self: GuiTextAlignment): int32 = self.int32
# Gui controls
type GuiControl* = enum
DEFAULT = 0
LABEL # LABELBUTTON
BUTTON # IMAGEBUTTON
TOGGLE # TOGGLEGROUP
SLIDER # SLIDERBAR
PROGRESSBAR
CHECKBOX
COMBOBOX
DROPDOWNBOX
TEXTBOX # TEXTBOXMULTI
VALUEBOX
SPINNER
LISTVIEW
COLORPICKER
SCROLLBAR
STATUSBAR
converter GuiControl2int32* (self: GuiControl): int32 = self.int32
# Gui base properties for every control
type GuiControlProperty* = enum
BORDER_COLOR_NORMAL = 0
BASE_COLOR_NORMAL
TEXT_COLOR_NORMAL
BORDER_COLOR_FOCUSED
BASE_COLOR_FOCUSED
TEXT_COLOR_FOCUSED
BORDER_COLOR_PRESSED
BASE_COLOR_PRESSED
TEXT_COLOR_PRESSED
BORDER_COLOR_DISABLED
BASE_COLOR_DISABLED
TEXT_COLOR_DISABLED
BORDER_WIDTH
TEXT_PADDING
TEXT_ALIGNMENT
RESERVED
converter GuiControlProperty2int32* (self: GuiControlProperty): int32 = self.int32
# Gui extended properties depend on control
# NOTE: We reserve a fixed size of additional properties per control
# DEFAULT properties
type GuiDefaultProperty* = enum
TEXT_SIZE = 16
TEXT_SPACING
LINE_COLOR
BACKGROUND_COLOR
converter GuiDefaultProperty2int32* (self: GuiDefaultProperty): int32 = self.int32
# Label
# typedef enum { } GuiLabelProperty;
# Button
# typedef enum { } GuiButtonProperty;
# Toggle / ToggleGroup
type GuiToggleProperty* = enum
GROUP_PADDING = 16
converter GuiToggleProperty2int32* (self: GuiToggleProperty): int32 = self.int32
# Slider / SliderBar
type GuiSliderProperty* = enum
SLIDER_WIDTH = 16
SLIDER_PADDING
converter GuiSliderProperty2int32* (self: GuiSliderProperty): int32 = self.int32
# ProgressBar
type GuiProgressBarProperty* = enum
PROGRESS_PADDING = 16
converter GuiProgressBarProperty2int32* (self: GuiProgressBarProperty): int32 = self.int32
# CheckBox
type GuiCheckBoxProperty* = enum
CHECK_PADDING = 16
converter GuiCheckBoxProperty2int32* (self: GuiCheckBoxProperty): int32 = self.int32
# ComboBox
type GuiComboBoxProperty* = enum
COMBO_BUTTON_WIDTH = 16
COMBO_BUTTON_PADDING
converter GuiComboBoxProperty2int32* (self: GuiComboBoxProperty): int32 = self.int32
# DropdownBox
type GuiDropdownBoxProperty* = enum
ARROW_PADDING = 16
DROPDOWN_ITEMS_PADDING
converter GuiDropdownBoxProperty2int32* (self: GuiDropdownBoxProperty): int32 = self.int32
# TextBox / TextBoxMulti / ValueBox / Spinner
type GuiTextBoxProperty* = enum
TEXT_INNER_PADDING = 16
TEXT_LINES_PADDING
COLOR_SELECTED_FG
COLOR_SELECTED_BG
converter GuiTextBoxProperty2int32* (self: GuiTextBoxProperty): int32 = self.int32
# Spinner
type GuiSpinnerProperty* = enum
SPIN_BUTTON_WIDTH = 16
SPIN_BUTTON_PADDING
converter GuiSpinnerProperty2int32* (self: GuiSpinnerProperty): int32 = self.int32
# ScrollBar
type GuiScrollBarProperty* = enum
ARROWS_SIZE = 16
ARROWS_VISIBLE
SCROLL_SLIDER_PADDING
SCROLL_SLIDER_SIZE
SCROLL_PADDING
SCROLL_SPEED
converter GuiScrollBarProperty2int32* (self: GuiScrollBarProperty): int32 = self.int32
# ScrollBar side
type GuiScrollBarSide* = enum
SCROLLBAR_LEFT_SIDE = 0
SCROLLBAR_RIGHT_SIDE
converter GuiScrollBarSide2int32* (self: GuiScrollBarSide): int32 = self.int32
# ListView
type GuiListViewProperty* = enum
LIST_ITEMS_HEIGHT = 16
LIST_ITEMS_PADDING
SCROLLBAR_WIDTH
SCROLLBAR_SIDE
converter GuiListViewProperty2int32* (self: GuiListViewProperty): int32 = self.int32
# ColorPicker
type GuiColorPickerProperty* = enum
COLOR_SELECTOR_SIZE = 16
HUEBAR_WIDTH # Right hue bar width
HUEBAR_PADDING # Right hue bar separation from panel
HUEBAR_SELECTOR_HEIGHT # Right hue bar selector height
HUEBAR_SELECTOR_OVERFLOW # Right hue bar selector overflow
converter GuiColorPickerProperty2int32* (self: GuiColorPickerProperty): int32 = self.int32
# ----------------------------------------------------------------------------------
# Global Variables Definition
# ----------------------------------------------------------------------------------
# ...
# ----------------------------------------------------------------------------------
# Module Functions Declaration
# ----------------------------------------------------------------------------------
# State modification functions
proc GuiEnable*() {.RAYGUIDEF, importc: "GuiEnable".} # Enable gui controls (global state)
proc GuiDisable*() {.RAYGUIDEF, importc: "GuiDisable".} # Disable gui controls (global state)
proc GuiLock*() {.RAYGUIDEF, importc: "GuiLock".} # Lock gui controls (global state)
proc GuiUnlock*() {.RAYGUIDEF, importc: "GuiUnlock".} # Unlock gui controls (global state)
proc GuiFade*(alpha: float32) {.RAYGUIDEF, importc: "GuiFade".} # Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
proc GuiSetState*(state: int32) {.RAYGUIDEF, importc: "GuiSetState".} # Set gui state (global state)
proc GuiGetState*(): int32 {.RAYGUIDEF, importc: "GuiGetState".} # Get gui state (global state)
# Font set/get functions
proc GuiSetFont*(font: Font) {.RAYGUIDEF, importc: "GuiSetFont".} # Set gui custom font (global state)
proc GuiGetFont*(): Font {.RAYGUIDEF, importc: "GuiGetFont".} # Get gui custom font (global state)
# Style set/get functions
proc GuiSetStyle*(control: int32; property: int32; value: int32) {.RAYGUIDEF, importc: "GuiSetStyle".} # Set one style property
proc GuiGetStyle*(control: int32; property: int32): int32 {.RAYGUIDEF, importc: "GuiGetStyle".} # Get one style property
# Container/separator controls, useful for controls organization
proc GuiWindowBox*(bounds: Rectangle; title: cstring): bool {.RAYGUIDEF, importc: "GuiWindowBox".} # Window Box control, shows a window that can be closed
proc GuiGroupBox*(bounds: Rectangle; text: cstring) {.RAYGUIDEF, importc: "GuiGroupBox".} # Group Box control with text name
proc GuiLine*(bounds: Rectangle; text: cstring) {.RAYGUIDEF, importc: "GuiLine".} # Line separator control, could contain text
proc GuiPanel*(bounds: Rectangle) {.RAYGUIDEF, importc: "GuiPanel".} # Panel control, useful to group controls
proc GuiScrollPanel*(bounds: Rectangle; content: Rectangle; scroll: ptr Vector2): Rectangle {.RAYGUIDEF, importc: "GuiScrollPanel".} # Scroll Panel control
# Basic controls set
proc GuiLabel*(bounds: Rectangle; text: cstring) {.RAYGUIDEF, importc: "GuiLabel".} # Label control, shows text
proc GuiButton*(bounds: Rectangle; text: cstring): bool {.RAYGUIDEF, importc: "GuiButton".} # Button control, returns true when clicked
proc GuiLabelButton*(bounds: Rectangle; text: cstring): bool {.RAYGUIDEF, importc: "GuiLabelButton".} # Label button control, show true when clicked
proc GuiImageButton*(bounds: Rectangle; text: cstring; texture: Texture2D): bool {.RAYGUIDEF, importc: "GuiImageButton".} # Image button control, returns true when clicked
proc GuiImageButtonEx*(bounds: Rectangle; text: cstring; texture: Texture2D; texSource: Rectangle): bool {.RAYGUIDEF, importc: "GuiImageButtonEx".} # Image button extended control, returns true when clicked
proc GuiToggle*(bounds: Rectangle; text: cstring; active: bool): bool {.RAYGUIDEF, importc: "GuiToggle".} # Toggle Button control, returns true when active
proc GuiToggleGroup*(bounds: Rectangle; text: cstring; active: int32): int32 {.RAYGUIDEF, importc: "GuiToggleGroup".} # Toggle Group control, returns active toggle index
proc GuiCheckBox*(bounds: Rectangle; text: cstring; checked: bool): bool {.RAYGUIDEF, importc: "GuiCheckBox".} # Check Box control, returns true when active
proc GuiComboBox*(bounds: Rectangle; text: cstring; active: int32): int32 {.RAYGUIDEF, importc: "GuiComboBox".} # Combo Box control, returns selected item index
proc GuiDropdownBox*(bounds: Rectangle; text: cstring; active: pointer; editMode: bool): bool {.RAYGUIDEF, importc: "GuiDropdownBox".} # Dropdown Box control, returns selected item
proc GuiSpinner*(bounds: Rectangle; text: cstring; value: pointer; minValue: int32; maxValue: int32; editMode: bool): bool {.RAYGUIDEF, importc: "GuiSpinner".} # Spinner control, returns selected value
proc GuiValueBox*(bounds: Rectangle; text: cstring; value: pointer; minValue: int32; maxValue: int32; editMode: bool): bool {.RAYGUIDEF, importc: "GuiValueBox".} # Value Box control, updates input text with numbers
proc GuiTextBox*(bounds: Rectangle; text: ptr char; textSize: int32; editMode: bool): bool {.RAYGUIDEF, importc: "GuiTextBox".} # Text Box control, updates input text
proc GuiTextBoxMulti*(bounds: Rectangle; text: ptr char; textSize: int32; editMode: bool): bool {.RAYGUIDEF, importc: "GuiTextBoxMulti".} # Text Box control with multiple lines
proc GuiSlider*(bounds: Rectangle; textLeft: cstring; textRight: cstring; value: float32; minValue: float32; maxValue: float32): float32 {.RAYGUIDEF, importc: "GuiSlider".} # Slider control, returns selected value
proc GuiSliderBar*(bounds: Rectangle; textLeft: cstring; textRight: cstring; value: float32; minValue: float32; maxValue: float32): float32 {.RAYGUIDEF, importc: "GuiSliderBar".} # Slider Bar control, returns selected value
proc GuiProgressBar*(bounds: Rectangle; textLeft: cstring; textRight: cstring; value: float32; minValue: float32; maxValue: float32): float32 {.RAYGUIDEF, importc: "GuiProgressBar".} # Progress Bar control, shows current progress value
proc GuiStatusBar*(bounds: Rectangle; text: cstring) {.RAYGUIDEF, importc: "GuiStatusBar".} # Status Bar control, shows info text
proc GuiDummyRec*(bounds: Rectangle; text: cstring) {.RAYGUIDEF, importc: "GuiDummyRec".} # Dummy control for placeholders
proc GuiScrollBar*(bounds: Rectangle; value: int32; minValue: int32; maxValue: int32): int32 {.RAYGUIDEF, importc: "GuiScrollBar".} # Scroll Bar control
proc GuiGrid*(bounds: Rectangle; spacing: float32; subdivs: int32): Vector2 {.RAYGUIDEF, importc: "GuiGrid".} # Grid control
# Advance controls set
proc GuiListView*(bounds: Rectangle; text: cstring; scrollIndex: pointer; active: int32): int32 {.RAYGUIDEF, importc: "GuiListView".} # List View control, returns selected list item index
proc GuiListViewEx*(bounds: Rectangle; text: cstring; count: int32; focus: pointer; scrollIndex: pointer; active: int32): int32 {.RAYGUIDEF, importc: "GuiListViewEx".} # List View with extended parameters
proc GuiMessageBox*(bounds: Rectangle; title: cstring; message: cstring; buttons: cstring): int32 {.RAYGUIDEF, importc: "GuiMessageBox".} # Message Box control, displays a message
proc GuiTextInputBox*(bounds: Rectangle; title: cstring; message: cstring; buttons: cstring; text: ptr char): int32 {.RAYGUIDEF, importc: "GuiTextInputBox".} # Text Input Box control, ask for text
proc GuiColorPicker*(bounds: Rectangle; color: Color): Color {.RAYGUIDEF, importc: "GuiColorPicker".} # Color Picker control (multiple color controls)
proc GuiColorPanel*(bounds: Rectangle; color: Color): Color {.RAYGUIDEF, importc: "GuiColorPanel".} # Color Panel control
proc GuiColorBarAlpha*(bounds: Rectangle; alpha: float32): float32 {.RAYGUIDEF, importc: "GuiColorBarAlpha".} # Color Bar Alpha control
proc GuiColorBarHue*(bounds: Rectangle; value: float32): float32 {.RAYGUIDEF, importc: "GuiColorBarHue".} # Color Bar Hue control
# Styles loading functions
proc GuiLoadStyle*(fileName: cstring) {.RAYGUIDEF, importc: "GuiLoadStyle".} # Load style file (.rgs)
proc GuiLoadStyleDefault*() {.RAYGUIDEF, importc: "GuiLoadStyleDefault".} # Load style default over global style
proc GuiIconText*(iconId: int32; text: cstring): cstring {.RAYGUIDEF, importc: "GuiIconText".} # Get text with icon id prepended (if supported)
# Gui icons functionality
proc GuiDrawIcon*(iconId: int32; position: Vector2; pixelSize: int32; color: Color) {.RAYGUIDEF, importc: "GuiDrawIcon".}
proc GuiGetIcons*(): uint32 {.RAYGUIDEF, importc: "GuiGetIcons".} # Get full icons data pointer
proc GuiGetIconData*(iconId: int32): uint32 {.RAYGUIDEF, importc: "GuiGetIconData".} # Get icon bit data
proc GuiSetIconData*(iconId: int32; data: uint32) {.RAYGUIDEF, importc: "GuiSetIconData".} # Set icon bit data
proc GuiSetIconPixel*(iconId: int32; x: int32; y: int32) {.RAYGUIDEF, importc: "GuiSetIconPixel".} # Set icon pixel value
proc GuiClearIconPixel*(iconId: int32; x: int32; y: int32) {.RAYGUIDEF, importc: "GuiClearIconPixel".} # Clear icon pixel value
proc GuiCheckIconPixel*(iconId: int32; x: int32; y: int32): bool {.RAYGUIDEF, importc: "GuiCheckIconPixel".} # Check icon pixel value
#
# RAYGUI IMPLEMENTATION
#

1291
src/gamepkg/raylib.nim

File diff suppressed because it is too large

270
src/gamepkg/raymath.nim

@ -0,0 +1,270 @@
#
# raymath v1.2 - Math functions to work with Vector3, Matrix and Quaternions
#
# CONFIGURATION:
#
# #define RAYMATH_IMPLEMENTATION
# Generates the implementation of the library into the included file.
# If not defined, the library is in header only mode and can be included in other headers
# or source files without problems. But only ONE file should hold the implementation.
#
# #define RAYMATH_HEADER_ONLY
# Define static inline functions code, so #include header suffices for use.
# This may use up lots of memory.
#
# #define RAYMATH_STANDALONE
# Avoid raylib.h header inclusion in this file.
# Vector3 and Matrix data types are defined internally in raymath module.
#
#
# LICENSE: zlib/libpng
#
# Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose, including commercial
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not claim that you
# wrote the original software. If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
# as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
#
template RAYMATH_H*(): auto = RAYMATH_H
# #define RAYMATH_STANDALONE
# #define RAYMATH_HEADER_ONLY
import raylib
{.pragma: RMDEF, cdecl, discardable, dynlib: "libraylib" & LEXT.}
# ----------------------------------------------------------------------------------
# Defines and Macros
# ----------------------------------------------------------------------------------
# Get float vector for Matrix
# Get float vector for Vector3
# ----------------------------------------------------------------------------------
# Types and Structures Definition
# ----------------------------------------------------------------------------------
# NOTE: Helper types to be used instead of array return types for *ToFloat functions
type float3* {.bycopy.} = object
v*: array[0..2, float32]
type float16* {.bycopy.} = object
v*: array[0..15, float32]
# ----------------------------------------------------------------------------------
# Module Functions Definition - Utils math
# ----------------------------------------------------------------------------------
# Clamp float value
proc Clamp*(value: float32; min: float32; max: float32): float32 {.RMDEF, importc: "Clamp".}
# Calculate linear interpolation between two floats
proc Lerp*(start: float32; endx: float32; amount: float32): float32 {.RMDEF, importc: "Lerp".}
# Normalize input value within input range
proc Normalize*(value: float32; start: float32; endx: float32): float32 {.RMDEF, importc: "Normalize".}
# Remap input value within input range to output range
proc Remap*(value: float32; inputStart: float32; inputEnd: float32; outputStart: float32; outputEnd: float32): float32 {.RMDEF, importc: "Remap".}
# ----------------------------------------------------------------------------------
# Module Functions Definition - Vector2 math
# ----------------------------------------------------------------------------------
# Vector with components value 0.0f
proc Vector2Zero*(): Vector2 {.RMDEF, importc: "Vector2Zero".}
# Vector with components value 1.0f
proc Vector2One*(): Vector2 {.RMDEF, importc: "Vector2One".}
# Add two vectors (v1 + v2)
proc Vector2Add*(v1: Vector2; v2: Vector2): Vector2 {.RMDEF, importc: "Vector2Add".}
# Add vector and float value
proc Vector2AddValue*(v: Vector2; add: float32): Vector2 {.RMDEF, importc: "Vector2AddValue".}
# Subtract two vectors (v1 - v2)
proc Vector2Subtract*(v1: Vector2; v2: Vector2): Vector2 {.RMDEF, importc: "Vector2Subtract".}
# Subtract vector by float value
proc Vector2SubtractValue*(v: Vector2; sub: float32): Vector2 {.RMDEF, importc: "Vector2SubtractValue".}
# Calculate vector length
proc Vector2Length*(v: Vector2): float32 {.RMDEF, importc: "Vector2Length".}
# Calculate vector square length
proc Vector2LengthSqr*(v: Vector2): float32 {.RMDEF, importc: "Vector2LengthSqr".}
# Calculate two vectors dot product
proc Vector2DotProduct*(v1: Vector2; v2: Vector2): float32 {.RMDEF, importc: "Vector2DotProduct".}
# Calculate distance between two vectors
proc Vector2Distance*(v1: Vector2; v2: Vector2): float32 {.RMDEF, importc: "Vector2Distance".}
# Calculate angle from two vectors in X-axis
proc Vector2Angle*(v1: Vector2; v2: Vector2): float32 {.RMDEF, importc: "Vector2Angle".}
# Scale vector (multiply by value)
proc Vector2Scale*(v: Vector2; scale: float32): Vector2 {.RMDEF, importc: "Vector2Scale".}
# Multiply vector by vector
proc Vector2Multiply*(v1: Vector2; v2: Vector2): Vector2 {.RMDEF, importc: "Vector2Multiply".}
# Negate vector
proc Vector2Negate*(v: Vector2): Vector2 {.RMDEF, importc: "Vector2Negate".}
# Divide vector by vector
proc Vector2Divide*(v1: Vector2; v2: Vector2): Vector2 {.RMDEF, importc: "Vector2Divide".}
# Normalize provided vector
proc Vector2Normalize*(v: Vector2): Vector2 {.RMDEF, importc: "Vector2Normalize".}
# Calculate linear interpolation between two vectors
proc Vector2Lerp*(v1: Vector2; v2: Vector2; amount: float32): Vector2 {.RMDEF, importc: "Vector2Lerp".}
# Calculate reflected vector to normal
proc Vector2Reflect*(v: Vector2; normal: Vector2): Vector2 {.RMDEF, importc: "Vector2Reflect".}
# Rotate Vector by float in Degrees.
proc Vector2Rotate*(v: Vector2; degs: float32): Vector2 {.RMDEF, importc: "Vector2Rotate".}
# Move Vector towards target
proc Vector2MoveTowards*(v: Vector2; target: Vector2; maxDistance: float32): Vector2 {.RMDEF, importc: "Vector2MoveTowards".}
# ----------------------------------------------------------------------------------
# Module Functions Definition - Vector3 math
# ----------------------------------------------------------------------------------
# Vector with components value 0.0f
proc Vector3Zero*(): Vector3 {.RMDEF, importc: "Vector3Zero".}
# Vector with components value 1.0f
proc Vector3One*(): Vector3 {.RMDEF, importc: "Vector3One".}
# Add two vectors
proc Vector3Add*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Add".}
# Add vector and float value
proc Vector3AddValue*(v: Vector3; add: float32): Vector3 {.RMDEF, importc: "Vector3AddValue".}
# Subtract two vectors
proc Vector3Subtract*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Subtract".}
# Subtract vector by float value
proc Vector3SubtractValue*(v: Vector3; sub: float32): Vector3 {.RMDEF, importc: "Vector3SubtractValue".}
# Multiply vector by scalar
proc Vector3Scale*(v: Vector3; scalar: float32): Vector3 {.RMDEF, importc: "Vector3Scale".}
# Multiply vector by vector
proc Vector3Multiply*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Multiply".}
# Calculate two vectors cross product
proc Vector3CrossProduct*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3CrossProduct".}
# Calculate one vector perpendicular vector
proc Vector3Perpendicular*(v: Vector3): Vector3 {.RMDEF, importc: "Vector3Perpendicular".}
# Calculate vector length
proc Vector3Length*(v: ptr Vector3): float32 {.RMDEF, importc: "Vector3Length".}
# Calculate vector square length
proc Vector3LengthSqr*(v: ptr Vector3): float32 {.RMDEF, importc: "Vector3LengthSqr".}
# Calculate two vectors dot product
proc Vector3DotProduct*(v1: Vector3; v2: Vector3): float32 {.RMDEF, importc: "Vector3DotProduct".}
# Calculate distance between two vectors
proc Vector3Distance*(v1: Vector3; v2: Vector3): float32 {.RMDEF, importc: "Vector3Distance".}
# Negate provided vector (invert direction)
proc Vector3Negate*(v: Vector3): Vector3 {.RMDEF, importc: "Vector3Negate".}
# Divide vector by vector
proc Vector3Divide*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Divide".}
# Normalize provided vector
proc Vector3Normalize*(v: Vector3): Vector3 {.RMDEF, importc: "Vector3Normalize".}
# Orthonormalize provided vectors
# Makes vectors normalized and orthogonal to each other
# Gram-Schmidt function implementation
proc Vector3OrthoNormalize*(v1: ptr Vector3; v2: ptr Vector3) {.RMDEF, importc: "Vector3OrthoNormalize".}
# Transforms a Vector3 by a given Matrix
proc Vector3Transform*(v: Vector3; mat: Matrix): Vector3 {.RMDEF, importc: "Vector3Transform".}
# Transform a vector by quaternion rotation
proc Vector3RotateByQuaternion*(v: Vector3; q: Quaternion): Vector3 {.RMDEF, importc: "Vector3RotateByQuaternion".}
# Calculate linear interpolation between two vectors
proc Vector3Lerp*(v1: Vector3; v2: Vector3; amount: float32): Vector3 {.RMDEF, importc: "Vector3Lerp".}
# Calculate reflected vector to normal
proc Vector3Reflect*(v: Vector3; normal: Vector3): Vector3 {.RMDEF, importc: "Vector3Reflect".}
# Get min value for each pair of components
proc Vector3Min*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Min".}
# Get max value for each pair of components
proc Vector3Max*(v1: Vector3; v2: Vector3): Vector3 {.RMDEF, importc: "Vector3Max".}
# Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)
# NOTE: Assumes P is on the plane of the triangle
proc Vector3Barycenter*(p: Vector3; a: Vector3; b: Vector3; c: Vector3): Vector3 {.RMDEF, importc: "Vector3Barycenter".}
# Get Vector3 as float array
proc Vector3ToFloatV*(v: Vector3): float3 {.RMDEF, importc: "Vector3ToFloatV".}
# ----------------------------------------------------------------------------------
# Module Functions Definition - Matrix math
# ----------------------------------------------------------------------------------
# Compute matrix determinant
proc MatrixDeterminant*(mat: Matrix): float32 {.RMDEF, importc: "MatrixDeterminant".}
# Get the trace of the matrix (sum of the values along the diagonal)
proc MatrixTrace*(mat: Matrix): float32 {.RMDEF, importc: "MatrixTrace".}
# Transposes provided matrix
proc MatrixTranspose*(mat: Matrix): Matrix {.RMDEF, importc: "MatrixTranspose".}
# Invert provided matrix
proc MatrixInvert*(mat: Matrix): Matrix {.RMDEF, importc: "MatrixInvert".}
# Normalize provided matrix
proc MatrixNormalize*(mat: Matrix): Matrix {.RMDEF, importc: "MatrixNormalize".}
# Get identity matrix
proc MatrixIdentity*(): Matrix {.RMDEF, importc: "MatrixIdentity".}
# Add two matrices
proc MatrixAdd*(left: Matrix; right: Matrix): Matrix {.RMDEF, importc: "MatrixAdd".}
# Subtract two matrices (left - right)
proc MatrixSubtract*(left: Matrix; right: Matrix): Matrix {.RMDEF, importc: "MatrixSubtract".}
# Get two matrix multiplication
# NOTE: When multiplying matrices... the order matters!
proc MatrixMultiply*(left: Matrix; right: Matrix): Matrix {.RMDEF, importc: "MatrixMultiply".}
# Get translation matrix
proc MatrixTranslate*(x: float32; y: float32; z: float32): Matrix {.RMDEF, importc: "MatrixTranslate".}
# Create rotation matrix from axis and angle
# NOTE: Angle should be provided in radians
proc MatrixRotate*(axis: Vector3; angle: float32): Matrix {.RMDEF, importc: "MatrixRotate".}
# Get x-rotation matrix (angle in radians)
proc MatrixRotateX*(angle: float32): Matrix {.RMDEF, importc: "MatrixRotateX".}
# Get y-rotation matrix (angle in radians)
proc MatrixRotateY*(angle: float32): Matrix {.RMDEF, importc: "MatrixRotateY".}
# Get z-rotation matrix (angle in radians)
proc MatrixRotateZ*(angle: float32): Matrix {.RMDEF, importc: "MatrixRotateZ".}
# Get xyz-rotation matrix (angles in radians)
proc MatrixRotateXYZ*(ang: Vector3): Matrix {.RMDEF, importc: "MatrixRotateXYZ".}
# Get zyx-rotation matrix (angles in radians)
proc MatrixRotateZYX*(ang: Vector3): Matrix {.RMDEF, importc: "MatrixRotateZYX".}
# Get scaling matrix
proc MatrixScale*(x: float32; y: float32; z: float32): Matrix {.RMDEF, importc: "MatrixScale".}
# Get perspective projection matrix
proc MatrixFrustum*(left: float64; right: float64; bottom: float64; top: float64; near: float64; far: float64): Matrix {.RMDEF, importc: "MatrixFrustum".}
# Get perspective projection matrix
# NOTE: Angle should be provided in radians
proc MatrixPerspective*(fovy: float64; aspect: float64; near: float64; far: float64): Matrix {.RMDEF, importc: "MatrixPerspective".}
# Get orthographic projection matrix
proc MatrixOrtho*(left: float64; right: float64; bottom: float64; top: float64; near: float64; far: float64): Matrix {.RMDEF, importc: "MatrixOrtho".}
# Get camera look-at matrix (view matrix)
proc MatrixLookAt*(eye: Vector3; target: Vector3; up: Vector3): Matrix {.RMDEF, importc: "MatrixLookAt".}
# Get float array of matrix data
proc MatrixToFloatV*(mat: Matrix): float16 {.RMDEF, importc: "MatrixToFloatV".}
# ----------------------------------------------------------------------------------
# Module Functions Definition - Quaternion math
# ----------------------------------------------------------------------------------
# Add two quaternions
proc QuaternionAdd*(q1: Quaternion; q2: Quaternion): Quaternion {.RMDEF, importc: "QuaternionAdd".}
# Add quaternion and float value
proc QuaternionAddValue*(q: Quaternion; add: float32): Quaternion {.RMDEF, importc: "QuaternionAddValue".}
# Subtract two quaternions
proc QuaternionSubtract*(q1: Quaternion; q2: Quaternion): Quaternion {.RMDEF, importc: "QuaternionSubtract".}
# Subtract quaternion and float value
proc QuaternionSubtractValue*(q: Quaternion; sub: float32): Quaternion {.RMDEF, importc: "QuaternionSubtractValue".}
# Get identity quaternion
proc QuaternionIdentity*(): Quaternion {.RMDEF, importc: "QuaternionIdentity".}
# Computes the length of a quaternion
proc QuaternionLength*(q: Quaternion): float32 {.RMDEF, importc: "QuaternionLength".}
# Normalize provided quaternion
proc QuaternionNormalize*(q: Quaternion): Quaternion {.RMDEF, importc: "QuaternionNormalize".}
# Invert provided quaternion
proc QuaternionInvert*(q: Quaternion): Quaternion {.RMDEF, importc: "QuaternionInvert".}
# Calculate two quaternion multiplication
proc QuaternionMultiply*(q1: Quaternion; q2: Quaternion): Quaternion {.RMDEF, importc: "QuaternionMultiply".}
# Scale quaternion by float value
proc QuaternionScale*(q: Quaternion; mul: float32): Quaternion {.RMDEF, importc: "QuaternionScale".}
# Divide two quaternions
proc QuaternionDivide*(q1: Quaternion; q2: Quaternion): Quaternion {.RMDEF, importc: "QuaternionDivide".}
# Calculate linear interpolation between two quaternions
proc QuaternionLerp*(q1: Quaternion; q2: Quaternion; amount: float32): Quaternion {.RMDEF, importc: "QuaternionLerp".}
# Calculate slerp-optimized interpolation between two quaternions
proc QuaternionNlerp*(q1: Quaternion; q2: Quaternion; amount: float32): Quaternion {.RMDEF, importc: "QuaternionNlerp".}
# Calculates spherical linear interpolation between two quaternions
proc QuaternionSlerp*(q1: Quaternion; q2: Quaternion; amount: float32): Quaternion {.RMDEF, importc: "QuaternionSlerp".}
# Calculate quaternion based on the rotation from one vector to another
proc QuaternionFromVector3ToVector3*(fromx: Vector3; to: Vector3): Quaternion {.RMDEF, importc: "QuaternionFromVector3ToVector3".}
# Get a quaternion for a given rotation matrix
proc QuaternionFromMatrix*(mat: Matrix): Quaternion {.RMDEF, importc: "QuaternionFromMatrix".}
# Get a matrix for a given quaternion
proc QuaternionToMatrix*(q: Quaternion): Matrix {.RMDEF, importc: "QuaternionToMatrix".}
# Get rotation quaternion for an angle and axis
# NOTE: angle must be provided in radians
proc QuaternionFromAxisAngle*(axis: Vector3; angle: float32): Quaternion {.RMDEF, importc: "QuaternionFromAxisAngle".}
# Get the rotation angle and axis for a given quaternion
proc QuaternionToAxisAngle*(q: Quaternion; outAxis: ptr Vector3; outAngle: float32) {.RMDEF, importc: "QuaternionToAxisAngle".}
# Get the quaternion equivalent to Euler angles
# NOTE: Rotation order is ZYX
proc QuaternionFromEuler*(pitch: float32; yaw: float32; roll: float32): Quaternion {.RMDEF, importc: "QuaternionFromEuler".}
# Get the Euler angles equivalent to quaternion (roll, pitch, yaw)
# NOTE: Angles are returned in a Vector3 struct in degrees
proc QuaternionToEuler*(q: Quaternion): Vector3 {.RMDEF, importc: "QuaternionToEuler".}
# Transform a quaternion given a transformation matrix
proc QuaternionTransform*(q: Quaternion; mat: Matrix): Quaternion {.RMDEF, importc: "QuaternionTransform".}
# Projects a Vector3 from screen space into object space
proc Vector3Unproject*(source: Vector3; projection: Matrix; view: Matrix): Vector3 {.RMDEF, importc: "Vector3Unproject".}

318
src/gamepkg/rlgl.nim

@ -0,0 +1,318 @@
#
# rlgl v3.7 - raylib OpenGL abstraction layer
#
# rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to
# pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...).
#
# When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
# VBO buffers (and VAOs if available). It requires calling 3 functions:
# rlglInit() - Initialize internal buffers and auxiliary resources
# rlglClose() - De-initialize internal buffers data and other auxiliar resources
#
# CONFIGURATION:
#
# #define GRAPHICS_API_OPENGL_11
# #define GRAPHICS_API_OPENGL_21
# #define GRAPHICS_API_OPENGL_33
# #define GRAPHICS_API_OPENGL_ES2
# Use selected OpenGL graphics backend, should be supported by platform
# Those preprocessor defines are only used on rlgl module, if OpenGL version is
# required by any other module, use rlGetVersion() to check it
#
# #define RLGL_IMPLEMENTATION
# Generates the implementation of the library into the included file.
# If not defined, the library is in header only mode and can be included in other headers
# or source files without problems. But only ONE file should hold the implementation.
#
# #define RLGL_STANDALONE
# Use rlgl as standalone library (no raylib dependency)
#
# #define SUPPORT_GL_DETAILS_INFO
# Show OpenGL extensions and capabilities detailed logs on init
#
# DEPENDENCIES:
# raymath - 3D math functionality (Vector3, Matrix, Quaternion)
# GLAD - OpenGL extensions loading (OpenGL 3.3 Core only)
#
#
# LICENSE: zlib/libpng
#
# Copyright (c) 2014-2021 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose, including commercial
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not claim that you
# wrote the original software. If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
# as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
#
template RLGL_H*(): auto = RLGL_H
{.pragma: RLAPI, cdecl, discardable, dynlib: "libraylib" & LEXT.}
import raylib
# Security check in case no GRAPHICS_API_OPENGL_* defined
# Security check in case multiple GRAPHICS_API_OPENGL_* defined
# OpenGL 2.1 uses most of OpenGL 3.3 Core functionality
# WARNING: Specific parts are checked with #if defines
template SUPPORT_RENDER_TEXTURES_HINT*(): auto = SUPPORT_RENDER_TEXTURES_HINT
# ----------------------------------------------------------------------------------
# Defines and Macros
# ----------------------------------------------------------------------------------
# Default internal render batch limits
# Internal Matrix stack
# Vertex buffers id limit
# Shader and material limits
# Projection matrix culling
# Texture parameters (equivalent to OpenGL defines)
template RL_TEXTURE_WRAP_S*(): auto = 0x2802
template RL_TEXTURE_WRAP_T*(): auto = 0x2803
template RL_TEXTURE_MAG_FILTER*(): auto = 0x2800
template RL_TEXTURE_MIN_FILTER*(): auto = 0x2801
template RL_TEXTURE_FILTER_NEAREST*(): auto = 0x2600
template RL_TEXTURE_FILTER_LINEAR*(): auto = 0x2601
template RL_TEXTURE_FILTER_MIP_NEAREST*(): auto = 0x2700
template RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR*(): auto = 0x2702
template RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST*(): auto = 0x2701
template RL_TEXTURE_FILTER_MIP_LINEAR*(): auto = 0x2703
template RL_TEXTURE_FILTER_ANISOTROPIC*(): auto = 0x3000
template RL_TEXTURE_WRAP_REPEAT*(): auto = 0x2901
template RL_TEXTURE_WRAP_CLAMP*(): auto = 0x812F
template RL_TEXTURE_WRAP_MIRROR_REPEAT*(): auto = 0x8370
template RL_TEXTURE_WRAP_MIRROR_CLAMP*(): auto = 0x8742
# Matrix modes (equivalent to OpenGL)
template RL_MODELVIEW*(): auto = 0x1700
template RL_PROJECTION*(): auto = 0x1701
template RL_TEXTURE*(): auto = 0x1702
# Primitive assembly draw modes
template RL_LINES*(): auto = 0x0001
template RL_TRIANGLES*(): auto = 0x0004
template RL_QUADS*(): auto = 0x0007
# GL equivalent data types
template RL_UNSIGNED_BYTE*(): auto = 0x1401
template RL_FLOAT*(): auto = 0x1406
# ----------------------------------------------------------------------------------
# Types and Structures Definition
# ----------------------------------------------------------------------------------
type FramebufferAttachType* = enum
RL_ATTACHMENT_COLOR_CHANNEL0 = 0
RL_ATTACHMENT_COLOR_CHANNEL1
RL_ATTACHMENT_COLOR_CHANNEL2
RL_ATTACHMENT_COLOR_CHANNEL3
RL_ATTACHMENT_COLOR_CHANNEL4
RL_ATTACHMENT_COLOR_CHANNEL5
RL_ATTACHMENT_COLOR_CHANNEL6
RL_ATTACHMENT_COLOR_CHANNEL7
RL_ATTACHMENT_DEPTH = 100
RL_ATTACHMENT_STENCIL = 200
converter FramebufferAttachType2int32* (self: FramebufferAttachType): int32 = self.int32
type FramebufferAttachTextureType* = enum
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z
RL_ATTACHMENT_TEXTURE2D = 100
RL_ATTACHMENT_RENDERBUFFER = 200
converter FramebufferAttachTextureType2int32* (self: FramebufferAttachTextureType): int32 = self.int32
# Dynamic vertex buffers (position + texcoords + colors + indices arrays)
type VertexBuffer* {.bycopy.} = object
elementsCount*: int32 # Number of elements in the buffer (QUADS)
vCounter*: int32 # Vertex position counter to process (and draw) from full buffer
tcCounter*: int32 # Vertex texcoord counter to process (and draw) from full buffer
cCounter*: int32 # Vertex color counter to process (and draw) from full buffer
vertices*: float32 # Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
texcoords*: float32 # Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
colors*: uint8 # Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
indices*: uint32 # Vertex indices (in case vertex data comes indexed) (6 indices per quad)
# Skipped another *indices
vaoId*: uint32 # OpenGL Vertex Array Object id
vboId*: array[0..3, uint32] # OpenGL Vertex Buffer Objects id (4 types of vertex data)
# Draw call type
# NOTE: Only texture changes register a new draw, other state-change-related elements are not
# used at this moment (vaoId, shaderId, matrices), raylib just forces a batch draw call if any
# of those state-change happens (this is done in core module)
type DrawCall* {.bycopy.} = object
mode*: int32 # Drawing mode: LINES, TRIANGLES, QUADS
vertexCount*: int32 # Number of vertex of the draw
vertexAlignment*: int32 # Number of vertex required for index alignment (LINES, TRIANGLES)
textureId*: uint32 # Texture id to be used on the draw -> Use to create new draw call if changes
# RenderBatch type
type RenderBatch* {.bycopy.} = object
buffersCount*: int32 # Number of vertex buffers (multi-buffering support)
currentBuffer*: int32 # Current buffer tracking in case of multi-buffering
vertexBuffer*: ptr VertexBuffer # Dynamic buffer(s) for vertex data
draws*: ptr DrawCall # Draw calls array, depends on textureId
drawsCounter*: int32 # Draw calls counter
currentDepth*: float32 # Current depth value for next draw
# ------------------------------------------------------------------------------------
# Functions Declaration - Matrix operations
# ------------------------------------------------------------------------------------
proc rlMatrixMode*(mode: int32) {.RLAPI, importc: "rlMatrixMode".} # Choose the current matrix to be transformed
proc rlPushMatrix*() {.RLAPI, importc: "rlPushMatrix".} # Push the current matrix to stack
proc rlPopMatrix*() {.RLAPI, importc: "rlPopMatrix".} # Pop lattest inserted matrix from stack
proc rlLoadIdentity*() {.RLAPI, importc: "rlLoadIdentity".} # Reset current matrix to identity matrix
proc rlTranslatef*(x: float32; y: float32; z: float32) {.RLAPI, importc: "rlTranslatef".} # Multiply the current matrix by a translation matrix
proc rlRotatef*(angleDeg: float32; x: float32; y: float32; z: float32) {.RLAPI, importc: "rlRotatef".} # Multiply the current matrix by a rotation matrix
proc rlScalef*(x: float32; y: float32; z: float32) {.RLAPI, importc: "rlScalef".} # Multiply the current matrix by a scaling matrix
proc rlMultMatrixf*(matf: float32) {.RLAPI, importc: "rlMultMatrixf".} # Multiply the current matrix by another matrix
proc rlFrustum*(left: float64; right: float64; bottom: float64; top: float64; znear: float64; zfar: float64) {.RLAPI, importc: "rlFrustum".}
proc rlOrtho*(left: float64; right: float64; bottom: float64; top: float64; znear: float64; zfar: float64) {.RLAPI, importc: "rlOrtho".}
proc rlViewport*(x: int32; y: int32; width: int32; height: int32) {.RLAPI, importc: "rlViewport".} # Set the viewport area
# ------------------------------------------------------------------------------------
# Functions Declaration - Vertex level operations
# ------------------------------------------------------------------------------------
proc rlBegin*(mode: int32) {.RLAPI, importc: "rlBegin".} # Initialize drawing mode (how to organize vertex)
proc rlEnd*() {.RLAPI, importc: "rlEnd".} # Finish vertex providing
proc rlVertex2i*(x: int32; y: int32) {.RLAPI, importc: "rlVertex2i".} # Define one vertex (position) - 2 int
proc rlVertex2f*(x: float32; y: float32) {.RLAPI, importc: "rlVertex2f".} # Define one vertex (position) - 2 float
proc rlVertex3f*(x: float32; y: float32; z: float32) {.RLAPI, importc: "rlVertex3f".} # Define one vertex (position) - 3 float
proc rlTexCoord2f*(x: float32; y: float32) {.RLAPI, importc: "rlTexCoord2f".} # Define one vertex (texture coordinate) - 2 float
proc rlNormal3f*(x: float32; y: float32; z: float32) {.RLAPI, importc: "rlNormal3f".} # Define one vertex (normal) - 3 float
proc rlColor4ub*(r: uint8; g: uint8; b: uint8; a: uint8) {.RLAPI, importc: "rlColor4ub".} # Define one vertex (color) - 4 byte
proc rlColor3f*(x: float32; y: float32; z: float32) {.RLAPI, importc: "rlColor3f".} # Define one vertex (color) - 3 float
proc rlColor4f*(x: float32; y: float32; z: float32; w: float32) {.RLAPI, importc: "rlColor4f".} # Define one vertex (color) - 4 float
# ------------------------------------------------------------------------------------
# Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2)
# NOTE: This functions are used to completely abstract raylib code from OpenGL layer,
# some of them are direct wrappers over OpenGL calls, some others are custom
# ------------------------------------------------------------------------------------
# Vertex buffers state
proc rlEnableVertexArray*(vaoId: uint32): bool {.RLAPI, importc: "rlEnableVertexArray".} # Enable vertex array (VAO, if supported)
proc rlDisableVertexArray*() {.RLAPI, importc: "rlDisableVertexArray".} # Disable vertex array (VAO, if supported)
proc rlEnableVertexBuffer*(id: uint32) {.RLAPI, importc: "rlEnableVertexBuffer".} # Enable vertex buffer (VBO)
proc rlDisableVertexBuffer*() {.RLAPI, importc: "rlDisableVertexBuffer".} # Disable vertex buffer (VBO)
proc rlEnableVertexBufferElement*(id: uint32) {.RLAPI, importc: "rlEnableVertexBufferElement".} # Enable vertex buffer element (VBO element)
proc rlDisableVertexBufferElement*() {.RLAPI, importc: "rlDisableVertexBufferElement".} # Disable vertex buffer element (VBO element)
proc rlEnableVertexAttribute*(index: uint32) {.RLAPI, importc: "rlEnableVertexAttribute".} # Enable vertex attribute index
proc rlDisableVertexAttribute*(index: uint32) {.RLAPI, importc: "rlDisableVertexAttribute".} # Disable vertex attribute index
proc rlEnableStatePointer*(vertexAttribType: int32; buffer: pointer) {.RLAPI, importc: "rlEnableStatePointer".}
proc rlDisableStatePointer*(vertexAttribType: int32) {.RLAPI, importc: "rlDisableStatePointer".}
# Textures state
proc rlActiveTextureSlot*(slot: int32) {.RLAPI, importc: "rlActiveTextureSlot".} # Select and active a texture slot
proc rlEnableTexture*(id: uint32) {.RLAPI, importc: "rlEnableTexture".} # Enable texture
proc rlDisableTexture*() {.RLAPI, importc: "rlDisableTexture".} # Disable texture
proc rlEnableTextureCubemap*(id: uint32) {.RLAPI, importc: "rlEnableTextureCubemap".} # Enable texture cubemap
proc rlDisableTextureCubemap*() {.RLAPI, importc: "rlDisableTextureCubemap".} # Disable texture cubemap
proc rlTextureParameters*(id: uint32; param: int32; value: int32) {.RLAPI, importc: "rlTextureParameters".} # Set texture parameters (filter, wrap)
# Shader state
proc rlEnableShader*(id: uint32) {.RLAPI, importc: "rlEnableShader".} # Enable shader program
proc rlDisableShader*() {.RLAPI, importc: "rlDisableShader".} # Disable shader program
# Framebuffer state
proc rlEnableFramebuffer*(id: uint32) {.RLAPI, importc: "rlEnableFramebuffer".} # Enable render texture (fbo)
proc rlDisableFramebuffer*() {.RLAPI, importc: "rlDisableFramebuffer".} # Disable render texture (fbo), return to default framebuffer
# General render state
proc rlEnableDepthTest*() {.RLAPI, importc: "rlEnableDepthTest".} # Enable depth test
proc rlDisableDepthTest*() {.RLAPI, importc: "rlDisableDepthTest".} # Disable depth test
proc rlEnableDepthMask*() {.RLAPI, importc: "rlEnableDepthMask".} # Enable depth write
proc rlDisableDepthMask*() {.RLAPI, importc: "rlDisableDepthMask".} # Disable depth write
proc rlEnableBackfaceCulling*() {.RLAPI, importc: "rlEnableBackfaceCulling".} # Enable backface culling
proc rlDisableBackfaceCulling*() {.RLAPI, importc: "rlDisableBackfaceCulling".} # Disable backface culling
proc rlEnableScissorTest*() {.RLAPI, importc: "rlEnableScissorTest".} # Enable scissor test
proc rlDisableScissorTest*() {.RLAPI, importc: "rlDisableScissorTest".} # Disable scissor test
proc rlScissor*(x: int32; y: int32; width: int32; height: int32) {.RLAPI, importc: "rlScissor".} # Scissor test
proc rlEnableWireMode*() {.RLAPI, importc: "rlEnableWireMode".} # Enable wire mode
proc rlDisableWireMode*() {.RLAPI, importc: "rlDisableWireMode".} # Disable wire mode
proc rlSetLineWidth*(width: float32) {.RLAPI, importc: "rlSetLineWidth".} # Set the line drawing width
proc rlGetLineWidth*(): float32 {.RLAPI, importc: "rlGetLineWidth".} # Get the line drawing width
proc rlEnableSmoothLines*() {.RLAPI, importc: "rlEnableSmoothLines".} # Enable line aliasing
proc rlDisableSmoothLines*() {.RLAPI, importc: "rlDisableSmoothLines".} # Disable line aliasing
proc rlEnableStereoRender*() {.RLAPI, importc: "rlEnableStereoRender".} # Enable stereo rendering
proc rlDisableStereoRender*() {.RLAPI, importc: "rlDisableStereoRender".} # Disable stereo rendering
proc rlIsStereoRenderEnabled*(): bool {.RLAPI, importc: "rlIsStereoRenderEnabled".} # Check if stereo render is enabled
proc rlClearColor*(r: uint8; g: uint8; b: uint8; a: uint8) {.RLAPI, importc: "rlClearColor".} # Clear color buffer with color
proc rlClearScreenBuffers*() {.RLAPI, importc: "rlClearScreenBuffers".} # Clear used screen buffers (color and depth)
proc rlCheckErrors*() {.RLAPI, importc: "rlCheckErrors".} # Check and log OpenGL error codes
proc rlSetBlendMode*(mode: int32) {.RLAPI, importc: "rlSetBlendMode".} # Set blending mode
proc rlSetBlendFactors*(glSrcFactor: int32; glDstFactor: int32; glEquation: int32) {.RLAPI, importc: "rlSetBlendFactors".} # Set blending mode factor and equation (using OpenGL factors)
# ------------------------------------------------------------------------------------
# Functions Declaration - rlgl functionality
# ------------------------------------------------------------------------------------
# rlgl initialization functions
proc rlglInit*(width: int32; height: int32) {.RLAPI, importc: "rlglInit".} # Initialize rlgl (buffers, shaders, textures, states)
proc rlglClose*() {.RLAPI, importc: "rlglClose".} # De-inititialize rlgl (buffers, shaders, textures)
proc rlLoadExtensions*(loader: pointer) {.RLAPI, importc: "rlLoadExtensions".} # Load OpenGL extensions (loader function required)
proc rlGetVersion*(): int32 {.RLAPI, importc: "rlGetVersion".} # Get current OpenGL version
proc rlGetFramebufferWidth*(): int32 {.RLAPI, importc: "rlGetFramebufferWidth".} # Get default framebuffer width
proc rlGetFramebufferHeight*(): int32 {.RLAPI, importc: "rlGetFramebufferHeight".} # Get default framebuffer height
proc rlGetShaderDefault*(): Shader {.RLAPI, importc: "rlGetShaderDefault".} # Get default shader
proc rlGetTextureDefault*(): Texture2D {.RLAPI, importc: "rlGetTextureDefault".} # Get default texture
# Render batch management
# NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
# but this render batch API is exposed in case of custom batches are required
proc rlLoadRenderBatch*(numBuffers: int32; bufferElements: int32): RenderBatch {.RLAPI, importc: "rlLoadRenderBatch".} # Load a render batch system
proc rlUnloadRenderBatch*(batch: RenderBatch) {.RLAPI, importc: "rlUnloadRenderBatch".} # Unload render batch system
proc rlDrawRenderBatch*(batch: ptr RenderBatch) {.RLAPI, importc: "rlDrawRenderBatch".} # Draw render batch data (Update->Draw->Reset)
proc rlSetRenderBatchActive*(batch: ptr RenderBatch) {.RLAPI, importc: "rlSetRenderBatchActive".} # Set the active render batch for rlgl (NULL for default internal)
proc rlDrawRenderBatchActive*() {.RLAPI, importc: "rlDrawRenderBatchActive".} # Update and draw internal render batch
proc rlCheckRenderBatchLimit*(vCount: int32): bool {.RLAPI, importc: "rlCheckRenderBatchLimit".} # Check internal buffer overflow for a given number of vertex
proc rlSetTexture*(id: uint32) {.RLAPI, importc: "rlSetTexture".} # Set current texture for render batch and check buffers limits
# ------------------------------------------------------------------------------------------------------------------------
# Vertex buffers management
proc rlLoadVertexArray*(): uint32 {.RLAPI, importc: "rlLoadVertexArray".} # Load vertex array (vao) if supported
proc rlLoadVertexBuffer*(buffer: pointer; size: int32; dynamic: bool): uint32 {.RLAPI, importc: "rlLoadVertexBuffer".} # Load a vertex buffer attribute
proc rlLoadVertexBufferElement*(buffer: pointer; size: int32; dynamic: bool): uint32 {.RLAPI, importc: "rlLoadVertexBufferElement".} # Load a new attributes element buffer
proc rlUpdateVertexBuffer*(bufferId: int32; data: pointer; dataSize: int32; offset: int32) {.RLAPI, importc: "rlUpdateVertexBuffer".} # Update GPU buffer with new data
proc rlUnloadVertexArray*(vaoId: uint32) {.RLAPI, importc: "rlUnloadVertexArray".}
proc rlUnloadVertexBuffer*(vboId: uint32) {.RLAPI, importc: "rlUnloadVertexBuffer".}
proc rlSetVertexAttribute*(index: uint32; compSize: int32; typex: int32; normalized: bool; stride: int32; pointer: pointer) {.RLAPI, importc: "rlSetVertexAttribute".}
proc rlSetVertexAttributeDivisor*(index: uint32; divisor: int32) {.RLAPI, importc: "rlSetVertexAttributeDivisor".}
proc rlSetVertexAttributeDefault*(locIndex: int32; value: pointer; attribType: int32; count: int32) {.RLAPI, importc: "rlSetVertexAttributeDefault".} # Set vertex attribute default value
proc rlDrawVertexArray*(offset: int32; count: int32) {.RLAPI, importc: "rlDrawVertexArray".}
proc rlDrawVertexArrayElements*(offset: int32; count: int32; buffer: pointer) {.RLAPI, importc: "rlDrawVertexArrayElements".}
proc rlDrawVertexArrayInstanced*(offset: int32; count: int32; instances: int32) {.RLAPI, importc: "rlDrawVertexArrayInstanced".}
proc rlDrawVertexArrayElementsInstanced*(offset: int32; count: int32; buffer: pointer; instances: int32) {.RLAPI, importc: "rlDrawVertexArrayElementsInstanced".}
# Textures management
proc rlLoadTexture*(data: pointer; width: int32; height: int32; format: int32; mipmapCount: int32): uint32 {.RLAPI, importc: "rlLoadTexture".} # Load texture in GPU
proc rlLoadTextureDepth*(width: int32; height: int32; useRenderBuffer: bool): uint32 {.RLAPI, importc: "rlLoadTextureDepth".} # Load depth texture/renderbuffer (to be attached to fbo)
proc rlLoadTextureCubemap*(data: pointer; size: int32; format: int32): uint32 {.RLAPI, importc: "rlLoadTextureCubemap".} # Load texture cubemap
proc rlUpdateTexture*(id: uint32; offsetX: int32; offsetY: int32; width: int32; height: int32; format: int32; data: pointer) {.RLAPI, importc: "rlUpdateTexture".} # Update GPU texture with new data
proc rlGetGlTextureFormats*(format: int32; glInternalFormat: uint32; glFormat: uint32; glType: uint32) {.RLAPI, importc: "rlGetGlTextureFormats".} # Get OpenGL internal formats
proc rlGetPixelFormatName*(format: uint32): cstring {.RLAPI, importc: "rlGetPixelFormatName".} # Get name string for pixel format
proc rlUnloadTexture*(id: uint32) {.RLAPI, importc: "rlUnloadTexture".} # Unload texture from GPU memory
proc rlGenerateMipmaps*(texture: ptr Texture2D) {.RLAPI, importc: "rlGenerateMipmaps".} # Generate mipmap data for selected texture
proc rlReadTexturePixels*(texture: Texture2D): pointer {.RLAPI, importc: "rlReadTexturePixels".} # Read texture pixel data
proc rlReadScreenPixels*(width: int32; height: int32): uint8 {.RLAPI, importc: "rlReadScreenPixels".} # Read screen pixel data (color buffer)
# Framebuffer management (fbo)
proc rlLoadFramebuffer*(width: int32; height: int32): uint32 {.RLAPI, importc: "rlLoadFramebuffer".} # Load an empty framebuffer
proc rlFramebufferAttach*(fboId: uint32; texId: uint32; attachType: int32; texType: int32; mipLevel: int32) {.RLAPI, importc: "rlFramebufferAttach".} # Attach texture/renderbuffer to a framebuffer
proc rlFramebufferComplete*(id: uint32): bool {.RLAPI, importc: "rlFramebufferComplete".} # Verify framebuffer is complete
proc rlUnloadFramebuffer*(id: uint32) {.RLAPI, importc: "rlUnloadFramebuffer".} # Delete framebuffer from GPU
# Shaders management
proc rlLoadShaderCode*(vsCode: cstring; fsCode: cstring): uint32 {.RLAPI, importc: "rlLoadShaderCode".} # Load shader from code strings
proc rlCompileShader*(shaderCode: cstring; typex: int32): uint32 {.RLAPI, importc: "rlCompileShader".} # Compile custom shader and return shader id (type: GL_VERTEX_SHADER, GL_FRAGMENT_SHADER)
proc rlLoadShaderProgram*(vShaderId: uint32; fShaderId: uint32): uint32 {.RLAPI, importc: "rlLoadShaderProgram".} # Load custom shader program
proc rlUnloadShaderProgram*(id: uint32) {.RLAPI, importc: "rlUnloadShaderProgram".} # Unload shader program
proc rlGetLocationUniform*(shaderId: uint32; uniformName: cstring): int32 {.RLAPI, importc: "rlGetLocationUniform".} # Get shader location uniform
proc rlGetLocationAttrib*(shaderId: uint32; attribName: cstring): int32 {.RLAPI, importc: "rlGetLocationAttrib".} # Get shader location attribute
proc rlSetUniform*(locIndex: int32; value: pointer; uniformType: int32; count: int32) {.RLAPI, importc: "rlSetUniform".} # Set shader value uniform
proc rlSetUniformMatrix*(locIndex: int32; mat: Matrix) {.RLAPI, importc: "rlSetUniformMatrix".} # Set shader value matrix
proc rlSetUniformSampler*(locIndex: int32; textureId: uint32) {.RLAPI, importc: "rlSetUniformSampler".} # Set shader value sampler
proc rlSetShader*(shader: Shader) {.RLAPI, importc: "rlSetShader".} # Set shader currently active
# Matrix state management
proc rlGetMatrixModelview*(): Matrix {.RLAPI, importc: "rlGetMatrixModelview".} # Get internal modelview matrix
proc rlGetMatrixProjection*(): Matrix {.RLAPI, importc: "rlGetMatrixProjection".} # Get internal projection matrix
proc rlGetMatrixTransform*(): Matrix {.RLAPI, importc: "rlGetMatrixTransform".} # Get internal accumulated transform matrix
proc rlGetMatrixProjectionStereo*(eye: int32): Matrix {.RLAPI, importc: "rlGetMatrixProjectionStereo".} # Get internal projection matrix for stereo render (selected eye)
proc rlGetMatrixViewOffsetStereo*(eye: int32): Matrix {.RLAPI, importc: "rlGetMatrixViewOffsetStereo".} # Get internal view offset matrix for stereo render (selected eye)
proc rlSetMatrixProjection*(proj: Matrix) {.RLAPI, importc: "rlSetMatrixProjection".} # Set a custom projection matrix (replaces internal projection matrix)
proc rlSetMatrixModelview*(view: Matrix) {.RLAPI, importc: "rlSetMatrixModelview".} # Set a custom modelview matrix (replaces internal modelview matrix)
proc rlSetMatrixProjectionStereo*(right: Matrix; left: Matrix) {.RLAPI, importc: "rlSetMatrixProjectionStereo".} # Set eyes projection matrices for stereo rendering
proc rlSetMatrixViewOffsetStereo*(right: Matrix; left: Matrix) {.RLAPI, importc: "rlSetMatrixViewOffsetStereo".} # Set eyes view offsets matrices for stereo rendering
# Quick and dirty cube/quad buffers load->draw->unload
proc rlLoadDrawCube*() {.RLAPI, importc: "rlLoadDrawCube".} # Load and draw a cube
proc rlLoadDrawQuad*() {.RLAPI, importc: "rlLoadDrawQuad".} # Load and draw a quad
#
# RLGL IMPLEMENTATION
#
type rlglLoadProc* = proc()
# ----------------------------------------------------------------------------------
# Global Variables Definition
# ----------------------------------------------------------------------------------

36
styles/README.md

@ -0,0 +1,36 @@
## raygui styles
`raygui` comes with **8 custom styles** carefully designed for the best visual experience. Those styles have been created using [rGuiStyler](https://raylibtech.itch.io/rguistyler) tool and they complement internal [default style](default), always available by `raygui`.
To use those styles with your `raygui` development, just need to call `GuiLoadStyle()` function at initialization, passing the `.rgs` file to load. Note that most of those styles depend on custom fonts that must be available together with the `.rgs` file.
Here it is a quick overview of those styles, you can navigate to each directory for additional information.
#### style: [default](default)
![default style](default/style_table.png)
#### style: [ashes](ashes)
![ashes style](ashes/style_table.png)
#### style: [bluish](bluish)
![bluish style](bluish/style_table.png)
#### style: [candy](candy)
![candy style](candy/style_table.png)
#### style: [cherry](cherry)
![cherry style](cherry/style_table.png)
#### style: [cyber](cyber)
![cyber style](cyber/style_table.png)
#### style: [jungle](jungle)
![jungle style](jungle/style_table.png)
#### style: [lavanda](lavanda)
![lavanda style](lavanda/style_table.png)
#### style: [terminal](terminal)
![terminal style](terminal/style_table.png)
*NOTE: Those styles require latest raylib 2.6-dev and latest raygui 2.6-dev.*

16
styles/ashes/README.md

@ -0,0 +1,16 @@
style: ashes
-------------
What once was life now is ashes, just as slight reminiscense covers the ground, a gray sequence of tones that reminds to a distant past.
![ashes style table](style_table.png)
screenshot
-----------
![ashes style screen](screenshot.png)
about font
-----------
"V5 Loxica Lixera" font by vFive Digital (Roberto Christen).
100% free font, downloaded from dafont.com: [v5loxica-lixera](https://www.dafont.com/v5loxica-lixera.font)

24
styles/ashes/ashes.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 16 0 v5loxical.ttf
p 00 00 0xf0f0f0ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x868686ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0xe6e6e6ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0x929999ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xeaeaeaff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0x98a1a8ff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0x3f3f3fff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0xf6f6f6ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0x414141ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x8b8b8bff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x777777ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x959595ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x00000010 TEXT_SIZE
p 00 17 0x00000001 TEXT_SPACING
p 00 18 0x9dadb1ff DEFAULT_LINE_COLOR
p 00 19 0x6b6b6bff DEFAULT_BACKGROUND_COLOR

51
styles/ashes/font_readme.txt

@ -0,0 +1,51 @@
V5 Loxica
---------------
Instructions:
++ Loxica (LIXERA) ++
For screen use, set at 16pt. Turn
antialiasing off. Set tracking to zero
for best results.
++ Loxica (ROBUSTA) ++
For screen use, set at 18pt. Turn
antialiasing off. Set tracking to zero
for best results.
Notes:
1. These faces do not contain any hinting
information since they were built for use
at the sizes listed above. Naturally, for
print use you are free to experiment.
2. Although the intended size for _lixera_
is 16pt (vs. 18pt for _robusta_), they share
the same optical size (where lixera is the
regular weight, and robusta is the bold).
3. Pronounciation: "lo-hee-ka lee-he-ra", and
"lo-hee-ka ro-bus-ta."
---------------
Usage: This is a free font--you may use
this and other V5 fonts at will. It may not
be sold, altered, or improperly credited,
however. All I ask is that you kindly inform
me if you find this font useful, and where
you've used it.
Enjoy,
©2000
Roberto Christen
rob@vfive.com

BIN
styles/ashes/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
styles/ashes/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
styles/ashes/v5loxical.ttf

Binary file not shown.

16
styles/bluish/README.md

@ -0,0 +1,16 @@
style: bluish
--------------
Like a breeze, a slight touch of color cover the clear sky, a spacious and relaxing feeling.
![bluish style table](style_table.png)
screenshot
-----------
![bluish style screen](screenshot.png)
about font
-----------
"Homespun BRK" font by AEnigma (Brian Kent).
100% free font, downloaded from dafont.com: [homespun-brk](https://www.dafont.com/homespun-brk.font)

24
styles/bluish/bluish.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 10 0 homespun.ttf
p 00 00 0x5ca6a6ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0xb4e8f3ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0x447e77ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0x5f8792ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xcdeff7ff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0x4c6c74ff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0x3b5b5fff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0xeaffffff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0x275057ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x96aaacff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0xc8d7d9ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x8c9c9eff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x0000000a TEXT_SIZE
p 00 17 0x00000001 TEXT_SPACING
p 00 18 0x84adb7ff DEFAULT_LINE_COLOR
p 00 19 0xe8eef1ff DEFAULT_BACKGROUND_COLOR

76
styles/bluish/font_readme.txt

@ -0,0 +1,76 @@
_______________________________
Homespun Created by Brian Kent
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Thanks for Downloading Homespun.
Homespun TT [.ttf]
Homespun [8pt] [.fon]
'homespun.fon' is a Windows Bitmap Font (.fon). This font is best
used at 8pt. To use it at larger point sizes (for images), try using
a graphics program like Photoshop, Paint Shop Pro, or the Paint
program that comes with Windows. Type out your text at the recommended
point size [8pt], then resize the image. Set the color mode to 256
or 2 colors so the edges don't get blured when resizing, then after you
have the text to the size that you want, then change back to a higher
color mode and edit the image.
For programs that don't show Bitmap Fonts in the Font Selector, you
may be able to get the font to work by typing in:
homespun brk
When using the TTF version, try using it with anti-aliasing off.
If you have any questions or comments, you can e-mail me at
kentpw@norwich.net
You can visit my Webpage <ÆNIGMA GAMES & FONTS> at
http://www.aenigmafonts.com/
________________
INSTALLING FONTS
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
There's a couple of ways to install Fonts. The 'easy' way to
install fonts is to just Unzip/place the font file [.ttf] into your
Windows\Fonts directory (I always use this method). If you're unable
to do it the 'easy' way, then try to do it this way (for Windows
95/98/NT):
1] Unzip the Font(s) to a folder (or somewhere, just remember where
you unzipped it) on your Computer.
2] Next, click on the START button, then select SETTINGS then
CONTROL PANEL.
3] When the Control Panel Window pops up, Double Click on FONTS.
4] When the FONTS window pops up, select File then Install New Font...
5] A Add Fonts window will pop up, just go to the folder that you
unzipped the Font(s) to, select the Font(s) and then click on OK.
Now the Font(s) are installed.
Now you can use the Font(s) in programs that utilize Fonts. Make
sure that you install the font(s) first, then open up your apps
(so the app will recognize the font). Sometimes you'll have to
wait until your computer 'auto-refreshes' for programs to recognize
fonts (Windows is sometimes slow to do that). You can refresh your
computer quicker by going into Windows Explorer -or- My Computer and
press F5 (or in the menubar select VIEW then REFRESH).
__________
DISCLAIMER
¯¯¯¯¯¯¯¯¯¯
-The font(s) in this zip file were created by me (Brian Kent). All
of my Fonts are Freeware, you can use them any way you want to
(Personal use, Commercial use, or whatever).
-If you have a Font related site and would like to offer my fonts on
your site, go right ahead. All I ask is that you keep this text file
intact with the Font.
-You may not Sell or Distribute my Fonts for profit or alter them in
any way without asking me first. [e-mail - kentpw@norwich.net]

BIN
styles/bluish/homespun.ttf

Binary file not shown.

BIN
styles/bluish/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
styles/bluish/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

16
styles/candy/README.md

@ -0,0 +1,16 @@
style: candy
-------------
Sweet, colorful, tasty! Enjoy this funfair ride and be careful with the witch of the candy house!
![candy style table](style_table.png)
screenshot
-----------
![candy style screen](screenshot.png)
about font
-----------
"V5 Eastergothic" font by vFive Digital (Roberto Christen).
100% free font, downloaded from dafont.com: [v5eastergothic](https://www.dafont.com/v5eastergothic.font)

24
styles/candy/candy.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 15 0 v5easter.ttf
p 00 00 0xe58b68ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0xfeda96ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0xe59b5fff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0xee813fff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xfcd85bff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0xfc6955ff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0xb34848ff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0xeb7272ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0xbd4a4aff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x94795dff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0xc2a37aff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x9c8369ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x0000000f TEXT_SIZE
p 00 17 0x00000001 TEXT_SPACING
p 00 18 0xd77575ff DEFAULT_LINE_COLOR
p 00 19 0xfff5e1ff DEFAULT_BACKGROUND_COLOR

27
styles/candy/font_readme.txt

@ -0,0 +1,27 @@
V5 Easter Gothic
----------------
Instructions:
++ Easter Gothic ++
For screen use, set at 15pt or any multiple
of 15 (display). Turn antialiasing off. Set
tracking to 100 for best results.
---------------
Usage: This is a free font--you may use
this and other V5 fonts at will. It may not
be sold, altered, or improperly credited,
however. All I ask is that you kindly inform
me if you find this font useful, and where
you've used it.
Enjoy,
©2000
Roberto Christen
rob@vfive.com

BIN
styles/candy/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
styles/candy/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
styles/candy/v5easter.ttf

Binary file not shown.

16
styles/cherry/README.md

@ -0,0 +1,16 @@
style: cherry
--------------
Sweet with a touch of liquour, covered in chocolate, just give it a try! Not suitable for every palate, only the most demanding.
![cherry style table](style_table.png)
screenshot
-----------
![cherry style screen](screenshot.png)
about font
-----------
"Westington" font by Hazel Abbiati.
100% free font, downloaded from dafont.com: [westington](https://www.dafont.com/westington.font)

BIN
styles/cherry/Westington.ttf

Binary file not shown.

24
styles/cherry/cherry.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 15 0 Westington.ttf
p 00 00 0xda5757ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x753233ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0xe17373ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0xfaaa97ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xe06262ff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0xfdb4aaff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0xe03c46ff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0x5b1e20ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0xc2474fff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0xa19292ff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x706060ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x9e8585ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x0000000f TEXT_SIZE
p 00 17 0x00000000 TEXT_SPACING
p 00 18 0xfb8170ff DEFAULT_LINE_COLOR
p 00 19 0x3a1720ff DEFAULT_BACKGROUND_COLOR

BIN
styles/cherry/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
styles/cherry/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
styles/cyber/Kyrou 7 Wide.ttf

Binary file not shown.

16
styles/cyber/README.md

@ -0,0 +1,16 @@
style: cyber
-------------
Future is now! Neons and shadows, city never sleeps! Robots waiting in the corners and expensive vending machines! You got the style!
![cyber style table](style_table.png)
screenshot
-----------
![cyber style screen](screenshot.png)
about font
-----------
"Grixel Kyrou 7 Wide" font by [Nikos Giannakopoulos](http://www.grixel.gr/).
100% free font, downloaded from dafont.com: [grixel-kyrou-7-wide](https://www.dafont.com/grixel-kyrou-7-wide.font)

24
styles/cyber/cyber.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 14 0 Kyrou 7 Wide.ttf
p 00 00 0x2f7486ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x024658ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0x51bfd3ff DEFAULT_TEXT_COLOR_NORMAL
p 00 00 0x82cde0ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 00 0x3299b4ff DEFAULT_BASE_COLOR_FOCUSED
p 00 00 0xb6e1eaff DEFAULT_TEXT_COLOR_FOCUSED
p 00 00 0xeb7630ff DEFAULT_BORDER_COLOR_PRESSED
p 00 00 0xffbc51ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0xd86f36ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x134b5aff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x02313dff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x17505fff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x0000000e DEFAULT_TEXT_SIZE
p 00 25 0x00000000 DEFAULT_TEXT_SPACING
p 00 18 0x81c0d0ff DEFAULT_LINE_COLOR
p 00 19 0x00222bff DEFAULT_BACKGROUND_COLOR

36
styles/cyber/font_readme.txt

@ -0,0 +1,36 @@
Thank you for downloading the free Grixel fonts. You can use them in your personal and commercial projects too. They include Western European, Central European, Turkish and Greek characters. They are Unicode TrueType fonts and are optimized to work in both Windows XP and Mac OS X platforms using Adobe Photoshop CS2 and Macromedia Flash 8.
Grixel fonts are under Creative Commons Attribution-NoDerivs 2.5 License which can be found here:
http://creativecommons.org/licenses/by-nd/2.5/
===============================================================
Attribution-NoDerivs 2.5
You are free:
* to copy, distribute, display, and perform the work
* to make commercial use of the work
Under the following conditions:
by
Attribution. You must attribute the work in the manner specified by the author or licensor.
nd
No Derivative Works. You may not alter, transform, or build upon this work.
* For any reuse or distribution, you must make clear to others the license terms of this work.
* Any of these conditions can be waived if you get permission from the copyright holder.
Your fair use and other rights are in no way affected by the above.
===============================================================
In no event shall Nikos Giannakopoulos be held liable to you for any consequential or incidental damages, including any lost revenue, profits, goodwill or savings, or for any claim by any third party caused by using these fonts.
Please read the UsageGuides.pdf before you use them.
Grixel - Greek pixel fonts | Nikos Giannakopoulos | www.grixel.gr

BIN
styles/cyber/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
styles/cyber/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

14
styles/default/README.md

@ -0,0 +1,14 @@
style: default
---------------
raylib style, simple and easy-to-use. Light colors, wide borders, a sophisticated touch.
![default style table](style_table.png)
screenshot
-----------
![default style screen](screenshot.png)
about font
-----------
raylib font by Ramon Santamaria ([@raysan5](https://twitter.com/raysan5)).

69
styles/default/default.rgs

@ -0,0 +1,69 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
p 00 00 0x838383ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0xc9c9c9ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0x686868ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0x5bb2d9ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xc9effeff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0x6c9bbcff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0x0492c7ff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0x97e8ffff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0x368bafff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0xb5c1c2ff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0xe6e9e9ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0xaeb7b8ff DEFAULT_TEXT_COLOR_DISABLED
p 00 12 0x1 DEFAULT_BORDER_WIDTH
p 00 13 0x0 DEFAULT_TEXT_PADDING
p 00 14 0x1 DEFAULT_TEXT_ALIGNMENT
p 00 15 0x0 DEFAULT_RESERVED
p 00 16 0xa DEFAULT_TEXT_SIZE
p 00 17 0x1 DEFAULT_TEXT_SPACING
p 00 18 0x90abb5ff DEFAULT_LINE_COLOR
p 00 19 0xf5f5f5ff DEFAULT_BACKGROUND_COLOR
p 01 14 0x0 LABEL_TEXT_ALIGNMENT
p 02 12 0x2 BUTTON_BORDER_WIDTH
p 03 16 0x2 TOGGLE_GROUP_PADDING
p 04 16 0xf SLIDER_SLIDER_WIDTH
p 04 13 0x5 SLIDER_TEXT_PADDING
p 05 16 0x1 PROGRESSBAR_PROGRESS_PADDING
p 06 13 0x5 CHECKBOX_TEXT_PADDING
p 06 14 0x2 CHECKBOX_TEXT_ALIGNMENT
p 06 16 0x1 CHECKBOX_CHECK_PADDING
p 07 16 0x1e COMBOBOX_COMBO_BUTTON_WIDTH
p 07 17 0x2 COMBOBOX_COMBO_BUTTON_PADDING
p 08 16 0x10 DROPDOWNBOX_ARROW_PADDING
p 08 17 0x2 DROPDOWNBOX_DROPDOWN_ITEMS_PADDING
p 09 13 0x5 TEXTBOX_TEXT_PADDING
p 09 14 0x0 TEXTBOX_TEXT_ALIGNMENT
p 09 16 0x5 TEXTBOX_TEXT_LINES_PADDING
p 09 17 0xf0fffeff TEXTBOX_COLOR_SELECTED_FG
p 09 18 0x839affe0 TEXTBOX_COLOR_SELECTED_BG
p 10 13 0x4 VALUEBOX_TEXT_PADDING
p 10 14 0x0 VALUEBOX_TEXT_ALIGNMENT
p 11 13 0x4 SPINNER_TEXT_PADDING
p 11 14 0x0 SPINNER_TEXT_ALIGNMENT
p 11 16 0x14 SPINNER_SPIN_BUTTON_WIDTH
p 11 17 0x2 SPINNER_SPIN_BUTTON_PADDING
p 12 16 0x1e LISTVIEW_LIST_ITEMS_HEIGHT
p 12 17 0x2 LISTVIEW_LIST_ITEMS_PADDING
p 12 18 0xa LISTVIEW_SCROLLBAR_WIDTH
p 12 19 0x2 LISTVIEW_SCROLLBAR_SIDE
p 13 16 0x6 COLORPICKER_COLOR_SELECTOR_SIZE
p 13 17 0x14 COLORPICKER_HUEBAR_WIDTH
p 13 18 0xa COLORPICKER_HUEBAR_PADDING
p 13 19 0x6 COLORPICKER_HUEBAR_SELECTOR_HEIGHT
p 13 20 0x2 COLORPICKER_HUEBAR_SELECTOR_OVERFLOW
p 14 12 0x0 SCROLLBAR_BORDER_WIDTH
p 14 16 0x6 SCROLLBAR_ARROWS_SIZE
p 14 17 0x0 SCROLLBAR_ARROWS_VISIBLE
p 14 18 0x0 SCROLLBAR_SCROLL_SLIDER_PADDING
p 14 19 0x10 SCROLLBAR_SCROLL_SLIDER_SIZE
p 14 20 0x0 SCROLLBAR_SCROLL_PADDING
p 14 21 0xa SCROLLBAR_SCROLL_SPEED
p 15 13 0xa STATUSBAR_TEXT_PADDING
p 15 14 0x0 STATUSBAR_TEXT_ALIGNMENT

BIN
styles/default/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
styles/default/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
styles/jungle/Pixel Intv.otf

Binary file not shown.

16
styles/jungle/README.md

@ -0,0 +1,16 @@
style: jungle
--------------
Sunset in the jungle, trees do not let to see the last rays of sun on the horizon, small creek in the path, mug on the shoes, a touch of danger and the adventure feeling, get into your jeep and drive with this style.
![jungle style table](style_table.png)
screenshot
-----------
![jungle style screen](screenshot.png)
about font
-----------
"Pixel Intv" font by [Pixel Sagas](http://www.pixelsagas.com) (Neale and Shayna Davidson).
100% free font, downloaded from dafont.com: [pixel-intv](https://www.dafont.com/pixel-intv.font)

47
styles/jungle/font_readme.txt

@ -0,0 +1,47 @@
Shareware/ Font License
Pixel Sagas Freeware Fonts EULA (End User License Agreement) and Software Inclusion Agreement
"Purchaser" and "User" may be used interchangeably in this agreement.
"Pixel Sagas" and "Neale Davidson" may be used interchangeably in this agreement. These all refer to the intellectual and legal property of Neale Davidson.
Usage
Pixel Saga's Shareware Fonts are free to use for personal, non-commercial purposes. No payment is necessary to use Pixel Saga's Freeware Fonts for personal use, and there is no limit to the amount of prints, pages, or other medium to be produced using them. However, you cannot offer the font for commercial sale, or offer for direct download. The inclusion othe font name and/or site URL in the credits or documentation when it is used is appreciated, but this is not mandatory.
Payment
Payment is not required for the use of Pixel Saga's Shareware Fonts. Commercial use requires a modest fee which can be paid through the pixelsagas.com web site through Paypal.com's services. The transaction receipt for any shareware "commercial license" purchase will suffice as proof of license.
Support
Font installation help is available at http://www.pixelsagas.com. If you experience problems with any Pixel Saga's Freeware font (such as spacing issues or missing characters), please verify that you have the correct and current version of the fonts. In the case of Freeware fonts, downloading the font directly from the Pixel Sagas site will ensure that the font files have not been altered.
Software Inclusion Agreement
Pixel Saga's software products are protected by copyright laws and International copyright treaties, as well as other intellectual property laws and treaties. All Pixel Saga's software products are licensed, not sold.
1) GRANT OF LICENSE
This document grants the user the following rights:
Installation and Use. The user may install and use an unlimited number of copies of the software product. The user may not offer Pixel Sagas freeware fonts for direct download unless the user has received explicit, written permission from Neale Davidson. Otherwise please direct users to the http://www.pixelsagas.com website. Pixel Sagas freeware fonts may, however, be embedded for web, publication, or general software use.
2) WARRANTIES
None
Pixel Sagas expressly disclaims any warranty for the software product. The software product and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the software product remains with the user.
No Liability For Consequential Damages.
In no event shall Neale Davidson or Pixel Sagas be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if Pixel Sagas has been advised of the possibility of such damages.
3) MISCELLANEOUS
Should the user have any questions concerning this document or you desire to contact Neale Davidson for any reason, please email jaynz@pixelsagas.com .
Governing Law
This agreement is governed by and subject to the laws of the United States of America.

24
styles/jungle/jungle.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 12 0 Pixel Intv.otf
p 00 00 0x60827dff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x2c3334ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0x82a29fff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0x5f9aa8ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0x334e57ff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0x6aa9b8ff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0xa9cb8dff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0x3b6357ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0x97af81ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x5b6462ff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x2c3334ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x666b69ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x0000000c TEXT_SIZE
p 00 17 0x00000000 TEXT_SPACING
p 00 18 0x638465ff DEFAULT_LINE_COLOR
p 00 19 0x2b3a3aff DEFAULT_BACKGROUND_COLOR

BIN
styles/jungle/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
styles/jungle/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
styles/lavanda/Cartridge.ttf

Binary file not shown.

16
styles/lavanda/README.md

@ -0,0 +1,16 @@
style: lavanda
---------------
Walk thought the fields full of lavanda, feels like a dream, a touch of fantasy, just relax and close your eyes, could you feel it?
![lavanda style table](style_table.png)
screenshot
-----------
![lavanda style screen](screenshot.png)
about font
-----------
"Cartridge" font by [jeti](https://fontenddev.com/)
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), downloaded from dafont.com: [cartridge](https://www.dafont.com/cartridge.font)

6
styles/lavanda/font_readme.txt

@ -0,0 +1,6 @@
Cartridge by jeti: A decorative, Art Nouveau-inspired font with a dainty, fantastical hand-lettered feel.
You are free to use this font for personal or commercial projects, all I ask is that you include credit.
Licensed under CC BY 4.0: https://creativecommons.org/licenses/by/4.0/
More info: https://fontenddev.com/fonts/cartridge/

24
styles/lavanda/lavanda.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 16 0 Cartridge.ttf
p 00 00 0xab9bd3ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x3e4350ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0xdadaf4ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0xee84a0ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0xf4b7c7ff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0xb7657bff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0xd5c8dbff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0x966ec0ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0xd7ccf7ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x8fa2bdff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x6b798dff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x8292a9ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x00000010 TEXT_SIZE
p 00 17 0x00000001 TEXT_SPACING
p 00 18 0x84adb7ff DEFAULT_LINE_COLOR
p 00 19 0x5b5b81ff DEFAULT_BACKGROUND_COLOR

BIN
styles/lavanda/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
styles/lavanda/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
styles/terminal/Mecha.ttf

Binary file not shown.

16
styles/terminal/README.md

@ -0,0 +1,16 @@
style: terminal
----------------
Start your terminal and type your commands! Feel the connection the data flow, that's your style!
![terminal style table](style_table.png)
screenshot
-----------
![terminal style screen](screenshot.png)
about font
-----------
"Mecha" font by Captain Falcon.
100% free font, downloaded from dafont.com: [mecha-cf](https://www.dafont.com/mecha-cf.font)

BIN
styles/terminal/screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
styles/terminal/style_table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

24
styles/terminal/terminal.rgs

@ -0,0 +1,24 @@
#
# rgs style text file (v3.1) - raygui style file generated using rGuiStyler
#
# Style properties:
# f <gen_font_size> <charmap_file> <font_file>
# p <control_id> <property_id> <property_value> <property_name>
#
f 16 0 Mecha.ttf
p 00 00 0x1c8d00ff DEFAULT_BORDER_COLOR_NORMAL
p 00 01 0x161313ff DEFAULT_BASE_COLOR_NORMAL
p 00 02 0x38f620ff DEFAULT_TEXT_COLOR_NORMAL
p 00 03 0xc3fbc6ff DEFAULT_BORDER_COLOR_FOCUSED
p 00 04 0x43bf2eff DEFAULT_BASE_COLOR_FOCUSED
p 00 05 0xdcfadcff DEFAULT_TEXT_COLOR_FOCUSED
p 00 06 0x1f5b19ff DEFAULT_BORDER_COLOR_PRESSED
p 00 07 0x43ff28ff DEFAULT_BASE_COLOR_PRESSED
p 00 08 0x1e6f15ff DEFAULT_TEXT_COLOR_PRESSED
p 00 09 0x223b22ff DEFAULT_BORDER_COLOR_DISABLED
p 00 10 0x182c18ff DEFAULT_BASE_COLOR_DISABLED
p 00 11 0x244125ff DEFAULT_TEXT_COLOR_DISABLED
p 00 16 0x00000010 TEXT_SIZE
p 00 57 0x00000000 TEXT_SPACING
p 00 18 0xe6fce3ff DEFAULT_LINE_COLOR
p 00 19 0x0c1505ff DEFAULT_BACKGROUND_COLOR

1
tests/config.nims

@ -0,0 +1 @@
switch("path", "$projectDir/../src")

12
tests/test1.nim

@ -0,0 +1,12 @@
# This is just an example to get you started. You may wish to put all of your
# tests into a single file, or separate them into multiple `test1`, `test2`
# etc. files (better names are recommended, just make sure the name starts with
# the letter 't').
#
# To run these tests, simply execute `nimble test`.
import unittest
import gamepkg/gui
#test "correct welcome":
#check getWelcomeMessage() == "Hello, World!"
Loading…
Cancel
Save