Remove static flag on platforms other than windows

This commit is contained in:
Alexander Klingenbeck 2023-08-02 20:23:35 +02:00 committed by iongion
parent 2ef1a00038
commit 3936f054f8
20 changed files with 2517 additions and 4540 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
build/
builddir/
runtime/
shaderc
rayjs

39
CHANGELOG.md Normal file
View File

@ -0,0 +1,39 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
Add your changes after this line, example:
`## [MAJOR.MINOR.REVISION-STABILITY] - DD.MM.YYYY`
## [1.0.1-dev] - 17.03.2024
### Added
- Changes specifier in [CHANGELOG.md](./CHANGELOG.md)
- Version specifier in [VERSION](./VERSION)
- Node version specifier in [.nvmrc](./bindings/.nvmrc) to allow compatibility
- Simple shell script to invoke the bindings generator in [`generate-bindings.sh`](./generate-bindings.sh)
- Simple shell script to invoke the build process in one step in [`build-rayjs.sh`](./build-rayjs.sh)
### Changed
- Upgraded raylib to [9a8d73e](https://github.com/raysan5/raylib/commit/9a8d73e6c32514275a0ba53fe528bcb7c2693e27)
- Upgraded raygui to [82ba2b1](https://github.com/raysan5/raygui/commit/82ba2b1a783208d6a1f80d8977d796635260c161)
- Upgraded quickjs to [6a89d7c](https://github.com/bellard/quickjs/commit/6a89d7c27099be84e5312a7ec73205d6a7abe1b4)
- Generated new bindings
- Upgraded all packages of the bindings generator
### Removed
- Removed the need of transpilation when using the bindings generator (this is useful to debug generator issues as ts-node can represent errors as they are, without the need of source maps)
- Removed webpack requirement
### Fixed
- Markdown linting errors

View File

@ -6,6 +6,10 @@ IF (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
ENDIF()
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DCONFIG_BIGNUM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -DCONFIG_BIGNUM")
endif (UNIX)
project(rayjs)
@ -17,14 +21,16 @@ message("=== Configure QuickJS ===")
set(quickjs_version 2021-03-27)
set(quickjs_sources_root ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/quickjs)
set(quickjs_sources
${quickjs_sources_root}/quickjs.h
#${quickjs_sources_root}/quickjs-libc.h
${quickjs_sources_root}/quickjs.c
${quickjs_sources_root}/libregexp.c
${quickjs_sources_root}/libunicode.c
${quickjs_sources_root}/libbf.c
${quickjs_sources_root}/cutils.c
#${quickjs_sources_root}/quickjs-libc.c
${quickjs_sources_root}/cutils.h
${quickjs_sources_root}/libbf.c
${quickjs_sources_root}/libbf.h
${quickjs_sources_root}/libregexp.c
${quickjs_sources_root}/libregexp.h
${quickjs_sources_root}/libunicode.h
${quickjs_sources_root}/libunicode.c
${quickjs_sources_root}/quickjs.h
${quickjs_sources_root}/quickjs.c
)
add_library(quickjs STATIC
${quickjs_sources}

View File

@ -1,22 +1,29 @@
![rayjs logo](./doc/logo.png)
# rayjs - Javascript + Raylib
QuickJS based Javascript bindings for raylib in a single ~3mb executable
## What is this?
rayjs is small ES2020 compliant Javascript interpreter based on [QuickJS](https://bellard.org/quickjs/) with bindings for [Raylib](https://www.raylib.com/). You can use it to develop desktop games with Javascript.
## What this is not
rayjs is not a binding for NodeJS nor is it running in the browser (yet). It's comes with its own Javascript engine (QuickJS) similar to how NodeJS comes with the V8 engine. That makes it much easier to run and distribute rayjs programs as all you need to run a program / game is the small rayjs executable. No installation, no dlls or additional files are needed.
## Features
* Compiles into a single, small executable without any dependencies for easy distribution
* Use modern Javascript features like classes or async/await
* In-depth auto-complete with definitions for the whole API
## Getting started
1. Download the binary for your platform from the [release section](https://github.com/mode777/rayjs/releases).
2. Unzip the executable to a folder and create a new text file in the same folder. Rename the file to `main.js`
3. Open the file with a text-editor (e.g. Notepad) and add the following code
```javascript
const screenWidth = 800;
const screenHeight = 450;
@ -35,11 +42,14 @@ rayjs is not a binding for NodeJS nor is it running in the browser (yet). It's c
}
closeWindow();
```
4. Run the `rayjs` executable
5. Congratulations, you have created your first rayjs app.
## Running code
rayjs will run code in three different modes
Rayjs will run code in three different modes
1. If no parameter is given it will look for a file called `main.js` in the executable directory
2. It will run a given Javascript file given as a command line argument like this `rayjs <filename>`
3. It will look for a file called `main.js` in a folder given as a command line argument like this `rayjs <foldername>`
@ -50,18 +60,18 @@ The directory of the main Javascript module will also be the working directory o
The following raylib APIs are supported so far (with a few exceptions):
- core (no VR support yet)
- shapes
- textures
- text (no support for GlyphInfo yet)
- models (no animation support)
- shaders
- audio
- raymath
- rcamera
- rlights
- raygui
- reasings
* core (no VR support yet)
* shapes
* textures
* text (no support for GlyphInfo yet)
* models (no animation support)
* shaders
* audio
* raymath
* rcamera
* rlights
* raygui
* reasings
Similar to including a header in C and for your convenience, all types/functions are provided globally. They are additionally available in a module called 'raylib'
@ -70,6 +80,7 @@ To check which API functions are not available (yet) check `/bindings/src/index.
## Additional APIs
Rayjs comes with some additional functionality on top of raylib to make writing raylib code with Javascript easier
```typescript
/** Replace material in slot materialIndex (Material is NOT unloaded) */
declare function setModelMaterial(model: Model, materialIndex: number, material: Material): void;
@ -92,6 +103,7 @@ Additionally it also comes with bindings to [lightmapper.h](https://github.com/a
## Auto-Complete / Intellisense
rayjs comes with full auto-complete support in the form of the definitions file `lib.raylib.d.ts`. These will work with Typescript and Javascript. In order to use them with Javascript you should create a Typescript configuration file in the project root (even if you are not using Typescript) called `tsconfig.json` with the following configuration
```json
{
"compilerOptions": {
@ -103,8 +115,9 @@ rayjs comes with full auto-complete support in the form of the definitions file
}
}
```
After that put the `lib.raylib.d.ts` file in the same folder and optionally restart your IDE. Auto-complete should be working:
![](doc/auto-complete.png)
![Autocomplete example](doc/auto-complete.png)
## Examples
@ -112,65 +125,77 @@ Some official raylib examples were already ported to Javascript and can be found
Additional examples are described here.
```
```shell
./rayjs examples/js_example_project
```
Barebones example project on how to structure a project that uses Javascript
```
```shell
./rayjs examples/js_mesh_generation.js
```
Shows how to create a mesh from Javascript ArrayBuffers
```
```shell
./rayjs examples/shaders/js_shaders_gradient_lighting.js
```
Creates a gradient and uses it as lighting for a 3d scene
```
```shell
./rayjs examples/ts_dungeon
```
Small example game that uses Typescript with Webpack for transpilation and bundling
```
```shell
./rayjs examples/ts_game
```
Example how to integrate existing JS libraries. This example integrates the Inkjs library to compile and play a game written in the Ink interactive fiction language.
### Lightmapper usage
Rayjs integrates the [lightmapper.h](https://github.com/ands/lightmapper/tree/master) library to render baked lighting.
The example demonstrates it's usage.
```
```shell
./rayjs examples/js_lightmapper.js
```
Meshes must have unwrapped lightmap uvs in the second UV channel.
![](2023-07-20-13-08-52.png)
![Example lightmap](2023-07-20-13-08-52.png)
The example uses an environment that is uniform white which will lead to baking pure ambient occlusion. To bake other light sources, lower the amount of ambient lighting and everything that is rendered with a color other than black will become an emissive lightsource during baking. Rendering will just work as usual and custom shaders are supported. E.g. while the raylib default shader does not support color intensities greater than 1.0, the lightmapper does support them for higher intensity lighting.
The example will try to bake lighting alongside the render loop which is still buggy and leads to artifacts. Baking before rendering works better.
## Performance
QuickJS is one of the [faster JS interpreters](https://bellard.org/quickjs/bench.html). I'm getting about 13000 bunnys in the unmodified bunnmark before dropping any frames on my 2020 Macbook Air M1 which seems pretty good.
QuickJS is one of the [faster JS interpreters](https://bellard.org/quickjs/bench.html). I'm getting about 13000 bunnies in the unmodified bunnmark before dropping any frames on my 2020 Macbook Air M1 which seems pretty good.
![Bunnymark](doc/bunny.png)
## Building
Here are some basic steps if you want to compile rayjs yourself.
You should use CMake for building. **Please note that QuickJS needs Mingw in order to compile correctly on Windows**
### Check out required files
```bash
```shell
git clone https://github.com/mode777/rayjs.git
git submodule update --init --recursive
```
### Build with cmake
Make sure you have cmake installed and in your path.
```bash
```shell
cd rayjs
mkdir build
cd build
cmake ..
make
./build-rayjs.sh
```
See [`build-rayjs.sh`](./build-rayjs.sh) to understand how to integrate

1
VERSION Normal file
View File

@ -0,0 +1 @@
1.0.1-dev

1
bindings/.nvmrc Normal file
View File

@ -0,0 +1 @@
20

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,16 @@
{
"name": "bindings",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js",
"watch": "webpack --watch --config webpack.config.js --mode development"
"bindings:generate": "ts-node ./src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"webpack": "^5.82.0",
"webpack-cli": "^5.0.2"
"dependencies": {
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
}
}

View File

@ -1,4 +1,5 @@
import { readFileSync, writeFileSync } from "fs";
import path from "path";
import { RayLibApi, RayLibFunction, RayLibStruct } from "./interfaces";
import { RayLibHeader } from "./raylib-header";
import { HeaderParser } from "./header-parser";
@ -24,6 +25,8 @@ function ignore(name: string){
}
function main() {
const baseDir = path.join(__dirname, "../../");
process.chdir(baseDir);
// Load the pre-generated raylib api
api = <RayLibApi>JSON.parse(readFileSync("thirdparty/raylib/parser/output/raylib_api.json", 'utf8'))
@ -330,7 +333,6 @@ function main(){
vResolution: { set: true, get: true },
hScreenSize: { set: true, get: true },
vScreenSize: { set: true, get: true },
vScreenCenter: { set: true, get: true },
eyeToScreenDistance: { set: true, get: true },
lensSeparationDistance: { set: true, get: true },
interpupillaryDistance: { set: true, get: true },

View File

@ -75,15 +75,24 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> extend
return sub
}
jsToC(type: string, name: string, src: string, classIds: StructLookup = {}, supressDeclaration = false, typeAlias?: string){
switch (typeAlias ?? type) {
jsToC(type: string, name: string, src: string, classIds: StructLookup = {}, suppressDeclaration = false, typeAlias?: string){
let typeSpecifier = typeAlias ?? type;
if (typeSpecifier !== undefined) {
typeSpecifier = typeSpecifier.replace(" *", "*"); // allow specifiers like type * and type* to be the same
}
switch (typeSpecifier) {
// Array Buffer
case "const void*":
case "void*":
case "bool*":
case "int*":
case "float*":
case "float*":
case "unsigned short*":
case "unsigned char*":
case "const unsigned char*":
case "unsigned int*":
case "const unsigned int*":
this.declare(name+"_size", "size_t")
this.declare(name+"_js", "void *", false, `(void *)JS_GetArrayBuffer(ctx, &${name}_size, ${src})`)
this.if(name+"_js == NULL").returnExp("JS_EXCEPTION")
@ -93,42 +102,45 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> extend
// String
case "const char*":
//case "char *":
if(!supressDeclaration) this.statement(`${type} ${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`)
if(!suppressDeclaration) this.statement(`${type} ${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`)
else this.statement(`${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`)
break;
case "double":
if(!supressDeclaration) this.statement(`${type} ${name}`)
if(!suppressDeclaration) this.statement(`${type} ${name}`)
this.statement(`JS_ToFloat64(ctx, &${name}, ${src})`)
break;
case "float":
this.statement("double _double_"+name)
this.statement(`JS_ToFloat64(ctx, &_double_${name}, ${src})`)
if(!supressDeclaration) this.statement(`${type} ${name} = (${type})_double_${name}`)
if(!suppressDeclaration) this.statement(`${type} ${name} = (${type})_double_${name}`)
else this.statement(`${name} = (${type})_double_${name}`)
break;
case "int":
if(!supressDeclaration) this.statement(`${type} ${name}`)
if(!suppressDeclaration) this.statement(`${type} ${name}`)
this.statement(`JS_ToInt32(ctx, &${name}, ${src})`)
break;
case "unsigned int":
if(!supressDeclaration) this.statement(`${type} ${name}`)
if(!suppressDeclaration) this.statement(`${type} ${name}`)
this.statement(`JS_ToUint32(ctx, &${name}, ${src})`)
break;
case "unsigned char":
this.statement("unsigned int _int_"+name)
this.statement(`JS_ToUint32(ctx, &_int_${name}, ${src})`)
if(!supressDeclaration) this.statement(`${type} ${name} = (${type})_int_${name}`)
if(!suppressDeclaration) this.statement(`${type} ${name} = (${type})_int_${name}`)
else this.statement(`${name} = (${type})_int_${name}`)
break;
case "bool":
if(!supressDeclaration) this.statement(`${type} ${name} = JS_ToBool(ctx, ${src})`)
if(!suppressDeclaration) this.statement(`${type} ${name} = JS_ToBool(ctx, ${src})`)
else this.statement(`${name} = JS_ToBool(ctx, ${src})`)
break;
default:
const isConst = type.startsWith('const')
const isPointer = type.endsWith(' *')
const classId = classIds[type.replace("const ", "").replace(" *", "")]
if(!classId) throw new Error("Cannot convert into parameter type: " + type)
if(!classId) {
console.error("Type: ", {type, name, src}, " not registered in ClassIds: ", classIds)
throw new Error("Cannot convert into parameter type: " + type)
}
const suffix = isPointer ? "" : "_ptr"
this.jsOpqToStructPtr(type.replace(" *", ""), name+suffix, src, classId)
this.statement(`if(${name+suffix} == NULL) return JS_EXCEPTION`)
@ -156,10 +168,16 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> extend
case "double":
this.declare(name, 'JSValue', false, `JS_NewFloat64(ctx, ${src})`)
break;
case "unsigned char *":
case "const char *":
case "char *":
this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`)
break;
case "unsigned int *":
case "const int *":
case "int *":
this.declare(name, 'JSValue', false, `JS_NewArrayBufferCopy(ctx, ${src}, sizeof(${src}))`)
break;
// case "unsigned char *":
// this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`)
// break;

View File

@ -1,24 +0,0 @@
const path = require('path');
module.exports = {
entry: './src/index.ts',
devtool: false,
target: "node",
mode: 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: 'generate-bindings.js',
path: path.resolve(__dirname, '..'),
},
};

16
build-rayjs.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )
PROJECT_HOME=$( realpath "$SCRIPTPATH" )
BUILD_TYPE=Debug
BUILD_DIR=build
cd "$PROJECT_HOME" && \
echo "Cleaning up build directory" && \
rm -fr build && \
./generate-bindings.sh && \
echo "Generating build files" && \
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=$BUILD_TYPE && \
echo "Building" && \
cmake --build "$BUILD_DIR" --config $BUILD_TYPE

View File

@ -334,8 +334,6 @@ interface VrDeviceInfo {
hScreenSize: number,
/** Vertical size in meters */
vScreenSize: number,
/** Screen center in meters */
vScreenCenter: number,
/** Distance between eye and display in meters */
eyeToScreenDistance: number,
/** Lens separation distance in meters */
@ -357,6 +355,16 @@ interface FilePathList {
declare var FilePathList: {
prototype: FilePathList;
}
interface AutomationEvent {
}
declare var AutomationEvent: {
prototype: AutomationEvent;
}
interface AutomationEventList {
}
declare var AutomationEventList: {
prototype: AutomationEventList;
}
interface Light {
type: number,
enabled: boolean,
@ -390,10 +398,10 @@ declare var LightmapperConfig: {
}
/** Initialize window and OpenGL context */
declare function initWindow(width: number, height: number, title: string | undefined | null): void;
/** Check if KEY_ESCAPE pressed or Close icon pressed */
declare function windowShouldClose(): boolean;
/** Close window and unload OpenGL context */
declare function closeWindow(): void;
/** Check if application should close (KEY_ESCAPE pressed or windows close icon clicked) */
declare function windowShouldClose(): boolean;
/** Check if window has been initialized successfully */
declare function isWindowReady(): boolean;
/** Check if window is currently fullscreen */
@ -416,6 +424,8 @@ declare function setWindowState(flags: number): void;
declare function clearWindowState(flags: number): void;
/** Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) */
declare function toggleFullscreen(): void;
/** Toggle window state: borderless windowed (only PLATFORM_DESKTOP) */
declare function toggleBorderlessWindowed(): void;
/** Set window state: maximized, if resizable (only PLATFORM_DESKTOP) */
declare function maximizeWindow(): void;
/** Set window state: minimized, if resizable (only PLATFORM_DESKTOP) */
@ -424,18 +434,22 @@ declare function minimizeWindow(): void;
declare function restoreWindow(): void;
/** Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) */
declare function setWindowIcon(image: Image): void;
/** Set title for window (only PLATFORM_DESKTOP) */
/** Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB) */
declare function setWindowTitle(title: string | undefined | null): void;
/** Set window position on screen (only PLATFORM_DESKTOP) */
declare function setWindowPosition(x: number, y: number): void;
/** Set monitor for the current window (fullscreen mode) */
/** Set monitor for the current window */
declare function setWindowMonitor(monitor: number): void;
/** Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) */
declare function setWindowMinSize(width: number, height: number): void;
/** Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE) */
declare function setWindowMaxSize(width: number, height: number): void;
/** Set window dimensions */
declare function setWindowSize(width: number, height: number): void;
/** Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) */
declare function setWindowOpacity(opacity: number): void;
/** Set window focused (only PLATFORM_DESKTOP) */
declare function setWindowFocused(): void;
/** Get current screen width */
declare function getScreenWidth(): number;
/** Get current screen height */
@ -464,7 +478,7 @@ declare function getMonitorRefreshRate(monitor: number): number;
declare function getWindowPosition(): Vector2;
/** Get window scale DPI factor */
declare function getWindowScaleDPI(): Vector2;
/** Get the human-readable, UTF-8 encoded name of the primary monitor */
/** Get the human-readable, UTF-8 encoded name of the specified monitor */
declare function getMonitorName(monitor: number): string | undefined | null;
/** Set clipboard text content */
declare function setClipboardText(text: string | undefined | null): void;
@ -543,45 +557,51 @@ declare function setShaderValueTexture(shader: Shader, locIndex: number, texture
/** Unload shader from GPU memory (VRAM) */
declare function unloadShader(shader: Shader): void;
/** Get a ray trace from mouse position */
declare function getMouseRay(mousePosition: Vector2, camera: Camera3D): Ray;
/** Get camera transform matrix (view matrix) */
declare function getCameraMatrix(camera: Camera3D): Matrix;
/** Get camera 2d transform matrix */
declare function getCameraMatrix2D(camera: Camera2D): Matrix;
declare function getScreenToWorldRay(mousePosition: Vector2, camera: Camera3D): Ray;
/** Get a ray trace from mouse position in a viewport */
declare function getScreenToWorldRayEx(mousePosition: Vector2, camera: Camera3D, width: number, height: number): Ray;
/** Get the screen space position for a 3d world space position */
declare function getWorldToScreen(position: Vector3, camera: Camera3D): Vector2;
/** Get the world space position for a 2d camera screen space position */
declare function getScreenToWorld2D(position: Vector2, camera: Camera2D): Vector2;
/** Get size position for a 3d world space position */
declare function getWorldToScreenEx(position: Vector3, camera: Camera3D, width: number, height: number): Vector2;
/** Get the screen space position for a 2d camera world space position */
declare function getWorldToScreen2D(position: Vector2, camera: Camera2D): Vector2;
/** Get the world space position for a 2d camera screen space position */
declare function getScreenToWorld2D(position: Vector2, camera: Camera2D): Vector2;
/** Get camera transform matrix (view matrix) */
declare function getCameraMatrix(camera: Camera3D): Matrix;
/** Get camera 2d transform matrix */
declare function getCameraMatrix2D(camera: Camera2D): Matrix;
/** Set target FPS (maximum) */
declare function setTargetFPS(fps: number): void;
/** Get current FPS */
declare function getFPS(): number;
/** Get time in seconds for last frame drawn (delta time) */
declare function getFrameTime(): number;
/** Get elapsed time in seconds since InitWindow() */
declare function getTime(): number;
/** Get a random value between min and max (both included) */
declare function getRandomValue(min: number, max: number): number;
/** Get current FPS */
declare function getFPS(): number;
/** Set the seed for the random number generator */
declare function setRandomSeed(seed: number): void;
/** Get a random value between min and max (both included) */
declare function getRandomValue(min: number, max: number): number;
/** Load random values sequence, no values repeated */
declare function loadRandomSequence(count: number, min: number, max: number): int;
/** Unload random values sequence */
declare function unloadRandomSequence(sequence: int): void;
/** Takes a screenshot of current screen (filename extension defines format) */
declare function takeScreenshot(fileName: string | undefined | null): void;
/** Setup init configuration flags (view FLAGS) */
declare function setConfigFlags(flags: number): void;
/** Open URL with default system browser (if available) */
declare function openURL(url: string | undefined | null): void;
/** Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) */
declare function traceLog(logLevel: number, text: string | undefined | null): void;
/** Set the current threshold (minimum) log level */
declare function setTraceLogLevel(logLevel: number): void;
/** Open URL with default system browser (if available) */
declare function openURL(url: string | undefined | null): void;
/** Load file data as byte array (read) */
declare function loadFileData(fileName: string | undefined | null): ArrayBuffer;
/** Save data to file from byte array (write), returns true on success */
declare function saveFileData(fileName: string | undefined | null, data: any, bytesToWrite: number): boolean;
declare function saveFileData(fileName: string | undefined | null, data: any, dataSize: number): boolean;
/** Load text data from file (read), returns a '\0' terminated string */
declare function loadFileText(fileName: string | undefined | null): string | undefined | null;
/** Save text data to file (write), string must be '\0' terminated, returns true on success */
@ -606,7 +626,7 @@ declare function getDirectoryPath(filePath: string | undefined | null): string |
declare function getPrevDirectoryPath(dirPath: string | undefined | null): string | undefined | null;
/** Get current working directory (uses static string) */
declare function getWorkingDirectory(): string | undefined | null;
/** Get the directory if the running application (uses static string) */
/** Get the directory of the running application (uses static string) */
declare function getApplicationDirectory(): string | undefined | null;
/** Change working directory, return true on success */
declare function changeDirectory(dir: string | undefined | null): boolean;
@ -622,20 +642,38 @@ declare function isFileDropped(): boolean;
declare function loadDroppedFiles(): string[];
/** Get file modification time (last write time) */
declare function getFileModTime(fileName: string | undefined | null): number;
/** Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS */
declare function loadAutomationEventList(fileName: string | undefined | null): AutomationEventList;
/** Unload automation events list from file */
declare function unloadAutomationEventList(list: AutomationEventList): void;
/** Export automation events list as text file */
declare function exportAutomationEventList(list: AutomationEventList, fileName: string | undefined | null): boolean;
/** Set automation event list to record to */
declare function setAutomationEventList(list: AutomationEventList): void;
/** Set automation event internal base frame to start recording */
declare function setAutomationEventBaseFrame(frame: number): void;
/** Start recording automation events (AutomationEventList must be set) */
declare function startAutomationEventRecording(): void;
/** Stop recording automation events */
declare function stopAutomationEventRecording(): void;
/** Play a recorded automation event */
declare function playAutomationEvent(event: AutomationEvent): void;
/** Check if a key has been pressed once */
declare function isKeyPressed(key: number): boolean;
/** Check if a key has been pressed again (Only PLATFORM_DESKTOP) */
declare function isKeyPressedRepeat(key: number): boolean;
/** Check if a key is being pressed */
declare function isKeyDown(key: number): boolean;
/** Check if a key has been released once */
declare function isKeyReleased(key: number): boolean;
/** Check if a key is NOT being pressed */
declare function isKeyUp(key: number): boolean;
/** Set a custom key to exit program (default is ESC) */
declare function setExitKey(key: number): void;
/** Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty */
declare function getKeyPressed(): number;
/** Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty */
declare function getCharPressed(): number;
/** Set a custom key to exit program (default is ESC) */
declare function setExitKey(key: number): void;
/** Check if a gamepad is available */
declare function isGamepadAvailable(gamepad: number): boolean;
/** Get gamepad internal name id */
@ -656,6 +694,8 @@ declare function getGamepadAxisCount(gamepad: number): number;
declare function getGamepadAxisMovement(gamepad: number, axis: number): number;
/** Set internal gamepad mappings (SDL_GameControllerDB) */
declare function setGamepadMappings(mappings: string | undefined | null): number;
/** Set gamepad vibration for both motors */
declare function setGamepadVibration(gamepad: number, leftMotor: number, rightMotor: number): void;
/** Check if a mouse button has been pressed once */
declare function isMouseButtonPressed(button: number): boolean;
/** Check if a mouse button is being pressed */
@ -716,22 +756,22 @@ declare function updateCamera(camera: Camera3D, mode: number): void;
declare function updateCameraPro(camera: Camera3D, movement: Vector3, rotation: Vector3, zoom: number): void;
/** Set texture and rectangle to be used on shapes drawing */
declare function setShapesTexture(texture: Texture, source: Rectangle): void;
/** Get texture that is used for shapes drawing */
declare function getShapesTexture(): Texture;
/** Get texture source rectangle that is used for shapes drawing */
declare function getShapesTextureRectangle(): Rectangle;
/** Draw a pixel */
declare function drawPixel(posX: number, posY: number, color: Color): void;
/** Draw a pixel (Vector version) */
declare function drawPixelV(position: Vector2, color: Color): void;
/** Draw a line */
declare function drawLine(startPosX: number, startPosY: number, endPosX: number, endPosY: number, color: Color): void;
/** Draw a line (Vector version) */
/** Draw a line (using gl lines) */
declare function drawLineV(startPos: Vector2, endPos: Vector2, color: Color): void;
/** Draw a line defining thickness */
/** Draw a line (using triangles/quads) */
declare function drawLineEx(startPos: Vector2, endPos: Vector2, thick: number, color: Color): void;
/** Draw a line using cubic-bezier curves in-out */
/** Draw line segment cubic-bezier in-out interpolation */
declare function drawLineBezier(startPos: Vector2, endPos: Vector2, thick: number, color: Color): void;
/** Draw line using quadratic bezier curves with a control point */
declare function drawLineBezierQuad(startPos: Vector2, endPos: Vector2, controlPos: Vector2, thick: number, color: Color): void;
/** Draw line using cubic bezier curves with 2 control points */
declare function drawLineBezierCubic(startPos: Vector2, endPos: Vector2, startControlPos: Vector2, endControlPos: Vector2, thick: number, color: Color): void;
/** Draw a color-filled circle */
declare function drawCircle(centerX: number, centerY: number, radius: number, color: Color): void;
/** Draw a piece of a circle */
@ -744,6 +784,8 @@ declare function drawCircleGradient(centerX: number, centerY: number, radius: nu
declare function drawCircleV(center: Vector2, radius: number, color: Color): void;
/** Draw circle outline */
declare function drawCircleLines(centerX: number, centerY: number, radius: number, color: Color): void;
/** Draw circle outline (Vector version) */
declare function drawCircleLinesV(center: Vector2, radius: number, color: Color): void;
/** Draw ellipse */
declare function drawEllipse(centerX: number, centerY: number, radiusH: number, radiusV: number, color: Color): void;
/** Draw ellipse outline */
@ -784,6 +826,36 @@ declare function drawPoly(center: Vector2, sides: number, radius: number, rotati
declare function drawPolyLines(center: Vector2, sides: number, radius: number, rotation: number, color: Color): void;
/** Draw a polygon outline of n sides with extended parameters */
declare function drawPolyLinesEx(center: Vector2, sides: number, radius: number, rotation: number, lineThick: number, color: Color): void;
/** Draw spline: Linear, minimum 2 points */
declare function drawSplineLinear(points: Vector2, pointCount: number, thick: number, color: Color): void;
/** Draw spline: B-Spline, minimum 4 points */
declare function drawSplineBasis(points: Vector2, pointCount: number, thick: number, color: Color): void;
/** Draw spline: Catmull-Rom, minimum 4 points */
declare function drawSplineCatmullRom(points: Vector2, pointCount: number, thick: number, color: Color): void;
/** Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] */
declare function drawSplineBezierQuadratic(points: Vector2, pointCount: number, thick: number, color: Color): void;
/** Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] */
declare function drawSplineBezierCubic(points: Vector2, pointCount: number, thick: number, color: Color): void;
/** Draw spline segment: Linear, 2 points */
declare function drawSplineSegmentLinear(p1: Vector2, p2: Vector2, thick: number, color: Color): void;
/** Draw spline segment: B-Spline, 4 points */
declare function drawSplineSegmentBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: number, color: Color): void;
/** Draw spline segment: Catmull-Rom, 4 points */
declare function drawSplineSegmentCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: number, color: Color): void;
/** Draw spline segment: Quadratic Bezier, 2 points, 1 control point */
declare function drawSplineSegmentBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, thick: number, color: Color): void;
/** Draw spline segment: Cubic Bezier, 2 points, 2 control points */
declare function drawSplineSegmentBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, thick: number, color: Color): void;
/** Get (evaluate) spline point: Linear */
declare function getSplinePointLinear(startPos: Vector2, endPos: Vector2, t: number): Vector2;
/** Get (evaluate) spline point: B-Spline */
declare function getSplinePointBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: number): Vector2;
/** Get (evaluate) spline point: Catmull-Rom */
declare function getSplinePointCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: number): Vector2;
/** Get (evaluate) spline point: Quadratic Bezier */
declare function getSplinePointBezierQuad(p1: Vector2, c2: Vector2, p3: Vector2, t: number): Vector2;
/** Get (evaluate) spline point: Cubic Bezier */
declare function getSplinePointBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, t: number): Vector2;
/** Check collision between two rectangles */
declare function checkCollisionRecs(rec1: Rectangle, rec2: Rectangle): boolean;
/** Check collision between two circles */
@ -804,6 +876,10 @@ declare function getCollisionRec(rec1: Rectangle, rec2: Rectangle): Rectangle;
declare function loadImage(fileName: string | undefined | null): Image;
/** Load image from RAW file data */
declare function loadImageRaw(fileName: string | undefined | null, width: number, height: number, format: number, headerSize: number): Image;
/** Load image from SVG file data or string with specified size */
declare function loadImageSvg(fileNameOrString: string | undefined | null, width: number, height: number): Image;
/** Load image sequence from memory buffer */
declare function loadImageAnimFromMemory(fileType: string | undefined | null, fileData: ArrayBuffer, dataSize: number, frames: int): Image;
/** Load image from memory buffer, fileType refers to extension: i.e. '.png' */
declare function loadImageFromMemory(fileType: string | undefined | null, fileData: ArrayBuffer, dataSize: number): Image;
/** Load image from GPU texture data */
@ -816,6 +892,8 @@ declare function isImageReady(image: Image): boolean;
declare function unloadImage(image: Image): void;
/** Export image data to file, returns true on success */
declare function exportImage(image: Image, fileName: string | undefined | null): boolean;
/** Export image to memory buffer */
declare function exportImageToMemory(image: Image, fileType: string | undefined | null, fileSize: int): ArrayBuffer;
/** Generate image: plain color */
declare function genImageColor(width: number, height: number, color: Color): Image;
/** Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient */
@ -858,6 +936,8 @@ declare function imageAlphaMask(image: Image, alphaMask: Image): void;
declare function imageAlphaPremultiply(image: Image): void;
/** Apply Gaussian blur using a box blur approximation */
declare function imageBlurGaussian(image: Image, blurSize: number): void;
/** Apply Custom Square image convolution kernel */
declare function imageKernelConvolution(image: Image, kernel: float*, kernelSize: number): void;
/** Resize image (Bicubic scaling algorithm) */
declare function imageResize(image: Image, newWidth: number, newHeight: number): void;
/** Resize image (Nearest-Neighbor scaling algorithm) */
@ -966,9 +1046,11 @@ declare function drawTextureRec(texture: Texture, source: Rectangle, position: V
declare function drawTexturePro(texture: Texture, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: number, tint: Color): void;
/** Draws a texture (or part of it) that stretches or shrinks nicely */
declare function drawTextureNPatch(texture: Texture, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: number, tint: Color): void;
/** Check if two colors are equal */
declare function colorIsEqual(col1: Color, col2: Color): boolean;
/** Get color with alpha applied, alpha goes from 0.0f to 1.0f */
declare function fade(color: Color, alpha: number): Color;
/** Get hexadecimal value for a Color */
/** Get hexadecimal value for a Color (0xRRGGBBAA) */
declare function colorToInt(color: Color): number;
/** Get Color normalized as float [0..1] */
declare function colorNormalize(color: Color): Vector4;
@ -996,7 +1078,7 @@ declare function getPixelDataSize(width: number, height: number, format: number)
declare function getFontDefault(): Font;
/** Load font from file into GPU memory (VRAM) */
declare function loadFont(fileName: string | undefined | null): Font;
/** Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set */
/** Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont */
declare function loadFontEx(fileName: string | undefined | null, fontSize: number): Font;
/** Load font from Image (XNA style) */
declare function loadFontFromImage(image: Image, key: Color, firstChar: number): Font;
@ -1014,6 +1096,8 @@ declare function drawTextEx(font: Font, text: string | undefined | null, positio
declare function drawTextPro(font: Font, text: string | undefined | null, position: Vector2, origin: Vector2, rotation: number, fontSize: number, spacing: number, tint: Color): void;
/** Draw one character (codepoint) */
declare function drawTextCodepoint(font: Font, codepoint: number, position: Vector2, fontSize: number, tint: Color): void;
/** Set vertical line spacing when drawing with line-breaks */
declare function setTextLineSpacing(spacing: number): void;
/** Measure string width for default font */
declare function measureText(text: string | undefined | null, fontSize: number): number;
/** Measure string size for Font */
@ -1098,12 +1182,14 @@ declare function unloadMesh(mesh: Mesh): void;
declare function drawMesh(mesh: Mesh, material: Material, transform: Matrix): void;
/** Draw multiple mesh instances with material and different transforms */
declare function drawMeshInstanced(mesh: Mesh, material: Material, transforms: Matrix, instances: number): void;
/** Export mesh data to file, returns true on success */
declare function exportMesh(mesh: Mesh, fileName: string | undefined | null): boolean;
/** Compute mesh bounding box limits */
declare function getMeshBoundingBox(mesh: Mesh): BoundingBox;
/** Compute mesh tangents */
declare function genMeshTangents(mesh: Mesh): void;
/** Export mesh data to file, returns true on success */
declare function exportMesh(mesh: Mesh, fileName: string | undefined | null): boolean;
/** Export mesh as code file (.h) defining multiple arrays of vertex attributes */
declare function exportMeshAsCode(mesh: Mesh, fileName: string | undefined | null): boolean;
/** Generate polygonal mesh */
declare function genMeshPoly(sides: number, radius: number): Mesh;
/** Generate plane mesh (with subdivisions) */
@ -1160,6 +1246,8 @@ declare function closeAudioDevice(): void;
declare function isAudioDeviceReady(): boolean;
/** Set master volume (listener) */
declare function setMasterVolume(volume: number): void;
/** Get master volume (listener) */
declare function getMasterVolume(): number;
/** Load wave data from file */
declare function loadWave(fileName: string | undefined | null): Wave;
/** Load wave from memory buffer, fileType refers to extension: i.e. '.wav' */
@ -1170,6 +1258,8 @@ declare function isWaveReady(wave: Wave): boolean;
declare function loadSound(fileName: string | undefined | null): Sound;
/** Load sound from wave data */
declare function loadSoundFromWave(wave: Wave): Sound;
/** Create a new sound that shares the same sample data as the source sound, does not own the sound data */
declare function loadSoundAlias(source: Sound): Sound;
/** Checks if a sound is ready */
declare function isSoundReady(sound: Sound): boolean;
/** Update sound buffer with new data */
@ -1178,6 +1268,8 @@ declare function updateSound(sound: Sound, data: any, sampleCount: number): void
declare function unloadWave(wave: Wave): void;
/** Unload sound */
declare function unloadSound(sound: Sound): void;
/** Unload a sound alias (does not deallocate sample data) */
declare function unloadSoundAlias(alias: Sound): void;
/** Export wave data to file, returns true on success */
declare function exportWave(wave: Wave, fileName: string | undefined | null): boolean;
/** Play a sound */
@ -1289,6 +1381,10 @@ declare function vector2Transform(v: Vector2, mat: Matrix): Vector2;
declare function vector2Lerp(v1: Vector2, v2: Vector2, amount: number): Vector2;
/** Calculate reflected vector to normal */
declare function vector2Reflect(v: Vector2, normal: Vector2): Vector2;
/** Get min value for each pair of components */
declare function vector2Min(v1: Vector2, v2: Vector2): Vector2;
/** Get max value for each pair of components */
declare function vector2Max(v1: Vector2, v2: Vector2): Vector2;
/** Rotate vector by angle */
declare function vector2Rotate(v: Vector2, angle: number): Vector2;
/** Move Vector towards target */
@ -1302,6 +1398,12 @@ declare function vector2Clamp(v: Vector2, min: Vector2, max: Vector2): Vector2;
declare function vector2ClampValue(v: Vector2, min: number, max: number): Vector2;
/** Check whether two given vectors are almost equal */
declare function vector2Equals(p: Vector2, q: Vector2): number;
/** Compute the direction of a refracted ray
v: normalized direction of the incoming ray
n: normalized normal vector of the interface of two optical media
r: ratio of the refractive index of the medium from where the ray comes
to the refractive index of the medium on the other side of the surface */
declare function vector2Refract(v: Vector2, n: Vector2, r: number): Vector2;
/** Vector with components value 0.0f */
declare function vector3Zero(): Vector3;
/** Vector with components value 1.0f */
@ -1340,12 +1442,18 @@ declare function vector3Negate(v: Vector3): Vector3;
declare function vector3Divide(v1: Vector3, v2: Vector3): Vector3;
/** Normalize provided vector */
declare function vector3Normalize(v: Vector3): Vector3;
/** //Calculate the projection of the vector v1 on to v2 */
declare function vector3Project(v1: Vector3, v2: Vector3): Vector3;
/** //Calculate the rejection of the vector v1 on to v2 */
declare function vector3Reject(v1: Vector3, v2: Vector3): Vector3;
/** Transforms a Vector3 by a given Matrix */
declare function vector3Transform(v: Vector3, mat: Matrix): Vector3;
/** Transform a vector by quaternion rotation */
declare function vector3RotateByQuaternion(v: Vector3, q: Vector4): Vector3;
/** Rotates a vector around an axis */
declare function vector3RotateByAxisAngle(v: Vector3, axis: Vector3, angle: number): Vector3;
/** Move Vector towards target */
declare function vector3MoveTowards(v: Vector3, target: Vector3, maxDistance: number): Vector3;
/** Calculate linear interpolation between two vectors */
declare function vector3Lerp(v1: Vector3, v2: Vector3, amount: number): Vector3;
/** Calculate reflected vector to normal */
@ -1369,13 +1477,36 @@ declare function vector3Clamp(v: Vector3, min: Vector3, max: Vector3): Vector3;
declare function vector3ClampValue(v: Vector3, min: number, max: number): Vector3;
/** Check whether two given vectors are almost equal */
declare function vector3Equals(p: Vector3, q: Vector3): number;
/** Compute the direction of a refracted ray where v specifies the
normalized direction of the incoming ray, n specifies the
normalized normal vector of the interface of two optical media,
and r specifies the ratio of the refractive index of the medium
from where the ray comes to the refractive index of the medium
on the other side of the surface */
/** Compute the direction of a refracted ray
v: normalized direction of the incoming ray
n: normalized normal vector of the interface of two optical media
r: ratio of the refractive index of the medium from where the ray comes
to the refractive index of the medium on the other side of the surface */
declare function vector3Refract(v: Vector3, n: Vector3, r: number): Vector3;
/** Calculate distance between two vectors */
declare function vector4Distance(v1: Vector4, v2: Vector4): number;
/** Calculate square distance between two vectors */
declare function vector4DistanceSqr(v1: Vector4, v2: Vector4): number;
/** Multiply vector by vector */
declare function vector4Multiply(v1: Vector4, v2: Vector4): Vector4;
/** Negate vector */
declare function vector4Negate(v: Vector4): Vector4;
/** Divide vector by vector */
declare function vector4Divide(v1: Vector4, v2: Vector4): Vector4;
/** Normalize provided vector */
declare function vector4Normalize(v: Vector4): Vector4;
/** Get min value for each pair of components */
declare function vector4Min(v1: Vector4, v2: Vector4): Vector4;
/** Get max value for each pair of components */
declare function vector4Max(v1: Vector4, v2: Vector4): Vector4;
/** Calculate linear interpolation between two vectors */
declare function vector4Lerp(v1: Vector4, v2: Vector4, amount: number): Vector4;
/** Move Vector towards target */
declare function vector4MoveTowards(v: Vector4, target: Vector4, maxDistance: number): Vector4;
/** Invert the given vector */
declare function vector4Invert(v: Vector4): Vector4;
/** Check whether two given vectors are almost equal */
declare function vector4Equals(p: Vector4, q: Vector4): number;
/** Compute matrix determinant */
declare function matrixDeterminant(mat: Matrix): number;
/** Get the trace of the matrix (sum of the values along the diagonal) */
@ -1506,7 +1637,7 @@ declare function guiUnlock(): void;
/** Check if gui is locked (global state) */
declare function guiIsLocked(): boolean;
/** Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f */
declare function guiFade(alpha: number): void;
declare function guiSetAlpha(alpha: number): void;
/** Set gui state (global state) */
declare function guiSetState(state: number): void;
/** Get gui state (global state) */
@ -1519,64 +1650,6 @@ declare function guiGetFont(): Font;
declare function guiSetStyle(control: number, property: number, value: number): void;
/** Get one style property */
declare function guiGetStyle(control: number, property: number): number;
/** Window Box control, shows a window that can be closed */
declare function guiWindowBox(bounds: Rectangle, title: string | undefined | null): boolean;
/** Group Box control with text name */
declare function guiGroupBox(bounds: Rectangle, text: string | undefined | null): void;
/** Line separator control, could contain text */
declare function guiLine(bounds: Rectangle, text: string | undefined | null): void;
/** Panel control, useful to group controls */
declare function guiPanel(bounds: Rectangle, text: string | undefined | null): void;
/** Scroll Panel control */
declare function guiScrollPanel(bounds: Rectangle, text: string | undefined | null, content: Rectangle, scroll: Vector2): Rectangle;
/** Label control, shows text */
declare function guiLabel(bounds: Rectangle, text: string | undefined | null): void;
/** Button control, returns true when clicked */
declare function guiButton(bounds: Rectangle, text: string | undefined | null): boolean;
/** Label button control, show true when clicked */
declare function guiLabelButton(bounds: Rectangle, text: string | undefined | null): boolean;
/** Toggle Button control, returns true when active */
declare function guiToggle(bounds: Rectangle, text: string | undefined | null, active: boolean): boolean;
/** Toggle Group control, returns active toggle index */
declare function guiToggleGroup(bounds: Rectangle, text: string | undefined | null, active: number): number;
/** Check Box control, returns true when active */
declare function guiCheckBox(bounds: Rectangle, text: string | undefined | null, checked: boolean): boolean;
/** Combo Box control, returns selected item index */
declare function guiComboBox(bounds: Rectangle, text: string | undefined | null, active: number): number;
/** Dropdown Box control, returns selected item */
declare function guiDropdownBox(bounds: Rectangle, text: string | undefined | null, active: { active: number }, editMode: boolean): boolean;
/** Spinner control, returns selected value */
declare function guiSpinner(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean;
/** Value Box control, updates input text with numbers */
declare function guiValueBox(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean;
/** Text Box control, updates input text */
declare function guiTextBox(bounds: Rectangle, text: { text: string }, editMode: boolean): boolean;
/** Slider control, returns selected value */
declare function guiSlider(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Slider Bar control, returns selected value */
declare function guiSliderBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Progress Bar control, shows current progress value */
declare function guiProgressBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Status Bar control, shows info text */
declare function guiStatusBar(bounds: Rectangle, text: string | undefined | null): void;
/** Dummy control for placeholders */
declare function guiDummyRec(bounds: Rectangle, text: string | undefined | null): void;
/** Grid control, returns mouse cell position */
declare function guiGrid(bounds: Rectangle, text: string | undefined | null, spacing: number, subdivs: number): Vector2;
/** List View control, returns selected list item index */
declare function guiListView(bounds: Rectangle, text: string | undefined | null, scrollIndex: { scrollIndex: number }, active: number): number;
/** Message Box control, displays a message */
declare function guiMessageBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null): number;
/** Text Input Box control, ask for text, supports secret */
declare function guiTextInputBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null, text: { text: string }, secretViewActive: { secretViewActive: number }): number;
/** Color Picker control (multiple color controls) */
declare function guiColorPicker(bounds: Rectangle, text: string | undefined | null, color: Color): Color;
/** Color Panel control */
declare function guiColorPanel(bounds: Rectangle, text: string | undefined | null, color: Color): Color;
/** Color Bar Alpha control */
declare function guiColorBarAlpha(bounds: Rectangle, text: string | undefined | null, alpha: number): number;
/** Color Bar Hue control */
declare function guiColorBarHue(bounds: Rectangle, text: string | undefined | null, value: number): number;
/** Load style file over global style variable (.rgs) */
declare function guiLoadStyle(fileName: string | undefined | null): void;
/** Load style default over global style */
@ -1593,6 +1666,70 @@ declare function guiIconText(iconId: number, text: string | undefined | null): s
declare function guiSetIconScale(scale: number): void;
/** Draw icon using pixel size at specified position */
declare function guiDrawIcon(iconId: number, posX: number, posY: number, pixelSize: number, color: Color): void;
/** Window Box control, shows a window that can be closed */
declare function guiWindowBox(bounds: Rectangle, title: string | undefined | null): number;
/** Group Box control with text name */
declare function guiGroupBox(bounds: Rectangle, text: string | undefined | null): number;
/** Line separator control, could contain text */
declare function guiLine(bounds: Rectangle, text: string | undefined | null): number;
/** Panel control, useful to group controls */
declare function guiPanel(bounds: Rectangle, text: string | undefined | null): number;
/** Scroll Panel control */
declare function guiScrollPanel(bounds: Rectangle, text: string | undefined | null, content: Rectangle, scroll: Vector2, view: Rectangle): number;
/** Label control */
declare function guiLabel(bounds: Rectangle, text: string | undefined | null): number;
/** Button control, returns true when clicked */
declare function guiButton(bounds: Rectangle, text: string | undefined | null): number;
/** Label button control, returns true when clicked */
declare function guiLabelButton(bounds: Rectangle, text: string | undefined | null): number;
/** Toggle Button control */
declare function guiToggle(bounds: Rectangle, text: string | undefined | null, active: bool): number;
/** Toggle Group control */
declare function guiToggleGroup(bounds: Rectangle, text: string | undefined | null, active: int): number;
/** Toggle Slider control */
declare function guiToggleSlider(bounds: Rectangle, text: string | undefined | null, active: int): number;
/** Check Box control, returns true when active */
declare function guiCheckBox(bounds: Rectangle, text: string | undefined | null, checked: bool): number;
/** Combo Box control */
declare function guiComboBox(bounds: Rectangle, text: string | undefined | null, active: int): number;
/** Dropdown Box control */
declare function guiDropdownBox(bounds: Rectangle, text: string | undefined | null, active: { active: number }, editMode: boolean): number;
/** Spinner control */
declare function guiSpinner(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): number;
/** Value Box control, updates input text with numbers */
declare function guiValueBox(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): number;
/** Text Box control, updates input text */
declare function guiTextBox(bounds: Rectangle, text: { text: string }, editMode: boolean): number;
/** Slider control */
declare function guiSlider(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: ArrayBuffer, minValue: number, maxValue: number): number;
/** Slider Bar control */
declare function guiSliderBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: ArrayBuffer, minValue: number, maxValue: number): number;
/** Progress Bar control */
declare function guiProgressBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: ArrayBuffer, minValue: number, maxValue: number): number;
/** Status Bar control, shows info text */
declare function guiStatusBar(bounds: Rectangle, text: string | undefined | null): number;
/** Dummy control for placeholders */
declare function guiDummyRec(bounds: Rectangle, text: string | undefined | null): number;
/** Grid control */
declare function guiGrid(bounds: Rectangle, text: string | undefined | null, spacing: number, subdivs: number, mouseCell: Vector2): number;
/** List View control */
declare function guiListView(bounds: Rectangle, text: string | undefined | null, scrollIndex: { scrollIndex: number }, active: int): number;
/** Message Box control, displays a message */
declare function guiMessageBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null): number;
/** Text Input Box control, ask for text, supports secret */
declare function guiTextInputBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null, text: { text: string }, secretViewActive: { secretViewActive: number }): number;
/** Color Picker control (multiple color controls) */
declare function guiColorPicker(bounds: Rectangle, text: string | undefined | null, color: Color): number;
/** Color Panel control */
declare function guiColorPanel(bounds: Rectangle, text: string | undefined | null, color: Color): number;
/** Color Bar Alpha control */
declare function guiColorBarAlpha(bounds: Rectangle, text: string | undefined | null, alpha: ArrayBuffer): number;
/** Color Bar Hue control */
declare function guiColorBarHue(bounds: Rectangle, text: string | undefined | null, value: ArrayBuffer): number;
/** Color Picker control that avoids conversion to RGB on each call (multiple color controls) */
declare function guiColorPickerHSV(bounds: Rectangle, text: string | undefined | null, colorHsv: Vector3): number;
/** Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV() */
declare function guiColorPanelHSV(bounds: Rectangle, text: string | undefined | null, colorHsv: Vector3): number;
/** //----------------------------------------------------------------------------------
Module Functions Declaration
//---------------------------------------------------------------------------------- */
@ -1759,6 +1896,8 @@ declare var FLAG_WINDOW_TRANSPARENT: number;
declare var FLAG_WINDOW_HIGHDPI: number;
/** Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED */
declare var FLAG_WINDOW_MOUSE_PASSTHROUGH: number;
/** Set to run program in borderless windowed mode */
declare var FLAG_BORDERLESS_WINDOWED_MODE: number;
/** Set to try enabling MSAA 4X */
declare var FLAG_MSAA_4X_HINT: number;
/** Set to try enabling interlaced video format (for V3D) */
@ -2203,6 +2342,12 @@ declare var PIXELFORMAT_UNCOMPRESSED_R32: number;
declare var PIXELFORMAT_UNCOMPRESSED_R32G32B32: number;
/** 32*4 bpp (4 channels - float) */
declare var PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: number;
/** 16 bpp (1 channel - half float) */
declare var PIXELFORMAT_UNCOMPRESSED_R16: number;
/** 16*3 bpp (3 channels - half float) */
declare var PIXELFORMAT_UNCOMPRESSED_R16G16B16: number;
/** 16*4 bpp (4 channels - half float) */
declare var PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: number;
/** 4 bpp (no alpha) */
declare var PIXELFORMAT_COMPRESSED_DXT1_RGB: number;
/** 4 bpp (1 bit alpha) */
@ -2336,6 +2481,18 @@ declare var TEXT_ALIGN_CENTER: number;
/** */
declare var TEXT_ALIGN_RIGHT: number;
/** */
declare var TEXT_ALIGN_TOP: number;
/** */
declare var TEXT_ALIGN_MIDDLE: number;
/** */
declare var TEXT_ALIGN_BOTTOM: number;
/** */
declare var TEXT_WRAP_NONE: number;
/** */
declare var TEXT_WRAP_CHAR: number;
/** */
declare var TEXT_WRAP_WORD: number;
/** */
declare var DEFAULT: number;
/** Used also for: LABELBUTTON */
declare var LABEL: number;
@ -2343,7 +2500,7 @@ declare var LABEL: number;
declare var BUTTON: number;
/** Used also for: TOGGLEGROUP */
declare var TOGGLE: number;
/** Used also for: SLIDERBAR */
/** Used also for: SLIDERBAR, TOGGLESLIDER */
declare var SLIDER: number;
/** */
declare var PROGRESSBAR: number;
@ -2367,38 +2524,36 @@ declare var COLORPICKER: number;
declare var SCROLLBAR: number;
/** */
declare var STATUSBAR: number;
/** */
/** Control border color in STATE_NORMAL */
declare var BORDER_COLOR_NORMAL: number;
/** */
/** Control base color in STATE_NORMAL */
declare var BASE_COLOR_NORMAL: number;
/** */
/** Control text color in STATE_NORMAL */
declare var TEXT_COLOR_NORMAL: number;
/** */
/** Control border color in STATE_FOCUSED */
declare var BORDER_COLOR_FOCUSED: number;
/** */
/** Control base color in STATE_FOCUSED */
declare var BASE_COLOR_FOCUSED: number;
/** */
/** Control text color in STATE_FOCUSED */
declare var TEXT_COLOR_FOCUSED: number;
/** */
/** Control border color in STATE_PRESSED */
declare var BORDER_COLOR_PRESSED: number;
/** */
/** Control base color in STATE_PRESSED */
declare var BASE_COLOR_PRESSED: number;
/** */
/** Control text color in STATE_PRESSED */
declare var TEXT_COLOR_PRESSED: number;
/** */
/** Control border color in STATE_DISABLED */
declare var BORDER_COLOR_DISABLED: number;
/** */
/** Control base color in STATE_DISABLED */
declare var BASE_COLOR_DISABLED: number;
/** */
/** Control text color in STATE_DISABLED */
declare var TEXT_COLOR_DISABLED: number;
/** */
/** Control border size, 0 for no border */
declare var BORDER_WIDTH: number;
/** */
/** Control text padding, not considering border */
declare var TEXT_PADDING: number;
/** */
/** Control text horizontal alignment inside control text bound (after border and padding) */
declare var TEXT_ALIGNMENT: number;
/** */
declare var RESERVED: number;
/** Text size (glyphs max height) */
declare var TEXT_SIZE: number;
/** Text spacing between glyphs */
@ -2407,6 +2562,12 @@ declare var TEXT_SPACING: number;
declare var LINE_COLOR: number;
/** Background color */
declare var BACKGROUND_COLOR: number;
/** Text spacing between lines */
declare var TEXT_LINE_SPACING: number;
/** Text vertical alignment inside text bounds (after border and padding) */
declare var TEXT_ALIGNMENT_VERTICAL: number;
/** Text wrap-mode inside text bounds */
declare var TEXT_WRAP_MODE: number;
/** ToggleGroup separation between toggles */
declare var GROUP_PADDING: number;
/** Slider size of internal bar */
@ -2415,17 +2576,17 @@ declare var SLIDER_WIDTH: number;
declare var SLIDER_PADDING: number;
/** ProgressBar internal padding */
declare var PROGRESS_PADDING: number;
/** */
/** ScrollBar arrows size */
declare var ARROWS_SIZE: number;
/** */
/** ScrollBar arrows visible */
declare var ARROWS_VISIBLE: number;
/** (SLIDERBAR, SLIDER_PADDING) */
/** ScrollBar slider internal padding */
declare var SCROLL_SLIDER_PADDING: number;
/** */
/** ScrollBar slider size */
declare var SCROLL_SLIDER_SIZE: number;
/** */
/** ScrollBar scroll padding from arrows */
declare var SCROLL_PADDING: number;
/** */
/** ScrollBar scrolling speed */
declare var SCROLL_SPEED: number;
/** CheckBox internal check padding */
declare var CHECK_PADDING: number;
@ -2437,16 +2598,8 @@ declare var COMBO_BUTTON_SPACING: number;
declare var ARROW_PADDING: number;
/** DropdownBox items separation */
declare var DROPDOWN_ITEMS_SPACING: number;
/** TextBox/TextBoxMulti/ValueBox/Spinner inner text padding */
declare var TEXT_INNER_PADDING: number;
/** TextBoxMulti lines separation */
declare var TEXT_LINES_SPACING: number;
/** TextBoxMulti vertical alignment: 0-CENTERED, 1-UP, 2-DOWN */
declare var TEXT_ALIGNMENT_VERTICAL: number;
/** TextBox supports multiple lines */
declare var TEXT_MULTILINE: number;
/** TextBox wrap mode for multiline: 0-NO_WRAP, 1-CHAR_WRAP, 2-WORD_WRAP */
declare var TEXT_WRAP_MODE: number;
/** TextBox in read-only mode: 0-text editable, 1-text no-editable */
declare var TEXT_READONLY: number;
/** Spinner left/right buttons width */
declare var SPIN_BUTTON_WIDTH: number;
/** Spinner buttons separation */
@ -2457,7 +2610,7 @@ declare var LIST_ITEMS_HEIGHT: number;
declare var LIST_ITEMS_SPACING: number;
/** ListView scrollbar size (usually width) */
declare var SCROLLBAR_WIDTH: number;
/** ListView scrollbar side (0-left, 1-right) */
/** ListView scrollbar side (0-SCROLLBAR_LEFT_SIDE, 1-SCROLLBAR_RIGHT_SIDE) */
declare var SCROLLBAR_SIDE: number;
/** */
declare var COLOR_SELECTOR_SIZE: number;
@ -2910,11 +3063,11 @@ declare var ICON_FILE: number;
/** */
declare var ICON_SAND_TIMER: number;
/** */
declare var ICON_220: number;
declare var ICON_WARNING: number;
/** */
declare var ICON_221: number;
declare var ICON_HELP_BOX: number;
/** */
declare var ICON_222: number;
declare var ICON_INFO_BOX: number;
/** */
declare var ICON_223: number;
/** */

View File

@ -1,9 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"target": "es2020",
"lib": [
"ES2020"
]
"checkJs": true,
"noEmit": true,
// get intellisense for the available platform APIs
"lib": ["es2020"]
}
}

File diff suppressed because it is too large Load Diff

10
generate-bindings.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
SCRIPTPATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )
PROJECT_HOME=$( realpath "$SCRIPTPATH" )
echo "Generating bindings"
cd "$PROJECT_HOME/bindings" && \
npm run bindings:generate

File diff suppressed because it is too large Load Diff

2
thirdparty/quickjs vendored

@ -1 +1 @@
Subproject commit 2788d71e823b522b178db3b3660ce93689534e6d
Subproject commit 6a89d7c27099be84e5312a7ec73205d6a7abe1b4

2
thirdparty/raygui vendored

@ -1 +1 @@
Subproject commit aa81c167f10707ea173ea1190eda18e57d841b8f
Subproject commit 82ba2b1a783208d6a1f80d8977d796635260c161

2
thirdparty/raylib vendored

@ -1 +1 @@
Subproject commit d3ea64983212f7451a9cfbf644da8a5c43dbc706
Subproject commit 9a8d73e6c32514275a0ba53fe528bcb7c2693e27