Compare commits

...

56 Commits

Author SHA1 Message Date
Fierelier
8172655e88 This is how you do it 2022-05-19 03:23:33 +02:00
Fierelier
4282020b02 Change LuaJIT 2.1+ (master) tree to LuaJIT 2.0 2022-05-19 03:15:34 +02:00
Fierelier
75205209df Add notice 2022-05-19 03:14:23 +02:00
TSnake41
e7b59f1537 Update binding and LuaJIT 2022-04-12 23:39:43 +02:00
TSnake41
29052e1e85 Merge branch 'saphire-raylua_r' 2022-03-20 12:55:36 +01:00
TSnake41
dba1274bc3 Add saphire build system support for raylua_r (#3) 2022-03-20 12:53:25 +01:00
Astie Teddy
1306640357
Merge pull request #3 from sneusse/no-console
Add a new executable that doesn't show the console (windows)
2022-03-20 12:44:45 +01:00
Sebastian Neusser
2b37b77a71 only use -mwindows on windows 2022-03-18 13:03:06 +01:00
Sebastian Neusser
6a8065fcdb built new executable using the windows subsystem
- use the raylua_r to build executables without the console window
2022-03-18 12:54:42 +01:00
TSnake41
6f4cc3bba7 Update binding 2022-03-12 14:06:03 +01:00
TSnake41
c008f46e82 Update binding 2022-02-15 12:45:32 +01:00
Astie Teddy
b5247f7b61 Update binding 2022-01-18 11:11:58 +01:00
TSnake41
035703b769 Fix wrong submodule for LuaJIT 2021-12-31 12:16:04 +01:00
TSnake41
2eee7452d2 Update binding 2021-12-29 13:21:32 +01:00
TSnake41
e426d561d3 Use rewritten shaders_compute_shader based on gol raylib example. 2021-11-04 21:43:06 +01:00
TSnake41
e846857ced Added EncodeDataBase64/DecodeDataBase64 that were missing. 2021-11-04 21:17:26 +01:00
TSnake41
262a663355 raylua v4.0a 2021-11-04 20:48:32 +01:00
TSnake41
95d558cb98 Fix dll issues on Windows 2021-11-04 20:43:28 +01:00
TSnake41
0eca951b26 Update embedded ressources notice.
raylib-lua was able to load file from payload since 3c68c3cfb9
2021-10-24 13:25:58 +02:00
TSnake41
707d2309b1 Improve building and conditional declarations.
raylib-lua now manages properly `if defined` declarations.
2021-10-24 13:16:32 +02:00
TSnake41
f501ca9512 Update binding
Build by default for OpenGL 4.3 (may be changed in the future)
Now consider LUA_PATH environment variable.
2021-10-17 00:00:01 +02:00
TSnake41
9fa0231089 Merge branch 'compute-shaders' into v4.0-dev 2021-10-16 23:45:35 +02:00
TSnake41
144738427f Improve gitignore 2021-10-16 23:43:21 +02:00
TSnake41
89b1ebf081 Update saphire build system, now cleaner and more efficient. 2021-10-16 23:41:39 +02:00
TSnake41
37ef1b240c Add current saphire build system and auto-completion code 2021-10-14 21:15:36 +02:00
TSnake41
3546bf9724 Add compute shader support from TSnake41/raylib 2021-10-14 21:13:34 +02:00
TSnake41
1c94c52802 Update binding 2021-10-03 13:19:17 +02:00
TSnake41
969e64725e Add FSR and custom font examples. 2021-10-02 19:14:10 +02:00
TSnake41
8815751ac9 Early work on raylib 4.0, updated all submodules 2021-10-02 19:03:57 +02:00
TSnake41
353b431aef raylua v3.7 2021-05-02 12:11:49 +02:00
TSnake41
3c68c3cfb9 Use callback API when applicable, implement MusicStream from payload.
Update proper example.
2021-05-01 22:30:32 +02:00
TSnake41
004ac65b28 Initial raylib v3.7 version. 2021-05-01 20:21:00 +02:00
TSnake41
5a8a6feee6 WIP raylib binding update 2021-04-22 19:05:57 +02:00
TSnake41
89e0058bb4 Update binding, update LuaJIT to Tarantool's fork. 2021-02-16 22:25:45 +01:00
TSnake41
7d11e0ea51 Update binding, add core_input_mouse example 2021-02-02 20:42:17 +01:00
TSnake41
88b7d0f17e Update raylib and raygui binding. 2021-01-28 23:42:11 +01:00
TSnake41
57f8548f4d Fix shapes_logo_raylib title 2020-12-29 14:04:56 +01:00
TSnake41
1fc022b604 Fixed various doc and make clean, added textures_software_rendering 2020-12-29 14:03:13 +01:00
TSnake41
e4eb705aa6 raylua v3.5a 2020-12-25 17:38:47 +01:00
TSnake41
a6e3c328a4 Merge branch 'v3.1-dev' 2020-12-21 13:43:30 +01:00
TSnake41
0d06ef4ea9 raylua v3.5-pre1 2020-12-21 13:42:18 +01:00
Astie Teddy
37a89f7b18 Add music in embedding demo. 2020-11-16 16:44:19 +01:00
Astie Teddy
49de44490e Update binding, add embedding logo demo. 2020-11-16 16:18:24 +01:00
Astie Teddy
062f5c3359 Improve building and DRM support 2020-10-07 12:40:58 +02:00
Astie Teddy
fc082f0837 Update raylib binding. 2020-10-07 12:28:06 +02:00
Astie Teddy
67997f2434 Remove remaining travis comment 2020-09-18 22:48:09 +02:00
Astie Teddy
41e6e4546f Remove travis comments that fail parsing. 2020-09-18 22:46:41 +02:00
Astie Teddy
e5a8695cfd Travis fix 2020-09-18 22:43:12 +02:00
Astie Teddy
71697aae94 Fix travis issues maybe 2020-09-18 22:41:43 +02:00
Astie Teddy
91aeeecd9e Various CI improvements 2020-09-18 22:38:30 +02:00
Astie Teddy
c38be1d514 Use xenial instead of trusty for Linux builds. 2020-09-18 22:16:34 +02:00
Astie Teddy
def481e94b Another try to fix travis 2020-09-18 22:13:30 +02:00
Astie Teddy
7a512136b1 Try to fix travis 2020-09-18 22:09:25 +02:00
Astie Teddy
8048acd890 Add travis 2020-09-18 21:39:10 +02:00
Astie Teddy
3e28c06db5 Update binding. 2020-09-18 18:10:29 +02:00
Astie Teddy
2914f26360 Update binding
No longer use fork : Use Load*FromMemory where possible
Fix builder issues
Improve error handling (stacktrace)
2020-09-17 17:37:13 +02:00
48 changed files with 17476 additions and 551 deletions

14
.gitignore vendored
View File

@ -1,14 +1,12 @@
*.o
wray_standalone\.exe
src/wray_api\.c
libwray\.a
*.res
*.a
raylua_e.exe
raylua_r.exe
raylua_s.exe
raylua_s
raylua_e
src/autogen/bind.c
src/autogen/boot.c
src/autogen/builder.c
libraylua.a
src/res/icon.res
libraylua.a

5
.gitmodules vendored
View File

@ -1,10 +1,11 @@
[submodule "LuaJIT"]
path = luajit
url = https://github.com/moonjit/moonjit
url = https://github.com/LuaJIT/LuaJIT
branch = v2.0
[submodule "raylib"]
path = raylib
url = https://github.com/TSnake41/raylib
url = https://github.com/raysan5/raylib
[submodule "raygui"]
path = raygui

70
.travis.yml Normal file
View File

@ -0,0 +1,70 @@
language: c
dist: xenial
git:
depth: 3
matrix:
include:
- os: linux
- os: osx
- os: windows
addons:
artifacts:
paths:
- build
apt:
packages:
- gcc-multilib
- libasound2-dev
- libxcursor-dev
- libxinerama-dev
- mesa-common-dev
- libx11-dev
- libxrandr-dev
- libxrandr2
- libxi-dev
- libgl1-mesa-dev
- libglu1-mesa-dev
before_cache:
- case $TRAVIS_OS_NAME in
windows)
$msys2 pacman --sync --clean --noconfirm
;;
esac
cache:
directories:
- $HOME/AppData/Local/Temp/chocolatey
- /C/tools/msys64
before_install:
- export MAKE=make
- case $TRAVIS_OS_NAME in
windows)
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
choco uninstall -y mingw
choco upgrade --no-progress -y msys2
export msys2='cmd //C RefreshEnv.cmd '
export msys2+='& set MSYS=winsymlinks:nativestrict '
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
export msys2+=" -msys2 -c "\"\$@"\" --"
$msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain
taskkill //IM gpg-agent.exe //F
export PATH=/C/tools/msys64/mingw64/bin:$PATH
export MAKE="$mingw64 make"
$msys2 pacman -S mingw-w64-x86_64-toolchain
;;
esac
- mkdir build
- $RUNNER $CC --version
before_script:
script:
- $RUNNER $MAKE
- mv raylua_s build/
- mv raylua_e build/

View File

