Add even more files

This commit is contained in:
TSnake41 2020-02-27 18:01:34 +01:00
parent dae35f0d74
commit bfcdb200b5
19 changed files with 1707 additions and 2215 deletions

10
.gitignore vendored
View File

@ -2,3 +2,13 @@
wray_standalone\.exe wray_standalone\.exe
src/wray_api\.c src/wray_api\.c
libwray\.a libwray\.a
raylua_e.exe
raylua_s.exe
src/autogen/bind.c
src/autogen/boot.c
src/autogen/builder.c

View File

@ -0,0 +1,15 @@
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.SetTargetFPS(60)
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
rl.CloseWindow()

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

View File

@ -0,0 +1,26 @@
local ffi = require "ffi"
local lua_color = ffi.new("Color", 3, 3, 128, 255)
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.SetTargetFPS(60)
local width, height = 800, 450
rl.InitWindow(800, 450, "raylib [shapes] example - basic shapes drawing")
while not rl.WindowShouldClose() do
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawRectangle(width / 2 - 128, height / 2 - 128, 256, 256, lua_color)
rl.DrawRectangle(width / 2 - 112, height / 2 - 112, 224, 224, rl.RAYWHITE)
rl.DrawText("raylib", width / 2 - 44, height / 2 + 24, 50, lua_color)
rl.DrawText("Lua", width / 2 - 44, height / 2 + 65, 50, lua_color)
rl.DrawText("this is NOT a texture!", 350, 370, 10, rl.GRAY)
rl.EndDrawing()
end
rl.CloseWindow()

View File

