diff --git a/.gitignore b/.gitignore index 443c4a2..3606dae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,13 @@ wray_standalone\.exe src/wray_api\.c libwray\.a + +raylua_e.exe + +raylua_s.exe + +src/autogen/bind.c + +src/autogen/boot.c + +src/autogen/builder.c diff --git a/examples/core_basic_window.lua b/examples/core_basic_window.lua new file mode 100644 index 0000000..1d76339 --- /dev/null +++ b/examples/core_basic_window.lua @@ -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() diff --git a/examples/resources/wabbit_alpha.png b/examples/resources/wabbit_alpha.png new file mode 100644 index 0000000..1a5eb0b Binary files /dev/null and b/examples/resources/wabbit_alpha.png differ diff --git a/examples/shapes_logo_raylib.lua b/examples/shapes_logo_raylib.lua new file mode 100644 index 0000000..84f9e82 --- /dev/null +++ b/examples/shapes_logo_raylib.lua @@ -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() diff --git a/examples/textures_bunnymark.lua b/examples/textures_bunnymark.lua new file mode 100644 index 0000000..3671f42 --- /dev/null +++ b/examples/textures_bunnymark.lua @@ -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 +---------------------------------------------------------------------------------------- diff --git a/makefile b/makefile index 5edb3d3..ea4b931 100644 --- a/makefile +++ b/makefile @@ -1,9 +1,16 @@ CFLAGS := -O2 -s -LDFLAGS := -O2 -s -lm -lluajit +LDFLAGS := -O2 -s -lm AR ?= ar 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 all: raylua_s raylua_e @@ -11,16 +18,36 @@ all: raylua_s raylua_e %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) -src/raylua_boot.c: src/raylib.lua src/raylua.lua - $(LUA) tools/lua2str.lua $@ raylua_boot $^ +all: luajit raylib raylua_s raylua_e -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) -raylua_e: src/lib/miniz.o src/raylua_boot.o src/raylua_builder.o src/raylua_e.o - $(CC) -o $@ $^ -lwray $(LDFLAGS) +raylua_e: src/raylua.o src/raylua_e.o src/raylua_builder.o src/lib/miniz.o + $(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: - 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 diff --git a/raylib b/raylib new file mode 160000 index 0000000..acfa967 --- /dev/null +++ b/raylib @@ -0,0 +1 @@ +Subproject commit acfa967e891997e862d1c77dac21ae9a484017c5 diff --git a/src/raylib.lua b/src/raylib.lua index 7f5e4d6..a0888e4 100644 --- a/src/raylib.lua +++ b/src/raylib.lua @@ -1,1020 +1,657 @@ -local ffi = require "ffi" -local raylib = {} -local raylib_so = ffi.load("raylib") - --- ffi cdef, based on raylib.h -ffi.cdef [[ - typedef struct Vector2 { - float x; - float y; - } Vector2; - typedef struct Vector3 { - float x; - float y; - float z; - } Vector3; - typedef struct Vector4 { - float x; - float y; - float z; - float w; - } Vector4; - typedef Vector4 Quaternion; - typedef struct Matrix { - float m0, m4, m8, m12; - float m1, m5, m9, m13; - float m2, m6, m10, m14; - float m3, m7, m11, m15; - } Matrix; - typedef struct Color { - unsigned char r; - unsigned char g; - unsigned char b; - unsigned char a; - } Color; - typedef struct Rectangle { - float x; - float y; - float width; - float height; - } Rectangle; - typedef struct Image { - void *data; - int width; - int height; - int mipmaps; - int format; - } Image; - typedef struct Texture2D { - unsigned int id; - int width; - int height; - int mipmaps; - int format; - } Texture2D; - typedef Texture2D Texture; - typedef Texture2D TextureCubemap; - typedef struct RenderTexture2D { - unsigned int id; - Texture2D texture; - Texture2D depth; - bool depthTexture; - } RenderTexture2D; - typedef RenderTexture2D RenderTexture; - typedef struct NPatchInfo { - Rectangle sourceRec; - int left; - int top; - int right; - int bottom; - int type; - } NPatchInfo; - typedef struct CharInfo { - int value; - int offsetX; - int offsetY; - int advanceX; - Image image; - } CharInfo; - typedef struct Font { - int baseSize; - int charsCount; - Texture2D texture; - Rectangle *recs; - CharInfo *chars; - } Font; - - typedef SpriteFont Font; - typedef struct Camera3D { - Vector3 position; - Vector3 target; - Vector3 up; - float fovy; - int type; - } Camera3D; - - typedef Camera3D Camera; - typedef struct Camera2D { - Vector2 offset; - Vector2 target; - float rotation; - float zoom; - } Camera2D; - typedef struct Mesh { - int vertexCount; - int triangleCount; - float *vertices; - float *texcoords; - float *texcoords2; - float *normals; - float *tangents; - unsigned char *colors; - unsigned short *indices; - float *animVertices; - float *animNormals; - int *boneIds; - float *boneWeights; - unsigned int vaoId; - unsigned int *vboId; - } Mesh; - typedef struct Shader { - unsigned int id; - int *locs; - } Shader; - typedef struct MaterialMap { - Texture2D texture; - Color color; - float value; - } MaterialMap; - typedef struct Material { - Shader shader; - MaterialMap *maps; - float *params; - } Material; - typedef struct Transform { - Vector3 translation; - Quaternion rotation; - Vector3 scale; - } Transform; - typedef struct BoneInfo { - char name[32]; - int parent; - } BoneInfo; - typedef struct Model { - Matrix transform; - - int meshCount; - Mesh *meshes; - - int materialCount; - Material *materials; - int *meshMaterial; - int boneCount; - BoneInfo *bones; - Transform *bindPose; - } Model; - typedef struct ModelAnimation { - int boneCount; - BoneInfo *bones; - - int frameCount; - Transform **framePoses; - } ModelAnimation; - typedef struct Ray { - Vector3 position; - Vector3 direction; - } Ray; - typedef struct RayHitInfo { - bool hit; - float distance; - Vector3 position; - Vector3 normal; - } RayHitInfo; - typedef struct BoundingBox { - Vector3 min; - Vector3 max; - } BoundingBox; - typedef struct Wave { - unsigned int sampleCount; - unsigned int sampleRate; - unsigned int sampleSize; - unsigned int channels; - void *data; - } Wave; - - typedef struct rAudioBuffer rAudioBuffer; - typedef struct AudioStream { - unsigned int sampleRate; - unsigned int sampleSize; - unsigned int channels; - - rAudioBuffer *buffer; - } AudioStream; - typedef struct Sound { - unsigned int sampleCount; - AudioStream stream; - } Sound; - typedef struct Music { - int ctxType; - void *ctxData; - - unsigned int sampleCount; - unsigned int loopCount; - - AudioStream stream; - } Music; - typedef struct VrDeviceInfo { - int hResolution; - int vResolution; - float hScreenSize; - float vScreenSize; - float vScreenCenter; - float eyeToScreenDistance; - float lensSeparationDistance; - float interpupillaryDistance; - float lensDistortionValues[4]; - float chromaAbCorrection[4]; - } VrDeviceInfo; - typedef enum { - FLAG_RESERVED = 1, - FLAG_FULLSCREEN_MODE= 2, - FLAG_WINDOW_RESIZABLE = 4, - FLAG_WINDOW_UNDECORATED = 8, - FLAG_WINDOW_TRANSPARENT = 16, - FLAG_WINDOW_HIDDEN= 128, - FLAG_WINDOW_ALWAYS_RUN= 256, - FLAG_MSAA_4X_HINT = 32, - FLAG_VSYNC_HINT = 64 - } ConfigFlag; - typedef enum { - LOG_ALL = 0, - LOG_TRACE, - LOG_DEBUG, - LOG_INFO, - LOG_WARNING, - LOG_ERROR, - LOG_FATAL, - LOG_NONE - } TraceLogType; - typedef enum { - KEY_APOSTROPHE= 39, - KEY_COMMA = 44, - KEY_MINUS = 45, - KEY_PERIOD= 46, - KEY_SLASH = 47, - KEY_ZERO = 48, - KEY_ONE = 49, - KEY_TWO = 50, - KEY_THREE = 51, - KEY_FOUR = 52, - KEY_FIVE = 53, - KEY_SIX = 54, - KEY_SEVEN = 55, - KEY_EIGHT = 56, - KEY_NINE = 57, - KEY_SEMICOLON = 59, - KEY_EQUAL = 61, - KEY_A = 65, - KEY_B = 66, - KEY_C = 67, - KEY_D = 68, - KEY_E = 69, - KEY_F = 70, - KEY_G = 71, - KEY_H = 72, - KEY_I = 73, - KEY_J = 74, - KEY_K = 75, - KEY_L = 76, - KEY_M = 77, - KEY_N = 78, - KEY_O = 79, - KEY_P = 80, - KEY_Q = 81, - KEY_R = 82, - KEY_S = 83, - KEY_T = 84, - KEY_U = 85, - KEY_V = 86, - KEY_W = 87, - KEY_X = 88, - KEY_Y = 89, - KEY_Z = 90, - KEY_SPACE = 32, - KEY_ESCAPE= 256, - KEY_ENTER = 257, - KEY_TAB = 258, - KEY_BACKSPACE = 259, - KEY_INSERT= 260, - KEY_DELETE= 261, - KEY_RIGHT = 262, - KEY_LEFT = 263, - KEY_DOWN = 264, - KEY_UP = 265, - KEY_PAGE_UP = 266, - KEY_PAGE_DOWN = 267, - KEY_HOME = 268, - KEY_END = 269, - KEY_CAPS_LOCK = 280, - KEY_SCROLL_LOCK = 281, - KEY_NUM_LOCK= 282, - KEY_PRINT_SCREEN= 283, - KEY_PAUSE = 284, - KEY_F1 = 290, - KEY_F2 = 291, - KEY_F3 = 292, - KEY_F4 = 293, - KEY_F5 = 294, - KEY_F6 = 295, - KEY_F7 = 296, - KEY_F8 = 297, - KEY_F9 = 298, - KEY_F10 = 299, - KEY_F11 = 300, - KEY_F12 = 301, - KEY_LEFT_SHIFT= 340, - KEY_LEFT_CONTROL= 341, - KEY_LEFT_ALT= 342, - KEY_LEFT_SUPER= 343, - KEY_RIGHT_SHIFT = 344, - KEY_RIGHT_CONTROL = 345, - KEY_RIGHT_ALT = 346, - KEY_RIGHT_SUPER = 347, - KEY_KB_MENU = 348, - KEY_LEFT_BRACKET= 91, - KEY_BACKSLASH = 92, - KEY_RIGHT_BRACKET = 93, - KEY_GRAVE = 96, - KEY_KP_0 = 320, - KEY_KP_1 = 321, - KEY_KP_2 = 322, - KEY_KP_3 = 323, - KEY_KP_4 = 324, - KEY_KP_5 = 325, - KEY_KP_6 = 326, - KEY_KP_7 = 327, - KEY_KP_8 = 328, - KEY_KP_9 = 329, - KEY_KP_DECIMAL= 330, - KEY_KP_DIVIDE = 331, - KEY_KP_MULTIPLY = 332, - KEY_KP_SUBTRACT = 333, - KEY_KP_ADD= 334, - KEY_KP_ENTER= 335, - KEY_KP_EQUAL= 336 - } KeyboardKey; - typedef enum { - KEY_BACK = 4, - KEY_MENU = 82, - KEY_VOLUME_UP = 24, - KEY_VOLUME_DOWN = 25 - } AndroidButton; - typedef enum { - MOUSE_LEFT_BUTTON = 0, - MOUSE_RIGHT_BUTTON= 1, - MOUSE_MIDDLE_BUTTON = 2 - } MouseButton; - typedef enum { - GAMEPAD_PLAYER1 = 0, - GAMEPAD_PLAYER2 = 1, - GAMEPAD_PLAYER3 = 2, - GAMEPAD_PLAYER4 = 3 - } GamepadNumber; - typedef enum { - GAMEPAD_BUTTON_UNKNOWN = 0, - GAMEPAD_BUTTON_LEFT_FACE_UP, - GAMEPAD_BUTTON_LEFT_FACE_RIGHT, - GAMEPAD_BUTTON_LEFT_FACE_DOWN, - GAMEPAD_BUTTON_LEFT_FACE_LEFT, - GAMEPAD_BUTTON_RIGHT_FACE_UP, - GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, - GAMEPAD_BUTTON_RIGHT_FACE_DOWN, - GAMEPAD_BUTTON_RIGHT_FACE_LEFT, - GAMEPAD_BUTTON_LEFT_TRIGGER_1, - GAMEPAD_BUTTON_LEFT_TRIGGER_2, - GAMEPAD_BUTTON_RIGHT_TRIGGER_1, - GAMEPAD_BUTTON_RIGHT_TRIGGER_2, - GAMEPAD_BUTTON_MIDDLE_LEFT, - GAMEPAD_BUTTON_MIDDLE, - GAMEPAD_BUTTON_MIDDLE_RIGHT, - GAMEPAD_BUTTON_LEFT_THUMB, - GAMEPAD_BUTTON_RIGHT_THUMB - } GamepadButton; - - typedef enum { - GAMEPAD_AXIS_UNKNOWN = 0, - GAMEPAD_AXIS_LEFT_X, - GAMEPAD_AXIS_LEFT_Y, - GAMEPAD_AXIS_RIGHT_X, - GAMEPAD_AXIS_RIGHT_Y, - GAMEPAD_AXIS_LEFT_TRIGGER, - GAMEPAD_AXIS_RIGHT_TRIGGER - } GamepadAxis; - typedef enum { - LOC_VERTEX_POSITION = 0, - LOC_VERTEX_TEXCOORD01, - LOC_VERTEX_TEXCOORD02, - LOC_VERTEX_NORMAL, - LOC_VERTEX_TANGENT, - LOC_VERTEX_COLOR, - LOC_MATRIX_MVP, - LOC_MATRIX_MODEL, - LOC_MATRIX_VIEW, - LOC_MATRIX_PROJECTION, - LOC_VECTOR_VIEW, - LOC_COLOR_DIFFUSE, - LOC_COLOR_SPECULAR, - LOC_COLOR_AMBIENT, - LOC_MAP_ALBEDO, - LOC_MAP_METALNESS, - LOC_MAP_NORMAL, - LOC_MAP_ROUGHNESS, - LOC_MAP_OCCLUSION, - LOC_MAP_EMISSION, - LOC_MAP_HEIGHT, - LOC_MAP_CUBEMAP, - LOC_MAP_IRRADIANCE, - LOC_MAP_PREFILTER, - LOC_MAP_BRDF - } ShaderLocationIndex; - - #define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO - #define LOC_MAP_SPECULAR LOC_MAP_METALNESS - - typedef enum { - UNIFORM_FLOAT = 0, - UNIFORM_VEC2, - UNIFORM_VEC3, - UNIFORM_VEC4, - UNIFORM_INT, - UNIFORM_IVEC2, - UNIFORM_IVEC3, - UNIFORM_IVEC4, - UNIFORM_SAMPLER2D - } ShaderUniformDataType; - typedef enum { - MAP_ALBEDO= 0, - MAP_METALNESS = 1, - MAP_NORMAL= 2, - MAP_ROUGHNESS = 3, - MAP_OCCLUSION, - MAP_EMISSION, - MAP_HEIGHT, - MAP_CUBEMAP, - MAP_IRRADIANCE, - MAP_PREFILTER, - MAP_BRDF - } MaterialMapType; - - #define MAP_DIFFUSE MAP_ALBEDO - #define MAP_SPECULAR MAP_METALNESS - - typedef enum { - UNCOMPRESSED_GRAYSCALE = 1, - UNCOMPRESSED_GRAY_ALPHA, - UNCOMPRESSED_R5G6B5, - UNCOMPRESSED_R8G8B8, - UNCOMPRESSED_R5G5B5A1, - UNCOMPRESSED_R4G4B4A4, - UNCOMPRESSED_R8G8B8A8, - UNCOMPRESSED_R32, - UNCOMPRESSED_R32G32B32, - UNCOMPRESSED_R32G32B32A32, - COMPRESSED_DXT1_RGB, - COMPRESSED_DXT1_RGBA, - COMPRESSED_DXT3_RGBA, - COMPRESSED_DXT5_RGBA, - COMPRESSED_ETC1_RGB, - COMPRESSED_ETC2_RGB, - COMPRESSED_ETC2_EAC_RGBA, - COMPRESSED_PVRT_RGB, - COMPRESSED_PVRT_RGBA, - COMPRESSED_ASTC_4x4_RGBA, - COMPRESSED_ASTC_8x8_RGBA - } PixelFormat; - typedef enum { - FILTER_POINT = 0, - FILTER_BILINEAR, - FILTER_TRILINEAR, - FILTER_ANISOTROPIC_4X, - FILTER_ANISOTROPIC_8X, - FILTER_ANISOTROPIC_16X, - } TextureFilterMode; - typedef enum { - CUBEMAP_AUTO_DETECT = 0, - CUBEMAP_LINE_VERTICAL, - CUBEMAP_LINE_HORIZONTAL, - CUBEMAP_CROSS_THREE_BY_FOUR, - CUBEMAP_CROSS_FOUR_BY_THREE, - CUBEMAP_PANORAMA - } CubemapLayoutType; - typedef enum { - WRAP_REPEAT = 0, - WRAP_CLAMP, - WRAP_MIRROR_REPEAT, - WRAP_MIRROR_CLAMP - } TextureWrapMode; - typedef enum { - FONT_DEFAULT = 0, - FONT_BITMAP, - FONT_SDF - } FontType; - typedef enum { - BLEND_ALPHA = 0, - BLEND_ADDITIVE, - BLEND_MULTIPLIED - } BlendMode; - typedef enum { - GESTURE_NONE = 0, - GESTURE_TAP = 1, - GESTURE_DOUBLETAP = 2, - GESTURE_HOLD= 4, - GESTURE_DRAG= 8, - GESTURE_SWIPE_RIGHT = 16, - GESTURE_SWIPE_LEFT= 32, - GESTURE_SWIPE_UP= 64, - GESTURE_SWIPE_DOWN= 128, - GESTURE_PINCH_IN= 256, - GESTURE_PINCH_OUT = 512 - } GestureType; - typedef enum { - CAMERA_CUSTOM = 0, - CAMERA_FREE, - CAMERA_ORBITAL, - CAMERA_FIRST_PERSON, - CAMERA_THIRD_PERSON - } CameraMode; - typedef enum { - CAMERA_PERSPECTIVE = 0, - CAMERA_ORTHOGRAPHIC - } CameraType; - typedef enum { - NPT_9PATCH = 0, - NPT_3PATCH_VERTICAL, - NPT_3PATCH_HORIZONTAL - } NPatchType; - 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); -]] - --- colors -local function new_color(r, g, b, a) - local c = ffi.new("Color") - c.r = r - c.g = g - c.b = b - c.a = a - return c -end - -raylib.LIGHTGRAY = new_color(200, 200, 200, 255) -raylib.GRAY = new_color(130, 130, 130, 255) -raylib.DARKGRAY = new_color(80, 80, 80, 255) -raylib.YELLOW = new_color(253, 249, 0, 255) -raylib.GOLD = new_color(255, 203, 0, 255) -raylib.ORANGE = new_color(255, 161, 0, 255) -raylib.PINK = new_color(255, 109, 194, 255) -raylib.RED = new_color(230, 41, 55, 255) -raylib.MAROON = new_color(190, 33, 55, 255) -raylib.GREEN = new_color(0, 228, 48, 255) -raylib.LIME = new_color(0, 158, 47, 255) -raylib.DARKGREEN = new_color(0, 117, 44, 255) -raylib.SKYBLUE = new_color(102, 191, 255, 255) -raylib.BLUE = new_color(0, 121, 241, 255) -raylib.DARKBLUE = new_color(0, 82, 172, 255) -raylib.PURPLE = new_color(200, 122, 255, 255) -raylib.VIOLET = new_color(135, 60, 190, 255) -raylib.DARKPURPLE = new_color(112, 31, 126, 255) -raylib.BEIGE = new_color(211, 176, 131, 255) -raylib.BROWN = new_color(127, 106, 79, 255) -raylib.DARKBROWN = new_color(76, 63, 47, 255) -raylib.WHITE = new_color(255, 255, 255, 255) -raylib.BLACK = new_color(0, 0, 0, 255) -raylib.BLANK = new_color(0, 0, 0, 0) -raylib.MAGENTA = new_color(255, 0, 255, 255) -raylib.RAYWHITE = new_color(245, 245, 245, 255) - -raylib.__index = function (self, key) - return raylib_so[key] -end - -raylib.__newindex = function () - error "raylib table is readonly" -end - -rl = setmetatable(raylib, raylib) -raylib = rl +print "[RAYLUA] Raylua boot script" + +local ffi = require "ffi" +local raylib = {} +local raylib_so = ffi.C + +-- structs definition +ffi.cdef [[ + typedef struct Vector2 { + float x; + float y; + } Vector2; + + typedef struct Vector3 { + float x; + float y; + float z; + } Vector3; + + typedef struct Vector4 { + float x; + float y; + float z; + float w; + } Vector4; + + typedef Vector4 Quaternion; + + typedef struct Matrix { + float m0, m4, m8, m12; + float m1, m5, m9, m13; + float m2, m6, m10, m14; + float m3, m7, m11, m15; + } Matrix; + + typedef struct Color { + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; + } Color; + + typedef struct Rectangle { + float x; + float y; + float width; + float height; + } Rectangle; + + typedef struct Image { + void *data; + int width; + int height; + int mipmaps; + int format; + } Image; + + typedef struct Texture2D { + unsigned int id; + int width; + int height; + int mipmaps; + int format; + } Texture2D; + typedef Texture2D Texture; + typedef Texture2D TextureCubemap; + + typedef struct RenderTexture2D { + unsigned int id; + Texture2D texture; + Texture2D depth; + bool depthTexture; + } RenderTexture2D; + + typedef RenderTexture2D RenderTexture; + typedef struct NPatchInfo { + Rectangle sourceRec; + int left; + int top; + int right; + int bottom; + int type; + } NPatchInfo; + + typedef struct CharInfo { + int value; + int offsetX; + int offsetY; + int advanceX; + Image image; + } CharInfo; + + typedef struct Font { + int baseSize; + int charsCount; + Texture2D texture; + Rectangle *recs; + CharInfo *chars; + } Font; + + typedef Font SpriteFont; + typedef struct Camera3D { + Vector3 position; + Vector3 target; + Vector3 up; + float fovy; + int type; + } Camera3D; + + typedef Camera3D Camera; + typedef struct Camera2D { + Vector2 offset; + Vector2 target; + float rotation; + float zoom; + } Camera2D; + + typedef struct Mesh { + int vertexCount; + int triangleCount; + float *vertices; + float *texcoords; + float *texcoords2; + float *normals; + float *tangents; + unsigned char *colors; + unsigned short *indices; + float *animVertices; + float *animNormals; + int *boneIds; + float *boneWeights; + unsigned int vaoId; + unsigned int *vboId; + } Mesh; + + typedef struct Shader { + unsigned int id; + int *locs; + } Shader; + + typedef struct MaterialMap { + Texture2D texture; + Color color; + float value; + } MaterialMap; + + typedef struct Material { + Shader shader; + MaterialMap *maps; + float *params; + } Material; + + typedef struct Transform { + Vector3 translation; + Quaternion rotation; + Vector3 scale; + } Transform; + + typedef struct BoneInfo { + char name[32]; + int parent; + } BoneInfo; + + typedef struct Model { + Matrix transform; + + int meshCount; + Mesh *meshes; + + int materialCount; + Material *materials; + int *meshMaterial; + int boneCount; + BoneInfo *bones; + Transform *bindPose; + } Model; + + typedef struct ModelAnimation { + int boneCount; + BoneInfo *bones; + + int frameCount; + Transform **framePoses; + } ModelAnimation; + + typedef struct Ray { + Vector3 position; + Vector3 direction; + } Ray; + + typedef struct RayHitInfo { + bool hit; + float distance; + Vector3 position; + Vector3 normal; + } RayHitInfo; + + typedef struct BoundingBox { + Vector3 min; + Vector3 max; + } BoundingBox; + + typedef struct Wave { + unsigned int sampleCount; + unsigned int sampleRate; + unsigned int sampleSize; + unsigned int channels; + void *data; + } Wave; + + typedef struct rAudioBuffer rAudioBuffer; + typedef struct AudioStream { + unsigned int sampleRate; + unsigned int sampleSize; + unsigned int channels; + + rAudioBuffer *buffer; + } AudioStream; + + typedef struct Sound { + unsigned int sampleCount; + AudioStream stream; + } Sound; + + typedef struct Music { + int ctxType; + void *ctxData; + + unsigned int sampleCount; + unsigned int loopCount; + + AudioStream stream; + } Music; + + typedef struct VrDeviceInfo { + int hResolution; + int vResolution; + float hScreenSize; + float vScreenSize; + float vScreenCenter; + float eyeToScreenDistance; + float lensSeparationDistance; + float interpupillaryDistance; + float lensDistortionValues[4]; + float chromaAbCorrection[4]; + } VrDeviceInfo; + + typedef enum { + FLAG_RESERVED = 1, + FLAG_FULLSCREEN_MODE= 2, + FLAG_WINDOW_RESIZABLE = 4, + FLAG_WINDOW_UNDECORATED = 8, + FLAG_WINDOW_TRANSPARENT = 16, + FLAG_WINDOW_HIDDEN= 128, + FLAG_WINDOW_ALWAYS_RUN= 256, + FLAG_MSAA_4X_HINT = 32, + FLAG_VSYNC_HINT = 64 + } ConfigFlag; + + typedef enum { + LOG_ALL = 0, + LOG_TRACE, + LOG_DEBUG, + LOG_INFO, + LOG_WARNING, + LOG_ERROR, + LOG_FATAL, + LOG_NONE + } TraceLogType; + + typedef enum { + KEY_APOSTROPHE= 39, + KEY_COMMA = 44, + KEY_MINUS = 45, + KEY_PERIOD= 46, + KEY_SLASH = 47, + KEY_ZERO = 48, + KEY_ONE = 49, + KEY_TWO = 50, + KEY_THREE = 51, + KEY_FOUR = 52, + KEY_FIVE = 53, + KEY_SIX = 54, + KEY_SEVEN = 55, + KEY_EIGHT = 56, + KEY_NINE = 57, + KEY_SEMICOLON = 59, + KEY_EQUAL = 61, + KEY_A = 65, + KEY_B = 66, + KEY_C = 67, + KEY_D = 68, + KEY_E = 69, + KEY_F = 70, + KEY_G = 71, + KEY_H = 72, + KEY_I = 73, + KEY_J = 74, + KEY_K = 75, + KEY_L = 76, + KEY_M = 77, + KEY_N = 78, + KEY_O = 79, + KEY_P = 80, + KEY_Q = 81, + KEY_R = 82, + KEY_S = 83, + KEY_T = 84, + KEY_U = 85, + KEY_V = 86, + KEY_W = 87, + KEY_X = 88, + KEY_Y = 89, + KEY_Z = 90, + KEY_SPACE = 32, + KEY_ESCAPE= 256, + KEY_ENTER = 257, + KEY_TAB = 258, + KEY_BACKSPACE = 259, + KEY_INSERT= 260, + KEY_DELETE= 261, + KEY_RIGHT = 262, + KEY_LEFT = 263, + KEY_DOWN = 264, + KEY_UP = 265, + KEY_PAGE_UP = 266, + KEY_PAGE_DOWN = 267, + KEY_HOME = 268, + KEY_END = 269, + KEY_CAPS_LOCK = 280, + KEY_SCROLL_LOCK = 281, + KEY_NUM_LOCK= 282, + KEY_PRINT_SCREEN= 283, + KEY_PAUSE = 284, + KEY_F1 = 290, + KEY_F2 = 291, + KEY_F3 = 292, + KEY_F4 = 293, + KEY_F5 = 294, + KEY_F6 = 295, + KEY_F7 = 296, + KEY_F8 = 297, + KEY_F9 = 298, + KEY_F10 = 299, + KEY_F11 = 300, + KEY_F12 = 301, + KEY_LEFT_SHIFT= 340, + KEY_LEFT_CONTROL= 341, + KEY_LEFT_ALT= 342, + KEY_LEFT_SUPER= 343, + KEY_RIGHT_SHIFT = 344, + KEY_RIGHT_CONTROL = 345, + KEY_RIGHT_ALT = 346, + KEY_RIGHT_SUPER = 347, + KEY_KB_MENU = 348, + KEY_LEFT_BRACKET= 91, + KEY_BACKSLASH = 92, + KEY_RIGHT_BRACKET = 93, + KEY_GRAVE = 96, + KEY_KP_0 = 320, + KEY_KP_1 = 321, + KEY_KP_2 = 322, + KEY_KP_3 = 323, + KEY_KP_4 = 324, + KEY_KP_5 = 325, + KEY_KP_6 = 326, + KEY_KP_7 = 327, + KEY_KP_8 = 328, + KEY_KP_9 = 329, + KEY_KP_DECIMAL= 330, + KEY_KP_DIVIDE = 331, + KEY_KP_MULTIPLY = 332, + KEY_KP_SUBTRACT = 333, + KEY_KP_ADD= 334, + KEY_KP_ENTER= 335, + KEY_KP_EQUAL= 336 + } KeyboardKey; + + typedef enum { + KEY_BACK = 4, + KEY_MENU = 82, + KEY_VOLUME_UP = 24, + KEY_VOLUME_DOWN = 25 + } AndroidButton; + + typedef enum { + MOUSE_LEFT_BUTTON = 0, + MOUSE_RIGHT_BUTTON= 1, + MOUSE_MIDDLE_BUTTON = 2 + } MouseButton; + + typedef enum { + GAMEPAD_PLAYER1 = 0, + GAMEPAD_PLAYER2 = 1, + GAMEPAD_PLAYER3 = 2, + GAMEPAD_PLAYER4 = 3 + } GamepadNumber; + + typedef enum { + GAMEPAD_BUTTON_UNKNOWN = 0, + GAMEPAD_BUTTON_LEFT_FACE_UP, + GAMEPAD_BUTTON_LEFT_FACE_RIGHT, + GAMEPAD_BUTTON_LEFT_FACE_DOWN, + GAMEPAD_BUTTON_LEFT_FACE_LEFT, + GAMEPAD_BUTTON_RIGHT_FACE_UP, + GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, + GAMEPAD_BUTTON_RIGHT_FACE_DOWN, + GAMEPAD_BUTTON_RIGHT_FACE_LEFT, + GAMEPAD_BUTTON_LEFT_TRIGGER_1, + GAMEPAD_BUTTON_LEFT_TRIGGER_2, + GAMEPAD_BUTTON_RIGHT_TRIGGER_1, + GAMEPAD_BUTTON_RIGHT_TRIGGER_2, + GAMEPAD_BUTTON_MIDDLE_LEFT, + GAMEPAD_BUTTON_MIDDLE, + GAMEPAD_BUTTON_MIDDLE_RIGHT, + GAMEPAD_BUTTON_LEFT_THUMB, + GAMEPAD_BUTTON_RIGHT_THUMB + } GamepadButton; + + typedef enum { + GAMEPAD_AXIS_UNKNOWN = 0, + GAMEPAD_AXIS_LEFT_X, + GAMEPAD_AXIS_LEFT_Y, + GAMEPAD_AXIS_RIGHT_X, + GAMEPAD_AXIS_RIGHT_Y, + GAMEPAD_AXIS_LEFT_TRIGGER, + GAMEPAD_AXIS_RIGHT_TRIGGER + } GamepadAxis; + + typedef enum { + LOC_VERTEX_POSITION = 0, + LOC_VERTEX_TEXCOORD01, + LOC_VERTEX_TEXCOORD02, + LOC_VERTEX_NORMAL, + LOC_VERTEX_TANGENT, + LOC_VERTEX_COLOR, + LOC_MATRIX_MVP, + LOC_MATRIX_MODEL, + LOC_MATRIX_VIEW, + LOC_MATRIX_PROJECTION, + LOC_VECTOR_VIEW, + LOC_COLOR_DIFFUSE, + LOC_COLOR_SPECULAR, + LOC_COLOR_AMBIENT, + LOC_MAP_ALBEDO, + LOC_MAP_METALNESS, + LOC_MAP_NORMAL, + LOC_MAP_ROUGHNESS, + LOC_MAP_OCCLUSION, + LOC_MAP_EMISSION, + LOC_MAP_HEIGHT, + LOC_MAP_CUBEMAP, + LOC_MAP_IRRADIANCE, + LOC_MAP_PREFILTER, + LOC_MAP_BRDF + } ShaderLocationIndex; + + typedef enum { + UNIFORM_FLOAT = 0, + UNIFORM_VEC2, + UNIFORM_VEC3, + UNIFORM_VEC4, + UNIFORM_INT, + UNIFORM_IVEC2, + UNIFORM_IVEC3, + UNIFORM_IVEC4, + UNIFORM_SAMPLER2D + } ShaderUniformDataType; + + typedef enum { + MAP_ALBEDO= 0, + MAP_METALNESS = 1, + MAP_NORMAL= 2, + MAP_ROUGHNESS = 3, + MAP_OCCLUSION, + MAP_EMISSION, + MAP_HEIGHT, + MAP_CUBEMAP, + MAP_IRRADIANCE, + MAP_PREFILTER, + MAP_BRDF + } MaterialMapType; + + typedef enum { + UNCOMPRESSED_GRAYSCALE = 1, + UNCOMPRESSED_GRAY_ALPHA, + UNCOMPRESSED_R5G6B5, + UNCOMPRESSED_R8G8B8, + UNCOMPRESSED_R5G5B5A1, + UNCOMPRESSED_R4G4B4A4, + UNCOMPRESSED_R8G8B8A8, + UNCOMPRESSED_R32, + UNCOMPRESSED_R32G32B32, + UNCOMPRESSED_R32G32B32A32, + COMPRESSED_DXT1_RGB, + COMPRESSED_DXT1_RGBA, + COMPRESSED_DXT3_RGBA, + COMPRESSED_DXT5_RGBA, + COMPRESSED_ETC1_RGB, + COMPRESSED_ETC2_RGB, + COMPRESSED_ETC2_EAC_RGBA, + COMPRESSED_PVRT_RGB, + COMPRESSED_PVRT_RGBA, + COMPRESSED_ASTC_4x4_RGBA, + COMPRESSED_ASTC_8x8_RGBA + } PixelFormat; + + typedef enum { + FILTER_POINT = 0, + FILTER_BILINEAR, + FILTER_TRILINEAR, + FILTER_ANISOTROPIC_4X, + FILTER_ANISOTROPIC_8X, + FILTER_ANISOTROPIC_16X, + } TextureFilterMode; + + typedef enum { + CUBEMAP_AUTO_DETECT = 0, + CUBEMAP_LINE_VERTICAL, + CUBEMAP_LINE_HORIZONTAL, + CUBEMAP_CROSS_THREE_BY_FOUR, + CUBEMAP_CROSS_FOUR_BY_THREE, + CUBEMAP_PANORAMA + } CubemapLayoutType; + + typedef enum { + WRAP_REPEAT = 0, + WRAP_CLAMP, + WRAP_MIRROR_REPEAT, + WRAP_MIRROR_CLAMP + } TextureWrapMode; + + typedef enum { + FONT_DEFAULT = 0, + FONT_BITMAP, + FONT_SDF + } FontType; + + typedef enum { + BLEND_ALPHA = 0, + BLEND_ADDITIVE, + BLEND_MULTIPLIED + } BlendMode; + + typedef enum { + GESTURE_NONE = 0, + GESTURE_TAP = 1, + GESTURE_DOUBLETAP = 2, + GESTURE_HOLD= 4, + GESTURE_DRAG= 8, + GESTURE_SWIPE_RIGHT = 16, + GESTURE_SWIPE_LEFT= 32, + GESTURE_SWIPE_UP= 64, + GESTURE_SWIPE_DOWN= 128, + GESTURE_PINCH_IN= 256, + GESTURE_PINCH_OUT = 512 + } GestureType; + + typedef enum { + CAMERA_CUSTOM = 0, + CAMERA_FREE, + CAMERA_ORBITAL, + CAMERA_FIRST_PERSON, + CAMERA_THIRD_PERSON + } CameraMode; + + typedef enum { + CAMERA_PERSPECTIVE = 0, + CAMERA_ORTHOGRAPHIC + } CameraType; + + typedef enum { + NPT_9PATCH = 0, + NPT_3PATCH_VERTICAL, + NPT_3PATCH_HORIZONTAL + } NPatchType; + + typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); +]] + +-- 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 +local function new_color(r, g, b, a) + local c = ffi.new("Color") + c.r = r + c.g = g + c.b = b + c.a = a + return c +end + +raylib.LIGHTGRAY = new_color(200, 200, 200, 255) +raylib.GRAY = new_color(130, 130, 130, 255) +raylib.DARKGRAY = new_color(80, 80, 80, 255) +raylib.YELLOW = new_color(253, 249, 0, 255) +raylib.GOLD = new_color(255, 203, 0, 255) +raylib.ORANGE = new_color(255, 161, 0, 255) +raylib.PINK = new_color(255, 109, 194, 255) +raylib.RED = new_color(230, 41, 55, 255) +raylib.MAROON = new_color(190, 33, 55, 255) +raylib.GREEN = new_color(0, 228, 48, 255) +raylib.LIME = new_color(0, 158, 47, 255) +raylib.DARKGREEN = new_color(0, 117, 44, 255) +raylib.SKYBLUE = new_color(102, 191, 255, 255) +raylib.BLUE = new_color(0, 121, 241, 255) +raylib.DARKBLUE = new_color(0, 82, 172, 255) +raylib.PURPLE = new_color(200, 122, 255, 255) +raylib.VIOLET = new_color(135, 60, 190, 255) +raylib.DARKPURPLE = new_color(112, 31, 126, 255) +raylib.BEIGE = new_color(211, 176, 131, 255) +raylib.BROWN = new_color(127, 106, 79, 255) +raylib.DARKBROWN = new_color(76, 63, 47, 255) +raylib.WHITE = new_color(255, 255, 255, 255) +raylib.BLACK = new_color(0, 0, 0, 255) +raylib.BLANK = new_color(0, 0, 0, 0) +raylib.MAGENTA = new_color(255, 0, 255, 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) + return raylib_so[key] +end + +raylib.__newindex = function () + error "raylib table is readonly" +end + +rl = setmetatable(raylib, raylib) +raylib = rl diff --git a/src/raylua.c b/src/raylua.c new file mode 100644 index 0000000..63922ad --- /dev/null +++ b/src/raylua.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#include +#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); +} diff --git a/src/raylua.h b/src/raylua.h new file mode 100644 index 0000000..e8a7ca5 --- /dev/null +++ b/src/raylua.h @@ -0,0 +1,8 @@ +#ifndef H_RAYLUA +#define H_RAYLUA + +#include + +void raylua_boot(lua_State *L, lua_CFunction loadfile); + +#endif /* H_RAYLUA */ diff --git a/src/raylua.lua b/src/raylua.lua index 3e7c5db..f498a96 100644 --- a/src/raylua.lua +++ b/src/raylua.lua @@ -1,22 +1,50 @@ -local load = loadstring - -if raylua then - -- Change the second loader to load files using raylua.loadfiles - package.loaders[2] = function (name) - for path in package.path:gmatch "([^;]+);?" do - path = path:gsub("?", name) - - local status, content = raylua.loadfiles(path) - if status then - local f, err = load(content) - assert(f, err) - - return f - end - end - - return nil - end -end - -require "main" +local load = loadstring + +if raylua.loadfile then + package.path = "?.lua" + + -- Change the second loader to load files using raylua.loadfile + package.loaders[2] = function (name) + for path in package.path:gmatch "([^;]+);?" do + path = path:gsub("?", name) + + local status, content = raylua.loadfile(path) + if status then + local f, err = load(content) + assert(f, err) + + return f + end + end + + return nil + end + + print "[RAYLUA] Load main.lua from payload." + require "main" + return +end + +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 diff --git a/src/raylua_boot.c b/src/raylua_boot.c deleted file mode 100644 index 93765c9..0000000 --- a/src/raylua_boot.c +++ /dev/null @@ -1,1043 +0,0 @@ -const char *raylua_boot = "local ffi = require \"ffi\"" "\n" -"local raylib = {}" "\n" -"local raylib_so = ffi.load(\"raylib\")" "\n" -"" "\n" -"-- ffi cdef, based on raylib.h" "\n" -"ffi.cdef [[" "\n" -" typedef struct Vector2 {" "\n" -" float x;" "\n" -" float y;" "\n" -" } Vector2;" "\n" -" typedef struct Vector3 {" "\n" -" float x;" "\n" -" float y;" "\n" -" float z;" "\n" -" } Vector3;" "\n" -" typedef struct Vector4 {" "\n" -" float x;" "\n" -" float y;" "\n" -" float z;" "\n" -" float w;" "\n" -" } Vector4;" "\n" -" typedef Vector4 Quaternion;" "\n" -" typedef struct Matrix {" "\n" -" float m0, m4, m8, m12;" "\n" -" float m1, m5, m9, m13;" "\n" -" float m2, m6, m10, m14;" "\n" -" float m3, m7, m11, m15;" "\n" -" } Matrix;" "\n" -" typedef struct Color {" "\n" -" unsigned char r;" "\n" -" unsigned char g;" "\n" -" unsigned char b;" "\n" -" unsigned char a;" "\n" -" } Color;" "\n" -" typedef struct Rectangle {" "\n" -" float x;" "\n" -" float y;" "\n" -" float width;" "\n" -" float height;" "\n" -" } Rectangle;" "\n" -" typedef struct Image {" "\n" -" void *data;" "\n" -" int width;" "\n" -" int height;" "\n" -" int mipmaps;" "\n" -" int format;" "\n" -" } Image;" "\n" -" typedef struct Texture2D {" "\n" -" unsigned int id;" "\n" -" int width;" "\n" -" int height;" "\n" -" int mipmaps;" "\n" -" int format;" "\n" -" } Texture2D;" "\n" -" typedef Texture2D Texture;" "\n" -" typedef Texture2D TextureCubemap;" "\n" -" typedef struct RenderTexture2D {" "\n" -" unsigned int id;" "\n" -" Texture2D texture;" "\n" -" Texture2D depth;" "\n" -" bool depthTexture;" "\n" -" } RenderTexture2D;" "\n" -" typedef RenderTexture2D RenderTexture;" "\n" -" typedef struct NPatchInfo {" "\n" -" Rectangle sourceRec;" "\n" -" int left;" "\n" -" int top;" "\n" -" int right;" "\n" -" int bottom;" "\n" -" int type;" "\n" -" } NPatchInfo;" "\n" -" typedef struct CharInfo {" "\n" -" int value;" "\n" -" int offsetX;" "\n" -" int offsetY;" "\n" -" int advanceX;" "\n" -" Image image;" "\n" -" } CharInfo;" "\n" -" typedef struct Font {" "\n" -" int baseSize;" "\n" -" int charsCount;" "\n" -" Texture2D texture;" "\n" -" Rectangle *recs;" "\n" -" CharInfo *chars;" "\n" -" } Font;" "\n" -"" "\n" -" typedef SpriteFont Font;" "\n" -" typedef struct Camera3D {" "\n" -" Vector3 position;" "\n" -" Vector3 target;" "\n" -" Vector3 up;" "\n" -" float fovy;" "\n" -" int type;" "\n" -" } Camera3D;" "\n" -"" "\n" -" typedef Camera3D Camera;" "\n" -" typedef struct Camera2D {" "\n" -" Vector2 offset;" "\n" -" Vector2 target;" "\n" -" float rotation;" "\n" -" float zoom;" "\n" -" } Camera2D;" "\n" -" typedef struct Mesh {" "\n" -" int vertexCount;" "\n" -" int triangleCount;" "\n" -" float *vertices;" "\n" -" float *texcoords;" "\n" -" float *texcoords2;" "\n" -" float *normals;" "\n" -" float *tangents;" "\n" -" unsigned char *colors;" "\n" -" unsigned short *indices;" "\n" -" float *animVertices;" "\n" -" float *animNormals;" "\n" -" int *boneIds;" "\n" -" float *boneWeights;" "\n" -" unsigned int vaoId;" "\n" -" unsigned int *vboId;" "\n" -" } Mesh;" "\n" -" typedef struct Shader {" "\n" -" unsigned int id;" "\n" -" int *locs;" "\n" -" } Shader;" "\n" -" typedef struct MaterialMap {" "\n" -" Texture2D texture;" "\n" -" Color color;" "\n" -" float value;" "\n" -" } MaterialMap;" "\n" -" typedef struct Material {" "\n" -" Shader shader;" "\n" -" MaterialMap *maps;" "\n" -" float *params;" "\n" -" } Material;" "\n" -" typedef struct Transform {" "\n" -" Vector3 translation;" "\n" -" Quaternion rotation;" "\n" -" Vector3 scale;" "\n" -" } Transform;" "\n" -" typedef struct BoneInfo {" "\n" -" char name[32];" "\n" -" int parent;" "\n" -" } BoneInfo;" "\n" -" typedef struct Model {" "\n" -" Matrix transform;" "\n" -"" "\n" -" int meshCount;" "\n" -" Mesh *meshes;" "\n" -"" "\n" -" int materialCount;" "\n" -" Material *materials;" "\n" -" int *meshMaterial;" "\n" -" int boneCount;" "\n" -" BoneInfo *bones;" "\n" -" Transform *bindPose;" "\n" -" } Model;" "\n" -" typedef struct ModelAnimation {" "\n" -" int boneCount;" "\n" -" BoneInfo *bones;" "\n" -"" "\n" -" int frameCount;" "\n" -" Transform **framePoses;" "\n" -" } ModelAnimation;" "\n" -" typedef struct Ray {" "\n" -" Vector3 position;" "\n" -" Vector3 direction;" "\n" -" } Ray;" "\n" -" typedef struct RayHitInfo {" "\n" -" bool hit;" "\n" -" float distance;" "\n" -" Vector3 position;" "\n" -" Vector3 normal;" "\n" -" } RayHitInfo;" "\n" -" typedef struct BoundingBox {" "\n" -" Vector3 min;" "\n" -" Vector3 max;" "\n" -" } BoundingBox;" "\n" -" typedef struct Wave {" "\n" -" unsigned int sampleCount;" "\n" -" unsigned int sampleRate;" "\n" -" unsigned int sampleSize;" "\n" -" unsigned int channels;" "\n" -" void *data;" "\n" -" } Wave;" "\n" -"" "\n" -" typedef struct rAudioBuffer rAudioBuffer;" "\n" -" typedef struct AudioStream {" "\n" -" unsigned int sampleRate;" "\n" -" unsigned int sampleSize;" "\n" -" unsigned int channels;" "\n" -"" "\n" -" rAudioBuffer *buffer;" "\n" -" } AudioStream;" "\n" -" typedef struct Sound {" "\n" -" unsigned int sampleCount;" "\n" -" AudioStream stream;" "\n" -" } Sound;" "\n" -" typedef struct Music {" "\n" -" int ctxType;" "\n" -" void *ctxData;" "\n" -"" "\n" -" unsigned int sampleCount;" "\n" -" unsigned int loopCount;" "\n" -"" "\n" -" AudioStream stream;" "\n" -" } Music;" "\n" -" typedef struct VrDeviceInfo {" "\n" -" int hResolution;" "\n" -" int vResolution;" "\n" -" float hScreenSize;" "\n" -" float vScreenSize;" "\n" -" float vScreenCenter;" "\n" -" float eyeToScreenDistance;" "\n" -" float lensSeparationDistance;" "\n" -" float interpupillaryDistance;" "\n" -" float lensDistortionValues[4];" "\n" -" float chromaAbCorrection[4];" "\n" -" } VrDeviceInfo;" "\n" -" typedef enum {" "\n" -" FLAG_RESERVED = 1," "\n" -" FLAG_FULLSCREEN_MODE= 2," "\n" -" FLAG_WINDOW_RESIZABLE = 4," "\n" -" FLAG_WINDOW_UNDECORATED = 8," "\n" -" FLAG_WINDOW_TRANSPARENT = 16," "\n" -" FLAG_WINDOW_HIDDEN= 128," "\n" -" FLAG_WINDOW_ALWAYS_RUN= 256," "\n" -" FLAG_MSAA_4X_HINT = 32," "\n" -" FLAG_VSYNC_HINT = 64" "\n" -" } ConfigFlag;" "\n" -" typedef enum {" "\n" -" LOG_ALL = 0," "\n" -" LOG_TRACE," "\n" -" LOG_DEBUG," "\n" -" LOG_INFO," "\n" -" LOG_WARNING," "\n" -" LOG_ERROR," "\n" -" LOG_FATAL," "\n" -" LOG_NONE" "\n" -" } TraceLogType;" "\n" -" typedef enum {" "\n" -" KEY_APOSTROPHE= 39," "\n" -" KEY_COMMA = 44," "\n" -" KEY_MINUS = 45," "\n" -" KEY_PERIOD= 46," "\n" -" KEY_SLASH = 47," "\n" -" KEY_ZERO = 48," "\n" -" KEY_ONE = 49," "\n" -" KEY_TWO = 50," "\n" -" KEY_THREE = 51," "\n" -" KEY_FOUR = 52," "\n" -" KEY_FIVE = 53," "\n" -" KEY_SIX = 54," "\n" -" KEY_SEVEN = 55," "\n" -" KEY_EIGHT = 56," "\n" -" KEY_NINE = 57," "\n" -" KEY_SEMICOLON = 59," "\n" -" KEY_EQUAL = 61," "\n" -" KEY_A = 65," "\n" -" KEY_B = 66," "\n" -" KEY_C = 67," "\n" -" KEY_D = 68," "\n" -" KEY_E = 69," "\n" -" KEY_F = 70," "\n" -" KEY_G = 71," "\n" -" KEY_H = 72," "\n" -" KEY_I = 73," "\n" -" KEY_J = 74," "\n" -" KEY_K = 75," "\n" -" KEY_L = 76," "\n" -" KEY_M = 77," "\n" -" KEY_N = 78," "\n" -" KEY_O = 79," "\n" -" KEY_P = 80," "\n" -" KEY_Q = 81," "\n" -" KEY_R = 82," "\n" -" KEY_S = 83," "\n" -" KEY_T = 84," "\n" -" KEY_U = 85," "\n" -" KEY_V = 86," "\n" -" KEY_W = 87," "\n" -" KEY_X = 88," "\n" -" KEY_Y = 89," "\n" -" KEY_Z = 90," "\n" -" KEY_SPACE = 32," "\n" -" KEY_ESCAPE= 256," "\n" -" KEY_ENTER = 257," "\n" -" KEY_TAB = 258," "\n" -" KEY_BACKSPACE = 259," "\n" -" KEY_INSERT= 260," "\n" -" KEY_DELETE= 261," "\n" -" KEY_RIGHT = 262," "\n" -" KEY_LEFT = 263," "\n" -" KEY_DOWN = 264," "\n" -" KEY_UP = 265," "\n" -" KEY_PAGE_UP = 266," "\n" -" KEY_PAGE_DOWN = 267," "\n" -" KEY_HOME = 268," "\n" -" KEY_END = 269," "\n" -" KEY_CAPS_LOCK = 280," "\n" -" KEY_SCROLL_LOCK = 281," "\n" -" KEY_NUM_LOCK= 282," "\n" -" KEY_PRINT_SCREEN= 283," "\n" -" KEY_PAUSE = 284," "\n" -" KEY_F1 = 290," "\n" -" KEY_F2 = 291," "\n" -" KEY_F3 = 292," "\n" -" KEY_F4 = 293," "\n" -" KEY_F5 = 294," "\n" -" KEY_F6 = 295," "\n" -" KEY_F7 = 296," "\n" -" KEY_F8 = 297," "\n" -" KEY_F9 = 298," "\n" -" KEY_F10 = 299," "\n" -" KEY_F11 = 300," "\n" -" KEY_F12 = 301," "\n" -" KEY_LEFT_SHIFT= 340," "\n" -" KEY_LEFT_CONTROL= 341," "\n" -" KEY_LEFT_ALT= 342," "\n" -" KEY_LEFT_SUPER= 343," "\n" -" KEY_RIGHT_SHIFT = 344," "\n" -" KEY_RIGHT_CONTROL = 345," "\n" -" KEY_RIGHT_ALT = 346," "\n" -" KEY_RIGHT_SUPER = 347," "\n" -" KEY_KB_MENU = 348," "\n" -" KEY_LEFT_BRACKET= 91," "\n" -" KEY_BACKSLASH = 92," "\n" -" KEY_RIGHT_BRACKET = 93," "\n" -" KEY_GRAVE = 96," "\n" -" KEY_KP_0 = 320," "\n" -" KEY_KP_1 = 321," "\n" -" KEY_KP_2 = 322," "\n" -" KEY_KP_3 = 323," "\n" -" KEY_KP_4 = 324," "\n" -" KEY_KP_5 = 325," "\n" -" KEY_KP_6 = 326," "\n" -" KEY_KP_7 = 327," "\n" -" KEY_KP_8 = 328," "\n" -" KEY_KP_9 = 329," "\n" -" KEY_KP_DECIMAL= 330," "\n" -" KEY_KP_DIVIDE = 331," "\n" -" KEY_KP_MULTIPLY = 332," "\n" -" KEY_KP_SUBTRACT = 333," "\n" -" KEY_KP_ADD= 334," "\n" -" KEY_KP_ENTER= 335," "\n" -" KEY_KP_EQUAL= 336" "\n" -" } KeyboardKey;" "\n" -" typedef enum {" "\n" -" KEY_BACK = 4," "\n" -" KEY_MENU = 82," "\n" -" KEY_VOLUME_UP = 24," "\n" -" KEY_VOLUME_DOWN = 25" "\n" -" } AndroidButton;" "\n" -" typedef enum {" "\n" -" MOUSE_LEFT_BUTTON = 0," "\n" -" MOUSE_RIGHT_BUTTON= 1," "\n" -" MOUSE_MIDDLE_BUTTON = 2" "\n" -" } MouseButton;" "\n" -" typedef enum {" "\n" -" GAMEPAD_PLAYER1 = 0," "\n" -" GAMEPAD_PLAYER2 = 1," "\n" -" GAMEPAD_PLAYER3 = 2," "\n" -" GAMEPAD_PLAYER4 = 3" "\n" -" } GamepadNumber;" "\n" -" typedef enum {" "\n" -" GAMEPAD_BUTTON_UNKNOWN = 0," "\n" -" GAMEPAD_BUTTON_LEFT_FACE_UP," "\n" -" GAMEPAD_BUTTON_LEFT_FACE_RIGHT," "\n" -" GAMEPAD_BUTTON_LEFT_FACE_DOWN," "\n" -" GAMEPAD_BUTTON_LEFT_FACE_LEFT," "\n" -" GAMEPAD_BUTTON_RIGHT_FACE_UP," "\n" -" GAMEPAD_BUTTON_RIGHT_FACE_RIGHT," "\n" -" GAMEPAD_BUTTON_RIGHT_FACE_DOWN," "\n" -" GAMEPAD_BUTTON_RIGHT_FACE_LEFT," "\n" -" GAMEPAD_BUTTON_LEFT_TRIGGER_1," "\n" -" GAMEPAD_BUTTON_LEFT_TRIGGER_2," "\n" -" GAMEPAD_BUTTON_RIGHT_TRIGGER_1," "\n" -" GAMEPAD_BUTTON_RIGHT_TRIGGER_2," "\n" -" GAMEPAD_BUTTON_MIDDLE_LEFT," "\n" -" GAMEPAD_BUTTON_MIDDLE," "\n" -" GAMEPAD_BUTTON_MIDDLE_RIGHT," "\n" -" GAMEPAD_BUTTON_LEFT_THUMB," "\n" -" GAMEPAD_BUTTON_RIGHT_THUMB" "\n" -" } GamepadButton;" "\n" -"" "\n" -" typedef enum {" "\n" -" GAMEPAD_AXIS_UNKNOWN = 0," "\n" -" GAMEPAD_AXIS_LEFT_X," "\n" -" GAMEPAD_AXIS_LEFT_Y," "\n" -" GAMEPAD_AXIS_RIGHT_X," "\n" -" GAMEPAD_AXIS_RIGHT_Y," "\n" -" GAMEPAD_AXIS_LEFT_TRIGGER," "\n" -" GAMEPAD_AXIS_RIGHT_TRIGGER" "\n" -" } GamepadAxis;" "\n" -" typedef enum {" "\n" -" LOC_VERTEX_POSITION = 0," "\n" -" LOC_VERTEX_TEXCOORD01," "\n" -" LOC_VERTEX_TEXCOORD02," "\n" -" LOC_VERTEX_NORMAL," "\n" -" LOC_VERTEX_TANGENT," "\n" -" LOC_VERTEX_COLOR," "\n" -" LOC_MATRIX_MVP," "\n" -" LOC_MATRIX_MODEL," "\n" -" LOC_MATRIX_VIEW," "\n" -" LOC_MATRIX_PROJECTION," "\n" -" LOC_VECTOR_VIEW," "\n" -" LOC_COLOR_DIFFUSE," "\n" -" LOC_COLOR_SPECULAR," "\n" -" LOC_COLOR_AMBIENT," "\n" -" LOC_MAP_ALBEDO," "\n" -" LOC_MAP_METALNESS," "\n" -" LOC_MAP_NORMAL," "\n" -" LOC_MAP_ROUGHNESS," "\n" -" LOC_MAP_OCCLUSION," "\n" -" LOC_MAP_EMISSION," "\n" -" LOC_MAP_HEIGHT," "\n" -" LOC_MAP_CUBEMAP," "\n" -" LOC_MAP_IRRADIANCE," "\n" -" LOC_MAP_PREFILTER," "\n" -" LOC_MAP_BRDF" "\n" -" } ShaderLocationIndex;" "\n" -"" "\n" -" #define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO" "\n" -" #define LOC_MAP_SPECULAR LOC_MAP_METALNESS" "\n" -"" "\n" -" typedef enum {" "\n" -" UNIFORM_FLOAT = 0," "\n" -" UNIFORM_VEC2," "\n" -" UNIFORM_VEC3," "\n" -" UNIFORM_VEC4," "\n" -" UNIFORM_INT," "\n" -" UNIFORM_IVEC2," "\n" -" UNIFORM_IVEC3," "\n" -" UNIFORM_IVEC4," "\n" -" UNIFORM_SAMPLER2D" "\n" -" } ShaderUniformDataType;" "\n" -" typedef enum {" "\n" -" MAP_ALBEDO= 0," "\n" -" MAP_METALNESS = 1," "\n" -" MAP_NORMAL= 2," "\n" -" MAP_ROUGHNESS = 3," "\n" -" MAP_OCCLUSION," "\n" -" MAP_EMISSION," "\n" -" MAP_HEIGHT," "\n" -" MAP_CUBEMAP," "\n" -" MAP_IRRADIANCE," "\n" -" MAP_PREFILTER," "\n" -" MAP_BRDF" "\n" -" } MaterialMapType;" "\n" -"" "\n" -" #define MAP_DIFFUSE MAP_ALBEDO" "\n" -" #define MAP_SPECULAR MAP_METALNESS" "\n" -"" "\n" -" typedef enum {" "\n" -" UNCOMPRESSED_GRAYSCALE = 1," "\n" -" UNCOMPRESSED_GRAY_ALPHA," "\n" -" UNCOMPRESSED_R5G6B5," "\n" -" UNCOMPRESSED_R8G8B8," "\n" -" UNCOMPRESSED_R5G5B5A1," "\n" -" UNCOMPRESSED_R4G4B4A4," "\n" -" UNCOMPRESSED_R8G8B8A8," "\n" -" UNCOMPRESSED_R32," "\n" -" UNCOMPRESSED_R32G32B32," "\n" -" UNCOMPRESSED_R32G32B32A32," "\n" -" COMPRESSED_DXT1_RGB," "\n" -" COMPRESSED_DXT1_RGBA," "\n" -" COMPRESSED_DXT3_RGBA," "\n" -" COMPRESSED_DXT5_RGBA," "\n" -" COMPRESSED_ETC1_RGB," "\n" -" COMPRESSED_ETC2_RGB," "\n" -" COMPRESSED_ETC2_EAC_RGBA," "\n" -" COMPRESSED_PVRT_RGB," "\n" -" COMPRESSED_PVRT_RGBA," "\n" -" COMPRESSED_ASTC_4x4_RGBA," "\n" -" COMPRESSED_ASTC_8x8_RGBA" "\n" -" } PixelFormat;" "\n" -" typedef enum {" "\n" -" FILTER_POINT = 0," "\n" -" FILTER_BILINEAR," "\n" -" FILTER_TRILINEAR," "\n" -" FILTER_ANISOTROPIC_4X," "\n" -" FILTER_ANISOTROPIC_8X," "\n" -" FILTER_ANISOTROPIC_16X," "\n" -" } TextureFilterMode;" "\n" -" typedef enum {" "\n" -" CUBEMAP_AUTO_DETECT = 0," "\n" -" CUBEMAP_LINE_VERTICAL," "\n" -" CUBEMAP_LINE_HORIZONTAL," "\n" -" CUBEMAP_CROSS_THREE_BY_FOUR," "\n" -" CUBEMAP_CROSS_FOUR_BY_THREE," "\n" -" CUBEMAP_PANORAMA" "\n" -" } CubemapLayoutType;" "\n" -" typedef enum {" "\n" -" WRAP_REPEAT = 0," "\n" -" WRAP_CLAMP," "\n" -" WRAP_MIRROR_REPEAT," "\n" -" WRAP_MIRROR_CLAMP" "\n" -" } TextureWrapMode;" "\n" -" typedef enum {" "\n" -" FONT_DEFAULT = 0," "\n" -" FONT_BITMAP," "\n" -" FONT_SDF" "\n" -" } FontType;" "\n" -" typedef enum {" "\n" -" BLEND_ALPHA = 0," "\n" -" BLEND_ADDITIVE," "\n" -" BLEND_MULTIPLIED" "\n" -" } BlendMode;" "\n" -" typedef enum {" "\n" -" GESTURE_NONE = 0," "\n" -" GESTURE_TAP = 1," "\n" -" GESTURE_DOUBLETAP = 2," "\n" -" GESTURE_HOLD= 4," "\n" -" GESTURE_DRAG= 8," "\n" -" GESTURE_SWIPE_RIGHT = 16," "\n" -" GESTURE_SWIPE_LEFT= 32," "\n" -" GESTURE_SWIPE_UP= 64," "\n" -" GESTURE_SWIPE_DOWN= 128," "\n" -" GESTURE_PINCH_IN= 256," "\n" -" GESTURE_PINCH_OUT = 512" "\n" -" } GestureType;" "\n" -" typedef enum {" "\n" -" CAMERA_CUSTOM = 0," "\n" -" CAMERA_FREE," "\n" -" CAMERA_ORBITAL," "\n" -" CAMERA_FIRST_PERSON," "\n" -" CAMERA_THIRD_PERSON" "\n" -" } CameraMode;" "\n" -" typedef enum {" "\n" -" CAMERA_PERSPECTIVE = 0," "\n" -" CAMERA_ORTHOGRAPHIC" "\n" -" } CameraType;" "\n" -" typedef enum {" "\n" -" NPT_9PATCH = 0," "\n" -" NPT_3PATCH_VERTICAL," "\n" -" NPT_3PATCH_HORIZONTAL" "\n" -" } NPatchType;" "\n" -" typedef void (*TraceLogCallback)(int logType, const char *text, va_list args);" "\n" -"" "\n" -" void InitWindow(int width, int height, const char *title);" "\n" -" bool WindowShouldClose(void);" "\n" -" void CloseWindow(void);" "\n" -" bool IsWindowReady(void);" "\n" -" bool IsWindowMinimized(void);" "\n" -" bool IsWindowResized(void);" "\n" -" bool IsWindowHidden(void);" "\n" -" void ToggleFullscreen(void);" "\n" -" void UnhideWindow(void);" "\n" -" void HideWindow(void);" "\n" -" void SetWindowIcon(Image image);" "\n" -" void SetWindowTitle(const char *title);" "\n" -" void SetWindowPosition(int x, int y);" "\n" -" void SetWindowMonitor(int monitor);" "\n" -" void SetWindowMinSize(int width, int height);" "\n" -" void SetWindowSize(int width, int height);" "\n" -" void *GetWindowHandle(void);" "\n" -" int GetScreenWidth(void);" "\n" -" int GetScreenHeight(void);" "\n" -" int GetMonitorCount(void);" "\n" -" int GetMonitorWidth(int monitor);" "\n" -" int GetMonitorHeight(int monitor);" "\n" -" int GetMonitorPhysicalWidth(int monitor);" "\n" -" int GetMonitorPhysicalHeight(int monitor);" "\n" -" Vector2 GetWindowPosition(void);" "\n" -" const char *GetMonitorName(int monitor);" "\n" -" const char *GetClipboardText(void);" "\n" -" void SetClipboardText(const char *text);" "\n" -" void ShowCursor(void);" "\n" -" void HideCursor(void);" "\n" -" bool IsCursorHidden(void);" "\n" -" void EnableCursor(void);" "\n" -" void DisableCursor(void);" "\n" -" void ClearBackground(Color color);" "\n" -" void BeginDrawing(void);" "\n" -" void EndDrawing(void);" "\n" -" void BeginMode2D(Camera2D camera);" "\n" -" void EndMode2D(void);" "\n" -" void BeginMode3D(Camera3D camera);" "\n" -" void EndMode3D(void);" "\n" -" void BeginTextureMode(RenderTexture2D target);" "\n" -" void EndTextureMode(void);" "\n" -" void BeginScissorMode(int x, int y, int width, int height);" "\n" -" void EndScissorMode(void);" "\n" -" Ray GetMouseRay(Vector2 mousePosition, Camera camera);" "\n" -" Matrix GetCameraMatrix(Camera camera);" "\n" -" Matrix GetCameraMatrix2D(Camera2D camera);" "\n" -" Vector2 GetWorldToScreen(Vector3 position, Camera camera);" "\n" -" Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height);" "\n" -" Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera);" "\n" -" Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera);" "\n" -" void SetTargetFPS(int fps);" "\n" -" int GetFPS(void);" "\n" -" float GetFrameTime(void);" "\n" -" double GetTime(void);" "\n" -" int ColorToInt(Color color);" "\n" -" Vector4 ColorNormalize(Color color);" "\n" -" Color ColorFromNormalized(Vector4 normalized);" "\n" -" Vector3 ColorToHSV(Color color);" "\n" -" Color ColorFromHSV(Vector3 hsv);" "\n" -" Color GetColor(int hexValue);" "\n" -" Color Fade(Color color, float alpha);" "\n" -" void SetConfigFlags(unsigned int flags);" "\n" -" void SetTraceLogLevel(int logType);" "\n" -" void SetTraceLogExit(int logType);" "\n" -" void SetTraceLogCallback(TraceLogCallback callback);" "\n" -" void TraceLog(int logType, const char *text, ...);" "\n" -" void TakeScreenshot(const char *fileName);" "\n" -" int GetRandomValue(int min, int max);" "\n" -" unsigned char *LoadFileData(const char *fileName, int *bytesRead);" "\n" -" void SaveFileData(const char *fileName, void *data, int bytesToWrite);" "\n" -" bool FileExists(const char *fileName);" "\n" -" bool IsFileExtension(const char *fileName, const char *ext);" "\n" -" bool DirectoryExists(const char *dirPath);" "\n" -" const char *GetExtension(const char *fileName);" "\n" -" const char *GetFileName(const char *filePath);" "\n" -" const char *GetFileNameWithoutExt(const char *filePath);" "\n" -" const char *GetDirectoryPath(const char *filePath);" "\n" -" const char *GetPrevDirectoryPath(const char *dirPath);" "\n" -" const char *GetWorkingDirectory(void);" "\n" -" char **GetDirectoryFiles(const char *dirPath, int *count);" "\n" -" void ClearDirectoryFiles(void);" "\n" -" bool ChangeDirectory(const char *dir);" "\n" -" bool IsFileDropped(void);" "\n" -" char **GetDroppedFiles(int *count);" "\n" -" void ClearDroppedFiles(void);" "\n" -" long GetFileModTime(const char *fileName);" "\n" -"" "\n" -" unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength);" "\n" -" unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength);" "\n" -" void StorageSaveValue(int position, int value);" "\n" -" int StorageLoadValue(int position);" "\n" -"" "\n" -" void OpenURL(const char *url);" "\n" -" bool IsKeyPressed(int key);" "\n" -" bool IsKeyDown(int key);" "\n" -" bool IsKeyReleased(int key);" "\n" -" bool IsKeyUp(int key);" "\n" -" void SetExitKey(int key);" "\n" -" int GetKeyPressed(void);" "\n" -" bool IsGamepadAvailable(int gamepad);" "\n" -" bool IsGamepadName(int gamepad, const char *name);" "\n" -" const char *GetGamepadName(int gamepad);" "\n" -" bool IsGamepadButtonPressed(int gamepad, int button);" "\n" -" bool IsGamepadButtonDown(int gamepad, int button);" "\n" -" bool IsGamepadButtonReleased(int gamepad, int button);" "\n" -" bool IsGamepadButtonUp(int gamepad, int button);" "\n" -" int GetGamepadButtonPressed(void);" "\n" -" int GetGamepadAxisCount(int gamepad);" "\n" -" float GetGamepadAxisMovement(int gamepad, int axis);" "\n" -" bool IsMouseButtonPressed(int button);" "\n" -" bool IsMouseButtonDown(int button);" "\n" -" bool IsMouseButtonReleased(int button);" "\n" -" bool IsMouseButtonUp(int button);" "\n" -" int GetMouseX(void);" "\n" -" int GetMouseY(void);" "\n" -" Vector2 GetMousePosition(void);" "\n" -" void SetMousePosition(int x, int y);" "\n" -" void SetMouseOffset(int offsetX, int offsetY);" "\n" -" void SetMouseScale(float scaleX, float scaleY);" "\n" -" int GetMouseWheelMove(void);" "\n" -" int GetTouchX(void);" "\n" -" int GetTouchY(void);" "\n" -" Vector2 GetTouchPosition(int index);" "\n" -" void SetGesturesEnabled(unsigned int gestureFlags);" "\n" -" bool IsGestureDetected(int gesture);" "\n" -" int GetGestureDetected(void);" "\n" -" int GetTouchPointsCount(void);" "\n" -" float GetGestureHoldDuration(void);" "\n" -" Vector2 GetGestureDragVector(void);" "\n" -" float GetGestureDragAngle(void);" "\n" -" Vector2 GetGesturePinchVector(void);" "\n" -" float GetGesturePinchAngle(void);" "\n" -" void SetCameraMode(Camera camera, int mode);" "\n" -" void UpdateCamera(Camera *camera);" "\n" -"" "\n" -" void SetCameraPanControl(int panKey);" "\n" -" void SetCameraAltControl(int altKey);" "\n" -" void SetCameraSmoothZoomControl(int szKey);" "\n" -" void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey);" "\n" -" void DrawPixel(int posX, int posY, Color color);" "\n" -" void DrawPixelV(Vector2 position, Color color);" "\n" -" void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color);" "\n" -" void DrawLineV(Vector2 startPos, Vector2 endPos, Color color);" "\n" -" void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color);" "\n" -" void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color);" "\n" -" void DrawLineStrip(Vector2 *points, int numPoints, Color color);" "\n" -" void DrawCircle(int centerX, int centerY, float radius, Color color);" "\n" -" void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color);" "\n" -" void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color);" "\n" -" void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2);" "\n" -" void DrawCircleV(Vector2 center, float radius, Color color);" "\n" -" void DrawCircleLines(int centerX, int centerY, float radius, Color color);" "\n" -" void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color);" "\n" -" void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color);" "\n" -" void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color);" "\n" -" void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color);" "\n" -" void DrawRectangle(int posX, int posY, int width, int height, Color color);" "\n" -" void DrawRectangleV(Vector2 position, Vector2 size, Color color);" "\n" -" void DrawRectangleRec(Rectangle rec, Color color);" "\n" -" void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);" "\n" -" void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);" "\n" -" void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);" "\n" -" void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4);" "\n" -" void DrawRectangleLines(int posX, int posY, int width, int height, Color color);" "\n" -" void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color);" "\n" -" void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color);" "\n" -" void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color);" "\n" -" void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);" "\n" -" void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);" "\n" -" void DrawTriangleFan(Vector2 *points, int numPoints, Color color);" "\n" -" void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color);" "\n" -" void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);" "\n" -" void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color);" "\n" -" bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2);" "\n" -" bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2);" "\n" -" bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec);" "\n" -" Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2);" "\n" -" bool CheckCollisionPointRec(Vector2 point, Rectangle rec);" "\n" -" bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius);" "\n" -" bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3);" "\n" -" Image LoadImage(const char *fileName);" "\n" -" Image LoadImageEx(Color *pixels, int width, int height);" "\n" -" Image LoadImagePro(void *data, int width, int height, int format);" "\n" -" Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize);" "\n" -" void ExportImage(Image image, const char *fileName);" "\n" -" void ExportImageAsCode(Image image, const char *fileName);" "\n" -" Texture2D LoadTexture(const char *fileName);" "\n" -" Texture2D LoadTextureFromImage(Image image);" "\n" -" TextureCubemap LoadTextureCubemap(Image image, int layoutType);" "\n" -" RenderTexture2D LoadRenderTexture(int width, int height);" "\n" -" void UnloadImage(Image image);" "\n" -" void UnloadTexture(Texture2D texture);" "\n" -" void UnloadRenderTexture(RenderTexture2D target);" "\n" -" Color *GetImageData(Image image);" "\n" -" Vector4 *GetImageDataNormalized(Image image);" "\n" -" Rectangle GetImageAlphaBorder(Image image, float threshold);" "\n" -" int GetPixelDataSize(int width, int height, int format);" "\n" -" Image GetTextureData(Texture2D texture);" "\n" -" Image GetScreenData(void);" "\n" -" void UpdateTexture(Texture2D texture, const void *pixels);" "\n" -" Image ImageCopy(Image image);" "\n" -" Image ImageFromImage(Image image, Rectangle rec);" "\n" -" void ImageToPOT(Image *image, Color fillColor);" "\n" -" void ImageFormat(Image *image, int newFormat);" "\n" -" void ImageAlphaMask(Image *image, Image alphaMask);" "\n" -" void ImageAlphaClear(Image *image, Color color, float threshold);" "\n" -" void ImageAlphaCrop(Image *image, float threshold);" "\n" -" void ImageAlphaPremultiply(Image *image);" "\n" -" void ImageCrop(Image *image, Rectangle crop);" "\n" -" void ImageResize(Image *image, int newWidth, int newHeight);" "\n" -" void ImageResizeNN(Image *image, int newWidth,int newHeight);" "\n" -" void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color);" "\n" -" void ImageMipmaps(Image *image);" "\n" -" void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp);" "\n" -" Color *ImageExtractPalette(Image image, int maxPaletteSize, int *extractCount);" "\n" -" Image ImageText(const char *text, int fontSize, Color color);" "\n" -" Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint);" "\n" -" void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint);" "\n" -" void ImageDrawRectangle(Image *dst, Rectangle rec, Color color);" "\n" -" void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color);" "\n" -" void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color);" "\n" -" void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color);" "\n" -" void ImageFlipVertical(Image *image);" "\n" -" void ImageFlipHorizontal(Image *image);" "\n" -" void ImageRotateCW(Image *image);" "\n" -" void ImageRotateCCW(Image *image);" "\n" -" void ImageColorTint(Image *image, Color color);" "\n" -" void ImageColorInvert(Image *image);" "\n" -" void ImageColorGrayscale(Image *image);" "\n" -" void ImageColorContrast(Image *image, float contrast);" "\n" -" void ImageColorBrightness(Image *image, int brightness);" "\n" -" void ImageColorReplace(Image *image, Color color, Color replace);" "\n" -" Image GenImageColor(int width, int height, Color color);" "\n" -" Image GenImageGradientV(int width, int height, Color top, Color bottom);" "\n" -" Image GenImageGradientH(int width, int height, Color left, Color right);" "\n" -" Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer);" "\n" -" Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2);" "\n" -" Image GenImageWhiteNoise(int width, int height, float factor);" "\n" -" Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale);" "\n" -" Image GenImageCellular(int width, int height, int tileSize);" "\n" -" void GenTextureMipmaps(Texture2D *texture);" "\n" -" void SetTextureFilter(Texture2D texture, int filterMode);" "\n" -" void SetTextureWrap(Texture2D texture, int wrapMode);" "\n" -" void DrawTexture(Texture2D texture, int posX, int posY, Color tint);" "\n" -" void DrawTextureV(Texture2D texture, Vector2 position, Color tint);" "\n" -" void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint);" "\n" -" void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint);" "\n" -" void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint);" "\n" -" void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint);" "\n" -" void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint);" "\n" -" Font GetFontDefault(void);" "\n" -" Font LoadFont(const char *fileName);" "\n" -" Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount);" "\n" -" Font LoadFontFromImage(Image image, Color key, int firstChar);" "\n" -" CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type);" "\n" -" Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod);" "\n" -" void UnloadFont(Font font);" "\n" -" void DrawFPS(int posX, int posY);" "\n" -" void DrawText(const char *text, int posX, int posY, int fontSize, Color color);" "\n" -" void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint);" "\n" -" void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint);" "\n" -" void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint," "\n" -" int selectStart, int selectLength, Color selectTint, Color selectBackTint);" "\n" -" void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint);" "\n" -" int MeasureText(const char *text, int fontSize);" "\n" -" Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);" "\n" -" int GetGlyphIndex(Font font, int codepoint);" "\n" -" int TextCopy(char *dst, const char *src);" "\n" -" bool TextIsEqual(const char *text1, const char *text2);" "\n" -" unsigned int TextLength(const char *text);" "\n" -" const char *TextFormat(const char *text, ...);" "\n" -" const char *TextSubtext(const char *text, int position, int length);" "\n" -" char *TextReplace(char *text, const char *replace, const char *by);" "\n" -" char *TextInsert(const char *text, const char *insert, int position);" "\n" -" const char *TextJoin(const char **textList, int count, const char *delimiter);" "\n" -" const char **TextSplit(const char *text, char delimiter, int *count);" "\n" -" void TextAppend(char *text, const char *append, int *position);" "\n" -" int TextFindIndex(const char *text, const char *find);" "\n" -" const char *TextToUpper(const char *text);" "\n" -" const char *TextToLower(const char *text);" "\n" -" const char *TextToPascal(const char *text);" "\n" -" int TextToInteger(const char *text);" "\n" -" char *TextToUtf8(int *codepoints, int length);" "\n" -" int *GetCodepoints(const char *text, int *count);" "\n" -" int GetCodepointsCount(const char *text);" "\n" -" int GetNextCodepoint(const char *text, int *bytesProcessed);" "\n" -" const char *CodepointToUtf8(int codepoint, int *byteLength);" "\n" -" void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color);" "\n" -" void DrawPoint3D(Vector3 position, Color color);" "\n" -" void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color);" "\n" -" void DrawCube(Vector3 position, float width, float height, float length, Color color);" "\n" -" void DrawCubeV(Vector3 position, Vector3 size, Color color);" "\n" -" void DrawCubeWires(Vector3 position, float width, float height, float length, Color color);" "\n" -" void DrawCubeWiresV(Vector3 position, Vector3 size, Color color);" "\n" -" void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color);" "\n" -" void DrawSphere(Vector3 centerPos, float radius, Color color);" "\n" -" void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color);" "\n" -" void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color);" "\n" -" void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color);" "\n" -" void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color);" "\n" -" void DrawPlane(Vector3 centerPos, Vector2 size, Color color);" "\n" -" void DrawRay(Ray ray, Color color);" "\n" -" void DrawGrid(int slices, float spacing);" "\n" -" void DrawGizmo(Vector3 position);" "\n" -" Model LoadModel(const char *fileName);" "\n" -" Model LoadModelFromMesh(Mesh mesh);" "\n" -" void UnloadModel(Model model);" "\n" -" Mesh *LoadMeshes(const char *fileName, int *meshCount);" "\n" -" void ExportMesh(Mesh mesh, const char *fileName);" "\n" -" void UnloadMesh(Mesh mesh);" "\n" -" Material *LoadMaterials(const char *fileName, int *materialCount);" "\n" -" Material LoadMaterialDefault(void);" "\n" -" void UnloadMaterial(Material material);" "\n" -" void SetMaterialTexture(Material *material, int mapType, Texture2D texture);" "\n" -" void SetModelMeshMaterial(Model *model, int meshId, int materialId);" "\n" -" ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount);" "\n" -" void UpdateModelAnimation(Model model, ModelAnimation anim, int frame);" "\n" -" void UnloadModelAnimation(ModelAnimation anim);" "\n" -" bool IsModelAnimationValid(Model model, ModelAnimation anim);" "\n" -" Mesh GenMeshPoly(int sides, float radius);" "\n" -" Mesh GenMeshPlane(float width, float length, int resX, int resZ);" "\n" -" Mesh GenMeshCube(float width, float height, float length);" "\n" -" Mesh GenMeshSphere(float radius, int rings, int slices);" "\n" -" Mesh GenMeshHemiSphere(float radius, int rings, int slices);" "\n" -" Mesh GenMeshCylinder(float radius, float height, int slices);" "\n" -" Mesh GenMeshTorus(float radius, float size, int radSeg, int sides);" "\n" -" Mesh GenMeshKnot(float radius, float size, int radSeg, int sides);" "\n" -" Mesh GenMeshHeightmap(Image heightmap, Vector3 size);" "\n" -" Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);" "\n" -" BoundingBox MeshBoundingBox(Mesh mesh);" "\n" -" void MeshTangents(Mesh *mesh);" "\n" -" void MeshBinormals(Mesh *mesh);" "\n" -" void DrawModel(Model model, Vector3 position, float scale, Color tint);" "\n" -" void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint);" "\n" -" void DrawModelWires(Model model, Vector3 position, float scale, Color tint);" "\n" -" void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint);" "\n" -" void DrawBoundingBox(BoundingBox box, Color color);" "\n" -" void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint);" "\n" -" void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint);" "\n" -" bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB);" "\n" -" bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);" "\n" -" bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius);" "\n" -" bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius);" "\n" -" bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *collisionPoint);" "\n" -" bool CheckCollisionRayBox(Ray ray, BoundingBox box);" "\n" -" RayHitInfo GetCollisionRayModel(Ray ray, Model model);" "\n" -" RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3);" "\n" -" RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);" "\n" -" char *LoadText(const char *fileName);" "\n" -" Shader LoadShader(const char *vsFileName, const char *fsFileName);" "\n" -" Shader LoadShaderCode(const char *vsCode, const char *fsCode);" "\n" -" void UnloadShader(Shader shader);" "\n" -" Shader GetShaderDefault(void);" "\n" -" Texture2D GetTextureDefault(void);" "\n" -" Texture2D GetShapesTexture(void);" "\n" -" Rectangle GetShapesTextureRec(void);" "\n" -" void SetShapesTexture(Texture2D texture, Rectangle source);" "\n" -" int GetShaderLocation(Shader shader, const char *uniformName);" "\n" -" void SetShaderValue(Shader shader, int uniformLoc, const void *value, int uniformType);" "\n" -" void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int uniformType, int count);" "\n" -" void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat);" "\n" -" void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture);" "\n" -" void SetMatrixProjection(Matrix proj);" "\n" -" void SetMatrixModelview(Matrix view);" "\n" -" Matrix GetMatrixModelview(void);" "\n" -" Matrix GetMatrixProjection(void);" "\n" -" Texture2D GenTextureCubemap(Shader shader, Texture2D map, int size);" "\n" -" Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size);" "\n" -" Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size);" "\n" -" Texture2D GenTextureBRDF(Shader shader, int size);" "\n" -" void BeginShaderMode(Shader shader);" "\n" -" void EndShaderMode(void);" "\n" -" void BeginBlendMode(int mode);" "\n" -" void EndBlendMode(void);" "\n" -" void InitVrSimulator(void);" "\n" -" void CloseVrSimulator(void);" "\n" -" void UpdateVrTracking(Camera *camera);" "\n" -" void SetVrConfiguration(VrDeviceInfo info, Shader distortion);" "\n" -" bool IsVrSimulatorReady(void);" "\n" -" void ToggleVrMode(void);" "\n" -" void BeginVrDrawing(void);" "\n" -" void EndVrDrawing(void);" "\n" -" void InitAudioDevice(void);" "\n" -" void CloseAudioDevice(void);" "\n" -" bool IsAudioDeviceReady(void);" "\n" -" void SetMasterVolume(float volume);" "\n" -" Wave LoadWave(const char *fileName);" "\n" -" Sound LoadSound(const char *fileName);" "\n" -" Sound LoadSoundFromWave(Wave wave);" "\n" -" void UpdateSound(Sound sound, const void *data, int samplesCount);" "\n" -" void UnloadWave(Wave wave);" "\n" -" void UnloadSound(Sound sound);" "\n" -" void ExportWave(Wave wave, const char *fileName);" "\n" -" void ExportWaveAsCode(Wave wave, const char *fileName);" "\n" -" void PlaySound(Sound sound);" "\n" -" void StopSound(Sound sound);" "\n" -" void PauseSound(Sound sound);" "\n" -" void ResumeSound(Sound sound);" "\n" -" void PlaySoundMulti(Sound sound);" "\n" -" void StopSoundMulti(void);" "\n" -" int GetSoundsPlaying(void);" "\n" -" bool IsSoundPlaying(Sound sound);" "\n" -" void SetSoundVolume(Sound sound, float volume);" "\n" -" void SetSoundPitch(Sound sound, float pitch);" "\n" -" void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);" "\n" -" Wave WaveCopy(Wave wave);" "\n" -" void WaveCrop(Wave *wave, int initSample, int finalSample);" "\n" -" float *GetWaveData(Wave wave);" "\n" -" Music LoadMusicStream(const char *fileName);" "\n" -" void UnloadMusicStream(Music music);" "\n" -" void PlayMusicStream(Music music);" "\n" -" void UpdateMusicStream(Music music);" "\n" -" void StopMusicStream(Music music);" "\n" -" void PauseMusicStream(Music music);" "\n" -" void ResumeMusicStream(Music music);" "\n" -" bool IsMusicPlaying(Music music);" "\n" -" void SetMusicVolume(Music music, float volume);" "\n" -" void SetMusicPitch(Music music, float pitch);" "\n" -" void SetMusicLoopCount(Music music, int count);" "\n" -" float GetMusicTimeLength(Music music);" "\n" -" float GetMusicTimePlayed(Music music);" "\n" -" AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels);" "\n" -" void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount);" "\n" -" void CloseAudioStream(AudioStream stream);" "\n" -" bool IsAudioStreamProcessed(AudioStream stream);" "\n" -" void PlayAudioStream(AudioStream stream);" "\n" -" void PauseAudioStream(AudioStream stream);" "\n" -" void ResumeAudioStream(AudioStream stream);" "\n" -" bool IsAudioStreamPlaying(AudioStream stream);" "\n" -" void StopAudioStream(AudioStream stream);" "\n" -" void SetAudioStreamVolume(AudioStream stream, float volume);" "\n" -" void SetAudioStreamPitch(AudioStream stream, float pitch);" "\n" -" void SetAudioStreamBufferSizeDefault(int size);" "\n" -"]]" "\n" -"" "\n" -"-- colors" "\n" -"local function new_color(r, g, b, a)" "\n" -" local c = ffi.new(\"Color\")" "\n" -" c.r = r" "\n" -" c.g = g" "\n" -" c.b = b" "\n" -" c.a = a" "\n" -" return c" "\n" -"end" "\n" -"" "\n" -"raylib.LIGHTGRAY = new_color(200, 200, 200, 255)" "\n" -"raylib.GRAY = new_color(130, 130, 130, 255)" "\n" -"raylib.DARKGRAY = new_color(80, 80, 80, 255)" "\n" -"raylib.YELLOW = new_color(253, 249, 0, 255)" "\n" -"raylib.GOLD = new_color(255, 203, 0, 255)" "\n" -"raylib.ORANGE = new_color(255, 161, 0, 255)" "\n" -"raylib.PINK = new_color(255, 109, 194, 255)" "\n" -"raylib.RED = new_color(230, 41, 55, 255)" "\n" -"raylib.MAROON = new_color(190, 33, 55, 255)" "\n" -"raylib.GREEN = new_color(0, 228, 48, 255)" "\n" -"raylib.LIME = new_color(0, 158, 47, 255)" "\n" -"raylib.DARKGREEN = new_color(0, 117, 44, 255)" "\n" -"raylib.SKYBLUE = new_color(102, 191, 255, 255)" "\n" -"raylib.BLUE = new_color(0, 121, 241, 255)" "\n" -"raylib.DARKBLUE = new_color(0, 82, 172, 255)" "\n" -"raylib.PURPLE = new_color(200, 122, 255, 255)" "\n" -"raylib.VIOLET = new_color(135, 60, 190, 255)" "\n" -"raylib.DARKPURPLE = new_color(112, 31, 126, 255)" "\n" -"raylib.BEIGE = new_color(211, 176, 131, 255)" "\n" -"raylib.BROWN = new_color(127, 106, 79, 255)" "\n" -"raylib.DARKBROWN = new_color(76, 63, 47, 255)" "\n" -"raylib.WHITE = new_color(255, 255, 255, 255)" "\n" -"raylib.BLACK = new_color(0, 0, 0, 255)" "\n" -"raylib.BLANK = new_color(0, 0, 0, 0)" "\n" -"raylib.MAGENTA = new_color(255, 0, 255, 255)" "\n" -"raylib.RAYWHITE = new_color(245, 245, 245, 255)" "\n" -"" "\n" -"raylib.__index = function (self, key)" "\n" -" return raylib_so[key]" "\n" -"end" "\n" -"" "\n" -"raylib.__newindex = function ()" "\n" -" error \"raylib table is readonly\"" "\n" -"end" "\n" -"" "\n" -"rl = setmetatable(raylib, raylib)" "\n" -"raylib = rl" "\n" -"local load = loadstring" "\n" -"" "\n" -"if raylua then" "\n" -" -- Change the second loader to load files using raylua.loadfiles" "\n" -" package.loaders[2] = function (name)" "\n" -" for path in package.path:gmatch \"([^;]+);?\" do" "\n" -" path = path:gsub(\"?\", name)" "\n" -"" "\n" -" local status, content = raylua.loadfiles(path)" "\n" -" if status then" "\n" -" local f, err = load(content)" "\n" -" assert(f, err)" "\n" -"" "\n" -" return f" "\n" -" end" "\n" -" end" "\n" -"" "\n" -" return nil" "\n" -" end" "\n" -"end" "\n" -"" "\n" -"require \"main\"" "\n" -; \ No newline at end of file diff --git a/src/raylua_boot.h b/src/raylua_boot.h deleted file mode 100644 index 36f543e..0000000 --- a/src/raylua_boot.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef H_RAYLUA_BOOT -#define H_RAYLUA_BOOT - -extern const char *raylua_boot; - -#endif /* H_RAYLUA_BOOT */ diff --git a/src/raylua_builder.c b/src/raylua_builder.c index 8d957c9..eceaa7c 100644 --- a/src/raylua_builder.c +++ b/src/raylua_builder.c @@ -25,17 +25,19 @@ #ifdef WIN32 #include "lib/dirent.h" #define stat _stat - -#ifndef strcasecmp -#define strcasecmp strcmpi -#endif #else #include #endif #include "lib/miniz.h" -#ifndef WRAY_NO_BUILDER +#include +#include +#include + +#ifndef RAYLUA_NO_BUILDER +#include "autogen/builder.c" + static void append_file(FILE *dst, FILE *src) { size_t count; @@ -46,125 +48,151 @@ static void append_file(FILE *dst, FILE *src) } 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; - int result = stat(input_path, &st); - if (result) { - printf("%s: Can't get file information.\n", input_path); - return 1; +typedef struct raylua_builder { + mz_zip_archive zip; + FILE *file; + fpos_t offset; +} 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); - 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; - } + builder->file = f; FILE *self = fopen(self_path, "rb"); - if (self == NULL) { - puts("Can't open itself"); + if (!self) { + 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; } - /* Copy self into output. */ - append_file(output, self); - fclose(self); + if (S_ISREG(st.st_mode)) + lua_pushstring(L, "file"); + 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. */ - fpos_t offset; - fgetpos(output, &offset); + return 1; +} - if (S_ISREG(st.st_mode)) { - /* Consider input as a bare bundle, just append file to get output. */ - FILE *input = fopen(input_path, "rb"); +static int list_dir(lua_State *L) +{ + const char *path = luaL_checkstring(L, -1); + DIR *d = opendir(path); - append_file(output, input); - 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 (!d) + return 0; - if (!mz_zip_writer_init_cfile(&zip, output, 0)) { - puts("Can't initialize zip writter inside output."); - return 0; - } + struct dirent *entry; + size_t count = 0; - DIR *d = opendir(input_path); - chdir(input_path); + lua_newtable(L); - struct dirent *entry; - - /* NOTE: Hardcoded 512 path limit. */ - char dest_path[512]; - - while ((entry = readdir(d))) { - char *original_path = entry->d_name; - memset(dest_path, 0, 512); - - 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); - - puts("Finalizing zip archive..."); - - if (!mz_zip_writer_finalize_archive(&zip)) - puts("Can't finalize archive."); - - mz_zip_end(&zip); - - // Write offset - fwrite(&offset, sizeof(fpos_t), 1, output); - fclose(output); + while ((entry = readdir(d))) { + lua_pushstring(L, entry->d_name); + lua_rawseti(L, -2, count++); } - free(output_path); + closedir(d); + return 1; +} + +int raylua_build_executable(const char *self, const char *input) +{ + lua_State *L = luaL_newstate(); + luaL_openlibs(L); + + lua_pushcfunction(L, get_type); + lua_setglobal(L, "get_type"); + + lua_pushcfunction(L, list_dir); + lua_setglobal(L, "list_dir"); + + lua_pushlightuserdata(L, append_file_offset); + lua_setglobal(L, "append_file_offset"); + + 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); + return 0; } #endif diff --git a/src/raylua_builder.lua b/src/raylua_builder.lua new file mode 100644 index 0000000..3af75fd --- /dev/null +++ b/src/raylua_builder.lua @@ -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" diff --git a/src/raylua_e.c b/src/raylua_e.c index 1365f2e..d7c1a5d 100644 --- a/src/raylua_e.c +++ b/src/raylua_e.c @@ -14,7 +14,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* Wray embedded executable */ +/* Raylua embedded executable */ #include #include #include @@ -23,11 +23,11 @@ #include #include -#include "raylua_boot.h" +#include "raylua.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); #endif @@ -97,10 +97,12 @@ int main(int argc, const char **argv) } lua_State *L = luaL_newstate(); + luaL_openlibs(L); if (L == NULL) puts("[RAYLUA] Unable to initialize Lua."); + /* Populate arg. */ lua_newtable(L); int i = 0; @@ -113,10 +115,7 @@ int main(int argc, const char **argv) lua_setglobal(L, "arg"); - lua_pushcfunction(L, raylua_loadfile); - lua_setglobal(L, "raylua_loadfile"); - - luaL_dostring(L, raylua_boot); + raylua_boot(L, raylua_loadfile); lua_close(L); return 0; } diff --git a/src/raylua_s.c b/src/raylua_s.c index e8912a7..d3219ff 100644 --- a/src/raylua_s.c +++ b/src/raylua_s.c @@ -18,7 +18,7 @@ #include #include -#include "raylua_boot.h" +#include "raylua.h" #include #include @@ -27,6 +27,7 @@ int main(int argc, const char **argv) { lua_State *L = luaL_newstate(); + luaL_openlibs(L); if (L == NULL) puts("[RAYLUA] Unable to initialize Lua."); @@ -43,7 +44,7 @@ int main(int argc, const char **argv) lua_setglobal(L, "arg"); - luaL_dostring(L, raylua_boot); + raylua_boot(L, NULL); lua_close(L); return 0; } diff --git a/tools/api.h b/tools/api.h new file mode 100644 index 0000000..57056d4 --- /dev/null +++ b/tools/api.h @@ -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); diff --git a/tools/genbind.lua b/tools/genbind.lua new file mode 100644 index 0000000..400e9ff --- /dev/null +++ b/tools/genbind.lua @@ -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()