@ -1,3 +1,5 @@
**NOTE:** This is a clone of [raylib-lua from TSnake41](https://github.com/TSnake41/raylib-lua), but using LuaJIT 2.0 instead of 2.1+, to support CPUs without SSE2.
![raylib-lua logo](assets/logo.png)
[![release](https://img.shields.io/github/v/release/TSnake41/raylib-lua?style=flat-square)](https://github.com/TSnake41/raylib-lua/releases/latest)
@ -63,8 +65,8 @@ If you need to update raylib binding, there are few tasks to do :
### Loading embedded ressources
Currently, raylib-lua doesn't support loading ressources from payload using
raylib API. However, you can still arbitrarily load files from payload using
Currently, raylib-lua support loading ressources from payload using
raylib API. You can also arbitrarily load files from payload using
`raylua.loadfile` which returns a boolean indicating success and file content.
### Making structs
@ -110,7 +112,7 @@ rl.CloseWindow()
### Compatibility
raylib-lua (raylua) currently uses raylib 3.1-dev API with some 3.0 API compatibility
raylib-lua (raylua) currently uses raylib 3.5 API.
(see [compat.lua](https://github.com/TSnake41/raylib-lua/blob/master/src/compat.lua)).
physac and rlgl modules are built-in by default.
raygui is supported, but is minimally tested, please report any issues you have

168
Saphirefile.lua Normal file
View File

@ -0,0 +1,168 @@
--[[
Saphire-based build system for raylib-lua
Copyright (C) 2021 Astie Teddy
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
]]
local saphire = require "saphire"
local c = require "saphire-c"
local Future = require "saphire-future"
local los = require "los"
local cc = os.getenv "CC" or "cc"
local ar = os.getenv "AR" or "ar"
local windres = os.getenv "WINDRES" or "windres"
-- TODO: Use current lua interpreter
local lua = os.getenv "LUA"
local needs_luajit_built = not (os.getenv "LUA")
local cflags = os.getenv "CFLAGS" or "-O2 -s"
local ldflags = os.getenv "LDFLAGS" or "-O2 -s -lm"
local ldflags_r = os.getenv "LDFLAGS_R" or ""
local modules = "raymath rlgl easings gestures physac raygui"
local graphics = os.getenv "GRAPHICS" or "GRAPHICS_API_OPENGL_43"
cflags = cflags .. " -Iluajit/src -Iraygui/src -Iraylib/src".. " -D" .. graphics
local raylua_so_path = "raylua.so" -- assume unix-like by default
local so_ldflags = ldflags
if los.type() == "linux" then
ldflags = ldflags .. " -ldl -pthread"
cflags = cflags .. " -fPIC"
so_ldflags = ldflags .. " -llua5.1"
lua = lua or "luajit/src/luajit"
elseif los.type() == "win32" then
ldflags = ldflags .. " -lopengl32 -lgdi32 -lwinmm -static "
so_ldflags = ldflags .. " -llua5.1.dll"
raylua_so_path = "raylua.dll"
ldflags_r = ldflags_r .. "-mwindows"
lua = lua or "luajit\\src\\luajit"
end
local libluajit
if saphire.targets.clean then
libluajit = {
command = "make -C luajit clean",
name = "LuaJIT"
}
else
libluajit = {
command = string.format("make -C luajit amalg CC=%s BUILDMODE=static MACOSX_DEPLOYMENT_TARGET=10.13", cc),
name = "LuaJIT"
}
end
saphire.do_single(libluajit)
libluajit[1] = "luajit/src/libluajit.a"
local libraylib = Future "raylib/src/libraylib.a"
saphire.do_subdir("raylib/src", false, "build/buildRaylib.lua", libraylib)
local function lua2c(files, output, name)
if saphire.targets.clean then
return string.format("rm -f %s", output)
else
return string.format("%s tools/lua2str.lua %s %s %s", lua, output, name, table.concat(files, " "))
end
end
local function genbind(output, modules)
if saphire.targets.clean then
return string.format("rm -f %s", output)
else
return string.format("%s tools/genbind.lua src/autogen/bind.c %s", lua, modules)
end
end
local raylua_src = {
c.src("src/raylua.c", function ()
-- Generate bind.c and boot.c
if needs_luajit_built then
-- LuaJIT needs to be built
libluajit:wait()
end
saphire.do_multi({
{
command = lua2c(
{ "src/raylib.lua", "src/compat.lua", "src/raylua.lua" },
"src/autogen/boot.c",
"raylua_boot_lua"
),
name = "boot.c"
},
{
command = genbind("src/autogen/bind.c", modules),
name = "bind.c"
}
}, true)
end)
}
local raylua_obj = c.compile(raylua_src, cflags .. " -D" .. graphics, "raylua", cc)
local libraylua = c.lib("libraylua.a", raylua_obj, "raylua", ar)
local raylua_s_src = {
"src/raylua_s.c"
}
local raylua_s_objs = c.compile(raylua_s_src, cflags, "raylua_s", cc)
local raylua_e_src = {
c.src("src/raylua_builder.c", function ()
saphire.do_single(lua2c({ "src/raylua_builder.lua" }, "src/autogen/builder.c", "raylua_builder_lua"), true)
end),
"src/raylua_e.c",
"src/lib/miniz.c",
"src/raylua_self.c",
}
local raylua_e_objs = c.compile(raylua_e_src, cflags, "raylua_e", cc)
local icon
if los.type() == "win32" then
icon = c.res("src/res/icon.rc", { "src/res/icon.ico" }, "icon", windres)
end
local raylua_s = c.link("raylua_s",
saphire.merge(raylua_s_objs, { libraylua, libraylib, libluajit, icon }),
ldflags,
false,
"raylua_s",
cc
)
local raylua_e = c.link("raylua_e",
saphire.merge(raylua_e_objs, { libraylua, libraylib, libluajit, icon }),
ldflags,
false,
"raylua_e",
cc
)
local raylua_r = c.link("raylua_r",
saphire.merge(raylua_e_objs, { libraylua, libraylib, libluajit, icon }),
ldflags .. " " .. ldflags_r,
false,
"raylua_r",
cc
)
local raylua_so = c.link(raylua_so_path,
saphire.merge(raylua_obj, { libraylib }),
so_ldflags,
true,
raylua_so_path,
cc
)

101
build/buildRaylib-bak.lua Normal file
View File

@ -0,0 +1,101 @@
local saphire = require "saphire"
local cc = os.getenv "CC" or "cc"
local ar = os.getenv "AR" or "ar"
local cflags = os.getenv "CFLAGS" or "-O2 -s"
local ldflags = os.getenv "LDFLAGS" or "-O2 -s -lm"
local include_paths = "-I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw"
local los = require "los"
local consts = {
RAYLIB_VERSION = "3.7.0",
RAYLIB_API_VERSION = "370",
}
local vars = saphire.map({
{ "RAYLIB_LIBTYPE", "STATIC" },
{ "RAYLIB_BUILD_MODE", "RELEASE" },
{ "RAYLIB_LIB_NAME", "raylib" },
{ "RAYLIB_RES_FILE", "./raylib.dll.rc.data" },
{ "PLATFORM", "PLATFORM_DESKTOP" },
{ "GRAPHICS", "GRAPHICS_API_OPENGL_33" },
{ "USE_EXTERNAL_GLFW", "FALSE" },
{ "USE_WAYLAND_DISPLAY", "FALSE" }
}, function (v)
return { v[1], os.getenv(v[1]) or v[2] }
end)
for i,v in ipairs(vars) do
vars[v[1]] = v[2]
end
local function build_c(src, obj, flags)
return {
command = string.format("%s -fdiagnostics-color=always -c -o %s %s %s %s %s", cc, obj, src, flags or "", cflags, ldflags),
name = "raylib",
display = obj
}
end
local function build_a(objs, lib)
return {
command = string.format("%s rcs %s %s", ar, lib, table.concat(objs, " ")),
name = "raylib",
lib = lib
}
end
local function build_e(files, output, flags)
return {
command = string.format("%s -fdiagnostics-color=always -o %s %s %s %s", cc, output, table.concat(files, " "), flags or "", ldflags),
name = "raylib",
display = output
}
end
local function build_res(src, output)
return {
command = string.format("%s %s -O coff %s", windres, src, output),
name = "raylib"
}
end
local objects = {
-- ["obj.o"] = { src... }
{ "rcore.o", { "rcore.c", "raylib.h", "rlgl.h", "utils.h", "raymath.h", "camera.h", "rgestures.h" } },
{ "rglfw.o", { "rglfw.c", flags = os.getenv "GLFW_OSX" or "" } },
{ "rshapes.o", { "rshapes.c", "raylib.h", "rlgl.h" } },
{ "rtextures.o", { "rtextures.c", "raylib.h", "rlgl.h", "utils.h" } },
{ "rtext.o", { "rtext.c", "raylib.h", "utils.h" } },
{ "utils.o", { "utils.c", "utils.h" } },
{ "rmodels.o", { "rmodels.c", "raylib.h", "rlgl.h", "raymath.h" } },
{ "raudio.o", { "raudio.c", "raylib.h" } }
}
if saphire.targets.clean then
saphire.do_multi(
saphire.map(objects, function (obj_info)
return {
command = string.format("rm -f %s", obj_info[1])
}
end), true)
else
saphire.do_multi(
saphire.map(objects, function (obj_info)
return function()
local obj, src = unpack(obj_info)
saphire.do_recipe(src, obj, build_c(src[1], obj,
table.concat({ "-D" .. vars.PLATFORM, "-D" .. vars.GRAPHICS, include_paths, src.flags }, " ")),
true)
end
end), true)
saphire.do_single(
build_a(
saphire.map(objects, function (obj) return obj[1] end),
"libraylib.a"),
true)
end

61
build/buildRaylib.lua Normal file
View File

@ -0,0 +1,61 @@
local future = arg[1]
local saphire = require "saphire"
local c = require "saphire-c"
local cc = os.getenv "CC" or "cc"
local ar = os.getenv "AR" or "ar"
local cflags = os.getenv "CFLAGS" or "-O2 -s"
local include_paths = "-I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw"
local los = require "los"
if los.type() == "linux" then
cflags = cflags .. " -fPIC"
end
local consts = {
RAYLIB_VERSION = "4.0.0",
RAYLIB_API_VERSION = "400",
}
local vars = saphire.map({
{ "RAYLIB_LIBTYPE", "STATIC" },
{ "RAYLIB_BUILD_MODE", "RELEASE" },
{ "RAYLIB_LIB_NAME", "raylib" },
{ "RAYLIB_RES_FILE", "./raylib.dll.rc.data" },
{ "PLATFORM", "PLATFORM_DESKTOP" },
{ "GRAPHICS", "GRAPHICS_API_OPENGL_43" },
{ "USE_EXTERNAL_GLFW", "FALSE" },
{ "USE_WAYLAND_DISPLAY", "FALSE" }
}, function (v)
return { v[1], os.getenv(v[1]) or v[2] }
end)
for i,v in ipairs(vars) do
vars[v[1]] = v[2]
end
local flags = string.format("%s -D%s -D%s %s", cflags, vars.PLATFORM, vars.GRAPHICS, include_paths)
local src = {
-- ["obj.o"] = { src... }
{ "rcore.o", { "rcore.c", "raylib.h", "rlgl.h", "utils.h", "raymath.h", "rcamera.h", "rgestures.h" } },
{ "rglfw.o", { "rglfw.c", flags = os.getenv "GLFW_OSX" or "" } },
{ "rshapes.o", { "rshapes.c", "raylib.h", "rlgl.h" } },
{ "rtextures.o", { "rtextures.c", "raylib.h", "rlgl.h", "utils.h" } },
{ "rtext.o", { "rtext.c", "raylib.h", "utils.h" } },
{ "utils.o", { "utils.c", "utils.h" } },
{ "rmodels.o", { "rmodels.c", "raylib.h", "rlgl.h", "raymath.h" } },
{ "raudio.o", { "raudio.c", "raylib.h" } }
}
local objs = c.compile(src, flags, "raylib", cc)
local libraylib = c.lib("libraylib.a", objs, "raylib")
libraylib:wait()
if future then
future:resolve()
end

View File

@ -4,10 +4,8 @@ rl.InitWindow(800, 450, "raylib [core] example - basic window")
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
rl.EndDrawing()
end

View File

@ -0,0 +1,30 @@
rl.SetTraceLogLevel(rl.LOG_WARNING)
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [core] example - mouse input");
local ball_position = rl.new("Vector2", -100, -100)
local ball_color = rl.DARKBLUE
while not rl.WindowShouldClose() do
ball_position.x = rl.GetMouseX()
ball_position.y = rl.GetMouseY()
if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
ball_color = rl.MAROON
elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_MIDDLE) then
ball_color = rl.LIME
elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_RIGHT) then
ball_color = rl.DARKBLUE
end
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawCircleV(ball_position, 40, ball_color)
rl.DrawText("move ball with mouse and click mouse button to change color",
10, 10, 20, rl.DARKGRAY)
rl.EndDrawing()
end
rl.CloseWindow()

View File

@ -0,0 +1,27 @@
local width, height = 800, 450
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [shapes] example - basic shapes drawing")
rl.InitAudioDevice()
local logo = rl.LoadTexture "ressources/logo.png"
local music = rl.LoadMusicStream "ressources/mini1111.xm"
rl.PlayMusicStream(music)
while not rl.WindowShouldClose() do
rl.UpdateMusicStream(music)
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawTexture(logo, width/2 - logo.width/2, height/2 - logo.height/2, rl.WHITE)
rl.DrawText("this is a texture!", 350, 370, 10, rl.GRAY)
rl.EndDrawing()
end
rl.UnloadMusicStream(music)
rl.CloseAudioDevice()
rl.CloseWindow()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

View File

@ -0,0 +1,44 @@
local width, height = 1280, 720
rl.SetConfigFlags(rl.FLAG_WINDOW_UNDECORATED)
rl.InitWindow(width, height, "raygui - portable window")
rl.SetTargetFPS(75)
local mouse_pos = rl.new("Vector2", 0, 0)
local window_pos = rl.GetWindowPosition()
local pan_offset = rl.new("Vector2", mouse_pos)
local drag_window = false
local exit_window = false
while not exit_window and not rl.WindowShouldClose() do
mouse_pos = rl.GetMousePosition()
if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
if rl.CheckCollisionPointRec(mouse_pos, rl.new("Rectangle", 0, 0, width, 20)) then
drag_window = true
pan_offset = rl.new("Vector2", mouse_pos)
end
end
if drag_window then
window_pos = window_pos + mouse_pos - pan_offset
if rl.IsMouseButtonReleased(rl.MOUSE_BUTTON_RIGHT) then
drag_window = false
end
rl.SetWindowPosition(window_pos.x, window_pos.y)
end
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
exit_window = rl.GuiWindowBox(rl.new("Rectangle", 0, 0, width, height), "PORTABLE WINDOW")
rl.DrawText(string.format("Mouse Position: [ %.0f, %.0f ]", mouse_pos.x, mouse_pos.y),
10, 40, 10, rl.DARKGRAY)
rl.EndDrawing()
end
rl.CloseWindow()

View File

@ -20,13 +20,10 @@ local menu = lynx.menu ({
})
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
--rl.SetTargetFPS(60)
rl.InitWindow(800, 450, "raylib [lua] example - lynx menu")
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.ClearBackground(rl.BLACK)
local pos = rl.GetMousePosition()
menu:input_mouse(pos.x, pos.y, 0)

View File

@ -46,7 +46,7 @@ rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(windowWidth, windowHeight, "my 32x32 game/demo")
local target = rl.LoadRenderTexture(gameScreenWidth, gameScreenHeight)
rl.SetTextureFilter(target.texture, rl.FILTER_POINT)
rl.SetTextureFilter(target.texture, rl.TEXTURE_FILTER_POINT)
rl.SetTargetFPS(60)

View File

@ -22,10 +22,10 @@ local camera = rl.new("Camera3D", {
local num_blocks = 15
while not rl.WindowShouldClose() do
local time = rl.GetTime()
local t = rl.GetTime()
local scale = (2.0 + math.sin(time)) * 0.7
local camera_time = time * 0.3
local scale = (2.0 + math.sin(t)) * 0.7
local camera_time = t * 0.3
camera.position.x = math.cos(camera_time) * 40.0
camera.position.z = math.sin(camera_time) * 40.0
@ -40,7 +40,7 @@ while not rl.WindowShouldClose() do
for y=0,num_blocks-1 do
for z=0,num_blocks-1 do
local block_scale = (x + y + z) / 30
local scatter = math.sin(block_scale * 20.0 + time * 4.0)
local scatter = math.sin(block_scale * 20.0 + t * 4.0)
local cube_pos = rl.new("Vector3",
(x - num_blocks / 2) * (scale * 3.0) + scatter,
@ -48,9 +48,7 @@ while not rl.WindowShouldClose() do
(z - num_blocks / 2) * (scale * 3.0) + scatter)
local cube_color = rl.ColorFromHSV(
rl.new("Vector3",
(((x + y + z) * 18) % 360), 0.75, 0.9
)
(((x + y + z) * 18) % 360), 0.75, 0.9
)
local cube_size = (2.4 - scale) * block_scale

View File

@ -20,7 +20,7 @@ circle.enabled = false
rl.SetTargetFPS(60)
while not rl.WindowShouldClose() do
rl.RunPhysicsStep()
rl.UpdatePhysics()
if needsReset then
floor = rl.CreatePhysicsBodyRectangle({ screenWidth/2, screenHeight }, 500, 100, 10)
@ -37,9 +37,9 @@ while not rl.WindowShouldClose() do
needsReset = true
end
if rl.IsMouseButtonPressed(rl.MOUSE_LEFT_BUTTON) then
if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
rl.CreatePhysicsBodyPolygon(rl.GetMousePosition(), rl.GetRandomValue(20, 80), rl.GetRandomValue(3, 8), 10);
elseif rl.IsMouseButtonPressed(rl.MOUSE_RIGHT_BUTTON) then
elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_RIGHT) then
rl.CreatePhysicsBodyCircle(rl.GetMousePosition(), rl.GetRandomValue(10, 45), 10)
end

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
#version 430
// Game of Life logic shader
#define GOL_WIDTH 768
layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(std430, binding = 1) readonly restrict buffer golLayout {
uint golBuffer[]; // golBuffer[x, y] = golBuffer[x + gl_NumWorkGroups.x * y]
};
layout(std430, binding = 2) writeonly restrict buffer golLayout2 {
uint golBufferDest[]; // golBufferDest[x, y] = golBufferDest[x + gl_NumWorkGroups.x * y]
};
#define fetchGol(x, y) ((((x) < 0) || ((y) < 0) || ((x) > GOL_WIDTH) || ((y) > GOL_WIDTH)) \
? (0) \
: golBuffer[(x) + GOL_WIDTH * (y)])
#define setGol(x, y, value) golBufferDest[(x) + GOL_WIDTH*(y)] = value
void main()
{
uint neighbourCount = 0;
uint x = gl_GlobalInvocationID.x;
uint y = gl_GlobalInvocationID.y;
neighbourCount += fetchGol(x - 1, y - 1); // Top left
neighbourCount += fetchGol(x, y - 1); // Top middle
neighbourCount += fetchGol(x + 1, y - 1); // Top right
neighbourCount += fetchGol(x - 1, y); // Left
neighbourCount += fetchGol(x + 1, y); // Right
neighbourCount += fetchGol(x - 1, y + 1); // Bottom left
neighbourCount += fetchGol(x, y + 1); // Bottom middle
neighbourCount += fetchGol(x + 1, y + 1); // Bottom right
if (neighbourCount == 3) setGol(x, y, 1);
else if (neighbourCount == 2) setGol(x, y, fetchGol(x, y));
else setGol(x, y, 0);
}

View File

@ -0,0 +1,29 @@
#version 430
// Game of Life rendering shader
// Just renders the content of the ssbo at binding 1 to screen
#define GOL_WIDTH 768
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
// Output fragment color
out vec4 finalColor;
// Input game of life grid.
layout(std430, binding = 1) readonly buffer golLayout
{
uint golBuffer[];
};
// Output resolution
uniform vec2 resolution;
void main()
{
ivec2 coords = ivec2(fragTexCoord*resolution);
if ((golBuffer[coords.x + coords.y*uvec2(resolution).x]) == 1) finalColor = vec4(1.0);
else finalColor = vec4(0.0, 0.0, 0.0, 1.0);
}

View File

@ -0,0 +1,51 @@
#version 430
// Game of life transfert shader
#define GOL_WIDTH 768
// Game Of Life Update Command
// NOTE: matches the structure defined on main program
struct GolUpdateCmd {
uint x; // x coordinate of the gol command
uint y; // y coordinate of the gol command
uint w; // width of the filled zone
uint enabled; // whether to enable or disable zone
};
// Local compute unit size
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
// Output game of life grid buffer
layout(std430, binding = 1) buffer golBufferLayout
{
uint golBuffer[]; // golBuffer[x, y] = golBuffer[x + GOL_WIDTH * y]
};
// Command buffer
layout(std430, binding = 3) readonly restrict buffer golUpdateLayout
{
uint count;
GolUpdateCmd commands[];
};
#define isInside(x, y) (((x) >= 0) && ((y) >= 0) && ((x) < GOL_WIDTH) && ((y) < GOL_WIDTH))
#define getBufferIndex(x, y) ((x) + GOL_WIDTH * (y))
void main()
{
uint cmdIndex = gl_GlobalInvocationID.x;
GolUpdateCmd cmd = commands[cmdIndex];
for (uint x = cmd.x; x < (cmd.x + cmd.w); x++)
{
for (uint y = cmd.y; y < (cmd.y + cmd.w); y++)
{
if (isInside(x, y))
{
if (cmd.enabled != 0) atomicOr(golBuffer[getBufferIndex(x, y)], 1);
else atomicAnd(golBuffer[getBufferIndex(x, y)], 0);
}
}
}
}

View File

@ -0,0 +1,134 @@
local ffi = require "ffi"
-- IMPORTANT: This must match gol*.glsl GOL_WIDTH constant.
-- This must be a multiple of 16 (check golLogic compute dispatch).
local GOL_WIDTH = 768
-- Maximum amount of queued draw commands (squares draw from mouse down events).
local MAX_BUFFERED_TRANSFERTS = 48
ffi.cdef [[
typedef struct GolUpdateCmd {
unsigned int x;
unsigned int y;
unsigned int w;
unsigned int enabled;
} GolUpdateCmd;
]]
ffi.cdef(string.format([[
typedef struct GolUpdateSSBO {
unsigned int count;
GolUpdateCmd commands[%d];
} GolUpdateSSBO;
]], MAX_BUFFERED_TRANSFERTS))
rl.InitWindow(GOL_WIDTH, GOL_WIDTH, "raylib [rlgl] example - compute shader - game of life")
local resolution = rl.new("Vector2", GOL_WIDTH, GOL_WIDTH)
local brushSize = 8
-- Game of Life logic compute shader
local golLogicCode = rl.LoadFileText("resources/glsl430/gol.glsl")
local golLogicShader = rl.rlCompileShader(golLogicCode, rl.RL_COMPUTE_SHADER);
local golLogicProgram = rl.rlLoadComputeShaderProgram(golLogicShader);
rl.UnloadFileText(golLogicCode);
-- Game of Life rendering compute shader
local golRenderShader = rl.LoadShader(nil, "resources/glsl430/gol_render.glsl")
local resUniformLoc = rl.GetShaderLocation(golRenderShader, "resolution")
local golTransfertCode = rl.LoadFileText("resources/glsl430/gol_transfert.glsl");
local golTransfertShader = rl.rlCompileShader(golTransfertCode, rl.RL_COMPUTE_SHADER);
local golTransfertProgram = rl.rlLoadComputeShaderProgram(golTransfertShader);
rl.UnloadFileText(golTransfertCode);
local ssboSize = ffi.sizeof("int[?]", GOL_WIDTH * GOL_WIDTH)
local ssboA = rl.rlLoadShaderBuffer(ssboSize, nil, rl.RL_DYNAMIC_COPY);
local ssboB = rl.rlLoadShaderBuffer(ssboSize, nil, rl.RL_DYNAMIC_COPY);
local transfertBuffer = ffi.new("struct GolUpdateSSBO")
transfertBuffer.count = 0
local transfertBufferSize = ffi.sizeof "struct GolUpdateSSBO"
local transfertSSBO = rl.rlLoadShaderBuffer(transfertBufferSize, nil, rl.RL_DYNAMIC_COPY);
-- Create a white texture of the size of the window to update
-- each pixel of the window using the fragment shader
local whiteImage = rl.GenImageColor(GOL_WIDTH, GOL_WIDTH, rl.WHITE);
local whiteTex = rl.LoadTextureFromImage(whiteImage);
rl.UnloadImage(whiteImage)
while not rl.WindowShouldClose() do
brushSize = math.floor(brushSize + rl.GetMouseWheelMove())
if ((rl.IsMouseButtonDown(rl.MOUSE_BUTTON_LEFT) or rl.IsMouseButtonDown(rl.MOUSE_BUTTON_RIGHT))
and (transfertBuffer.count < MAX_BUFFERED_TRANSFERTS)) then
-- Buffer a new command
transfertBuffer.commands[transfertBuffer.count].x = rl.GetMouseX() - brushSize/2
transfertBuffer.commands[transfertBuffer.count].y = rl.GetMouseY() - brushSize/2
transfertBuffer.commands[transfertBuffer.count].w = brushSize
transfertBuffer.commands[transfertBuffer.count].enabled = rl.IsMouseButtonDown(rl.MOUSE_BUTTON_LEFT)
transfertBuffer.count = transfertBuffer.count + 1
elseif transfertBuffer.count > 0 then
-- Process transfert buffer
-- Send SSBO buffer to GPU
rl.rlUpdateShaderBufferElements(transfertSSBO, transfertBuffer, transfertBufferSize, 0);
-- Process ssbo command
rl.rlEnableShader(golTransfertProgram);
rl.rlBindShaderBuffer(ssboA, 1);
rl.rlBindShaderBuffer(transfertSSBO, 3);
rl.rlComputeShaderDispatch(transfertBuffer.count, 1, 1) -- each GPU unit will process a command
rl.rlDisableShader();
transfertBuffer.count = 0;
else
-- Process game of life logic
rl.rlEnableShader(golLogicProgram)
rl.rlBindShaderBuffer(ssboA, 1)
rl.rlBindShaderBuffer(ssboB, 2)
rl.rlComputeShaderDispatch(GOL_WIDTH / 16, GOL_WIDTH / 16, 1)
rl.rlDisableShader()
ssboA, ssboB = ssboB, ssboA
end
rl.rlBindShaderBuffer(ssboA, 1)
rl.SetShaderValue(golRenderShader, resUniformLoc, resolution, rl.SHADER_UNIFORM_VEC2);
rl.BeginDrawing()
rl.ClearBackground(rl.BLANK)
rl.BeginShaderMode(golRenderShader)
rl.DrawTexture(whiteTex, 0, 0, rl.WHITE)
rl.EndShaderMode()
rl.DrawRectangleLines(
rl.GetMouseX() - brushSize/2,
rl.GetMouseY() - brushSize/2,
brushSize, brushSize,
rl.RED)
rl.DrawText("Use Mouse wheel to increase/decrease brush size", 10, 10, 20, rl.WHITE);
rl.DrawFPS(rl.GetScreenWidth() - 100, 10);
rl.EndDrawing()
end
rl.rlUnloadShaderBuffer(ssboA);
rl.rlUnloadShaderBuffer(ssboB);
rl.rlUnloadShaderBuffer(transfertSSBO);
-- Unload compute shader programs
rl.rlUnloadShaderProgram(golTransfertProgram)
rl.rlUnloadShaderProgram(golLogicProgram)
rl.UnloadTexture(whiteTex) -- Unload white texture
rl.UnloadShader(golRenderShader) -- Unload rendering fragment shader
rl.CloseWindow() -- Close window and OpenGL context

View File

@ -0,0 +1,232 @@
local screenWidth = 1920
local screenHeight = 1080
local preset = 3
local default_sharpness = 1.0
local presets = {
{ 2.0, "Performance" },
{ 1.7, "Balanced" },
{ 1.5, "Quality" },
{ 1.3, "Ultra Quality" },
{ 1.0, "Custom (Native)" }
}
local use_fsr = true
local ratio = presets[preset][1]
local num_blocks = 15
local screenSize = rl.new("Vector2", screenWidth, screenHeight)
local fbWidth = screenWidth / ratio
local fbHeight = screenHeight / ratio
local fbSize = rl.new("Vector2", fbWidth, fbHeight)
rl.SetConfigFlags(rl.FLAG_FULLSCREEN_MODE)
rl.InitWindow(screenWidth, screenHeight, "raylua [shaders] example - AMD FSR")
local render_texture = rl.LoadRenderTexture(fbWidth, fbHeight)
local dest_fb = rl.LoadRenderTexture(screenWidth, screenHeight)
local easu_shader = rl.LoadShader(nil, "resources/fsr/fsrEasu.frag")
local srcSize_loc = rl.GetShaderLocation(easu_shader, "srcSize")
local dstSize_loc = rl.GetShaderLocation(easu_shader, "dstSize")
rl.SetShaderValue(easu_shader, srcSize_loc, fbSize, rl.SHADER_UNIFORM_VEC2)
rl.SetShaderValue(easu_shader, dstSize_loc, screenSize, rl.SHADER_UNIFORM_VEC2)
local rcas_shader = rl.LoadShader(nil, "resources/fsr/fsrRcas.frag")
local sharpness_loc = rl.GetShaderLocation(rcas_shader, "sharpness")
local size_loc = rl.GetShaderLocation(rcas_shader, "dstSize")
local sharpness = rl.new("float[1]", default_sharpness)
rl.SetShaderValue(rcas_shader, sharpness_loc, sharpness, rl.SHADER_UNIFORM_FLOAT)
rl.SetShaderValue(rcas_shader, size_loc, screenSize, rl.SHADER_UNIFORM_VEC2)
local camera = rl.new("Camera3D", {
position = { 30, 20, 30 },
target = { 0, 0, 0 },
up = { 0, 1, 0 },
fovy = 70,
type = rl.CAMERA_PERSPECTIVE
})
local enable_easu = false
local enable_rcas = false
local stop_animation = false
local t = 0.0
local bilinear = false
while not rl.WindowShouldClose() do
if not stop_animation then
t = rl.GetTime()
end
local scale = (2.0 + math.sin(t)) * 0.7
local camera_time = t * 0.3
camera.position.x = math.cos(camera_time) * 40.0
camera.position.z = math.sin(camera_time) * 40.0
if use_fsr then
rl.BeginTextureMode(render_texture)
else
rl.BeginDrawing()
end
rl.BeginMode3D(camera)
rl.ClearBackground(rl.RAYWHITE)
rl.DrawGrid(10, 5.0)
for x=0,num_blocks-1 do
for y=0,num_blocks-1 do
for z=0,num_blocks-1 do
local block_scale = (x + y + z) / 30
local scatter = math.sin(block_scale * 20.0 + t * 4.0)
local cube_pos = rl.new("Vector3",
(x - num_blocks / 2) * (scale * 3.0) + scatter,
(y - num_blocks / 2) * (scale * 2.0) + scatter,
(z - num_blocks / 2) * (scale * 3.0) + scatter)
local cube_color = rl.ColorFromHSV(
(((x + y + z) * 18) % 360), 0.75, 0.9
)
local cube_size = (2.4 - scale) * block_scale
rl.DrawCube(cube_pos, cube_size, cube_size, cube_size, cube_color)
end
end
end
rl.EndMode3D()
if use_fsr then
rl.EndTextureMode()
rl.BeginTextureMode(dest_fb)
rl.ClearBackground(rl.RAYWHITE)
if enable_easu then
rl.BeginShaderMode(easu_shader)
end
rl.DrawTextureEx(render_texture.texture, screenSize, 180, ratio, rl.WHITE)
if enable_easu then
rl.EndShaderMode()
end
rl.EndTextureMode()
rl.BeginDrawing()
rl.ClearBackground(rl.WHITE)
if enable_rcas then
rl.BeginShaderMode(rcas_shader)
end
rl.DrawTextureEx(dest_fb.texture, screenSize, 180, 1.0, rl.WHITE)
if enable_rcas then
rl.EndShaderMode()
end
end
rl.DrawFPS(10, 10)
if use_fsr then
rl.DrawText("EASU", 10, 32, 20, enable_easu and rl.GREEN or rl.RED)
rl.DrawText("RCAS", 10, 54, 20, enable_rcas and rl.GREEN or rl.RED)
rl.DrawText(string.format("sharpness: %.1f", sharpness[0]), 10, 74, 10, rl.BLACK)
rl.DrawText(string.format("Preset: %s (%.1f)", presets[preset][2], ratio), 10, 86, 10, rl.BLACK)
rl.DrawText(string.format("Resolution: %dx%d", fbWidth, fbHeight), 10, 98, 10, rl.BLACK)
rl.DrawText(string.format("Filter: %s", bilinear and "bilinear" or "point"), 10, 110, 10, rl.BLACK)
else
rl.DrawText("NATIVE", 10, 32, 20, rl.BLUE)
end
rl.EndDrawing()
if rl.IsKeyPressed(rl.KEY_E) then
enable_easu = not enable_easu
end
if rl.IsKeyPressed(rl.KEY_R) then
enable_rcas = not enable_rcas
end
if rl.IsKeyPressed(rl.KEY_N) then
use_fsr = not use_fsr
end
if rl.IsKeyPressed(rl.KEY_LEFT) then
sharpness[0] = math.max(0.0, sharpness[0] - 0.1)
rl.SetShaderValue(rcas_shader, sharpness_loc, sharpness, rl.SHADER_UNIFORM_FLOAT)
end
if rl.IsKeyPressed(rl.KEY_RIGHT) then
sharpness[0] = math.min(2.0, sharpness[0] + 0.1)
rl.SetShaderValue(rcas_shader, sharpness_loc, sharpness, rl.SHADER_UNIFORM_FLOAT)
end
if rl.IsKeyPressed(rl.KEY_F) then
bilinear = not bilinear
rl.SetTextureFilter(render_texture.texture,
bilinear and rl.TEXTURE_FILTER_BILINEAR or rl.TEXTURE_FILTER_POINT)
end
local preset_changed = false
if rl.IsKeyPressed(rl.KEY_UP) then
preset_changed = true
preset = preset + 1
if preset == #presets + 1 then
preset = 1
end
end
if rl.IsKeyPressed(rl.KEY_DOWN) then
preset_changed = true
preset = preset - 1
if preset == 0 then
preset = #presets
end
end
if rl.IsKeyPressed(rl.KEY_S) then
stop_animation = not stop_animation
end
if rl.IsKeyPressed(rl.KEY_F11) then
rl.ToggleFullscreen()
end
if preset_changed then
ratio = presets[preset][1]
fbWidth = screenWidth / ratio
fbHeight = screenHeight / ratio
fbSize = rl.new("Vector2", fbWidth, fbHeight)
rl.UnloadRenderTexture(render_texture)
render_texture = rl.LoadRenderTexture(fbWidth, fbHeight)
rl.SetTextureFilter(render_texture.texture,
bilinear and rl.TEXTURE_FILTER_BILINEAR or rl.TEXTURE_FILTER_POINT)
end
end
rl.UnloadRenderTexture(render_texture)
rl.UnloadRenderTexture(dest_fb)
rl.CloseWindow()

View File

@ -3,7 +3,7 @@ local lua_color = rl.new("Color", 3, 3, 128, 255)
local width, height = 800, 450
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [shapes] example - basic shapes drawing")
rl.InitWindow(800, 450, "raylib [shapes] example - raylib logo")
while not rl.WindowShouldClose() do
rl.BeginDrawing()

View File

@ -0,0 +1,18 @@
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [core] example - basic window")
local font = rl.LoadFontEx("resources/NotoSans-Medium.ttf", 32, nil, 255)
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.DrawFPS(10, 10)
rl.ClearBackground(rl.RAYWHITE)
rl.DrawTextEx(font, "Congrats! You created your first window!", rl.new("Vector2", 174, 200), 32, 0, rl.BLACK)
rl.EndDrawing()
end
rl.CloseWindow()

View File

@ -0,0 +1,42 @@
local lua_color = rl.new("Color", 3, 3, 128, 255)
local width, height = 800, 450
--rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.SetTraceLogLevel(rl.LOG_WARNING)
rl.InitWindow(width, height, "raylib [shapes] example - software rendered raylib logo")
local framebuffer = rl.new "Image"
local fb_data = rl.new("Color[?]", width * height)
framebuffer.width = width
framebuffer.height = height
framebuffer.format = rl.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
framebuffer.mipmaps = 1
framebuffer.data = fb_data
local fb_texture = rl.LoadTextureFromImage(framebuffer)
while not rl.WindowShouldClose() do
--rl.ImageClearBackground(framebuffer, rl.RAYWHITE)
for i=0,width*height-1 do
fb_data[i] = rl.RAYWHITE
end
rl.ImageDrawRectangle(framebuffer, width / 2 - 128, height / 2 - 128, 256, 256, lua_color)
rl.ImageDrawRectangle(framebuffer, width / 2 - 112, height / 2 - 112, 224, 224, rl.RAYWHITE)
rl.ImageDrawText(framebuffer, "raylib", width / 2 - 44, height / 2 + 24, 50, lua_color)
rl.ImageDrawText(framebuffer, "Lua", width / 2 - 44, height / 2 + 65, 50, lua_color)
rl.ImageDrawText(framebuffer, "this is NOT a texture!", 350, 370, 10, rl.GRAY)
rl.UpdateTexture(fb_texture, fb_data)
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawTexture(fb_texture, 0, 0, rl.WHITE)
rl.DrawFPS(10, 10)
rl.EndDrawing()
end
rl.CloseWindow()

2
luajit

@ -1 +1 @@
Subproject commit 76958aa0c445aa817ff41d3a7987e9b7ba7a58c2
Subproject commit 5e3c45c43bb0e0f1f2917d432e9d2dba12c42a6e

View File

@ -7,12 +7,22 @@ LUA ?= luajit/src/luajit
WINDRES ?= windres
CFLAGS += -Iluajit/src -Iraylib/src -Iraygui/src
LDFLAGS += -Lluajit/src -Lraylib -lraylib
LDFLAGS += luajit/src/libluajit.a raylib/src/libraylib.a
MODULES := raymath rlgl easings gestures physac raygui
# raylib settings
PLATFORM ?= PLATFORM_DESKTOP
GRAPHICS ?= GRAPHICS_API_OPENGL_33
CFLAGS += -D$(GRAPHICS) -D$(PLATFORM)
USE_WAYLAND_DISPLAY ?= FALSE
USE_EXTERNAL_GLFW ?= FALSE
ifeq ($(OS),Windows_NT)
LDFLAGS += -lopengl32 -lgdi32 -lwinmm -static
LDFLAGS_R += -mwindows
EXTERNAL_FILES := src/res/icon.res
else ifeq ($(shell uname),Darwin)
LDFLAGS += -framework CoreVideo -framework IOKit -framework Cocoa \
@ -20,20 +30,32 @@ else ifeq ($(shell uname),Darwin)
-Wl,-pagezero_size,10000,-image_base,100000000
EXTERNAL_FILES :=
else
LDFLAGS += -ldl -lX11 -lpthread
LDFLAGS += -ldl -lpthread
ifeq ($(PLATFORM),PLATFORM_DRM)
LDFLAGS += -ldrm -lGLESv2 -lEGL -lgbm
else
LDFLAGS += -lX11
endif
EXTERNAL_FILES :=
endif
all: raylua_s raylua_e luajit raylib
all: raylua_s raylua_e raylua_r luajit raylib
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
luajit:
$(MAKE) -C luajit amalg CC=$(CC) BUILDMODE=static MACOSX_DEPLOYMENT_TARGET=10.13
$(MAKE) -C luajit amalg \
CC=$(CC) BUILDMODE=static \
MACOSX_DEPLOYMENT_TARGET=10.13
raylib:
$(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" -C raylib/src
$(MAKE) -C raylib/src \
CC=$(CC) AR=$(AR) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
USE_WAYLAND_DISPLAY="$(USE_WAYLAND_DISPLAY)" \
USE_EXTERNAL_GLFW="$(USE_EXTERNAL_GLFW)" \
PLATFORM="$(PLATFORM)" GRAPHICS="$(GRAPHICS)"
raylua_s: src/raylua_s.o $(EXTERNAL_FILES) libraylua.a
$(CC) -o $@ $^ $(LDFLAGS) luajit/src/libluajit.a
@ -42,6 +64,10 @@ raylua_e: src/raylua_e.o src/raylua_self.o src/raylua_builder.o src/lib/miniz.o
$(EXTERNAL_FILES) libraylua.a
$(CC) -o $@ $^ $(LDFLAGS) luajit/src/libluajit.a
raylua_r: src/raylua_e.o src/raylua_self.o src/raylua_builder.o src/lib/miniz.o \
$(EXTERNAL_FILES) libraylua.a
$(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS_R) luajit/src/libluajit.a
src/res/icon.res: src/res/icon.rc
$(WINDRES) $^ -O coff $@
@ -70,9 +96,10 @@ src/autogen/builder.c: src/raylua_builder.lua
clean:
rm -rf raylua_s raylua_e libraylua.a src/raylua_e.o src/raylua_s.o \
src/raylua.o src/raylua_self.o src/raylua_builder.o src/autogen/*.c \
src/lib/miniz.o
src/lib/miniz.o src/res/icon.res
$(MAKE) -C luajit clean
$(MAKE) -C raylib/src clean
rm -f raylib/libraylib.a
.PHONY: all src/autogen/bind.c src/autogen/boot.c raylua_s raylua_e luajit \
raylib clean

2
raygui

@ -1 +1 @@
Subproject commit 07b30c30af7309b396cfa458d30f54b38ef78808
Subproject commit 865bb293764073c01e74314ef647464f1f10fd96

2
raylib

@ -1 +1 @@
Subproject commit be03613d1b6f9b0051d78c790f97df069150c65f
Subproject commit 559ffc633164c30824065a63324ba08efa651ee6

View File

@ -14,9 +14,26 @@
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
]]
-- math metamethods
local new = ffi.new
-- Load*() wrappers.
if raylua.loadfile then
local LoadMusicStream = rl.LoadMusicStream
function rl.LoadMusicStream(path)
local f, err = raylua.loadfile(path)
if f then
local ext = "." .. path:gsub(".+%.", "")
return rl.LoadMusicStreamFromMemory(ext, ffi.cast("void *", f), #f)
else
print(("RAYLUA: %s"):format(err))
return LoadMusicStream(path)
end
end
end
-- math metamethods
ffi.metatype("Vector2", {
__add = function (a, b)
if ffi.istype("Vector2", b) then

File diff suppressed because it is too large Load Diff

View File

@ -24,23 +24,24 @@
#include <rlgl.h>
#include <raymath.h>
#include <easings.h>
#include <gestures.h>
#include <extras/easings.h>
#include <rgestures.h>
#define RAYGUI_SUPPORT_ICONS
#define RAYGUI_IMPLEMENTATION
#define RAYGUI_STATIC
#include <raygui.h>
#define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include <physac.h>
#include <extras/physac.h>
#include "autogen/bind.c"
#include "autogen/boot.c"
extern const char *raylua_boot_str;
#ifdef WIN32
__declspec(dllexport)
#endif
void raylua_boot(lua_State *L, lua_CFunction loadfile, lua_CFunction listfiles,
bool repl)
{
@ -66,12 +67,21 @@ void raylua_boot(lua_State *L, lua_CFunction loadfile, lua_CFunction listfiles,
lua_pushboolean(L, repl);
lua_settable(L, -3);
lua_pushstring(L, "raylib_version");
lua_pushstring(L, RAYLIB_VERSION);
lua_settable(L, -3);
lua_setglobal(L, "raylua");
if (luaL_dostring(L, raylua_boot_lua))
if (luaL_dostring(L, raylua_boot_lua)) {
fputs(luaL_checkstring(L, -1), stderr);
fputc('\n', stderr);
}
}
#ifdef WIN32
__declspec(dllexport)
#endif
int luaopen_raylua(lua_State *L)
{
raylua_boot(L, NULL, NULL, false);

View File

@ -16,7 +16,7 @@
local load = loadstring
raylua.version = "v3.1-dev1"
raylua.version = "v4.0b"
function raylua.repl()
print("> raylua " .. raylua.version .. " <")
@ -45,6 +45,10 @@ end
package.path = "?.lua;?/init.lua"
if os.getenv "LUA_PATH" then
package.path = package.path .. ";" .. os.getenv "LUA_PATH"
end
if raylua.loadfile then
-- Change the second loader to load files using raylua.loadfile
package.loaders[2] = function (name)
@ -65,16 +69,37 @@ if raylua.loadfile then
end
print "RAYLUA: Load main.lua from payload."
require "main"
local f, err = load(raylua.loadfile "main.lua", "main.lua")
if f then
local status, f_err = xpcall(f, debug.traceback)
if not status then
print(f_err)
end
else
print(err)
end
if not raylua.isrepl then
-- Keep launching the repl even with `loadfile` defined.
return
end
-- Keep launching the repl even with `loadfile` defined.
end
if arg and arg[1] then
dofile(arg[1])
local f, err = loadfile(arg[1])
if f then
local status, f_err = xpcall(f, debug.traceback)
if not status then
print(f_err)
end
else
print(err)
end
return
end

View File

@ -150,7 +150,7 @@ static int list_dir(lua_State *L)
return 0;
struct dirent *entry;
size_t count = 0;
size_t count = 1;
lua_newtable(L);

View File

@ -83,7 +83,7 @@ if t == "directory" then
local function add_dir(root, dir)
for i,file in ipairs(list_dir(path_concat(root, dir))) do
if file ~= ".." then
if file ~= ".." and file ~= "." then
local partial_file_path, full_file_path
if dir then

View File

@ -62,7 +62,12 @@ int raylua_loadfile(lua_State *L)
return 2;
}
mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0);
if (!mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0)) {
free(buffer);
lua_pushnil(L);
lua_pushfstring(L, "%s: Can't extract file.", path);
return 2;
}
lua_pushlstring(L, buffer, size);
free(buffer);
@ -92,24 +97,28 @@ unsigned char *raylua_loadFileData(const char *path, unsigned int *out_size)
{
int index = mz_zip_reader_locate_file(&zip_file, path, NULL, 0);
if (index == -1) {
printf("RAYLUA: WARN: File not found in payload : '%s'", path);
printf("RAYLUA: WARN: File not found in payload. '%s'\n", path);
return NULL;
}
mz_zip_archive_file_stat stat;
if (!mz_zip_reader_file_stat(&zip_file, index, &stat)) {
printf("RAYLUA: WARN: Can't get file information of '%s' in payload.", path);
printf("RAYLUA: WARN: Can't get file information in payload. '%s'\n", path);
return NULL;
}
size_t size = stat.m_uncomp_size;
unsigned char *buffer = RL_MALLOC(size);
if (buffer == NULL) {
printf("RAYLUA: WARN: Can't allocate file buffer for '%s'.", path);
printf("RAYLUA: WARN: Can't allocate file buffer. '%s'\n", path);
return NULL;
}
mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0);
if (!mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0)) {
free(buffer);
printf("RAYLUA: WARN: Can't extract file. '%s'\n", path);
return NULL;
}
*out_size = size;
return buffer;
@ -119,26 +128,31 @@ char *raylua_loadFileText(const char *path)
{
int index = mz_zip_reader_locate_file(&zip_file, path, NULL, 0);
if (index == -1) {
printf("RAYLUA: WARN: File not found in payload : '%s'", path);
printf("RAYLUA: WARN: File not found in payload. '%s'\n", path);
return NULL;
}
mz_zip_archive_file_stat stat;
if (!mz_zip_reader_file_stat(&zip_file, index, &stat)) {
printf("RAYLUA: WARN: Can't get file information of '%s' in payload.", path);
printf("RAYLUA: WARN: Can't get file information in payload. '%s'\n", path);
return NULL;
}
size_t size = stat.m_uncomp_size;
char *buffer = RL_MALLOC(size + 1);
if (buffer == NULL) {
printf("RAYLUA: WARN: Can't allocate file buffer for '%s'.", path);
printf("RAYLUA: WARN: Can't allocate file buffer. '%s'\n", path);
return NULL;
}
buffer[size] = '\0';
mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0);
if (!mz_zip_reader_extract_to_mem(&zip_file, index, buffer, size, 0)) {
free(buffer);
printf("RAYLUA: WARN: Can't extract file. '%s'\n", path);
return NULL;
}
return buffer;
}
@ -174,11 +188,6 @@ int main(int argc, const char **argv)
lua_setglobal(L, "arg");
SetFilesystemOverride((FilesystemOverride){
.loadFileData = &raylua_loadFileData,
.loadFileText = &raylua_loadFileText,
});
FILE *self = raylua_open_self(argv[0]);
if (self == NULL) {
@ -186,6 +195,9 @@ int main(int argc, const char **argv)
return 1;
}
SetLoadFileDataCallback(raylua_loadFileData);
SetLoadFileTextCallback(raylua_loadFileText);
if (!raylua_init_payload(self)) {
#ifdef RAYLUA_NO_BUILDER
puts("RAYLUA: No payload.");

View File

@ -2,18 +2,18 @@ void InitWindow(int width, int height, const char *title)
bool WindowShouldClose(void)
void CloseWindow(void)
bool IsWindowReady(void)
bool IsWindowFullscreen(void)
bool IsWindowHidden(void)
bool IsWindowMinimized(void)
bool IsWindowMaximized(void)
bool IsWindowFocused(void)
bool IsWindowResized(void)
bool IsWindowHidden(void)
bool IsWindowFullscreen(void)
bool IsWindowState(unsigned int flag)
void SetWindowState(unsigned int flags)
void ClearWindowState(unsigned int flags)
void ToggleFullscreen(void)
void UnhideWindow(void)
void HideWindow(void)
void DecorateWindow(void)
void UndecorateWindow(void)
void MaximizeWindow(void)
void MinimizeWindow(void)
void RestoreWindow(void)
void SetWindowIcon(Image image)
void SetWindowTitle(const char *title)
@ -21,10 +21,15 @@ void SetWindowPosition(int x, int y)
void SetWindowMonitor(int monitor)
void SetWindowMinSize(int width, int height)
void SetWindowSize(int width, int height)
void SetWindowOpacity(float opacity)
void *GetWindowHandle(void)
int GetScreenWidth(void)
int GetScreenHeight(void)
int GetRenderWidth(void)
int GetRenderHeight(void)
int GetMonitorCount(void)
int GetCurrentMonitor(void)
Vector2 GetMonitorPosition(int monitor)
int GetMonitorWidth(int monitor)
int GetMonitorHeight(int monitor)
int GetMonitorPhysicalWidth(int monitor)
@ -33,8 +38,11 @@ int GetMonitorRefreshRate(int monitor)
Vector2 GetWindowPosition(void)
Vector2 GetWindowScaleDPI(void)
const char *GetMonitorName(int monitor)
const char *GetClipboardText(void)
void SetClipboardText(const char *text)
const char *GetClipboardText(void)
void SwapScreenBuffer(void)
void PollInputEvents(void)
void WaitTime(float ms)
void ShowCursor(void)
void HideCursor(void)
bool IsCursorHidden(void)
@ -50,8 +58,25 @@ void BeginMode3D(Camera3D camera)
void EndMode3D(void)
void BeginTextureMode(RenderTexture2D target)
void EndTextureMode(void)
void BeginShaderMode(Shader shader)
void EndShaderMode(void)
void BeginBlendMode(int mode)
void EndBlendMode(void)
void BeginScissorMode(int x, int y, int width, int height)
void EndScissorMode(void)
void BeginVrStereoMode(VrStereoConfig config)
void EndVrStereoMode(void)
VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
void UnloadVrStereoConfig(VrStereoConfig config)
Shader LoadShader(const char *vsFileName, const char *fsFileName)
Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
int GetShaderLocation(Shader shader, const char *uniformName)
int GetShaderLocationAttrib(Shader shader, const char *attribName)
void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType)
void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count)
void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat)
void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
void UnloadShader(Shader shader)
Ray GetMouseRay(Vector2 mousePosition, Camera camera)
Matrix GetCameraMatrix(Camera camera)
Matrix GetCameraMatrix2D(Camera2D camera)
@ -63,33 +88,33 @@ void SetTargetFPS(int fps)
int GetFPS(void)
float GetFrameTime(void)
double GetTime(void)
int ColorToInt(Color color)
Vector4 ColorNormalize(Color color)
Color ColorFromNormalized(Vector4 normalized)
Vector3 ColorToHSV(Color color)
Color ColorFromHSV(Vector3 hsv)
Color GetColor(int hexValue)
Color Fade(Color color, float alpha)
void SetConfigFlags(unsigned int flags)
void SetTraceLogLevel(int logType)
void SetTraceLogExit(int logType)
void SetTraceLogCallback(TraceLogCallback callback)
void TraceLog(int logType, const char *text, ...)
void TakeScreenshot(const char *fileName)
int GetRandomValue(int min, int max)
unsigned char *LoadFileData(const char *fileName, int *bytesRead)
void SaveFileData(const char *fileName, void *data, int bytesToWrite)
void SetRandomSeed(unsigned int seed)
void TakeScreenshot(const char *fileName)
void SetConfigFlags(unsigned int flags)
void TraceLog(int logLevel, const char *text, ...)
void SetTraceLogLevel(int logLevel)
void *MemAlloc(int size)
void *MemRealloc(void *ptr, int size)
void MemFree(void *ptr)
void SetTraceLogCallback(TraceLogCallback callback)
unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
void UnloadFileData(unsigned char *data)
bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite)
char *LoadFileText(const char *fileName)
void SaveFileText(const char *fileName, char *text)
void UnloadFileText(char *text)
bool SaveFileText(const char *fileName, char *text)
bool FileExists(const char *fileName)
bool IsFileExtension(const char *fileName, const char *ext)
bool DirectoryExists(const char *dirPath)
const char *GetExtension(const char *fileName)
bool IsFileExtension(const char *fileName, const char *ext)
int GetFileLength(const char *fileName)
const char *GetFileExtension(const char *fileName)
const char *GetFileName(const char *filePath)
const char *GetFileNameWithoutExt(const char *filePath)
const char *GetDirectoryPath(const char *filePath)
const char *GetPrevDirectoryPath(const char *dirPath)
const char *GetWorkingDirectory(void)
const char *GetApplicationDirectory(void)
char **GetDirectoryFiles(const char *dirPath, int *count)
void ClearDirectoryFiles(void)
bool ChangeDirectory(const char *dir)
@ -97,10 +122,12 @@ bool IsFileDropped(void)
char **GetDroppedFiles(int *count)
void ClearDroppedFiles(void)
long GetFileModTime(const char *fileName)
unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength)
unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength)
void SaveStorageValue(int position, int value)
int LoadStorageValue(int position)
unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize)
unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize)
char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize)
unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize)
bool SaveStorageValue(unsigned int position, int value)
int LoadStorageValue(unsigned int position)
void OpenURL(const char *url)
bool IsKeyPressed(int key)
bool IsKeyDown(int key)
@ -108,8 +135,8 @@ bool IsKeyReleased(int key)
bool IsKeyUp(int key)
void SetExitKey(int key)
int GetKeyPressed(void)
int GetCharPressed(void)
bool IsGamepadAvailable(int gamepad)
bool IsGamepadName(int gamepad, const char *name)
const char *GetGamepadName(int gamepad)
bool IsGamepadButtonPressed(int gamepad, int button)
bool IsGamepadButtonDown(int gamepad, int button)
@ -118,6 +145,7 @@ bool IsGamepadButtonUp(int gamepad, int button)
int GetGamepadButtonPressed(void)
int GetGamepadAxisCount(int gamepad)
float GetGamepadAxisMovement(int gamepad, int axis)
int SetGamepadMappings(const char *mappings)
bool IsMouseButtonPressed(int button)
bool IsMouseButtonDown(int button)
bool IsMouseButtonReleased(int button)
@ -125,17 +153,20 @@ bool IsMouseButtonUp(int button)
int GetMouseX(void)
int GetMouseY(void)
Vector2 GetMousePosition(void)
Vector2 GetMouseDelta(void)
void SetMousePosition(int x, int y)
void SetMouseOffset(int offsetX, int offsetY)
void SetMouseScale(float scaleX, float scaleY)
int GetMouseWheelMove(void)
float GetMouseWheelMove(void)
void SetMouseCursor(int cursor)
int GetTouchX(void)
int GetTouchY(void)
Vector2 GetTouchPosition(int index)
void SetGesturesEnabled(unsigned int gestureFlags)
int GetTouchPointId(int index)
int GetTouchPointCount(void)
void SetGesturesEnabled(unsigned int flags)
bool IsGestureDetected(int gesture)
int GetGestureDetected(void)
int GetTouchPointsCount(void)
float GetGestureHoldDuration(void)
Vector2 GetGestureDragVector(void)
float GetGestureDragAngle(void)
@ -143,27 +174,30 @@ Vector2 GetGesturePinchVector(void)
float GetGesturePinchAngle(void)
void SetCameraMode(Camera camera, int mode)
void UpdateCamera(Camera *camera)
void SetCameraPanControl(int panKey)
void SetCameraAltControl(int altKey)
void SetCameraSmoothZoomControl(int szKey)
void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey)
void SetCameraPanControl(int keyPan)
void SetCameraAltControl(int keyAlt)
void SetCameraSmoothZoomControl(int keySmoothZoom)
void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown)
void SetShapesTexture(Texture2D texture, Rectangle source)
void DrawPixel(int posX, int posY, Color color)
void DrawPixelV(Vector2 position, Color color)
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color)
void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
void DrawLineStrip(Vector2 *points, int numPoints, Color color)
void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color)
void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color)
void DrawLineStrip(Vector2 *points, int pointCount, Color color)
void DrawCircle(int centerX, int centerY, float radius, Color color)
void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color)
void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color)
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2)
void DrawCircleV(Vector2 center, float radius, Color color)
void DrawCircleLines(int centerX, int centerY, float radius, Color color)
void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color)
void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color)
void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color)
void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color)
void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color)
void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color)
void DrawRectangle(int posX, int posY, int width, int height, Color color)
void DrawRectangleV(Vector2 position, Vector2 size, Color color)
void DrawRectangleRec(Rectangle rec, Color color)
@ -172,73 +206,57 @@ void DrawRectangleGradientV(int posX, int posY, int width, int height, Color col
void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2)
void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color)
void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color)
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color)
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, float lineThick, Color color)
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
void DrawTriangleFan(Vector2 *points, int numPoints, Color color)
void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color)
void DrawTriangleFan(Vector2 *points, int pointCount, Color color)
void DrawTriangleStrip(Vector2 *points, int pointCount, Color color)
void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color)
void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color)
void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color)
bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2)
bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius)
bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3)
bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint)
bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold)
Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
Image LoadImage(const char *fileName)
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize)
Image LoadImageAnim(const char *fileName, int *frames)
void ExportImage(Image image, const char *fileName)
void ExportImageAsCode(Image image, const char *fileName)
Texture2D LoadTexture(const char *fileName)
Texture2D LoadTextureFromImage(Image image)
TextureCubemap LoadTextureCubemap(Image image, int layoutType)
RenderTexture2D LoadRenderTexture(int width, int height)
Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
Image LoadImageFromTexture(Texture2D texture)
Image LoadImageFromScreen(void)
void UnloadImage(Image image)
void UnloadTexture(Texture2D texture)
void UnloadRenderTexture(RenderTexture2D target)
Color *GetImageData(Image image)
Vector4 *GetImageDataNormalized(Image image)
Rectangle GetImageAlphaBorder(Image image, float threshold)
int GetPixelDataSize(int width, int height, int format)
Image GetTextureData(Texture2D texture)
Image GetScreenData(void)
void UpdateTexture(Texture2D texture, const void *pixels)
void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels)
bool ExportImage(Image image, const char *fileName)
bool ExportImageAsCode(Image image, const char *fileName)
Image GenImageColor(int width, int height, Color color)
Image GenImageGradientV(int width, int height, Color top, Color bottom)
Image GenImageGradientH(int width, int height, Color left, Color right)
Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
Image GenImageWhiteNoise(int width, int height, float factor)
Image GenImageCellular(int width, int height, int tileSize)
Image ImageCopy(Image image)
Image ImageFromImage(Image image, Rectangle rec)
void ImageToPOT(Image *image, Color fillColor)
void ImageFormat(Image *image, int newFormat)
void ImageAlphaMask(Image *image, Image alphaMask)
void ImageAlphaClear(Image *image, Color color, float threshold)
void ImageAlphaCrop(Image *image, float threshold)
void ImageAlphaPremultiply(Image *image)
void ImageCrop(Image *image, Rectangle crop)
void ImageResize(Image *image, int newWidth, int newHeight)
void ImageResizeNN(Image *image, int newWidth,int newHeight)
void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color)
void ImageMipmaps(Image *image)
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
Color *GetImagePalette(Image image, int maxPaletteSize, int *extractCount)
Image ImageText(const char *text, int fontSize, Color color)
Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint)
void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint)
void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color)
void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color)
void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color)
void ImageClearBackground(Image *dst, Color color)
void ImageDrawPixel(Image *dst, int posX, int posY, Color color)
void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color)
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void ImageFormat(Image *image, int newFormat)
void ImageToPOT(Image *image, Color fill)
void ImageCrop(Image *image, Rectangle crop)
void ImageAlphaCrop(Image *image, float threshold)
void ImageAlphaClear(Image *image, Color color, float threshold)
void ImageAlphaMask(Image *image, Image alphaMask)
void ImageAlphaPremultiply(Image *image)
void ImageResize(Image *image, int newWidth, int newHeight)
void ImageResizeNN(Image *image, int newWidth,int newHeight)
void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill)
void ImageMipmaps(Image *image)
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
void ImageFlipVertical(Image *image)
void ImageFlipHorizontal(Image *image)
void ImageRotateCW(Image *image)
@ -249,40 +267,85 @@ void ImageColorGrayscale(Image *image)
void ImageColorContrast(Image *image, float contrast)
void ImageColorBrightness(Image *image, int brightness)
void ImageColorReplace(Image *image, Color color, Color replace)
Image GenImageColor(int width, int height, Color color)
Image GenImageGradientV(int width, int height, Color top, Color bottom)
Image GenImageGradientH(int width, int height, Color left, Color right)
Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
Image GenImageWhiteNoise(int width, int height, float factor)
Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale)
Image GenImageCellular(int width, int height, int tileSize)
Color *LoadImageColors(Image image)
Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount)
void UnloadImageColors(Color *colors)
void UnloadImagePalette(Color *colors)
Rectangle GetImageAlphaBorder(Image image, float threshold)
Color GetImageColor(Image image, int x, int y)
void ImageClearBackground(Image *dst, Color color)
void ImageDrawPixel(Image *dst, int posX, int posY, Color color)
void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color)
void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color)
void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color)
void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color)
void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint)
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
Texture2D LoadTexture(const char *fileName)
Texture2D LoadTextureFromImage(Image image)
TextureCubemap LoadTextureCubemap(Image image, int layout)
RenderTexture2D LoadRenderTexture(int width, int height)
void UnloadTexture(Texture2D texture)
void UnloadRenderTexture(RenderTexture2D target)
void UpdateTexture(Texture2D texture, const void *pixels)
void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels)
void GenTextureMipmaps(Texture2D *texture)
void SetTextureFilter(Texture2D texture, int filterMode)
void SetTextureWrap(Texture2D texture, int wrapMode)
void SetTextureFilter(Texture2D texture, int filter)
void SetTextureWrap(Texture2D texture, int wrap)
void DrawTexture(Texture2D texture, int posX, int posY, Color tint)
void DrawTextureV(Texture2D texture, Vector2 position, Color tint)
void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint)
void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint)
void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint)
void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint)
void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint)
void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint)
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint)
void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint)
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
Color Fade(Color color, float alpha)
int ColorToInt(Color color)
Vector4 ColorNormalize(Color color)
Color ColorFromNormalized(Vector4 normalized)
Vector3 ColorToHSV(Color color)
Color ColorFromHSV(float hue, float saturation, float value)
Color ColorAlpha(Color color, float alpha)
Color ColorAlphaBlend(Color dst, Color src, Color tint)
Color GetColor(int hexValue)
Color GetPixelColor(void *srcPtr, int format)
void SetPixelColor(void *dstPtr, Color color, int format)
int GetPixelDataSize(int width, int height, int format)
Font GetFontDefault(void)
Font LoadFont(const char *fileName)
Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount)
Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount)
Font LoadFontFromImage(Image image, Color key, int firstChar)
CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type)
Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod)
Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount)
GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type)
Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod)
void UnloadFontData(GlyphInfo *chars, int glyphCount)
void UnloadFont(Font font)
bool ExportFontAsCode(Font font, const char *fileName)
void DrawFPS(int posX, int posY)
void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint)
void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint)
void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint)
void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint)
int MeasureText(const char *text, int fontSize)
Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing)
int GetGlyphIndex(Font font, int codepoint)
GlyphInfo GetGlyphInfo(Font font, int codepoint)
Rectangle GetGlyphAtlasRec(Font font, int codepoint)
int *LoadCodepoints(const char *text, int *count)
void UnloadCodepoints(int *codepoints)
int GetCodepointCount(const char *text)
int GetCodepoint(const char *text, int *bytesProcessed)
const char *CodepointToUTF8(int codepoint, int *byteSize)
char *TextCodepointsToUTF8(const int *codepoints, int length)
int TextCopy(char *dst, const char *src)
bool TextIsEqual(const char *text1, const char *text2)
unsigned int TextLength(const char *text)
@ -298,117 +361,91 @@ const char *TextToUpper(const char *text)
const char *TextToLower(const char *text)
const char *TextToPascal(const char *text)
int TextToInteger(const char *text)
char *TextToUtf8(int *codepoints, int length)
int *GetCodepoints(const char *text, int *count)
int GetCodepointsCount(const char *text)
int GetNextCodepoint(const char *text, int *bytesProcessed)
const char *CodepointToUtf8(int codepoint, int *byteLength)
void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
void DrawPoint3D(Vector3 position, Color color)
void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color)
void DrawCube(Vector3 position, float width, float height, float length, Color color)
void DrawCubeV(Vector3 position, Vector3 size, Color color)
void DrawCubeWires(Vector3 position, float width, float height, float length, Color color)
void DrawCubeWiresV(Vector3 position, Vector3 size, Color color)
void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
void DrawSphere(Vector3 centerPos, float radius, Color color)
void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color)
void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color)
void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color)
void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color)
void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color)
void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color)
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
void DrawRay(Ray ray, Color color)
void DrawGrid(int slices, float spacing)
void DrawGizmo(Vector3 position)
Model LoadModel(const char *fileName)
Model LoadModelFromMesh(Mesh mesh)
void UnloadModel(Model model)
Mesh *LoadMeshes(const char *fileName, int *meshCount)
void ExportMesh(Mesh mesh, const char *fileName)
void UnloadModelKeepMeshes(Model model)
BoundingBox GetModelBoundingBox(Model model)
void DrawModel(Model model, Vector3 position, float scale, Color tint)
void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
void DrawBoundingBox(BoundingBox box, Color color)
void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint)
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint)
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
void UploadMesh(Mesh *mesh, bool dynamic)
void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset)
void UnloadMesh(Mesh mesh)
Material *LoadMaterials(const char *fileName, int *materialCount)
Material LoadMaterialDefault(void)
void UnloadMaterial(Material material)
void SetMaterialTexture(Material *material, int mapType, Texture2D texture)
void SetModelMeshMaterial(Model *model, int meshId, int materialId)
ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount)
void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
void UnloadModelAnimation(ModelAnimation anim)
bool IsModelAnimationValid(Model model, ModelAnimation anim)
void DrawMesh(Mesh mesh, Material material, Matrix transform)
void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances)
bool ExportMesh(Mesh mesh, const char *fileName)
BoundingBox GetMeshBoundingBox(Mesh mesh)
void GenMeshTangents(Mesh *mesh)
void GenMeshBinormals(Mesh *mesh)
Mesh GenMeshPoly(int sides, float radius)
Mesh GenMeshPlane(float width, float length, int resX, int resZ)
Mesh GenMeshCube(float width, float height, float length)
Mesh GenMeshSphere(float radius, int rings, int slices)
Mesh GenMeshHemiSphere(float radius, int rings, int slices)
Mesh GenMeshCylinder(float radius, float height, int slices)
Mesh GenMeshCone(float radius, float height, int slices)
Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
Mesh GenMeshKnot(float radius, float size, int radSeg, int sides)
Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
BoundingBox MeshBoundingBox(Mesh mesh)
void MeshTangents(Mesh *mesh)
void MeshBinormals(Mesh *mesh)
void MeshNormalsSmooth(Mesh *mesh)
void DrawModel(Model model, Vector3 position, float scale, Color tint)
void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
void DrawBoundingBox(BoundingBox box, Color color)
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint)
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB)
Material *LoadMaterials(const char *fileName, int *materialCount)
Material LoadMaterialDefault(void)
void UnloadMaterial(Material material)
void SetMaterialTexture(Material *material, int mapType, Texture2D texture)
void SetModelMeshMaterial(Model *model, int meshId, int materialId)
ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount)
void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
void UnloadModelAnimation(ModelAnimation anim)
void UnloadModelAnimations(ModelAnimation* animations, unsigned int count)
bool IsModelAnimationValid(Model model, ModelAnimation anim)
bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2)
bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2)
bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius)
bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *collisionPoint)
bool CheckCollisionRayBox(Ray ray, BoundingBox box)
RayHitInfo GetCollisionRayModel(Ray ray, Model model)
RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight)
Shader LoadShader(const char *vsFileName, const char *fsFileName)
Shader LoadShaderCode(const char *vsCode, const char *fsCode)
void UnloadShader(Shader shader)
Shader GetShaderDefault(void)
Texture2D GetTextureDefault(void)
Texture2D GetShapesTexture(void)
Rectangle GetShapesTextureRec(void)
void SetShapesTexture(Texture2D texture, Rectangle source)
int GetShaderLocation(Shader shader, const char *uniformName)
void SetShaderValue(Shader shader, int uniformLoc, const void *value, int uniformType)
void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int uniformType, int count)
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat)
void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture)
void SetMatrixProjection(Matrix proj)
void SetMatrixModelview(Matrix view)
Matrix GetMatrixModelview(void)
Matrix GetMatrixProjection(void)
Texture2D GenTextureCubemap(Shader shader, Texture2D map, int size)
Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
Texture2D GenTextureBRDF(Shader shader, int size)
void BeginShaderMode(Shader shader)
void EndShaderMode(void)
void BeginBlendMode(int mode)
void EndBlendMode(void)
void InitVrSimulator(void)
void CloseVrSimulator(void)
void UpdateVrTracking(Camera *camera)
void SetVrConfiguration(VrDeviceInfo info, Shader distortion)
bool IsVrSimulatorReady(void)
void ToggleVrMode(void)
void BeginVrDrawing(void)
void EndVrDrawing(void)
RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius)
RayCollision GetRayCollisionBox(Ray ray, BoundingBox box)
RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4)
void InitAudioDevice(void)
void CloseAudioDevice(void)
bool IsAudioDeviceReady(void)
void SetMasterVolume(float volume)
Wave LoadWave(const char *fileName)
Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
Sound LoadSound(const char *fileName)
Sound LoadSoundFromWave(Wave wave)
void UpdateSound(Sound sound, const void *data, int samplesCount)
void UpdateSound(Sound sound, const void *data, int sampleCount)
void UnloadWave(Wave wave)
void UnloadSound(Sound sound)
void ExportWave(Wave wave, const char *fileName)
void ExportWaveAsCode(Wave wave, const char *fileName)
bool ExportWave(Wave wave, const char *fileName)
bool ExportWaveAsCode(Wave wave, const char *fileName)
void PlaySound(Sound sound)
void StopSound(Sound sound)
void PauseSound(Sound sound)
@ -419,25 +456,30 @@ int GetSoundsPlaying(void)
bool IsSoundPlaying(Sound sound)
void SetSoundVolume(Sound sound, float volume)
void SetSoundPitch(Sound sound, float pitch)
void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
void SetSoundPan(Sound sound, float pan)
Wave WaveCopy(Wave wave)
void WaveCrop(Wave *wave, int initSample, int finalSample)
float *GetWaveData(Wave wave)
void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
float *LoadWaveSamples(Wave wave)
void UnloadWaveSamples(float *samples)
Music LoadMusicStream(const char *fileName)
Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char* data, int dataSize)
void UnloadMusicStream(Music music)
void PlayMusicStream(Music music)
bool IsMusicStreamPlaying(Music music)
void UpdateMusicStream(Music music)
void StopMusicStream(Music music)
void PauseMusicStream(Music music)
void ResumeMusicStream(Music music)
bool IsMusicPlaying(Music music)
void SeekMusicStream(Music music, float position)
void SetMusicVolume(Music music, float volume)
void SetMusicPan(Music music, float pan)
void SetMusicPitch(Music music, float pitch)
float GetMusicTimeLength(Music music)
float GetMusicTimePlayed(Music music)
AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
void CloseAudioStream(AudioStream stream)
AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)
void UnloadAudioStream(AudioStream stream)
void UpdateAudioStream(AudioStream stream, const void *data, int frameCount)
bool IsAudioStreamProcessed(AudioStream stream)
void PlayAudioStream(AudioStream stream)
void PauseAudioStream(AudioStream stream)
@ -446,4 +488,8 @@ bool IsAudioStreamPlaying(AudioStream stream)
void StopAudioStream(AudioStream stream)
void SetAudioStreamVolume(AudioStream stream, float volume)
void SetAudioStreamPitch(AudioStream stream, float pitch)
void SetAudioStreamPan(AudioStream stream, float pan)
void SetAudioStreamBufferSizeDefault(int size)
void SetAudioStreamCallback(AudioStream stream, AudioCallback callback)
void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor)
void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor)

View File

@ -0,0 +1,139 @@
local json = require "json"
local content = io.open(arg[1], "r"):read "*a"
local t = json.decode(content)
print "---@diagnostic disable"
print "---raylib-lua binding"
print "rl = {}"
local ffi_type_list = {}
local function luaify(t)
-- strings
for _,v in ipairs { "void %*", "char %*" } do
if string.find(t, v) then
return 'string|lightuserdata'
end
end
for _,v in ipairs { "char" } do
if string.find(t, v) then
return "number|string[]"
end
end
for _,v in ipairs { "int", "long", "float", "double" } do
if string.find(t, v) then
return "number"
end
end
local t = t:gsub(" ", "_"):gsub("*", "_ptr"):gsub("__", "_")
if t:find "_ptr" then
t = t .. "|lightuserdata"
end
return t
end
for _,enum in ipairs(t.enums) do
print("---@alias " .. enum.name)
for _,v in pairs(enum.values) do
print(string.format("---| '%s'", v.name))
end
if enum.description ~= "" then
print("---" .. enum.description)
end
print ""
for _,v in pairs(enum.values) do
if v.description ~= "" then
print("---" .. v.description)
end
print(string.format("rl.%s = %u", v.name, v.value))
end
end
for _,struct in ipairs(t.structs) do
print(string.format("---@class %s%s", struct.name,
(struct.description ~= "") and string.format(" @ %s", struct.description) or ""))
print(string.format("---@alias %s_ptr %s", struct.name, struct.name))
print(string.format("---@alias %s_ptr_ptr %s", struct.name, struct.name))
if struct.name == "Texture" then
print "---@alias Texture2D Texture"
end
if struct.name == "RenderTexture" then
print "---@alias RenderTexture2D RenderTexture"
end
ffi_type_list[#ffi_type_list+1] = struct.name
for _,field in pairs(struct.fields) do
for n in field.name:gmatch "([^, ]+),?" do
local arraySize = n:match "%[(.-)%]"
if arraySize then
n = n:match("(%S-)%[.-%]")
field.type = string.format("%s[]", luaify(field.type), arraySize)
end
print(string.format('---@field %s %s%s', n, luaify(field.type),
(field.description ~= "") and string.format(" # %s", field.description) or ""))
end
end
print(string.format('---Constructed using `rl.new("%s", ...)`', struct.name))
print(string.format("local %s = {}", struct.name))
end
for _,func in ipairs(t.functions) do
local arraySize
local args = {}
local vla = false
for i,param in ipairs(func.params or {}) do
if param.name ~= "" then
arraySize = param.name:match "%[(.-)%]"
if arraySize then
param.name = param.name:match("(%S-)%[.-%]")
param.type = string.format("%s[%d]", param.type, arraySize)
end
arraySize = param.name:match "%[(.-)%]"
if arraySize then
param.name = param.name:match("(%S-)%[.-%]")
param.type = string.format("%s[%d]", luaify(param.type), arraySize)
end
print(string.format('---@param %s %s', param.name, luaify(param.type)))
args[#args + 1] = param.name
else
vla = true
end
end
if func.returnType and func.returnType ~= "void" then
print(string.format('---@return %s', luaify(func.returnType)))
end
if vla then
print "---@vararg any"
end
if func.description ~= "" then
print("---" .. func.description)
end
print(string.format("function rl.%s(%s%s) end", func.name, table.concat(args, ","), vla and ", ..." or ""))
end
print "---Create a new variable of ffi type `t`"
for i,t in ipairs(ffi_type_list) do
print(string.format([[---@overload fun(t: '"%s"', ...): %s]], t, t))
end
print("function rl.new(...) end")

388
tools/autocomplete/json.lua Normal file
View File

@ -0,0 +1,388 @@
--
-- json.lua
--
-- Copyright (c) 2020 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-- of the Software, and to permit persons to whom the Software is furnished to do
-- so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
local json = { _version = "0.1.2" }
-------------------------------------------------------------------------------
-- Encode
-------------------------------------------------------------------------------
local encode
local escape_char_map = {
[ "\\" ] = "\\",
[ "\"" ] = "\"",
[ "\b" ] = "b",
[ "\f" ] = "f",
[ "\n" ] = "n",
[ "\r" ] = "r",
[ "\t" ] = "t",
}
local escape_char_map_inv = { [ "/" ] = "/" }
for k, v in pairs(escape_char_map) do
escape_char_map_inv[v] = k
end
local function escape_char(c)
return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte()))
end
local function encode_nil(val)
return "null"
end
local function encode_table(val, stack)
local res = {}
stack = stack or {}
-- Circular reference?
if stack[val] then error("circular reference") end
stack[val] = true
if rawget(val, 1) ~= nil or next(val) == nil then
-- Treat as array -- check keys are valid and it is not sparse
local n = 0
for k in pairs(val) do
if type(k) ~= "number" then
error("invalid table: mixed or invalid key types")
end
n = n + 1
end
if n ~= #val then
error("invalid table: sparse array")
end
-- Encode
for i, v in ipairs(val) do
table.insert(res, encode(v, stack))
end
stack[val] = nil
return "[" .. table.concat(res, ",") .. "]"
else
-- Treat as an object
for k, v in pairs(val) do
if type(k) ~= "string" then
error("invalid table: mixed or invalid key types")
end
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
end
stack[val] = nil
return "{" .. table.concat(res, ",") .. "}"
end
end
local function encode_string(val)
return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
end
local function encode_number(val)
-- Check for NaN, -inf and inf
if val ~= val or val <= -math.huge or val >= math.huge then
error("unexpected number value '" .. tostring(val) .. "'")
end
return string.format("%.14g", val)
end
local type_func_map = {
[ "nil" ] = encode_nil,
[ "table" ] = encode_table,
[ "string" ] = encode_string,
[ "number" ] = encode_number,
[ "boolean" ] = tostring,
}
encode = function(val, stack)
local t = type(val)
local f = type_func_map[t]
if f then
return f(val, stack)
end
error("unexpected type '" .. t .. "'")
end
function json.encode(val)
return ( encode(val) )
end
-------------------------------------------------------------------------------
-- Decode
-------------------------------------------------------------------------------
local parse
local function create_set(...)
local res = {}
for i = 1, select("#", ...) do
res[ select(i, ...) ] = true
end
return res
end
local space_chars = create_set(" ", "\t", "\r", "\n")
local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
local literals = create_set("true", "false", "null")
local literal_map = {
[ "true" ] = true,
[ "false" ] = false,
[ "null" ] = nil,
}
local function next_char(str, idx, set, negate)
for i = idx, #str do
if set[str:sub(i, i)] ~= negate then
return i
end
end
return #str + 1
end
local function decode_error(str, idx, msg)
local line_count = 1
local col_count = 1
for i = 1, idx - 1 do
col_count = col_count + 1
if str:sub(i, i) == "\n" then
line_count = line_count + 1
col_count = 1
end
end
error( string.format("%s at line %d col %d", msg, line_count, col_count) )
end
local function codepoint_to_utf8(n)
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
local f = math.floor
if n <= 0x7f then
return string.char(n)
elseif n <= 0x7ff then
return string.char(f(n / 64) + 192, n % 64 + 128)
elseif n <= 0xffff then
return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
elseif n <= 0x10ffff then
return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
f(n % 4096 / 64) + 128, n % 64 + 128)
end
error( string.format("invalid unicode codepoint '%x'", n) )
end
local function parse_unicode_escape(s)
local n1 = tonumber( s:sub(1, 4), 16 )
local n2 = tonumber( s:sub(7, 10), 16 )
-- Surrogate pair?
if n2 then
return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
else
return codepoint_to_utf8(n1)
end
end
local function parse_string(str, i)
local res = ""
local j = i + 1
local k = j
while j <= #str do
local x = str:byte(j)
if x < 32 then
decode_error(str, j, "control character in string")
elseif x == 92 then -- `\`: Escape
res = res .. str:sub(k, j - 1)
j = j + 1
local c = str:sub(j, j)
if c == "u" then
local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1)
or str:match("^%x%x%x%x", j + 1)
or decode_error(str, j - 1, "invalid unicode escape in string")
res = res .. parse_unicode_escape(hex)
j = j + #hex
else
if not escape_chars[c] then
decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string")
end
res = res .. escape_char_map_inv[c]
end
k = j + 1
elseif x == 34 then -- `"`: End of string
res = res .. str:sub(k, j - 1)
return res, j + 1
end
j = j + 1
end
decode_error(str, i, "expected closing quote for string")
end
local function parse_number(str, i)
local x = next_char(str, i, delim_chars)
local s = str:sub(i, x - 1)
local n = tonumber(s)
if not n then
decode_error(str, i, "invalid number '" .. s .. "'")
end
return n, x
end
local function parse_literal(str, i)
local x = next_char(str, i, delim_chars)
local word = str:sub(i, x - 1)
if not literals[word] then
decode_error(str, i, "invalid literal '" .. word .. "'")
end
return literal_map[word], x
end
local function parse_array(str, i)
local res = {}
local n = 1
i = i + 1
while 1 do
local x
i = next_char(str, i, space_chars, true)
-- Empty / end of array?
if str:sub(i, i) == "]" then
i = i + 1
break
end
-- Read token
x, i = parse(str, i)
res[n] = x
n = n + 1
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "]" then break end
if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
end
return res, i
end
local function parse_object(str, i)
local res = {}
i = i + 1
while 1 do
local key, val
i = next_char(str, i, space_chars, true)
-- Empty / end of object?
if str:sub(i, i) == "}" then
i = i + 1
break
end
-- Read key
if str:sub(i, i) ~= '"' then
decode_error(str, i, "expected string for key")
end
key, i = parse(str, i)
-- Read ':' delimiter
i = next_char(str, i, space_chars, true)
if str:sub(i, i) ~= ":" then
decode_error(str, i, "expected ':' after key")
end
i = next_char(str, i + 1, space_chars, true)
-- Read value
val, i = parse(str, i)
-- Set
res[key] = val
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "}" then break end
if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
end
return res, i
end
local char_func_map = {
[ '"' ] = parse_string,
[ "0" ] = parse_number,
[ "1" ] = parse_number,
[ "2" ] = parse_number,
[ "3" ] = parse_number,
[ "4" ] = parse_number,
[ "5" ] = parse_number,
[ "6" ] = parse_number,
[ "7" ] = parse_number,
[ "8" ] = parse_number,
[ "9" ] = parse_number,
[ "-" ] = parse_number,
[ "t" ] = parse_literal,
[ "f" ] = parse_literal,
[ "n" ] = parse_literal,
[ "[" ] = parse_array,
[ "{" ] = parse_object,
}
parse = function(str, idx)
local chr = str:sub(idx, idx)
local f = char_func_map[chr]
if f then
return f(str, idx)
end
decode_error(str, idx, "unexpected character '" .. chr .. "'")
end
function json.decode(str)
if type(str) ~= "string" then
error("expected argument of type string, got " .. type(str))
end
local res, idx = parse(str, next_char(str, 1, space_chars, true))
idx = next_char(str, idx, space_chars, true)
if idx <= #str then
decode_error(str, idx, "trailing garbage")
end
return res
end
return json

File diff suppressed because it is too large Load Diff

View File

@ -8,24 +8,39 @@ local keywords = {
local structs = {
"Vector2", "Vector3", "Vector4", "Quaternion",
"Matrix", "Color", "Rectangle", "Image", "Texture", "Texture2D",
"RenderTexture", "NPatchInfo", "CharInfo", "Font",
"RenderTexture", "NPatchInfo", "GlyphInfo", "Font",
"Camera", "Camera2D", "Mesh", "Shader", "MaterialMap",
"Material", "Model", "Transform", "BoneInfo", "ModelAnimation",
"Ray", "RayHitInfo", "BoundingBox", "Wave", "Sound", "Music",
"Ray", "RayCollision", "BoundingBox", "Wave", "Sound", "Music",
"AudioStream", "VrDeviceInfo", "Camera3D", "RenderTexture2D",
"TextureCubemap", "TraceLogCallback", "PhysicsBody",
"GestureEvent", "GuiStyle", "GuiTextBoxState"
"GestureEvent", "GuiStyle", "GuiTextBoxState",
"TraceLogCallback", "VertexBuffer", "DrawCall", "RenderBatch",
"ShaderAttributeDataType", "MaterialMapIndex", "VrStereoConfig",
"AudioCallback"
}
local rl_structs = {
"rlTraceLogLevel", "rlPixelFormat", "rlTextureFilter",
"rlBlendMode", "rlShaderLocationIndex", "rlShaderUniformDataType",
"rlShaderAttributeDataType", "rlFramebufferAttachType",
"rlFramebufferAttachTextureType", "rlVertexBuffer", "rlDrawCall",
"rlRenderBatch"
}
local functions = {}
local proto = {}
local counter = 0
local file = io.open(arg[1], "wb")
local modules = { "api" }
local funcname
local custom_support = {
["rlgl"] = function (line)
return line:gsub("[%s*]+(rl%w+)", function (part)
return line:gsub("([%s*]+)(rl%w+)", function (pre, part)
functions[#functions + 1] = part
funcname = part
counter = counter + 1
if counter == 2 then
@ -37,57 +52,10 @@ local custom_support = {
end
}
local file = io.open(arg[1], "wb")
local modules = { "api" }
for i=2,#arg do
modules[i] = arg[i]
end
for _,modname in ipairs(modules) do
for line in io.lines("tools/" .. modname .. ".h") do
if custom_support[modname] then
line = custom_support[modname](line)
end
line = line:gsub("(%W)([%l%d][%w_]*)", function (before, part)
for i,keyword in ipairs(keywords) do
if part == keyword then
return before .. part
end
end
return before
end)
line = line:gsub("%u%w+", function (part)
for i,struct in ipairs(structs) do
if part == struct then
return part
end
end
functions[#functions + 1] = part
counter = counter + 1
if count == 2 then
print("WARN: Multiple matches for: " .. line)
end
return "(*)"
end)
-- Strip spaces
line = line:gsub("([(),*.])%s+(%w)", function (a, b) return a .. b end)
line = line:gsub("(%w)%s+([(),*.])", function (a, b) return a .. b end)
proto[#proto + 1] = line
end
end
assert(#proto == #functions, "Mismatching proto and function count : " ..
#proto .. " ~= " .. #functions)
file:write [[
struct raylua_bind_entry {
const char *name;
@ -98,12 +66,76 @@ struct raylua_bind_entry {
struct raylua_bind_entry raylua_entries[] = {
]]
for i=1,#proto do
local name, proto = functions[i], proto[i]
file:write(string.format('{ "%s", "%s", &%s },\n', name, proto, name))
for _,modname in ipairs(modules) do
for line in io.lines("tools/" .. modname .. ".h") do
if line:sub(1, 2) ~= "//" then
if line:sub(1, 1) == "#" then
file:write(" " .. line .. "\n")
else
counter = 0
funcname = nil
if custom_support[modname] then
line = custom_support[modname](line)
end
line = line:gsub("(%W)([%l%d][%w_]*)", function (before, part)
for i,keyword in ipairs(keywords) do
if part == keyword
or part == "t" then -- uintX_t workaround
return before .. part
end
end
for i,s in ipairs(rl_structs) do
if part == s then
return before .. part
end
end
return before
end)
line = line:gsub("%u%w+", function (part)
for i,struct in ipairs(structs) do
if part == struct then
return part
end
end
functions[#functions + 1] = part
funcname = part
counter = counter + 1
if counter == 2 then
print("WARN: Multiple matches for: " .. line)
end
return "(*)"
end)
-- Strip spaces
line = line:gsub("([(),*.])%s+(%w)", function (a, b) return a .. b end)
line = line:gsub("(%w)%s+([(),*.])", function (a, b) return a .. b end)
proto[#proto + 1] = line
if funcname and line then
file:write(string.format(' { "%s", "%s", &%s },\n', funcname, line, funcname))
elseif counter == 0 then
print("WARN: Invalid entry", funcname, line)
end
end
end
end
end
file:write '{ NULL, NULL, NULL },\n'
assert(#proto == #functions, "Mismatching proto and function count : " ..
#proto .. " ~= " .. #functions)
print(string.format("Bound %d functions.", #proto))
file:write ' { NULL, NULL, NULL },\n'
file:write "};\n"
file:close()

View File

@ -1,20 +1,19 @@
void InitPhysics(void)
void RunPhysicsStep(void)
void UpdatePhysics(void)
void ResetPhysics(void)
void ClosePhysics(void)
void SetPhysicsTimeStep(double delta)
bool IsPhysicsEnabled(void)
void SetPhysicsGravity(float x, float y)
PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density)
PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density)
PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density)
void DestroyPhysicsBody(PhysicsBody body)
void PhysicsAddForce(PhysicsBody body, Vector2 force)
void PhysicsAddTorque(PhysicsBody body, float amount)
void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
int GetPhysicsBodiesCount(void)
void SetPhysicsBodyRotation(PhysicsBody body, float radians)
PhysicsBody GetPhysicsBody(int index)
int GetPhysicsBodiesCount(void)
int GetPhysicsShapeType(int index)
int GetPhysicsShapeVerticesCount(int index)
Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex)
void SetPhysicsBodyRotation(PhysicsBody body, float radians)
void DestroyPhysicsBody(PhysicsBody body)
void ResetPhysics(void)
void ClosePhysics(void)
Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex)

View File

@ -2,6 +2,7 @@ void GuiEnable(void)
void GuiDisable(void)
void GuiLock(void)
void GuiUnlock(void)
bool GuiIsLocked(void)
void GuiFade(float alpha)
void GuiSetState(int state)
int GuiGetState(void)
@ -9,20 +10,14 @@ void GuiSetFont(Font font)
Font GuiGetFont(void)
void GuiSetStyle(int control, int property, int value)
int GuiGetStyle(int control, int property)
void GuiEnableTooltip(void)
void GuiDisableTooltip(void)
void GuiSetTooltip(const char *tooltip)
void GuiClearTooltip(void)
bool GuiWindowBox(Rectangle bounds, const char *title)
void GuiGroupBox(Rectangle bounds, const char *text)
void GuiLine(Rectangle bounds, const char *text)
void GuiPanel(Rectangle bounds)
Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
void GuiPanel(Rectangle bounds, const char *text)
Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll)
void GuiLabel(Rectangle bounds, const char *text)
bool GuiButton(Rectangle bounds, const char *text)
bool GuiLabelButton(Rectangle bounds, const char *text)
bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture)
bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource)
bool GuiToggle(Rectangle bounds, const char *text, bool active)
int GuiToggleGroup(Rectangle bounds, const char *text, int active)
bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
@ -37,23 +32,23 @@ float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight
float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue)
void GuiStatusBar(Rectangle bounds, const char *text)
void GuiDummyRec(Rectangle bounds, const char *text)
int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs)
Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs)
int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active)
int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active)
int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons)
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text)
Color GuiColorPicker(Rectangle bounds, Color color)
Color GuiColorPanel(Rectangle bounds, Color color)
float GuiColorBarAlpha(Rectangle bounds, float alpha)
float GuiColorBarHue(Rectangle bounds, float value)
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, int *secretViewActive)
Color GuiColorPicker(Rectangle bounds, const char *text, Color color)
Color GuiColorPanel(Rectangle bounds, const char *text, Color color)
float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha)
float GuiColorBarHue(Rectangle bounds, const char *text, float value)
void GuiLoadStyle(const char *fileName)
void GuiLoadStyleDefault(void)
const char *GuiIconText(int iconId, const char *text)
void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color)
void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color)
unsigned int *GuiGetIcons(void)
unsigned int *GuiGetIconData(int iconId)
void GuiSetIconData(int iconId, unsigned int *data)
void GuiSetIconScale(unsigned int scale)
void GuiSetIconPixel(int iconId, int x, int y)
void GuiClearIconPixel(int iconId, int x, int y)
bool GuiCheckIconPixel(int iconId, int x, int y)
bool GuiCheckIconPixel(int iconId, int x, int y)

View File

@ -9,15 +9,19 @@ Vector2 Vector2AddValue(Vector2 v, float add)
Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
Vector2 Vector2SubtractValue(Vector2 v, float sub)
float Vector2Length(Vector2 v)
float Vector2LengthSqr(Vector2 v)
float Vector2DotProduct(Vector2 v1, Vector2 v2)
float Vector2Distance(Vector2 v1, Vector2 v2)
float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
float Vector2Angle(Vector2 v1, Vector2 v2)
Vector2 Vector2Scale(Vector2 v, float scale)
Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)
Vector2 Vector2Negate(Vector2 v)
Vector2 Vector2Divide(Vector2 v1, Vector2 v2)
Vector2 Vector2Normalize(Vector2 v)
Vector2 Vector2Transform(Vector2 v, Matrix mat)
Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
Vector2 Vector2Reflect(Vector2 v, Vector2 normal)
Vector2 Vector2Rotate(Vector2 v, float degs)
Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)
Vector3 Vector3Zero(void)
@ -31,8 +35,11 @@ Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)
Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
Vector3 Vector3Perpendicular(Vector3 v)
float Vector3Length(const Vector3 v)
float Vector3LengthSqr(const Vector3 v)
float Vector3DotProduct(Vector3 v1, Vector3 v2)
float Vector3Distance(Vector3 v1, Vector3 v2)
float Vector3DistanceSqr(Vector3 v1, Vector3 v2)
Vector2 Vector3Angle(Vector3 v1, Vector3 v2)
Vector3 Vector3Negate(Vector3 v)
Vector3 Vector3Divide(Vector3 v1, Vector3 v2)
Vector3 Vector3Normalize(Vector3 v)
@ -49,18 +56,18 @@ float MatrixDeterminant(Matrix mat)
float MatrixTrace(Matrix mat)
Matrix MatrixTranspose(Matrix mat)
Matrix MatrixInvert(Matrix mat)
Matrix MatrixNormalize(Matrix mat)
Matrix MatrixIdentity(void)
Matrix MatrixAdd(Matrix left, Matrix right)
Matrix MatrixSubtract(Matrix left, Matrix right)
Matrix MatrixMultiply(Matrix left, Matrix right)
Matrix MatrixTranslate(float x, float y, float z)
Matrix MatrixRotate(Vector3 axis, float angle)
Matrix MatrixRotateXYZ(Vector3 ang)
Matrix MatrixRotateX(float angle)
Matrix MatrixRotateY(float angle)
Matrix MatrixRotateZ(float angle)
Matrix MatrixRotateXYZ(Vector3 ang)
Matrix MatrixRotateZYX(Vector3 ang)
Matrix MatrixScale(float x, float y, float z)
Matrix MatrixMultiply(Matrix left, Matrix right)
Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)
Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
@ -85,7 +92,7 @@ Quaternion QuaternionFromMatrix(Matrix mat)
Matrix QuaternionToMatrix(Quaternion q)
Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
Quaternion QuaternionFromEuler(float roll, float pitch, float yaw)
Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
Vector3 QuaternionToEuler(Quaternion q)
Quaternion QuaternionTransform(Quaternion q, Matrix mat)
Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)

View File

@ -3,7 +3,7 @@ void rlPushMatrix(void)
void rlPopMatrix(void)
void rlLoadIdentity(void)
void rlTranslatef(float x, float y, float z)
void rlRotatef(float angleDeg, float x, float y, float z)
void rlRotatef(float angle, float x, float y, float z)
void rlScalef(float x, float y, float z)
void rlMultMatrixf(float *matf)
void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar)
@ -16,16 +16,38 @@ void rlVertex2f(float x, float y)
void rlVertex3f(float x, float y, float z)
void rlTexCoord2f(float x, float y)
void rlNormal3f(float x, float y, float z)
void rlColor4ub(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void rlColor3f(float x, float y, float z)
void rlColor4f(float x, float y, float z, float w)
bool rlEnableVertexArray(unsigned int vaoId)
void rlDisableVertexArray(void)
void rlEnableVertexBuffer(unsigned int id)
void rlDisableVertexBuffer(void)
void rlEnableVertexBufferElement(unsigned int id)
void rlDisableVertexBufferElement(void)
void rlEnableVertexAttribute(unsigned int index)
void rlDisableVertexAttribute(unsigned int index)
#if defined(GRAPHICS_API_OPENGL_11)
void rlEnableStatePointer(int vertexAttribType, void *buffer)
void rlDisableStatePointer(int vertexAttribType)
#endif
void rlActiveTextureSlot(int slot)
void rlEnableTexture(unsigned int id)
void rlDisableTexture(void)
void rlEnableTextureCubemap(unsigned int id)
void rlDisableTextureCubemap(void)
void rlTextureParameters(unsigned int id, int param, int value)
void rlEnableRenderTexture(unsigned int id)
void rlDisableRenderTexture(void)
void rlEnableShader(unsigned int id)
void rlDisableShader(void)
void rlEnableFramebuffer(unsigned int id)
void rlDisableFramebuffer(void)
void rlActiveDrawBuffers(int count)
void rlEnableColorBlend(void)
void rlDisableColorBlend(void)
void rlEnableDepthTest(void)
void rlDisableDepthTest(void)
void rlEnableDepthMask(void)
void rlDisableDepthMask(void)
void rlEnableBackfaceCulling(void)
void rlDisableBackfaceCulling(void)
void rlEnableScissorTest(void)
@ -33,38 +55,92 @@ void rlDisableScissorTest(void)
void rlScissor(int x, int y, int width, int height)
void rlEnableWireMode(void)
void rlDisableWireMode(void)
void rlDeleteTextures(unsigned int id)
void rlDeleteRenderTextures(RenderTexture2D target)
void rlDeleteShader(unsigned int id)
void rlDeleteVertexArrays(unsigned int id)
void rlDeleteBuffers(unsigned int id)
void rlClearColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void rlSetLineWidth(float width)
float rlGetLineWidth(void)
void rlEnableSmoothLines(void)
void rlDisableSmoothLines(void)
void rlEnableStereoRender(void)
void rlDisableStereoRender(void)
bool rlIsStereoRenderEnabled(void)
void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void rlClearScreenBuffers(void)
void rlUpdateBuffer(int bufferId, void *data, int dataSize)
unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, int size, bool dynamic)
void rlCheckErrors(void)
void rlSetBlendMode(int mode)
void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
void rlglInit(int width, int height)
void rlglClose(void)
void rlglDraw(void)
void rlCheckErrors(void)
int rlGetVersion(void)
bool rlCheckBufferLimit(int vCount)
void rlSetDebugMarker(const char *text)
void rlSetBlendMode(int glSrcFactor, int glDstFactor, int glEquation)
void rlLoadExtensions(void *loader)
unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount)
unsigned int rlLoadTextureDepth(int width, int height, int bits, bool useRenderBuffer)
unsigned int rlLoadTextureCubemap(void *data, int size, int format)
int rlGetVersion(void)
int rlGetFramebufferWidth(void)
int rlGetFramebufferHeight(void)
unsigned int rlGetTextureIdDefault(void)
unsigned int rlGetShaderIdDefault(void)
int *rlGetShaderLocsDefault(void)
rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements)
void rlUnloadRenderBatch(rlRenderBatch batch)
void rlDrawRenderBatch(rlRenderBatch *batch)
void rlSetRenderBatchActive(rlRenderBatch *batch)
void rlDrawRenderBatchActive(void)
bool rlCheckRenderBatchLimit(int vCount)
void rlSetTexture(unsigned int id)
unsigned int rlLoadVertexArray(void)
unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic)
unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic)
void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset)
void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset)
void rlUnloadVertexArray(unsigned int vaoId)
void rlUnloadVertexBuffer(unsigned int vboId)
void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer)
void rlSetVertexAttributeDivisor(unsigned int index, int divisor)
void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count)
void rlDrawVertexArray(int offset, int count)
void rlDrawVertexArrayElements(int offset, int count, const void *buffer)
void rlDrawVertexArrayInstanced(int offset, int count, int instances)
void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances)
unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount)
unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data)
void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType)
void rlGetGlTextureFormats(int format, int *glInternalFormat, int *glFormat, int *glType)
const char *rlGetPixelFormatName(unsigned int format)
void rlUnloadTexture(unsigned int id)
void rlGenerateMipmaps(Texture2D *texture)
void *rlReadTexturePixels(Texture2D texture)
void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps)
void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
unsigned char *rlReadScreenPixels(int width, int height)
RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depthBits, bool useDepthTexture)
void rlRenderTextureAttach(RenderTexture target, unsigned int id, int attachType)
bool rlRenderTextureComplete(RenderTexture target)
void rlLoadMesh(Mesh *mesh, bool dynamic)
void rlUpdateMesh(Mesh mesh, int buffer, int num)
void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index)
void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
void rlUnloadMesh(Mesh mesh)
unsigned int rlLoadFramebuffer(int width, int height)
void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel)
bool rlFramebufferComplete(unsigned int id)
void rlUnloadFramebuffer(unsigned int id)
unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode)
unsigned int rlCompileShader(const char *shaderCode, int type)
unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
void rlUnloadShaderProgram(unsigned int id)
int rlGetLocationUniform(unsigned int shaderId, const char *uniformName)
int rlGetLocationAttrib(unsigned int shaderId, const char *attribName)
void rlSetUniform(int locIndex, const void *value, int uniformType, int count)
void rlSetUniformMatrix(int locIndex, Matrix mat)
void rlSetUniformSampler(int locIndex, unsigned int textureId)
void rlSetShader(unsigned int id, int *locs)
#if defined(GRAPHICS_API_OPENGL_43)
unsigned int rlLoadComputeShaderProgram(int shaderId)
void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ)
unsigned int rlLoadShaderBuffer(unsigned long long size, const void *data, int usageHint)
void rlUnloadShaderBuffer(unsigned int ssboId)
void rlUpdateShaderBufferElements(unsigned int id, const void *data, unsigned long long dataSize, unsigned long long offset)
unsigned long long rlGetShaderBufferSize(unsigned int id)
void rlReadShaderBufferElements(unsigned int id, void *dest, unsigned long long count, unsigned long long offset)
void rlBindShaderBuffer(unsigned int id, unsigned int index)
void rlCopyBuffersElements(unsigned int destId, unsigned int srcId, unsigned long long destOffset, unsigned long long srcOffset, unsigned long long count)
void rlBindImageTexture(unsigned int id, unsigned int index, unsigned int format, int readonly)
#endif
Matrix rlGetMatrixModelview(void)
Matrix rlGetMatrixProjection(void)
Matrix rlGetMatrixTransform(void)
Matrix rlGetMatrixProjectionStereo(int eye)
Matrix rlGetMatrixViewOffsetStereo(int eye)
void rlSetMatrixProjection(Matrix proj)
void rlSetMatrixModelview(Matrix view)
void rlSetMatrixProjectionStereo(Matrix right, Matrix left)
void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left)
void rlLoadDrawCube(void)
void rlLoadDrawQuad(void)