@ -0,0 +1,112 @@
--------------------------------------------------------------------------------------------
--
-- raylib [textures] example - Bunnymark
--
-- This example has been created using raylib 1.6 (www.raylib.com)
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
--
-- Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
--
--------------------------------------------------------------------------------------------
local ffi = require "ffi"
local MAX_BUNNIES = 100000 -- 100K bunnies limit
-- This is the maximum amount of elements (quads) per batch
-- NOTE: This value is defined in [rlgl] module and can be changed there
local MAX_BATCH_ELEMENTS = 8192
-- Create the Bunny class.
Bunny = {}
Bunny.__index = Bunny
function Bunny:new(pos, spd, col)
local bunny = {}
setmetatable(bunny,Bunny)
bunny.position = pos
bunny.speed = spd
bunny.color = col
return bunny
end
function Bunny:update(texture)
self.position.x = self.position.x + self.speed.x
self.position.y = self.position.y + self.speed.y
if ((self.position.x + texture.width/2) > rl.GetScreenWidth()) or ((self.position.x + texture.width/2) < 0) then
self.speed.x = self.speed.x * -1
end
if ((self.position.y + texture.height/2) > rl.GetScreenHeight()) or ((self.position.y + texture.height/2 - 40) < 0) then
self.speed.y = self.speed.y * -1
end
end
-- Initialization
----------------------------------------------------------------------------------------
local screenWidth = 800
local screenHeight = 450
rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark")
-- Load bunny texture
local texBunny = rl.LoadTexture("resources/wabbit_alpha.png")
local bunnies = {}
rl.SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
----------------------------------------------------------------------------------------
-- Main game loop
while not rl.WindowShouldClose() do -- Detect window close button or ESC key
-- Update
------------------------------------------------------------------------------------
if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON) then
-- Create more bunnies
for i = 1, 100 do
if #bunnies < MAX_BUNNIES then
local speed = ffi.new("Vector2", rl.GetRandomValue(-250, 250) / 60, rl.GetRandomValue(-250, 250) / 60)
local color = ffi.new("Color", rl.GetRandomValue(50, 240), rl.GetRandomValue(80, 240), rl.GetRandomValue(100, 240), 255)
--bunnies[#bunnies] = Bunny:new(nil, GetMousePosition(), speed, color)
table.insert(bunnies, Bunny:new(rl.GetMousePosition(), speed, color))
end
end
end
-- Update bunnies
for i = 1, #bunnies do
bunnies[i]:update(texBunny)
end
------------------------------------------------------------------------------------
-- Draw
------------------------------------------------------------------------------------
rl.BeginDrawing();
rl.ClearBackground(rl.RAYWHITE);
for i = 1, #bunnies do
-- NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
-- a draw call is launched and buffer starts being filled again;
-- before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU...
-- Process of sending data is costly and it could happen that GPU data has not been completely
-- processed for drawing while new data is tried to be sent (updating current in-use buffers)
-- it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies
rl.DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, bunnies[i].color);
end
rl.DrawRectangle(0, 0, screenWidth, 40, rl.BLACK)
rl.DrawText("bunnies: " .. #bunnies, 120, 10, 20, rl.GREEN)
rl.DrawText("batched draw calls: " .. math.ceil(1 + #bunnies / MAX_BATCH_ELEMENTS), 320, 10, 20, rl.MAROON)
-- DrawText(FormatText("bunnies: %i", #bunnies), 120, 10, 20, GREEN)
-- DrawText(FormatText("batched draw calls: %i", 1 + #bunnies/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON)
rl.DrawFPS(10, 10)
rl.EndDrawing()
------------------------------------------------------------------------------------
end
-- De-Initialization
----------------------------------------------------------------------------------------
rl.UnloadTexture(texBunny) -- Unload bunny texture
rl.CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------

View File

@ -1,9 +1,16 @@
CFLAGS := -O2 -s CFLAGS := -O2 -s
LDFLAGS := -O2 -s -lm -lluajit LDFLAGS := -O2 -s -lm
AR ?= ar AR ?= ar
LUA ?= luajit LUA ?= luajit
CFLAGS += -Iluajit/src -Iraylib/src
LDFLAGS += -Lluajit/src -lluajit -Lraylib/src -lraylib
ifeq ($(OS),Windows_NT)
LDFLAGS += -lopengl32 -lgdi32 -lwinmm
endif
BOOT_FILES := src/raylib.lua src/raylua.lua BOOT_FILES := src/raylib.lua src/raylua.lua
all: raylua_s raylua_e all: raylua_s raylua_e
@ -11,16 +18,36 @@ all: raylua_s raylua_e
%.o: %.c %.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
src/raylua_boot.c: src/raylib.lua src/raylua.lua all: luajit raylib raylua_s raylua_e
$(LUA) tools/lua2str.lua $@ raylua_boot $^
raylua_s: src/raylua_boot.o src/raylua_s.o luajit:
$(MAKE) -C luajit amalg BUILDMODE=static
raylib:
$(MAKE) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" -C raylib/src
raylua_s: src/raylua.o src/raylua_s.o
$(CC) -o $@ $^ $(LDFLAGS) $(CC) -o $@ $^ $(LDFLAGS)
raylua_e: src/lib/miniz.o src/raylua_boot.o src/raylua_builder.o src/raylua_e.o raylua_e: src/raylua.o src/raylua_e.o src/raylua_builder.o src/lib/miniz.o
$(CC) -o $@ $^ -lwray $(LDFLAGS) $(CC) -o $@ $^ $(LDFLAGS)
src/raylua.o: src/autogen/boot.c src/autogen/bind.c
src/raylua_builder.o: src/autogen/builder.c
src/autogen/boot.c: src/raylib.lua src/raylua.lua
$(LUA) tools/lua2str.lua $@ raylua_boot_lua $^
src/autogen/bind.c:
$(LUA) tools/genbind.lua $@
src/autogen/builder.c: src/raylua_builder.lua
$(LUA) tools/lua2str.lua $@ raylua_builder_lua $^
clean: clean:
rm -rf raylua_s raylua_e src/raylua_boot.c src/*.o src/lib/miniz.o rm -rf raylua_s raylua_e src/raylua_e.o src/raylua_s.o src/raylua.o src/autogen/*.c
$(MAKE) -C luajit clean
$(MAKE) -C raylib clean
.PHONY: raylua_s raylua_e .PHONY: all src/autogen/bind.c src/autogen/boot.c raylua_s raylua_e luajit raylib clean

1
raylib Submodule

@ -0,0 +1 @@
Subproject commit acfa967e891997e862d1c77dac21ae9a484017c5

View File

@ -1,43 +1,52 @@
print "[RAYLUA] Raylua boot script"
local ffi = require "ffi" local ffi = require "ffi"
local raylib = {} local raylib = {}
local raylib_so = ffi.load("raylib") local raylib_so = ffi.C
-- ffi cdef, based on raylib.h -- structs definition
ffi.cdef [[ ffi.cdef [[
typedef struct Vector2 { typedef struct Vector2 {
float x; float x;
float y; float y;
} Vector2; } Vector2;
typedef struct Vector3 { typedef struct Vector3 {
float x; float x;
float y; float y;
float z; float z;
} Vector3; } Vector3;
typedef struct Vector4 { typedef struct Vector4 {
float x; float x;
float y; float y;
float z; float z;
float w; float w;
} Vector4; } Vector4;
typedef Vector4 Quaternion; typedef Vector4 Quaternion;
typedef struct Matrix { typedef struct Matrix {
float m0, m4, m8, m12; float m0, m4, m8, m12;
float m1, m5, m9, m13; float m1, m5, m9, m13;
float m2, m6, m10, m14; float m2, m6, m10, m14;
float m3, m7, m11, m15; float m3, m7, m11, m15;
} Matrix; } Matrix;
typedef struct Color { typedef struct Color {
unsigned char r; unsigned char r;
unsigned char g; unsigned char g;
unsigned char b; unsigned char b;
unsigned char a; unsigned char a;
} Color; } Color;
typedef struct Rectangle { typedef struct Rectangle {
float x; float x;
float y; float y;
float width; float width;
float height; float height;
} Rectangle; } Rectangle;
typedef struct Image { typedef struct Image {
void *data; void *data;
int width; int width;
@ -45,6 +54,7 @@ ffi.cdef [[
int mipmaps; int mipmaps;
int format; int format;
} Image; } Image;
typedef struct Texture2D { typedef struct Texture2D {
unsigned int id; unsigned int id;
int width; int width;
@ -54,12 +64,14 @@ ffi.cdef [[
} Texture2D; } Texture2D;
typedef Texture2D Texture; typedef Texture2D Texture;
typedef Texture2D TextureCubemap; typedef Texture2D TextureCubemap;
typedef struct RenderTexture2D { typedef struct RenderTexture2D {
unsigned int id; unsigned int id;
Texture2D texture; Texture2D texture;
Texture2D depth; Texture2D depth;
bool depthTexture; bool depthTexture;
} RenderTexture2D; } RenderTexture2D;
typedef RenderTexture2D RenderTexture; typedef RenderTexture2D RenderTexture;
typedef struct NPatchInfo { typedef struct NPatchInfo {
Rectangle sourceRec; Rectangle sourceRec;
@ -69,6 +81,7 @@ ffi.cdef [[
int bottom; int bottom;
int type; int type;
} NPatchInfo; } NPatchInfo;
typedef struct CharInfo { typedef struct CharInfo {
int value; int value;
int offsetX; int offsetX;
@ -76,6 +89,7 @@ ffi.cdef [[
int advanceX; int advanceX;
Image image; Image image;
} CharInfo; } CharInfo;
typedef struct Font { typedef struct Font {
int baseSize; int baseSize;
int charsCount; int charsCount;
@ -84,7 +98,7 @@ ffi.cdef [[
CharInfo *chars; CharInfo *chars;
} Font; } Font;
typedef SpriteFont Font; typedef Font SpriteFont;
typedef struct Camera3D { typedef struct Camera3D {
Vector3 position; Vector3 position;
Vector3 target; Vector3 target;
@ -100,6 +114,7 @@ ffi.cdef [[
float rotation; float rotation;
float zoom; float zoom;
} Camera2D; } Camera2D;
typedef struct Mesh { typedef struct Mesh {
int vertexCount; int vertexCount;
int triangleCount; int triangleCount;
@ -117,29 +132,35 @@ ffi.cdef [[
unsigned int vaoId; unsigned int vaoId;
unsigned int *vboId; unsigned int *vboId;
} Mesh; } Mesh;
typedef struct Shader { typedef struct Shader {
unsigned int id; unsigned int id;
int *locs; int *locs;
} Shader; } Shader;
typedef struct MaterialMap { typedef struct MaterialMap {
Texture2D texture; Texture2D texture;
Color color; Color color;
float value; float value;
} MaterialMap; } MaterialMap;
typedef struct Material { typedef struct Material {
Shader shader; Shader shader;
MaterialMap *maps; MaterialMap *maps;
float *params; float *params;
} Material; } Material;
typedef struct Transform { typedef struct Transform {
Vector3 translation; Vector3 translation;
Quaternion rotation; Quaternion rotation;
Vector3 scale; Vector3 scale;
} Transform; } Transform;
typedef struct BoneInfo { typedef struct BoneInfo {
char name[32]; char name[32];
int parent; int parent;
} BoneInfo; } BoneInfo;
typedef struct Model { typedef struct Model {
Matrix transform; Matrix transform;
@ -153,6 +174,7 @@ ffi.cdef [[
BoneInfo *bones; BoneInfo *bones;
Transform *bindPose; Transform *bindPose;
} Model; } Model;
typedef struct ModelAnimation { typedef struct ModelAnimation {
int boneCount; int boneCount;
BoneInfo *bones; BoneInfo *bones;
@ -160,20 +182,24 @@ ffi.cdef [[
int frameCount; int frameCount;
Transform **framePoses; Transform **framePoses;
} ModelAnimation; } ModelAnimation;
typedef struct Ray { typedef struct Ray {
Vector3 position; Vector3 position;
Vector3 direction; Vector3 direction;
} Ray; } Ray;
typedef struct RayHitInfo { typedef struct RayHitInfo {
bool hit; bool hit;
float distance; float distance;
Vector3 position; Vector3 position;
Vector3 normal; Vector3 normal;
} RayHitInfo; } RayHitInfo;
typedef struct BoundingBox { typedef struct BoundingBox {
Vector3 min; Vector3 min;
Vector3 max; Vector3 max;
} BoundingBox; } BoundingBox;
typedef struct Wave { typedef struct Wave {
unsigned int sampleCount; unsigned int sampleCount;
unsigned int sampleRate; unsigned int sampleRate;
@ -190,10 +216,12 @@ ffi.cdef [[
rAudioBuffer *buffer; rAudioBuffer *buffer;
} AudioStream; } AudioStream;
typedef struct Sound { typedef struct Sound {
unsigned int sampleCount; unsigned int sampleCount;
AudioStream stream; AudioStream stream;
} Sound; } Sound;
typedef struct Music { typedef struct Music {
int ctxType; int ctxType;
void *ctxData; void *ctxData;
@ -203,6 +231,7 @@ ffi.cdef [[
AudioStream stream; AudioStream stream;
} Music; } Music;
typedef struct VrDeviceInfo { typedef struct VrDeviceInfo {
int hResolution; int hResolution;
int vResolution; int vResolution;
@ -215,6 +244,7 @@ ffi.cdef [[
float lensDistortionValues[4]; float lensDistortionValues[4];
float chromaAbCorrection[4]; float chromaAbCorrection[4];
} VrDeviceInfo; } VrDeviceInfo;
typedef enum { typedef enum {
FLAG_RESERVED = 1, FLAG_RESERVED = 1,
FLAG_FULLSCREEN_MODE= 2, FLAG_FULLSCREEN_MODE= 2,
@ -226,6 +256,7 @@ ffi.cdef [[
FLAG_MSAA_4X_HINT = 32, FLAG_MSAA_4X_HINT = 32,
FLAG_VSYNC_HINT = 64 FLAG_VSYNC_HINT = 64
} ConfigFlag; } ConfigFlag;
typedef enum { typedef enum {
LOG_ALL = 0, LOG_ALL = 0,
LOG_TRACE, LOG_TRACE,
@ -236,6 +267,7 @@ ffi.cdef [[
LOG_FATAL, LOG_FATAL,
LOG_NONE LOG_NONE
} TraceLogType; } TraceLogType;
typedef enum { typedef enum {
KEY_APOSTROPHE= 39, KEY_APOSTROPHE= 39,
KEY_COMMA = 44, KEY_COMMA = 44,
@ -343,23 +375,27 @@ ffi.cdef [[
KEY_KP_ENTER= 335, KEY_KP_ENTER= 335,
KEY_KP_EQUAL= 336 KEY_KP_EQUAL= 336
} KeyboardKey; } KeyboardKey;
typedef enum { typedef enum {
KEY_BACK = 4, KEY_BACK = 4,
KEY_MENU = 82, KEY_MENU = 82,
KEY_VOLUME_UP = 24, KEY_VOLUME_UP = 24,
KEY_VOLUME_DOWN = 25 KEY_VOLUME_DOWN = 25
} AndroidButton; } AndroidButton;
typedef enum { typedef enum {
MOUSE_LEFT_BUTTON = 0, MOUSE_LEFT_BUTTON = 0,
MOUSE_RIGHT_BUTTON= 1, MOUSE_RIGHT_BUTTON= 1,
MOUSE_MIDDLE_BUTTON = 2 MOUSE_MIDDLE_BUTTON = 2
} MouseButton; } MouseButton;
typedef enum { typedef enum {
GAMEPAD_PLAYER1 = 0, GAMEPAD_PLAYER1 = 0,
GAMEPAD_PLAYER2 = 1, GAMEPAD_PLAYER2 = 1,
GAMEPAD_PLAYER3 = 2, GAMEPAD_PLAYER3 = 2,
GAMEPAD_PLAYER4 = 3 GAMEPAD_PLAYER4 = 3
} GamepadNumber; } GamepadNumber;
typedef enum { typedef enum {
GAMEPAD_BUTTON_UNKNOWN = 0, GAMEPAD_BUTTON_UNKNOWN = 0,
GAMEPAD_BUTTON_LEFT_FACE_UP, GAMEPAD_BUTTON_LEFT_FACE_UP,
@ -390,6 +426,7 @@ ffi.cdef [[
GAMEPAD_AXIS_LEFT_TRIGGER, GAMEPAD_AXIS_LEFT_TRIGGER,
GAMEPAD_AXIS_RIGHT_TRIGGER GAMEPAD_AXIS_RIGHT_TRIGGER
} GamepadAxis; } GamepadAxis;
typedef enum { typedef enum {
LOC_VERTEX_POSITION = 0, LOC_VERTEX_POSITION = 0,
LOC_VERTEX_TEXCOORD01, LOC_VERTEX_TEXCOORD01,
@ -418,9 +455,6 @@ ffi.cdef [[
LOC_MAP_BRDF LOC_MAP_BRDF
} ShaderLocationIndex; } ShaderLocationIndex;
#define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO
#define LOC_MAP_SPECULAR LOC_MAP_METALNESS
typedef enum { typedef enum {
UNIFORM_FLOAT = 0, UNIFORM_FLOAT = 0,
UNIFORM_VEC2, UNIFORM_VEC2,
@ -432,6 +466,7 @@ ffi.cdef [[
UNIFORM_IVEC4, UNIFORM_IVEC4,
UNIFORM_SAMPLER2D UNIFORM_SAMPLER2D
} ShaderUniformDataType; } ShaderUniformDataType;
typedef enum { typedef enum {
MAP_ALBEDO= 0, MAP_ALBEDO= 0,
MAP_METALNESS = 1, MAP_METALNESS = 1,
@ -446,9 +481,6 @@ ffi.cdef [[
MAP_BRDF MAP_BRDF
} MaterialMapType; } MaterialMapType;
#define MAP_DIFFUSE MAP_ALBEDO
#define MAP_SPECULAR MAP_METALNESS
typedef enum { typedef enum {
UNCOMPRESSED_GRAYSCALE = 1, UNCOMPRESSED_GRAYSCALE = 1,
UNCOMPRESSED_GRAY_ALPHA, UNCOMPRESSED_GRAY_ALPHA,
@ -472,6 +504,7 @@ ffi.cdef [[
COMPRESSED_ASTC_4x4_RGBA, COMPRESSED_ASTC_4x4_RGBA,
COMPRESSED_ASTC_8x8_RGBA COMPRESSED_ASTC_8x8_RGBA
} PixelFormat; } PixelFormat;
typedef enum { typedef enum {
FILTER_POINT = 0, FILTER_POINT = 0,
FILTER_BILINEAR, FILTER_BILINEAR,
@ -480,6 +513,7 @@ ffi.cdef [[
FILTER_ANISOTROPIC_8X, FILTER_ANISOTROPIC_8X,
FILTER_ANISOTROPIC_16X, FILTER_ANISOTROPIC_16X,
} TextureFilterMode; } TextureFilterMode;
typedef enum { typedef enum {
CUBEMAP_AUTO_DETECT = 0, CUBEMAP_AUTO_DETECT = 0,
CUBEMAP_LINE_VERTICAL, CUBEMAP_LINE_VERTICAL,
@ -488,22 +522,26 @@ ffi.cdef [[
CUBEMAP_CROSS_FOUR_BY_THREE, CUBEMAP_CROSS_FOUR_BY_THREE,
CUBEMAP_PANORAMA CUBEMAP_PANORAMA
} CubemapLayoutType; } CubemapLayoutType;
typedef enum { typedef enum {
WRAP_REPEAT = 0, WRAP_REPEAT = 0,
WRAP_CLAMP, WRAP_CLAMP,
WRAP_MIRROR_REPEAT, WRAP_MIRROR_REPEAT,
WRAP_MIRROR_CLAMP WRAP_MIRROR_CLAMP
} TextureWrapMode; } TextureWrapMode;
typedef enum { typedef enum {
FONT_DEFAULT = 0, FONT_DEFAULT = 0,
FONT_BITMAP, FONT_BITMAP,
FONT_SDF FONT_SDF
} FontType; } FontType;
typedef enum { typedef enum {
BLEND_ALPHA = 0, BLEND_ALPHA = 0,
BLEND_ADDITIVE, BLEND_ADDITIVE,
BLEND_MULTIPLIED BLEND_MULTIPLIED
} BlendMode; } BlendMode;
typedef enum { typedef enum {
GESTURE_NONE = 0, GESTURE_NONE = 0,
GESTURE_TAP = 1, GESTURE_TAP = 1,
@ -517,6 +555,7 @@ ffi.cdef [[
GESTURE_PINCH_IN= 256, GESTURE_PINCH_IN= 256,
GESTURE_PINCH_OUT = 512 GESTURE_PINCH_OUT = 512
} GestureType; } GestureType;
typedef enum { typedef enum {
CAMERA_CUSTOM = 0, CAMERA_CUSTOM = 0,
CAMERA_FREE, CAMERA_FREE,
@ -524,453 +563,46 @@ ffi.cdef [[
CAMERA_FIRST_PERSON, CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON CAMERA_THIRD_PERSON
} CameraMode; } CameraMode;
typedef enum { typedef enum {
CAMERA_PERSPECTIVE = 0, CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC CAMERA_ORTHOGRAPHIC
} CameraType; } CameraType;
typedef enum { typedef enum {
NPT_9PATCH = 0, NPT_9PATCH = 0,
NPT_3PATCH_VERTICAL, NPT_3PATCH_VERTICAL,
NPT_3PATCH_HORIZONTAL NPT_3PATCH_HORIZONTAL
} NPatchType; } NPatchType;
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);
void InitWindow(int width, int height, const char *title);
bool WindowShouldClose(void);
void CloseWindow(void);
bool IsWindowReady(void);
bool IsWindowMinimized(void);
bool IsWindowResized(void);
bool IsWindowHidden(void);
void ToggleFullscreen(void);
void UnhideWindow(void);
void HideWindow(void);
void SetWindowIcon(Image image);
void SetWindowTitle(const char *title);
void SetWindowPosition(int x, int y);
void SetWindowMonitor(int monitor);
void SetWindowMinSize(int width, int height);
void SetWindowSize(int width, int height);
void *GetWindowHandle(void);
int GetScreenWidth(void);
int GetScreenHeight(void);
int GetMonitorCount(void);
int GetMonitorWidth(int monitor);
int GetMonitorHeight(int monitor);
int GetMonitorPhysicalWidth(int monitor);
int GetMonitorPhysicalHeight(int monitor);
Vector2 GetWindowPosition(void);
const char *GetMonitorName(int monitor);
const char *GetClipboardText(void);
void SetClipboardText(const char *text);
void ShowCursor(void);
void HideCursor(void);
bool IsCursorHidden(void);
void EnableCursor(void);
void DisableCursor(void);
void ClearBackground(Color color);
void BeginDrawing(void);
void EndDrawing(void);
void BeginMode2D(Camera2D camera);
void EndMode2D(void);
void BeginMode3D(Camera3D camera);
void EndMode3D(void);
void BeginTextureMode(RenderTexture2D target);
void EndTextureMode(void);
void BeginScissorMode(int x, int y, int width, int height);
void EndScissorMode(void);
Ray GetMouseRay(Vector2 mousePosition, Camera camera);
Matrix GetCameraMatrix(Camera camera);
Matrix GetCameraMatrix2D(Camera2D camera);
Vector2 GetWorldToScreen(Vector3 position, Camera camera);
Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height);
Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera);
Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera);
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);
bool FileExists(const char *fileName);
bool IsFileExtension(const char *fileName, const char *ext);
bool DirectoryExists(const char *dirPath);
const char *GetExtension(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);
char **GetDirectoryFiles(const char *dirPath, int *count);
void ClearDirectoryFiles(void);
bool ChangeDirectory(const char *dir);
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 StorageSaveValue(int position, int value);
int StorageLoadValue(int position);
void OpenURL(const char *url);
bool IsKeyPressed(int key);
bool IsKeyDown(int key);
bool IsKeyReleased(int key);
bool IsKeyUp(int key);
void SetExitKey(int key);
int GetKeyPressed(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);
bool IsGamepadButtonReleased(int gamepad, int button);
bool IsGamepadButtonUp(int gamepad, int button);
int GetGamepadButtonPressed(void);
int GetGamepadAxisCount(int gamepad);
float GetGamepadAxisMovement(int gamepad, int axis);
bool IsMouseButtonPressed(int button);
bool IsMouseButtonDown(int button);
bool IsMouseButtonReleased(int button);
bool IsMouseButtonUp(int button);
int GetMouseX(void);
int GetMouseY(void);
Vector2 GetMousePosition(void);
void SetMousePosition(int x, int y);
void SetMouseOffset(int offsetX, int offsetY);
void SetMouseScale(float scaleX, float scaleY);
int GetMouseWheelMove(void);
int GetTouchX(void);
int GetTouchY(void);
Vector2 GetTouchPosition(int index);
void SetGesturesEnabled(unsigned int gestureFlags);
bool IsGestureDetected(int gesture);
int GetGestureDetected(void);
int GetTouchPointsCount(void);
float GetGestureHoldDuration(void);
Vector2 GetGestureDragVector(void);
float GetGestureDragAngle(void);
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 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 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 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 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);
void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);
void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);
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 DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color);
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int 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 DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);
void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, 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);
Image LoadImage(const char *fileName);
Image LoadImageEx(Color *pixels, int width, int height);
Image LoadImagePro(void *data, int width, int height, int format);
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize);
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);
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);
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 *ImageExtractPalette(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, Rectangle rec, Color color);
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color);
void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color);
void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color);
void ImageFlipVertical(Image *image);
void ImageFlipHorizontal(Image *image);
void ImageRotateCW(Image *image);
void ImageRotateCCW(Image *image);
void ImageColorTint(Image *image, Color color);
void ImageColorInvert(Image *image);
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);
void GenTextureMipmaps(Texture2D *texture);
void SetTextureFilter(Texture2D texture, int filterMode);
void SetTextureWrap(Texture2D texture, int wrapMode);
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 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);
Font GetFontDefault(void);
Font LoadFont(const char *fileName);
Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount);
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);
void UnloadFont(Font font);
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);
int MeasureText(const char *text, int fontSize);
Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
int GetGlyphIndex(Font font, int codepoint);
int TextCopy(char *dst, const char *src);
bool TextIsEqual(const char *text1, const char *text2);
unsigned int TextLength(const char *text);
const char *TextFormat(const char *text, ...);
const char *TextSubtext(const char *text, int position, int length);
char *TextReplace(char *text, const char *replace, const char *by);
char *TextInsert(const char *text, const char *insert, int position);
const char *TextJoin(const char **textList, int count, const char *delimiter);
const char **TextSplit(const char *text, char delimiter, int *count);
void TextAppend(char *text, const char *append, int *position);
int TextFindIndex(const char *text, const char *find);
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 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 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 DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, 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 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);
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 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 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);
bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);
bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius);
bool CheckCollisionRaySphere(Ray ray, 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);
char *LoadText(const char *fileName);
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);
void InitAudioDevice(void);
void CloseAudioDevice(void);
bool IsAudioDeviceReady(void);
void SetMasterVolume(float volume);
Wave LoadWave(const char *fileName);
Sound LoadSound(const char *fileName);
Sound LoadSoundFromWave(Wave wave);
void UpdateSound(Sound sound, const void *data, int samplesCount);
void UnloadWave(Wave wave);
void UnloadSound(Sound sound);
void ExportWave(Wave wave, const char *fileName);
void ExportWaveAsCode(Wave wave, const char *fileName);
void PlaySound(Sound sound);
void StopSound(Sound sound);
void PauseSound(Sound sound);
void ResumeSound(Sound sound);
void PlaySoundMulti(Sound sound);
void StopSoundMulti(void);
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);
Wave WaveCopy(Wave wave);
void WaveCrop(Wave *wave, int initSample, int finalSample);
float *GetWaveData(Wave wave);
Music LoadMusicStream(const char *fileName);
void UnloadMusicStream(Music music);
void PlayMusicStream(Music music);
void UpdateMusicStream(Music music);
void StopMusicStream(Music music);
void PauseMusicStream(Music music);
void ResumeMusicStream(Music music);
bool IsMusicPlaying(Music music);
void SetMusicVolume(Music music, float volume);
void SetMusicPitch(Music music, float pitch);
void SetMusicLoopCount(Music music, int count);
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);
bool IsAudioStreamProcessed(AudioStream stream);
void PlayAudioStream(AudioStream stream);
void PauseAudioStream(AudioStream stream);
void ResumeAudioStream(AudioStream stream);
bool IsAudioStreamPlaying(AudioStream stream);
void StopAudioStream(AudioStream stream);
void SetAudioStreamVolume(AudioStream stream, float volume);
void SetAudioStreamPitch(AudioStream stream, float pitch);
void SetAudioStreamBufferSizeDefault(int size);
]] ]]
-- Load bind entry
ffi.cdef [[
struct raylua_bind_entry {
const char *name;
const char *proto;
void *ptr;
};
]]
do
local entries = ffi.cast("struct raylua_bind_entry *", raylua.bind_entries)
local i = ffi.new("size_t", 0)
local NULL = ffi.new("void *", nil)
print "[RAYLUA] Loading FFI binding entries."
while entries[i].name ~= NULL do
local name, proto = ffi.string(entries[i].name), ffi.string(entries[i].proto)
raylib[name] = ffi.cast(proto, entries[i].ptr)
i = i + 1
end
print("[RAYLUA] Loaded " .. tonumber(i) .. " FFI entries.")
end
-- colors -- colors
local function new_color(r, g, b, a) local function new_color(r, g, b, a)
local c = ffi.new("Color") local c = ffi.new("Color")
@ -1008,6 +640,11 @@ raylib.BLANK = new_color(0, 0, 0, 0)
raylib.MAGENTA = new_color(255, 0, 255, 255) raylib.MAGENTA = new_color(255, 0, 255, 255)
raylib.RAYWHITE = new_color(245, 245, 245, 255) raylib.RAYWHITE = new_color(245, 245, 245, 255)
raylib.LOC_MAP_DIFFUSE = raylib_so.LOC_MAP_ALBEDO
raylib.LOC_MAP_SPECULAR = raylib_so.LOC_MAP_METALNESS
raylib.MAP_DIFFUSE = raylib_so.MAP_ALBEDO
raylib.MAP_SPECULAR = raylib_so.MAP_METALNESS
raylib.__index = function (self, key) raylib.__index = function (self, key)
return raylib_so[key] return raylib_so[key]
end end

31
src/raylua.c Normal file
View File

@ -0,0 +1,31 @@
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <raylib.h>
#include "autogen/bind.c"
#include "autogen/boot.c"
extern const char *raylua_boot_str;
void raylua_boot(lua_State *L, lua_CFunction loadfile)
{
lua_newtable(L);
if (loadfile) {
lua_pushstring(L, "loadfile");
lua_pushcfunction(L, loadfile);
lua_settable(L, -3);
}
lua_pushstring(L, "bind_entries");
lua_pushlightuserdata(L, raylua_entries);
lua_settable(L, -3);
lua_setglobal(L, "raylua");
if (luaL_dostring(L, raylua_boot_lua))
fputs(luaL_checkstring(L, -1), stderr);
}

8
src/raylua.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef H_RAYLUA
#define H_RAYLUA
#include <lua.h>
void raylua_boot(lua_State *L, lua_CFunction loadfile);
#endif /* H_RAYLUA */

View File

@ -1,12 +1,14 @@
local load = loadstring local load = loadstring
if raylua then if raylua.loadfile then
-- Change the second loader to load files using raylua.loadfiles package.path = "?.lua"
-- Change the second loader to load files using raylua.loadfile
package.loaders[2] = function (name) package.loaders[2] = function (name)
for path in package.path:gmatch "([^;]+);?" do for path in package.path:gmatch "([^;]+);?" do
path = path:gsub("?", name) path = path:gsub("?", name)
local status, content = raylua.loadfiles(path) local status, content = raylua.loadfile(path)
if status then if status then
local f, err = load(content) local f, err = load(content)
assert(f, err) assert(f, err)
@ -17,6 +19,32 @@ if raylua then
return nil return nil
end end
print "[RAYLUA] Load main.lua from payload."
require "main"
return
end end
require "main" if arg[1] then
dofile(arg[1])
else
-- Run small REPL
print ">> raylua WIP repl <<"
print ""
while true do
io.write "> "
local line = io.read "l"
local f, err = loadstring(line)
if f then
local status, err = pcall(f)
if not status then
print(err)
end
else
print(err)
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#ifndef H_RAYLUA_BOOT
#define H_RAYLUA_BOOT
extern const char *raylua_boot;
#endif /* H_RAYLUA_BOOT */

View File

@ -25,17 +25,19 @@
#ifdef WIN32 #ifdef WIN32
#include "lib/dirent.h" #include "lib/dirent.h"
#define stat _stat #define stat _stat
#ifndef strcasecmp
#define strcasecmp strcmpi
#endif
#else #else
#include <dirent.h> #include <dirent.h>
#endif #endif
#include "lib/miniz.h" #include "lib/miniz.h"
#ifndef WRAY_NO_BUILDER #include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifndef RAYLUA_NO_BUILDER
#include "autogen/builder.c"
static void append_file(FILE *dst, FILE *src) static void append_file(FILE *dst, FILE *src)
{ {
size_t count; size_t count;
@ -46,125 +48,151 @@ static void append_file(FILE *dst, FILE *src)
} while(count == 4096); } while(count == 4096);
} }
int wray_build_executable(const char *self_path, const char *input_path) static void append_file_offset(FILE *output, FILE *source, FILE *input)
{ {
printf("Create new executable from %s.\n", input_path); append_file(output, source);
fpos_t pos;
fgetpos(output, &pos);
append_file(output, input);
fwrite(&pos, sizeof(fpos_t), 1, output);
}
struct stat st; typedef struct raylua_builder {
int result = stat(input_path, &st); mz_zip_archive zip;
if (result) { FILE *file;
printf("%s: Can't get file information.\n", input_path); fpos_t offset;
return 1; } raylua_builder;
raylua_builder *raylua_builder_new(const char *self_path, const char *path)
{
raylua_builder *builder = malloc(sizeof(raylua_builder));
mz_zip_zero_struct(&builder->zip);
FILE *f = fopen(path, "wb");
if (!f) {
free(builder);
return NULL;
} }
size_t arg_len = strlen(input_path); builder->file = f;
size_t len = arg_len + 5; // + ".exe\0"
char output_path[len];
strcpy(output_path, input_path);
if (output_path[arg_len - 1] == '/') {
/* Remove trailing '/'. */
output_path[arg_len - 1] = '\0';
arg_len--;
}
strncpy(output_path + arg_len, ".exe", 5);
FILE *output = fopen(output_path, "wb");
if (output == NULL) {
printf("Can't open %s for writing.\n", output_path);
return 1;
}
FILE *self = fopen(self_path, "rb"); FILE *self = fopen(self_path, "rb");
if (self == NULL) { if (!self) {
puts("Can't open itself"); free(builder);
fclose(f);
return NULL;
}
append_file(f, self);
fgetpos(f, &builder->offset); /* get eof offset */
fclose(self);
if (!mz_zip_writer_init_cfile(&builder->zip, f, 0)) {
free(builder);
fclose(f);
fclose(self);
return NULL;
}
return builder;
}
void raylua_builder_close(raylua_builder *builder)
{
mz_zip_writer_finalize_archive(&builder->zip);
/* Write offset */
fwrite(&builder->offset, sizeof(fpos_t), 1, builder->file);
fclose(builder->file);
free(builder);
}
void raylua_builder_add(raylua_builder *builder, const char *path, const char *dest)
{
if (!dest)
dest = path;
if (!mz_zip_writer_add_file(&builder->zip, dest, path, NULL, 0,
MZ_BEST_COMPRESSION))
printf("Unable to write %s (%s)\n", dest, path);
}
static int get_type(lua_State *L)
{
const char *path = luaL_checkstring(L, -1);
struct stat st;
if (stat(path, &st)) {
lua_pushboolean(L, 0);
return 1; return 1;
} }
/* Copy self into output. */ if (S_ISREG(st.st_mode))
append_file(output, self); lua_pushstring(L, "file");
fclose(self); else if (S_ISDIR(st.st_mode))
lua_pushstring(L, "directory");
else
lua_pushstring(L, "other");
/* Get the offset to put it at the end of the file. */ return 1;
fpos_t offset; }
fgetpos(output, &offset);
if (S_ISREG(st.st_mode)) { static int list_dir(lua_State *L)
/* Consider input as a bare bundle, just append file to get output. */ {
FILE *input = fopen(input_path, "rb"); const char *path = luaL_checkstring(L, -1);
DIR *d = opendir(path);
append_file(output, input); if (!d)
fclose(input);
} else if (S_ISDIR(st.st_mode)) {
/* We need to explore the directory and write each file to a zip file. */
mz_zip_archive zip;
mz_zip_zero_struct(&zip);
if (!mz_zip_writer_init_cfile(&zip, output, 0)) {
puts("Can't initialize zip writter inside output.");
return 0; return 0;
}
DIR *d = opendir(input_path);
chdir(input_path);
struct dirent *entry; struct dirent *entry;
size_t count = 0;
/* NOTE: Hardcoded 512 path limit. */ lua_newtable(L);
char dest_path[512];
while ((entry = readdir(d))) { while ((entry = readdir(d))) {
char *original_path = entry->d_name; lua_pushstring(L, entry->d_name);
memset(dest_path, 0, 512); lua_rawseti(L, -2, count++);
struct stat st;
if (stat(original_path, &st)) {
printf("Skip %s (stat() failed)\n", original_path);
continue;
}
if (!S_ISREG(st.st_mode)) {
printf("Skip %s (not a file)\n", original_path);
continue;
}
size_t len = strlen(original_path);
if (len > 512) {
printf("Skipping %s: path too long\n", original_path);
continue;
}
if (len > 5 && strcmp(original_path + len - 5, ".wren") == 0) {
len -= 5; /* Exclude .wren extension. */
}
strncpy(dest_path, original_path, len);
printf("Add %s (original: %s)...\n", dest_path, original_path);
if (!mz_zip_writer_add_file(&zip, dest_path, original_path, NULL, 0,
MZ_BEST_COMPRESSION)) {
printf("miniz error: %x\n", mz_zip_get_last_error(&zip));
}
} }
closedir(d); closedir(d);
return 1;
}
puts("Finalizing zip archive..."); int raylua_build_executable(const char *self, const char *input)
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
if (!mz_zip_writer_finalize_archive(&zip)) lua_pushcfunction(L, get_type);
puts("Can't finalize archive."); lua_setglobal(L, "get_type");
mz_zip_end(&zip); lua_pushcfunction(L, list_dir);
lua_setglobal(L, "list_dir");
// Write offset lua_pushlightuserdata(L, append_file_offset);
fwrite(&offset, sizeof(fpos_t), 1, output); lua_setglobal(L, "append_file_offset");
fclose(output);
} lua_pushlightuserdata(L, &raylua_builder_new);
lua_setglobal(L, "builder_new");
lua_pushlightuserdata(L, &raylua_builder_close);
lua_setglobal(L, "builder_close");
lua_pushlightuserdata(L, &raylua_builder_add);
lua_setglobal(L, "builder_add");
lua_pushstring(L, self);
lua_setglobal(L, "self_path");
lua_pushstring(L, input);
lua_setglobal(L, "input_path");
if (luaL_dostring(L, raylua_builder_lua))
fputs(luaL_checkstring(L, -1), stderr);
free(output_path);
return 0; return 0;
} }
#endif #endif

112
src/raylua_builder.lua Normal file
View File

@ -0,0 +1,112 @@
local t = get_type(input_path)
local ffi = require "ffi"
print ">> Raylua builder <<"
ffi.cdef "typedef struct raylua_builder raylua_builder;"
local builder_new = ffi.cast("raylua_builder *(*)(const char *, const char *)", builder_new)
local builder_close = ffi.cast("void (*)(raylua_builder *)", builder_close)
local builder_add = ffi.cast("void (*)(raylua_builder *, const char *, const char *)", builder_add)
local function path_concat(...)
return table.concat({ ... }, "/")
end
if ffi.os == "Windows" and self_path:sub("-4") ~= ".exe" then
self_path = self_path .. ".exe"
end
print("Self is " .. self_path)
if t == "directory" then
local path = input_path
if ffi.os == "Windows" then
path = path .. ".exe"
else
path = path .. ".elf"
end
print("Building " .. path)
local builder = builder_new(self_path, path)
assert(builder ~= ffi.new("void *", nil), "Can't initialize builder")
local have_main = false
local function add_dir(root, dir)
for i,file in ipairs(list_dir(path_concat(root, dir))) do
if file ~= ".." then
local partial_file_path, full_file_path
if dir then
partial_file_path = path_concat(dir, file)
full_file_path = path_concat(root, dir, file)
else
partial_file_path = file
full_file_path = path_concat(root, file)
end
if partial_file_path == "main.lua" then
have_main = true
end
local t = get_type(full_file_path)
if t == "file" then
print("Adding file " .. partial_file_path)
builder_add(builder, full_file_path, partial_file_path)
elseif t == "directory" then
print("Adding directory " .. partial_file_path .. "/")
add_dir(root, partial_file_path)
else
print("Unknown file type " .. partial_file_path)
end
end
end
end
add_dir(input_path, nil)
if not have_main then
print("WARN: main.lua is missing, your executable may not run")
end
builder_close(builder)
elseif t == "file" then
local ext = input_path:sub(-4)
-- Remove extension
local path = input_path:sub(0, #input_path - 4)
if ffi.os == "Windows" then
path = path .. ".exe"
else
path = path .. ".elf"
end
print("Building " .. path)
if ext == ".zip" then
print "Build from zip file."
local dest = assert(io.open(path, "wb"), "Can't open destination file.")
local source = assert(io.open(self_path, "rb"), "Can't open self file.")
local input = assert(io.open(input_path, "rb"), "Can't open zip file.")
append_file_offset(output, source, input)
dest:close()
source:close()
input:close()
elseif ext == ".lua" then
print "Build from lua file."
local builder = builder_new(self_path, path)
builder_add(builder, input_path, "main.lua")
builder_close(builder)
end
end
print "Done"

View File

@ -14,7 +14,7 @@
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* Wray embedded executable */ /* Raylua embedded executable */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
@ -23,11 +23,11 @@
#include <lualib.h> #include <lualib.h>
#include <lauxlib.h> #include <lauxlib.h>
#include "raylua_boot.h" #include "raylua.h"
#include "lib/miniz.h" #include "lib/miniz.h"
#ifndef WRAY_NO_BUILDER #ifndef RAYLUA_NO_BUILDER
int raylua_build_executable(const char *self_path, const char *input_path); int raylua_build_executable(const char *self_path, const char *input_path);
#endif #endif
@ -97,10 +97,12 @@ int main(int argc, const char **argv)
} }
lua_State *L = luaL_newstate(); lua_State *L = luaL_newstate();
luaL_openlibs(L);
if (L == NULL) if (L == NULL)
puts("[RAYLUA] Unable to initialize Lua."); puts("[RAYLUA] Unable to initialize Lua.");
/* Populate arg. */
lua_newtable(L); lua_newtable(L);
int i = 0; int i = 0;
@ -113,10 +115,7 @@ int main(int argc, const char **argv)
lua_setglobal(L, "arg"); lua_setglobal(L, "arg");
lua_pushcfunction(L, raylua_loadfile); raylua_boot(L, raylua_loadfile);
lua_setglobal(L, "raylua_loadfile");
luaL_dostring(L, raylua_boot);
lua_close(L); lua_close(L);
return 0; return 0;
} }

View File

@ -18,7 +18,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "raylua_boot.h" #include "raylua.h"
#include <lua.h> #include <lua.h>
#include <lualib.h> #include <lualib.h>
@ -27,6 +27,7 @@
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
lua_State *L = luaL_newstate(); lua_State *L = luaL_newstate();
luaL_openlibs(L);
if (L == NULL) if (L == NULL)
puts("[RAYLUA] Unable to initialize Lua."); puts("[RAYLUA] Unable to initialize Lua.");
@ -43,7 +44,7 @@ int main(int argc, const char **argv)
lua_setglobal(L, "arg"); lua_setglobal(L, "arg");
luaL_dostring(L, raylua_boot); raylua_boot(L, NULL);
lua_close(L); lua_close(L);
return 0; return 0;
} }

430
tools/api.h Normal file
View File

@ -0,0 +1,430 @@
void InitWindow(int width, int height, const char *title);
bool WindowShouldClose(void);
void CloseWindow(void);
bool IsWindowReady(void);
bool IsWindowMinimized(void);
bool IsWindowResized(void);
bool IsWindowHidden(void);
void ToggleFullscreen(void);
void UnhideWindow(void);
void HideWindow(void);
void SetWindowIcon(Image image);
void SetWindowTitle(const char *title);
void SetWindowPosition(int x, int y);
void SetWindowMonitor(int monitor);
void SetWindowMinSize(int width, int height);
void SetWindowSize(int width, int height);
void *GetWindowHandle(void);
int GetScreenWidth(void);
int GetScreenHeight(void);
int GetMonitorCount(void);
int GetMonitorWidth(int monitor);
int GetMonitorHeight(int monitor);
int GetMonitorPhysicalWidth(int monitor);
int GetMonitorPhysicalHeight(int monitor);
Vector2 GetWindowPosition(void);
const char *GetMonitorName(int monitor);
const char *GetClipboardText(void);
void SetClipboardText(const char *text);
void ShowCursor(void);
void HideCursor(void);
bool IsCursorHidden(void);
void EnableCursor(void);
void DisableCursor(void);
void ClearBackground(Color color);
void BeginDrawing(void);
void EndDrawing(void);
void BeginMode2D(Camera2D camera);
void EndMode2D(void);
void BeginMode3D(Camera3D camera);
void EndMode3D(void);
void BeginTextureMode(RenderTexture2D target);
void EndTextureMode(void);
void BeginScissorMode(int x, int y, int width, int height);
void EndScissorMode(void);
Ray GetMouseRay(Vector2 mousePosition, Camera camera);
Matrix GetCameraMatrix(Camera camera);
Matrix GetCameraMatrix2D(Camera2D camera);
Vector2 GetWorldToScreen(Vector3 position, Camera camera);
Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height);
Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera);
Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera);
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);
bool FileExists(const char *fileName);
bool IsFileExtension(const char *fileName, const char *ext);
bool DirectoryExists(const char *dirPath);
const char *GetExtension(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);
char **GetDirectoryFiles(const char *dirPath, int *count);
void ClearDirectoryFiles(void);
bool ChangeDirectory(const char *dir);
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);
void OpenURL(const char *url);
bool IsKeyPressed(int key);
bool IsKeyDown(int key);
bool IsKeyReleased(int key);
bool IsKeyUp(int key);
void SetExitKey(int key);
int GetKeyPressed(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);
bool IsGamepadButtonReleased(int gamepad, int button);
bool IsGamepadButtonUp(int gamepad, int button);
int GetGamepadButtonPressed(void);
int GetGamepadAxisCount(int gamepad);
float GetGamepadAxisMovement(int gamepad, int axis);
bool IsMouseButtonPressed(int button);
bool IsMouseButtonDown(int button);
bool IsMouseButtonReleased(int button);
bool IsMouseButtonUp(int button);
int GetMouseX(void);
int GetMouseY(void);
Vector2 GetMousePosition(void);
void SetMousePosition(int x, int y);
void SetMouseOffset(int offsetX, int offsetY);
void SetMouseScale(float scaleX, float scaleY);
int GetMouseWheelMove(void);
int GetTouchX(void);
int GetTouchY(void);
Vector2 GetTouchPosition(int index);
void SetGesturesEnabled(unsigned int gestureFlags);
bool IsGestureDetected(int gesture);
int GetGestureDetected(void);
int GetTouchPointsCount(void);
float GetGestureHoldDuration(void);
Vector2 GetGestureDragVector(void);
float GetGestureDragAngle(void);
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 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 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 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 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);
void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);
void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);
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 DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color);
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int 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 DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);
void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, 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);
Image LoadImage(const char *fileName);
Image LoadImageEx(Color *pixels, int width, int height);
Image LoadImagePro(void *data, int width, int height, int format);
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize);
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);
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);
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 *ImageExtractPalette(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, Rectangle rec, Color color);
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color);
void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color);
void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color);
void ImageFlipVertical(Image *image);
void ImageFlipHorizontal(Image *image);
void ImageRotateCW(Image *image);
void ImageRotateCCW(Image *image);
void ImageColorTint(Image *image, Color color);
void ImageColorInvert(Image *image);
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);
void GenTextureMipmaps(Texture2D *texture);
void SetTextureFilter(Texture2D texture, int filterMode);
void SetTextureWrap(Texture2D texture, int wrapMode);
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 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);
Font GetFontDefault(void);
Font LoadFont(const char *fileName);
Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount);
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);
void UnloadFont(Font font);
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);
int MeasureText(const char *text, int fontSize);
Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
int GetGlyphIndex(Font font, int codepoint);
int TextCopy(char *dst, const char *src);
bool TextIsEqual(const char *text1, const char *text2);
unsigned int TextLength(const char *text);
const char *TextFormat(const char *text, ...);
const char *TextSubtext(const char *text, int position, int length);
char *TextReplace(char *text, const char *replace, const char *by);
char *TextInsert(const char *text, const char *insert, int position);
const char *TextJoin(const char **textList, int count, const char *delimiter);
const char **TextSplit(const char *text, char delimiter, int *count);
void TextAppend(char *text, const char *append, int *position);
int TextFindIndex(const char *text, const char *find);
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 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 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 DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, 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 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);
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 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 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);
bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);
bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius);
bool CheckCollisionRaySphere(Ray ray, 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);
char *LoadText(const char *fileName);
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);
void InitAudioDevice(void);
void CloseAudioDevice(void);
bool IsAudioDeviceReady(void);
void SetMasterVolume(float volume);
Wave LoadWave(const char *fileName);
Sound LoadSound(const char *fileName);
Sound LoadSoundFromWave(Wave wave);
void UpdateSound(Sound sound, const void *data, int samplesCount);
void UnloadWave(Wave wave);
void UnloadSound(Sound sound);
void ExportWave(Wave wave, const char *fileName);
void ExportWaveAsCode(Wave wave, const char *fileName);
void PlaySound(Sound sound);
void StopSound(Sound sound);
void PauseSound(Sound sound);
void ResumeSound(Sound sound);
void PlaySoundMulti(Sound sound);
void StopSoundMulti(void);
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);
Wave WaveCopy(Wave wave);
void WaveCrop(Wave *wave, int initSample, int finalSample);
float *GetWaveData(Wave wave);
Music LoadMusicStream(const char *fileName);
void UnloadMusicStream(Music music);
void PlayMusicStream(Music music);
void UpdateMusicStream(Music music);
void StopMusicStream(Music music);
void PauseMusicStream(Music music);
void ResumeMusicStream(Music music);
bool IsMusicPlaying(Music music);
void SetMusicVolume(Music music, float volume);
void SetMusicPitch(Music music, float pitch);
void SetMusicLoopCount(Music music, int count);
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);
bool IsAudioStreamProcessed(AudioStream stream);
void PlayAudioStream(AudioStream stream);
void PauseAudioStream(AudioStream stream);
void ResumeAudioStream(AudioStream stream);
bool IsAudioStreamPlaying(AudioStream stream);
void StopAudioStream(AudioStream stream);
void SetAudioStreamVolume(AudioStream stream, float volume);
void SetAudioStreamPitch(AudioStream stream, float pitch);
void SetAudioStreamBufferSizeDefault(int size);

76
tools/genbind.lua Normal file
View File

@ -0,0 +1,76 @@
local keywords = {
"int", "long", "short", "char", "float", "double",
"uint8_t", "uint16_t", "uint32_t", "uint64_t",
"const", "unsigned", "register",
"void", "intptr_t", "bool"
}
local structs = {
"Vector2", "Vector3", "Vector4", "Quaternion",
"Matrix", "Color", "Rectangle", "Image", "Texture", "Texture2D",
"RenderTexture", "NPatchInfo", "CharInfo", "Font",
"Camera", "Camera2D", "Mesh", "Shader", "MaterialMap",
"Material", "Model", "Transform", "BoneInfo", "ModelAnimation",
"Ray", "RayHitInfo", "BoundingBox", "Wave", "Sound", "Music",
"AudioStream", "VrDeviceInfo", "Camera3D", "RenderTexture2D",
"TextureCubemap", "TraceLogCallback"
}
local functions = {}
local proto = {}
for line in io.lines "tools/api.h" do
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)
local count = 0
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
count = count + 1
if count == 2 then
print("WARN: Multiple match for: " .. line)
end
return "(*)"
end)
proto[#proto + 1] = line:gsub(";", "")
end
assert(#proto == #functions, "Mismatching proto and function count.")
local file = io.open(arg[1], "w")
file:write [[
struct raylua_bind_entry {
const char *name;
const char *proto;
void *ptr;
};
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))
end
file:write '{ NULL, NULL, NULL },\n'
file:write "};\n"
file:close()