diff --git a/CHANGELOG_5.5.md b/CHANGELOG_5.5.md new file mode 100644 index 0000000..7830438 --- /dev/null +++ b/CHANGELOG_5.5.md @@ -0,0 +1,100 @@ +# Changelog: raylib 4.5 → 5.5 Migration + +## Overview + +This changelog documents all changes made during the migration of rayjs from raylib **4.5** to **5.5** (stable), including raygui **3.6** → **4.0**. + +## Git + +- Branch: `update-raylib` +- Commit: `52be0e6` — "switch raylib to v5.5 and raygui to v4.0 stable releases" + +--- + +## Submodules Updated + +| Submodule | From | To | +|-----------|------|-----| +| `thirdparty/raylib` | `dbc56a8` (6.0-dev) | `c1ab645` (tag **5.5**) | +| `thirdparty/raygui` | `aa81c16` (tag **3.6**) | `25c8c65` (tag **4.0**) | + +--- + +## Files Modified + +### `src/quickjs.c` +- Removed `#include ` and `GLFWwindow`-specific F5 reload code (now uses `IsKeyPressed(KEY_F5)` only, platform-agnostic) + +### `bindings/src/quickjs.ts` +- **`jsToC()`** — Added type conversions: + - `char` → first char of JS string + - `short`, `int *`, `long` + - `unsigned short`, `unsigned long` + - `const float *` + - `bool *` → local `bool` variable + - `char *` (both `const char *` and non-const) +- **`jsToJs()`** — Fixed pointer return types: + - `unsigned int *`, `unsigned char *` → `*ptr ? JS_NewUint32(ctx, *ptr) : JS_NULL` + - `int *` → `JS_NewInt32` + - Separated non-pointer unsigned types from pointer versions + +### `bindings/src/index.ts` +- **Removed** `ignore()` calls for functions that no longer exist in 5.5: + - `IsAudioStreamReady`, `Vector3OrthoNormalize`, `Vector3ToFloatV`, `MatrixToFloatV`, `QuaternionToAxisAngle` +- **Fixed `VrDeviceInfo`** struct — removed non-existent field `vScreenCenter` (not present in 5.5) +- **Fixed `GuiListView`** — added second out-parameter `active` at index 3 (raygui 4.0 has `scrollIndex` at 2 + `active` at 3) +- **Fixed `GuiTextInputBox`** — ignored `secretViewActive` (bool*) parameter, wrote custom body without `setOutParamString` conflict +- **Added `LoadRandomSequence`** to `ignore()` (returns `int*`) +- **Added auto-ignore filter** — automatically ignores functions with unsupported parameter/return types (`supportedTypes` set with all raylib types + aliases like `Texture2D`, `Camera`, `Quaternion`, `ModelSkeleton`, `GestureEvent`) +- **Added `needsBufferReturn()` handler** — special codegen for 5 functions that return `unsigned char *` + `int *` size param (produces `JS_NewArrayBufferCopy` instead of `JS_NewUint32`): + - `LoadFileData`, `CompressData`, `DecompressData`, `DecodeDataBase64`, `ExportImageToMemory` + +### `src/bindings/js_raylib_core.h` +- **Fully regenerated** (718 functions bound, 105 ignored) +- 0 JavaScript errors + +### `examples/lib.raylib.d.ts` +- **Fully regenerated** TypeScript declarations + +### `thirdparty/raylib/parser/output/raylib_api.json` +- **Regenerated** from raylib 5.5 (12,137 lines) + +### `generate-bindings.js` +- **Rebuilt** via webpack from updated sources + +--- + +## New Files + +| File | Description | +|------|-------------| +| `examples/textures/bunnymark_opt.js` | Optimized bunnymark benchmark (Float32Array, no GC pressure) | +| `MIGRATION_TABLE.md` | Full function-by-function migration table (581 functions) | +| `CHANGELOG_5.5.md` | This file | + +--- + +## Deleted/Failed Build Directories + +| Path | Reason | +|------|--------| +| `build-sdl/` | Unsuccessful SDL backend build (GLFW symbols not available) | + +--- + +## Build & Runtime Status + +- **Build**: `[100%] Built target rayjs` — 0 errors, 1 warning (LoadFileData `unsigned int *` → `int *` sign mismatch — safe) +- **Runtime**: raylib 5.5 initializes successfully, OpenGL 4.1 on Apple M2 +- **Examples tested**: `main.js`, `bunnymark.js`, `bunnymark_opt.js` — all run without errors + +--- + +## Known Issues / Future Work + +1. **LoadFileData warning** — `unsigned int*` passed where `int*` expected (cosmetic, runtime-safe) +2. **SDL backend** — needs `#ifdef`-separated GLFW/SDL code in `quickjs.c` +3. **GPU Skinning** — `Mesh` struct missing `boneMatrices` and `boneCount` fields in binding (P1 — silent runtime misalignment) +4. **Model animations** — still `ignore()`'d as in 4.5 (can be un-ignored if needed) +5. **GetScreenToWorldRay** — available but no JS-side alias for old `GetMouseRay` +6. **Auto-ignore audit** — 105 ignored functions, some may be bindable \ No newline at end of file diff --git a/bindings/src/index.ts b/bindings/src/index.ts index ca9485a..d5ea213 100644 --- a/bindings/src/index.ts +++ b/bindings/src/index.ts @@ -330,7 +330,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 }, @@ -395,6 +394,67 @@ function main(){ const traceLog = getFunction(api.functions, "TraceLog")! traceLog.params?.pop() + // Auto-ignore functions with unsupported parameter/return types + const supportedTypes = new Set([ + 'void', 'int', 'float', 'double', 'bool', 'unsigned int', 'unsigned char', 'long', + 'char *', 'const char *', + 'void *', 'const void *', + 'unsigned char *', 'const unsigned char *', 'unsigned short *', 'float *', + 'int *', 'unsigned int *', + 'Color', 'Rectangle', 'Vector2', 'Vector3', 'Vector4', 'Matrix', + 'Image', 'Texture', 'Texture2D', 'TextureCubemap', 'RenderTexture', 'RenderTexture2D', + 'NPatchInfo', 'GlyphInfo', 'Font', + 'Camera', 'Camera3D', 'Camera2D', 'Mesh', 'Shader', 'Material', 'MaterialMap', + 'Transform', 'BoneInfo', 'Model', 'ModelAnimation', 'ModelAnimPose', + 'Ray', 'RayCollision', 'BoundingBox', 'Wave', 'AudioStream', 'Sound', 'Music', + 'VrDeviceInfo', 'VrStereoConfig', + 'FilePathList', 'AutomationEvent', 'AutomationEventList', + 'Light', 'Lightmapper', 'LightmapperConfig', + 'Quaternion', 'ModelSkeleton', 'GestureEvent', + 'TraceLogCallback', 'LoadFileDataCallback', 'SaveFileDataCallback', + 'LoadFileTextCallback', 'SaveFileTextCallback' + ]) + api.functions.forEach(fn => { + if (fn.binding?.ignore) return; + const stripType = (t: string) => t.replace(/^const /, '').replace(/\*+$/, '').replace(/ \*$/, '').trim() + const allParamsOk = (fn.params || []).every(p => { + const t = p.binding?.typeAlias || p.type + return supportedTypes.has(t) || supportedTypes.has(stripType(t)) + }) + const retStripped = stripType(fn.returnType) + if (!allParamsOk || !supportedTypes.has(fn.returnType) && !supportedTypes.has(retStripped)) { + if (!fn.name.startsWith('Text')) { + console.log(`Auto-ignoring ${fn.name} (return: ${fn.returnType}, params: [${(fn.params||[]).map(p=>p.type).join(', ')}])`) + } + fn.binding = { ignore: true } + } + }) + + // Special case: functions returning unsigned char * with int * size parameter → ArrayBuffer + const needsBufferReturn = (fn: RayLibFunction) => { + if (fn.returnType !== 'unsigned char *') return false; + const last = fn.params?.[fn.params.length - 1]; + return last && (last.type === 'int *' || last.type === 'unsigned int *'); + } + api.functions.filter(needsBufferReturn).forEach(fn => { + const sizeParam = fn.params![fn.params!.length - 1]; + const dataVar = fn.name === 'CompressData' ? 'compData' : 'data'; + fn.binding = { + body: gen => { + for (let i = 0; i < fn.params!.length - 1; i++) { + const p = fn.params![i]; + gen.jsToC(p.type, p.name, `argv[${i}]`, core.structLookup) + } + gen.declare(sizeParam.name, 'int', false, '0') + gen.call(fn.name, fn.params!.map(p => p.name).slice(0, -1).concat(['&' + sizeParam.name]), { type: 'unsigned char *', name: dataVar }) + gen.statement(`JSValue buf = JS_NewArrayBufferCopy(ctx, (const uint8_t*)${dataVar}, ${sizeParam.name})`) + gen.statement(`if (${dataVar}) MemFree(${dataVar})`) + gen.returnExp('buf') + } + } + console.log(`Special buffer binding for ${fn.name}`) + }) + // Memory functions not supported on JS, just use ArrayBuffer ignore("MemAlloc") ignore("MemRealloc") @@ -426,6 +486,7 @@ function main(){ // TODO: SaveFileData works but unnecessary makes copy of memory getFunction(api.functions, "SaveFileData")!.binding = { } ignore("ExportDataAsCode") + ignore("LoadRandomSequence") getFunction(api.functions, "LoadFileText")!.binding = { after: gen => gen.call("UnloadFileText", ["returnVal"]) } getFunction(api.functions, "SaveFileText")!.params![1].binding = { typeAlias: "const char *" } ignore("UnloadFileText") @@ -538,7 +599,6 @@ function main(){ ignore("UnloadWaveSamples") ignore("LoadMusicStreamFromMemory") ignore("LoadAudioStream") - ignore("IsAudioStreamReady") ignore("UnloadAudioStream") ignore("UpdateAudioStream") ignore("IsAudioStreamProcessed") @@ -557,10 +617,6 @@ function main(){ ignore("AttachAudioMixedProcessor") ignore("DetachAudioMixedProcessor") - ignore("Vector3OrthoNormalize") - ignore("Vector3ToFloatV") - ignore("MatrixToFloatV") - ignore("QuaternionToAxisAngle") core.exportGlobalDouble("DEG2RAD", "(PI/180.0)") core.exportGlobalDouble("RAD2DEG", "(180.0/PI)") @@ -611,6 +667,7 @@ function main(){ setOutParam(getFunction(api.functions, "GuiSpinner")!, 2) setOutParam(getFunction(api.functions, "GuiValueBox")!, 2) setOutParam(getFunction(api.functions, "GuiListView")!, 2) + setOutParam(getFunction(api.functions, "GuiListView")!, 3) // const setStringListParam = (fun: RayLibFunction, index: number, indexLen: number) => { // const lenParam = fun!.params![indexLen] @@ -637,9 +694,19 @@ function main(){ setOutParamString(getFunction(api.functions, "GuiTextBox")!, 1,2) - const gtib = getFunction(api.functions, "GuiTextInputBox")! - setOutParamString(gtib,4,5) - setOutParam(gtib, 6) + getFunction(api.functions, "GuiTextInputBox")!.binding = { + body: gen => { + gen.jsToC("Rectangle", "bounds", "argv[0]", core.structLookup) + gen.jsToC("const char *", "title", "argv[1]", core.structLookup) + gen.jsToC("const char *", "message", "argv[2]", core.structLookup) + gen.jsToC("const char *", "buttons", "argv[3]", core.structLookup) + gen.jsToC("char *", "text", "argv[4]", core.structLookup) + gen.jsToC("int", "textMaxSize", "argv[5]", core.structLookup) + gen.call("GuiTextInputBox", ["bounds", "title", "message", "buttons", "text", "textMaxSize", "NULL"], { type: "int", name: "returnVal" }) + gen.jsCleanUpParameter("const char *", "text") + gen.statement("return JS_NewInt32(ctx, returnVal)") + } + } // needs string array ignore("GuiTabBar") diff --git a/bindings/src/quickjs.ts b/bindings/src/quickjs.ts index d333780..5a07b74 100644 --- a/bindings/src/quickjs.ts +++ b/bindings/src/quickjs.ts @@ -81,6 +81,7 @@ export abstract class GenericQuickJsGenerator extend case "const void *": case "void *": case "float *": + case "const float *": case "unsigned short *": case "unsigned char *": case "const unsigned char *": @@ -92,7 +93,7 @@ export abstract class GenericQuickJsGenerator extend break; // String case "const char *": - //case "char *": + case "char *": if(!supressDeclaration) 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; @@ -106,14 +107,39 @@ export abstract class GenericQuickJsGenerator extend if(!supressDeclaration) this.statement(`${type} ${name} = (${type})_double_${name}`) else this.statement(`${name} = (${type})_double_${name}`) break; + case "char": + if(!supressDeclaration) this.declare(name, type, false, `(JS_IsNull(${src}) || JS_IsUndefined(${src})) ? 0 : JS_ToCString(ctx, ${src})[0]`) + else this.statement(`${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? 0 : JS_ToCString(ctx, ${src})[0]`) + break; + case "short": + if(!supressDeclaration) this.statement(`${type} ${name}`) + this.statement(`{ int _tmp; JS_ToInt32(ctx, &_tmp, ${src}); ${name} = (short)_tmp; }`) + break; case "int": if(!supressDeclaration) this.statement(`${type} ${name}`) this.statement(`JS_ToInt32(ctx, &${name}, ${src})`) break; + case "int *": + if(!supressDeclaration) this.statement(`int ${name}_int`) + this.statement(`JS_ToInt32(ctx, &${name}_int, ${src})`) + this.statement(`${type} ${name} = &${name}_int`) + break; + case "long": + if(!supressDeclaration) this.statement(`${type} ${name}`) + this.statement(`JS_ToInt64(ctx, &${name}, ${src})`) + break; case "unsigned int": if(!supressDeclaration) this.statement(`${type} ${name}`) this.statement(`JS_ToUint32(ctx, &${name}, ${src})`) break; + case "unsigned short": + if(!supressDeclaration) this.statement(`${type} ${name}`) + this.statement(`{ unsigned int _tmp; JS_ToUint32(ctx, &_tmp, ${src}); ${name} = (unsigned short)_tmp; }`) + break; + case "unsigned long": + if(!supressDeclaration) this.statement(`${type} ${name}`) + this.statement(`{ unsigned long long _tmp; JS_ToInt64(ctx, (int64_t *)&_tmp, ${src}); ${name} = (unsigned long)_tmp; }`) + break; case "unsigned char": this.statement("unsigned int _int_"+name) this.statement(`JS_ToUint32(ctx, &_int_${name}, ${src})`) @@ -124,6 +150,11 @@ export abstract class GenericQuickJsGenerator extend if(!supressDeclaration) this.statement(`${type} ${name} = JS_ToBool(ctx, ${src})`) else this.statement(`${name} = JS_ToBool(ctx, ${src})`) break; + case "bool *": + if(!supressDeclaration) this.statement(`bool ${name}_val`) + this.statement(`${name}_val = JS_ToBool(ctx, ${src})`) + this.statement(`${type} ${name} = &${name}_val`) + break; default: const isConst = type.startsWith('const') const isPointer = type.endsWith(' *') @@ -139,15 +170,20 @@ export abstract class GenericQuickJsGenerator extend jsToJs(type: string, name: string, src: string, classIds: StructLookup = {}){ switch (type) { case "int": + case "int *": case "long": - this.declare(name,'JSValue', false, `JS_NewInt32(ctx, ${src})`) + this.declare(name, 'JSValue', false, `JS_NewInt32(ctx, ${src})`) break; case "long": this.declare(name,'JSValue', false, `JS_NewInt64(ctx, ${src})`) break; case "unsigned int": case "unsigned char": - this.declare(name,'JSValue', false, `JS_NewUint32(ctx, ${src})`) + this.declare(name, 'JSValue', false, `JS_NewUint32(ctx, ${src})`) + break; + case "unsigned int *": + case "unsigned char *": + this.declare(name, 'JSValue', false, `${src} ? JS_NewUint32(ctx, *${src}) : JS_NULL`) break; case "bool": this.declare(name, 'JSValue', false, `JS_NewBool(ctx, ${src})`) @@ -160,9 +196,6 @@ export abstract class GenericQuickJsGenerator extend case "char *": this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`) break; - // case "unsigned char *": - // this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`) - // break; default: const classId = classIds[type] if(!classId) throw new Error("Cannot convert parameter type to Javascript: " + type) @@ -231,7 +264,6 @@ export abstract class GenericQuickJsGenerator extend const body = this.function(`js_${structName}_finalizer`, "void", args, true) body.statement(`${structName}* ptr = JS_GetOpaque(val, ${classId})`) body.if("ptr", cond => { - //cond.call("TraceLog", ["LOG_INFO",`"Finalize ${structName} %p"`,"ptr"]) if(onFinalize) onFinalize(cond, "ptr") cond.call("js_free_rt", ["rt","ptr"]) }) @@ -299,5 +331,4 @@ export class QuickJsGenerator extends GenericQuickJsGenerator createGenerator(): QuickJsGenerator { return new QuickJsGenerator() } -} - +} \ No newline at end of file diff --git a/examples/lib.raylib.d.ts b/examples/lib.raylib.d.ts index 753df65..44a8212 100644 --- a/examples/lib.raylib.d.ts +++ b/examples/lib.raylib.d.ts @@ -194,9 +194,9 @@ interface Mesh { animVertices: ArrayBuffer, /** Animated normals (after bones transformations) */ animNormals: ArrayBuffer, - /** Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) */ + /** Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) (shader-location = 6) */ boneIds: ArrayBuffer, - /** Vertex bone weight, up to 4 bones influence by vertex (skinning) */ + /** Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7) */ boneWeights: ArrayBuffer, } declare var Mesh: { @@ -259,7 +259,7 @@ declare var ModelAnimation: { interface Ray { /** Ray position (origin) */ position: Vector3, - /** Ray direction */ + /** Ray direction (normalized) */ direction: Vector3, } declare var Ray: { @@ -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,52 +398,58 @@ 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 */ declare function isWindowFullscreen(): boolean; -/** Check if window is currently hidden (only PLATFORM_DESKTOP) */ +/** Check if window is currently hidden */ declare function isWindowHidden(): boolean; -/** Check if window is currently minimized (only PLATFORM_DESKTOP) */ +/** Check if window is currently minimized */ declare function isWindowMinimized(): boolean; -/** Check if window is currently maximized (only PLATFORM_DESKTOP) */ +/** Check if window is currently maximized */ declare function isWindowMaximized(): boolean; -/** Check if window is currently focused (only PLATFORM_DESKTOP) */ +/** Check if window is currently focused */ declare function isWindowFocused(): boolean; /** Check if window has been resized last frame */ declare function isWindowResized(): boolean; /** Check if one specific window flag is enabled */ declare function isWindowState(flag: number): boolean; -/** Set window configuration state using flags (only PLATFORM_DESKTOP) */ +/** Set window configuration state using flags */ declare function setWindowState(flags: number): void; /** Clear window configuration state flags */ declare function clearWindowState(flags: number): void; -/** Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) */ +/** Toggle window state: fullscreen/windowed, resizes monitor to match window resolution */ declare function toggleFullscreen(): void; -/** Set window state: maximized, if resizable (only PLATFORM_DESKTOP) */ +/** Toggle window state: borderless windowed, resizes window to match monitor resolution */ +declare function toggleBorderlessWindowed(): void; +/** Set window state: maximized, if resizable */ declare function maximizeWindow(): void; -/** Set window state: minimized, if resizable (only PLATFORM_DESKTOP) */ +/** Set window state: minimized, if resizable */ declare function minimizeWindow(): void; -/** Set window state: not minimized/maximized (only PLATFORM_DESKTOP) */ +/** Set window state: not minimized/maximized */ declare function restoreWindow(): void; -/** Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) */ +/** Set icon for window (single image, RGBA 32bit) */ declare function setWindowIcon(image: Image): void; -/** Set title for window (only PLATFORM_DESKTOP) */ +/** Set title for window */ declare function setWindowTitle(title: string | undefined | null): void; -/** Set window position on screen (only PLATFORM_DESKTOP) */ +/** Set window position on screen */ 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) */ +/** Set window opacity [0.0f..1.0f] */ declare function setWindowOpacity(opacity: number): void; +/** Set window focused */ +declare function setWindowFocused(): void; /** Get current screen width */ declare function getScreenWidth(): number; /** Get current screen height */ @@ -446,7 +460,7 @@ declare function getRenderWidth(): number; declare function getRenderHeight(): number; /** Get number of connected monitors */ declare function getMonitorCount(): number; -/** Get current connected monitor */ +/** Get current monitor where window is placed */ declare function getCurrentMonitor(): number; /** Get specified monitor position */ declare function getMonitorPosition(monitor: number): Vector2; @@ -464,12 +478,14 @@ 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; /** Get clipboard text content */ declare function getClipboardText(): string | undefined | null; +/** Get clipboard image content */ +declare function getClipboardImage(): Image; /** Enable waiting for events on EndDrawing(), no automatic event polling */ declare function enableEventWaiting(): void; /** Disable waiting for events on EndDrawing(), automatic events polling */ @@ -528,8 +544,8 @@ declare function unloadVrStereoConfig(config: VrStereoConfig): void; declare function loadShader(vsFileName: string | undefined | null, fsFileName: string | undefined | null): Shader; /** Load shader from code strings and bind default locations */ declare function loadShaderFromMemory(vsCode: string | undefined | null, fsCode: string | undefined | null): Shader; -/** Check if a shader is ready */ -declare function isShaderReady(shader: Shader): boolean; +/** Check if a shader is valid (loaded on GPU) */ +declare function isShaderValid(shader: Shader): boolean; /** Get shader uniform location */ declare function getShaderLocation(shader: Shader, uniformName: string | undefined | null): number; /** Get shader attribute location */ @@ -542,46 +558,50 @@ declare function setShaderValueMatrix(shader: Shader, locIndex: number, mat: Mat declare function setShaderValueTexture(shader: Shader, locIndex: number, texture: Texture): void; /** 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; +/** Get a ray trace from screen position (i.e mouse) */ +declare function getScreenToWorldRay(position: Vector2, camera: Camera3D): Ray; +/** Get a ray trace from screen position (i.e mouse) in a viewport */ +declare function getScreenToWorldRayEx(position: 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; +/** 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,15 +626,19 @@ 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; +/** Create directories (including full path requested), returns 0 on success */ +declare function makeDirectory(dirPath: string | undefined | null): number; /** Change working directory, return true on success */ declare function changeDirectory(dir: string | undefined | null): boolean; /** Check if a given path is a file or a directory */ declare function isPathFile(path: string | undefined | null): boolean; +/** Check if fileName is valid for the platform/OS */ +declare function isFileNameValid(fileName: string | undefined | null): boolean; /** Load directory filepaths */ declare function loadDirectoryFiles(dirPath: string | undefined | null): string[]; -/** Load directory filepaths with extension filtering and recursive directory scan */ +/** Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result */ declare function loadDirectoryFilesEx(basePath: string | undefined | null, filter: string | undefined | null, scanSubdirs: boolean): string[]; /** Check if a file has been dropped into window */ declare function isFileDropped(): boolean; @@ -622,20 +646,44 @@ declare function isFileDropped(): boolean; declare function loadDroppedFiles(): string[]; /** Get file modification time (last write time) */ declare function getFileModTime(fileName: string | undefined | null): number; +/** Compute CRC32 hash code */ +declare function computeCRC32(data: ArrayBuffer, dataSize: number): number; +/** Compute MD5 hash code, returns static int[4] (16 bytes) */ +declare function computeMD5(data: ArrayBuffer, dataSize: number): unsigned int; +/** Compute SHA1 hash code, returns static int[5] (20 bytes) */ +declare function computeSHA1(data: ArrayBuffer, dataSize: number): unsigned int; +/** 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 */ +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 +704,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 (duration in seconds) */ +declare function setGamepadVibration(gamepad: number, leftMotor: number, rightMotor: number, duration: 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 */ @@ -700,7 +750,7 @@ declare function setGesturesEnabled(flags: number): void; declare function isGestureDetected(gesture: number): boolean; /** Get latest detected gesture */ declare function getGestureDetected(): number; -/** Get gesture hold time in milliseconds */ +/** Get gesture hold time in seconds */ declare function getGestureHoldDuration(): number; /** Get gesture drag vector */ declare function getGestureDragVector(): Vector2; @@ -716,22 +766,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; -/** Draw a pixel */ +/** 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 using geometry [Can be slow, use with care] */ declare function drawPixel(posX: number, posY: number, color: Color): void; -/** Draw a pixel (Vector version) */ +/** Draw a pixel using geometry (Vector version) [Can be slow, use with care] */ 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 */ @@ -739,11 +789,13 @@ declare function drawCircleSector(center: Vector2, radius: number, startAngle: n /** Draw circle sector outline */ declare function drawCircleSectorLines(center: Vector2, radius: number, startAngle: number, endAngle: number, segments: number, color: Color): void; /** Draw a gradient-filled circle */ -declare function drawCircleGradient(centerX: number, centerY: number, radius: number, color1: Color, color2: Color): void; +declare function drawCircleGradient(centerX: number, centerY: number, radius: number, inner: Color, outer: Color): void; /** Draw a color-filled circle (Vector version) */ 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 */ @@ -761,19 +813,21 @@ declare function drawRectangleRec(rec: Rectangle, color: Color): void; /** Draw a color-filled rectangle with pro parameters */ declare function drawRectanglePro(rec: Rectangle, origin: Vector2, rotation: number, color: Color): void; /** Draw a vertical-gradient-filled rectangle */ -declare function drawRectangleGradientV(posX: number, posY: number, width: number, height: number, color1: Color, color2: Color): void; +declare function drawRectangleGradientV(posX: number, posY: number, width: number, height: number, top: Color, bottom: Color): void; /** Draw a horizontal-gradient-filled rectangle */ -declare function drawRectangleGradientH(posX: number, posY: number, width: number, height: number, color1: Color, color2: Color): void; +declare function drawRectangleGradientH(posX: number, posY: number, width: number, height: number, left: Color, right: Color): void; /** Draw a gradient-filled rectangle with custom vertex colors */ -declare function drawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color): void; +declare function drawRectangleGradientEx(rec: Rectangle, topLeft: Color, bottomLeft: Color, topRight: Color, bottomRight: Color): void; /** Draw rectangle outline */ declare function drawRectangleLines(posX: number, posY: number, width: number, height: number, color: Color): void; /** Draw rectangle outline with extended parameters */ declare function drawRectangleLinesEx(rec: Rectangle, lineThick: number, color: Color): void; /** Draw rectangle with rounded edges */ declare function drawRectangleRounded(rec: Rectangle, roundness: number, segments: number, color: Color): void; +/** Draw rectangle lines with rounded edges */ +declare function drawRectangleRoundedLines(rec: Rectangle, roundness: number, segments: number, color: Color): void; /** Draw rectangle with rounded edges outline */ -declare function drawRectangleRoundedLines(rec: Rectangle, roundness: number, segments: number, lineThick: number, color: Color): void; +declare function drawRectangleRoundedLinesEx(rec: Rectangle, roundness: number, segments: number, lineThick: number, color: Color): void; /** Draw a color-filled triangle (vertex in counter-clockwise order!) */ declare function drawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color): void; /** Draw triangle outline (vertex in counter-clockwise order!) */ @@ -784,12 +838,44 @@ 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 */ declare function checkCollisionCircles(center1: Vector2, radius1: number, center2: Vector2, radius2: number): boolean; /** Check collision between circle and rectangle */ declare function checkCollisionCircleRec(center: Vector2, radius: number, rec: Rectangle): boolean; +/** Check if circle collides with a line created betweeen two points [p1] and [p2] */ +declare function checkCollisionCircleLine(center: Vector2, radius: number, p1: Vector2, p2: Vector2): boolean; /** Check if point is inside rectangle */ declare function checkCollisionPointRec(point: Vector2, rec: Rectangle): boolean; /** Check if point is inside circle */ @@ -804,18 +890,22 @@ 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 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 */ declare function loadImageFromTexture(texture: Texture): Image; /** Load image from screen buffer and (screenshot) */ declare function loadImageFromScreen(): Image; -/** Check if an image is ready */ -declare function isImageReady(image: Image): boolean; +/** Check if an image is valid (data and parameters) */ +declare function isImageValid(image: Image): boolean; /** Unload image from CPU memory (RAM) */ 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 */ @@ -838,6 +928,8 @@ declare function genImageText(width: number, height: number, text: string | unde declare function imageCopy(image: Image): Image; /** Create an image from another image piece */ declare function imageFromImage(image: Image, rec: Rectangle): Image; +/** Create an image from a selected channel of another image (GRAYSCALE) */ +declare function imageFromChannel(image: Image, selectedChannel: number): Image; /** Create an image from text (default font) */ declare function imageText(text: string | undefined | null, fontSize: number, color: Color): Image; /** Create an image from text (custom sprite font) */ @@ -858,6 +950,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 convolution kernel to image */ +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) */ @@ -872,7 +966,7 @@ declare function imageDither(image: Image, rBpp: number, gBpp: number, bBpp: num declare function imageFlipVertical(image: Image): void; /** Flip image horizontally */ declare function imageFlipHorizontal(image: Image): void; -/** Rotate image by input angle in degrees (-359 to 359) */ +/** Rotate image by input angle in degrees (-359 to 359) */ declare function imageRotate(image: Image, degrees: number): void; /** Rotate image clockwise 90deg */ declare function imageRotateCW(image: Image): void; @@ -906,6 +1000,8 @@ declare function imageDrawPixelV(dst: Image, position: Vector2, color: Color): v declare function imageDrawLine(dst: Image, startPosX: number, startPosY: number, endPosX: number, endPosY: number, color: Color): void; /** Draw line within an image (Vector version) */ declare function imageDrawLineV(dst: Image, start: Vector2, end: Vector2, color: Color): void; +/** Draw a line defining thickness within an image */ +declare function imageDrawLineEx(dst: Image, start: Vector2, end: Vector2, thick: number, color: Color): void; /** Draw a filled circle within an image */ declare function imageDrawCircle(dst: Image, centerX: number, centerY: number, radius: number, color: Color): void; /** Draw a filled circle within an image (Vector version) */ @@ -922,6 +1018,16 @@ declare function imageDrawRectangleV(dst: Image, position: Vector2, size: Vector declare function imageDrawRectangleRec(dst: Image, rec: Rectangle, color: Color): void; /** Draw rectangle lines within an image */ declare function imageDrawRectangleLines(dst: Image, rec: Rectangle, thick: number, color: Color): void; +/** Draw triangle within an image */ +declare function imageDrawTriangle(dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color): void; +/** Draw triangle with interpolated colors within an image */ +declare function imageDrawTriangleEx(dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, c1: Color, c2: Color, c3: Color): void; +/** Draw triangle outline within an image */ +declare function imageDrawTriangleLines(dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color): void; +/** Draw a triangle fan defined by points within an image (first vertex is the center) */ +declare function imageDrawTriangleFan(dst: Image, points: Vector2, pointCount: number, color: Color): void; +/** Draw a triangle strip defined by points within an image */ +declare function imageDrawTriangleStrip(dst: Image, points: Vector2, pointCount: number, color: Color): void; /** Draw a source image within a destination image (tint applied to source) */ declare function imageDraw(dst: Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color): void; /** Draw text (using default font) within an image (destination) */ @@ -936,12 +1042,12 @@ declare function loadTextureFromImage(image: Image): Texture; declare function loadTextureCubemap(image: Image, layout: number): Texture; /** Load texture for rendering (framebuffer) */ declare function loadRenderTexture(width: number, height: number): RenderTexture; -/** Check if a texture is ready */ -declare function isTextureReady(texture: Texture): boolean; +/** Check if a texture is valid (loaded in GPU) */ +declare function isTextureValid(texture: Texture): boolean; /** Unload texture from GPU memory (VRAM) */ declare function unloadTexture(texture: Texture): void; -/** Check if a render texture is ready */ -declare function isRenderTextureReady(target: RenderTexture): boolean; +/** Check if a render texture is valid (loaded in GPU) */ +declare function isRenderTextureValid(target: RenderTexture): boolean; /** Unload render texture from GPU memory (VRAM) */ declare function unloadRenderTexture(target: RenderTexture): void; /** Update GPU texture with new data */ @@ -966,9 +1072,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; @@ -988,6 +1096,8 @@ declare function colorContrast(color: Color, contrast: number): Color; declare function colorAlpha(color: Color, alpha: number): Color; /** Get src alpha-blended into dst color with tint */ declare function colorAlphaBlend(dst: Color, src: Color, tint: Color): Color; +/** Get color lerp interpolation between two colors, factor [0.0f..1.0f] */ +declare function colorLerp(color1: Color, color2: Color, factor: number): Color; /** Get Color structure from hexadecimal value */ declare function getColor(hexValue: number): Color; /** Get pixel data size in bytes for certain format */ @@ -996,12 +1106,12 @@ 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 set, font size is provided in pixels height */ 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; -/** Check if a font is ready */ -declare function isFontReady(font: Font): boolean; +/** Check if a font is valid (font data loaded, WARNING: GPU texture not checked) */ +declare function isFontValid(font: Font): boolean; /** Unload font from GPU memory (VRAM) */ declare function unloadFont(font: Font): void; /** Draw current FPS */ @@ -1014,6 +1124,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 */ @@ -1066,8 +1178,8 @@ declare function drawGrid(slices: number, spacing: number): void; declare function loadModel(fileName: string | undefined | null): Model; /** Load model from generated mesh (default material) */ declare function loadModelFromMesh(mesh: Mesh): Model; -/** Check if a model is ready */ -declare function isModelReady(model: Model): boolean; +/** Check if a model is valid (loaded in GPU, VAO/VBOs) */ +declare function isModelValid(model: Model): boolean; /** Unload model (including meshes) from memory (RAM and/or VRAM) */ declare function unloadModel(model: Model): void; /** Compute model bounding box limits (considers all meshes) */ @@ -1080,10 +1192,14 @@ declare function drawModelEx(model: Model, position: Vector3, rotationAxis: Vect declare function drawModelWires(model: Model, position: Vector3, scale: number, tint: Color): void; /** Draw a model wires (with texture if set) with extended parameters */ declare function drawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: number, scale: Vector3, tint: Color): void; +/** Draw a model as points */ +declare function drawModelPoints(model: Model, position: Vector3, scale: number, tint: Color): void; +/** Draw a model as points with extended parameters */ +declare function drawModelPointsEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: number, scale: Vector3, tint: Color): void; /** Draw bounding box (wires) */ declare function drawBoundingBox(box: BoundingBox, color: Color): void; /** Draw a billboard texture */ -declare function drawBillboard(camera: Camera3D, texture: Texture, position: Vector3, size: number, tint: Color): void; +declare function drawBillboard(camera: Camera3D, texture: Texture, position: Vector3, scale: number, tint: Color): void; /** Draw a billboard texture defined by source */ declare function drawBillboardRec(camera: Camera3D, texture: Texture, source: Rectangle, position: Vector3, size: Vector2, tint: Color): void; /** Draw a billboard texture defined by source and rotation */ @@ -1098,12 +1214,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) */ @@ -1128,14 +1246,16 @@ declare function genMeshHeightmap(heightmap: Image, size: Vector3): Mesh; declare function genMeshCubicmap(cubicmap: Image, cubeSize: Vector3): Mesh; /** Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) */ declare function loadMaterialDefault(): Material; -/** Check if a material is ready */ -declare function isMaterialReady(material: Material): boolean; +/** Check if a material is valid (shader assigned, map textures loaded in GPU) */ +declare function isMaterialValid(material: Material): boolean; /** Unload material from GPU memory (VRAM) */ declare function unloadMaterial(material: Material): void; /** Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) */ declare function setMaterialTexture(material: Material, mapType: number, texture: Texture): void; /** Set material for a mesh */ declare function setModelMeshMaterial(model: Model, meshId: number, materialId: number): void; +/** Update model animation mesh bone matrices (GPU skinning) */ +declare function updateModelAnimationBones(model: Model, anim: ModelAnimation, frame: number): void; /** Check collision between two spheres */ declare function checkCollisionSpheres(center1: Vector3, radius1: number, center2: Vector3, radius2: number): boolean; /** Check collision between two bounding boxes */ @@ -1160,24 +1280,30 @@ 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' */ declare function loadWaveFromMemory(fileType: string | undefined | null, fileData: ArrayBuffer, dataSize: number): Wave; -/** Checks if wave data is ready */ -declare function isWaveReady(wave: Wave): boolean; +/** Checks if wave data is valid (data loaded and parameters) */ +declare function isWaveValid(wave: Wave): boolean; /** Load sound from file */ declare function loadSound(fileName: string | undefined | null): Sound; /** Load sound from wave data */ declare function loadSoundFromWave(wave: Wave): Sound; -/** Checks if a sound is ready */ -declare function isSoundReady(sound: Sound): boolean; +/** 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 valid (data loaded and buffers initialized) */ +declare function isSoundValid(sound: Sound): boolean; /** Update sound buffer with new data */ declare function updateSound(sound: Sound, data: any, sampleCount: number): void; /** Unload wave data */ 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 */ @@ -1198,14 +1324,14 @@ declare function setSoundPitch(sound: Sound, pitch: number): void; declare function setSoundPan(sound: Sound, pan: number): void; /** Copy a wave to a new wave */ declare function waveCopy(wave: Wave): Wave; -/** Crop a wave to defined samples range */ -declare function waveCrop(wave: Wave, initSample: number, finalSample: number): void; +/** Crop a wave to defined frames range */ +declare function waveCrop(wave: Wave, initFrame: number, finalFrame: number): void; /** Convert wave data to desired format */ declare function waveFormat(wave: Wave, sampleRate: number, sampleSize: number, channels: number): void; /** Load music stream from file */ declare function loadMusicStream(fileName: string | undefined | null): Music; -/** Checks if a music stream is ready */ -declare function isMusicReady(music: Music): boolean; +/** Checks if a music stream is valid (context and buffers initialized) */ +declare function isMusicValid(music: Music): boolean; /** Unload music stream */ declare function unloadMusicStream(music: Music): void; /** Start music playing */ @@ -1232,6 +1358,8 @@ declare function setMusicPan(music: Music, pan: number): void; declare function getMusicTimeLength(music: Music): number; /** Get current music time played (in seconds) */ declare function getMusicTimePlayed(music: Music): number; +/** Checks if an audio stream is valid (buffers initialized) */ +declare function isAudioStreamValid(stream: AudioStream): boolean; /** Clamp float value */ declare function clamp(value: number, min: number, max: number): number; /** Calculate linear interpolation between two floats */ @@ -1289,6 +1417,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 +1434,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,14 +1478,27 @@ 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; +/** Orthonormalize provided vectors +Makes vectors normalized and orthogonal to each other +Gram-Schmidt function implementation */ +declare function vector3OrthoNormalize(v1: Vector3, v2: Vector3): void; /** 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 cubic hermite interpolation between two vectors and their tangents +as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic */ +declare function vector3CubicHermite(v1: Vector3, tangent1: Vector3, v2: Vector3, tangent2: Vector3, amount: number): Vector3; /** Calculate reflected vector to normal */ declare function vector3Reflect(v: Vector3, normal: Vector3): Vector3; /** Get min value for each pair of components */ @@ -1369,13 +1520,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) */ @@ -1416,7 +1590,7 @@ declare function matrixRotateZYX(angle: Vector3): Matrix; /** Get scaling matrix */ declare function matrixScale(x: number, y: number, z: number): Matrix; /** Get perspective projection matrix */ -declare function matrixFrustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix; +declare function matrixFrustum(left: number, right: number, bottom: number, top: number, nearPlane: number, farPlane: number): Matrix; /** Get perspective projection matrix NOTE: Fovy angle must be provided in radians */ declare function matrixPerspective(fovY: number, aspect: number, nearPlane: number, farPlane: number): Matrix; @@ -1452,6 +1626,9 @@ declare function quaternionLerp(q1: Vector4, q2: Vector4, amount: number): Vecto declare function quaternionNlerp(q1: Vector4, q2: Vector4, amount: number): Vector4; /** Calculates spherical linear interpolation between two quaternions */ declare function quaternionSlerp(q1: Vector4, q2: Vector4, amount: number): Vector4; +/** Calculate quaternion cubic spline interpolation using Cubic Hermite Spline algorithm +as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic */ +declare function quaternionCubicHermiteSpline(q1: Vector4, outTangent1: Vector4, q2: Vector4, inTangent2: Vector4, t: number): Vector4; /** Calculate quaternion based on the rotation from one vector to another */ declare function quaternionFromVector3ToVector3(from: Vector3, to: Vector3): Vector4; /** Get a quaternion for a given rotation matrix */ @@ -1461,6 +1638,8 @@ declare function quaternionToMatrix(q: Vector4): Matrix; /** Get rotation quaternion for an angle and axis NOTE: Angle must be provided in radians */ declare function quaternionFromAxisAngle(axis: Vector3, angle: number): Vector4; +/** Get the rotation angle and axis for a given quaternion */ +declare function quaternionToAxisAngle(q: Vector4, outAxis: Vector3, outAngle: ArrayBuffer): void; /** Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX */ declare function quaternionFromEuler(pitch: number, yaw: number, roll: number): Vector4; @@ -1471,6 +1650,8 @@ declare function quaternionToEuler(q: Vector4): Vector3; declare function quaternionTransform(q: Vector4, mat: Matrix): Vector4; /** Check whether two given quaternions are almost equal */ declare function quaternionEquals(p: Vector4, q: Vector4): number; +/** Decompose a transformation matrix into its rotational, translational and scaling components */ +declare function matrixDecompose(mat: Matrix, translation: Vector3, rotation: Quaternion, scale: Vector3): void; /** */ declare function getCameraForward(camera: Camera3D): Vector3; /** */ @@ -1506,7 +1687,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 +1700,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 +1716,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, shows text */ +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, show true when clicked */ +declare function guiLabelButton(bounds: Rectangle, text: string | undefined | null): number; +/** Toggle Button control, returns true when active */ +declare function guiToggle(bounds: Rectangle, text: string | undefined | null, active: bool): number; +/** Toggle Group control, returns active toggle index */ +declare function guiToggleGroup(bounds: Rectangle, text: string | undefined | null, active: int): number; +/** Toggle Slider control, returns true when clicked */ +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, returns selected item index */ +declare function guiComboBox(bounds: Rectangle, text: string | undefined | null, active: int): number; +/** Dropdown Box control, returns selected item */ +declare function guiDropdownBox(bounds: Rectangle, text: string | undefined | null, active: { active: number }, editMode: boolean): number; +/** Spinner control, returns selected value */ +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, returns selected value */ +declare function guiSlider(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: ArrayBuffer, 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: ArrayBuffer, 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: 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, returns mouse cell position */ +declare function guiGrid(bounds: Rectangle, text: string | undefined | null, spacing: number, subdivs: number, mouseCell: Vector2): number; +/** List View control, returns selected list item index */ +declare function guiListView(bounds: Rectangle, text: string | undefined | null, scrollIndex: { scrollIndex: number }, active: { 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: string | undefined | null, textMaxSize: number, secretViewActive: bool): 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 returns HSV color value, used by GuiColorPickerHSV() */ +declare function guiColorPanelHSV(bounds: Rectangle, text: string | undefined | null, colorHsv: Vector3): number; /** //---------------------------------------------------------------------------------- Module Functions Declaration //---------------------------------------------------------------------------------- */ @@ -1759,6 +1946,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) */ @@ -2047,17 +2236,17 @@ declare var GAMEPAD_BUTTON_LEFT_FACE_DOWN: number; declare var GAMEPAD_BUTTON_LEFT_FACE_LEFT: number; /** Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) */ declare var GAMEPAD_BUTTON_RIGHT_FACE_UP: number; -/** Gamepad right button right (i.e. PS3: Square, Xbox: X) */ +/** Gamepad right button right (i.e. PS3: Circle, Xbox: B) */ declare var GAMEPAD_BUTTON_RIGHT_FACE_RIGHT: number; /** Gamepad right button down (i.e. PS3: Cross, Xbox: A) */ declare var GAMEPAD_BUTTON_RIGHT_FACE_DOWN: number; -/** Gamepad right button left (i.e. PS3: Circle, Xbox: B) */ +/** Gamepad right button left (i.e. PS3: Square, Xbox: X) */ declare var GAMEPAD_BUTTON_RIGHT_FACE_LEFT: number; /** Gamepad top/back trigger left (first), it could be a trailing button */ declare var GAMEPAD_BUTTON_LEFT_TRIGGER_1: number; /** Gamepad top/back trigger left (second), it could be a trailing button */ declare var GAMEPAD_BUTTON_LEFT_TRIGGER_2: number; -/** Gamepad top/back trigger right (one), it could be a trailing button */ +/** Gamepad top/back trigger right (first), it could be a trailing button */ declare var GAMEPAD_BUTTON_RIGHT_TRIGGER_1: number; /** Gamepad top/back trigger right (second), it could be a trailing button */ declare var GAMEPAD_BUTTON_RIGHT_TRIGGER_2: number; @@ -2157,6 +2346,12 @@ declare var SHADER_LOC_MAP_IRRADIANCE: number; declare var SHADER_LOC_MAP_PREFILTER: number; /** Shader location: sampler2d texture: brdf */ declare var SHADER_LOC_MAP_BRDF: number; +/** Shader location: vertex attribute: boneIds */ +declare var SHADER_LOC_VERTEX_BONEIDS: number; +/** Shader location: vertex attribute: boneWeights */ +declare var SHADER_LOC_VERTEX_BONEWEIGHTS: number; +/** Shader location: array of matrices uniform: boneMatrices */ +declare var SHADER_LOC_BONE_MATRICES: number; /** Shader uniform type: float */ declare var SHADER_UNIFORM_FLOAT: number; /** Shader uniform type: vec2 (2 float) */ @@ -2203,6 +2398,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) */ @@ -2255,8 +2456,6 @@ declare var CUBEMAP_LAYOUT_LINE_HORIZONTAL: number; declare var CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR: number; /** Layout is defined by a 4x3 cross with cubemap faces */ declare var CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE: number; -/** Layout is defined by a panorama image (equirrectangular map) */ -declare var CUBEMAP_LAYOUT_PANORAMA: number; /** Default font generation, anti-aliased */ declare var FONT_DEFAULT: number; /** Bitmap font generation, no anti-aliasing */ @@ -2301,15 +2500,15 @@ declare var GESTURE_SWIPE_DOWN: number; declare var GESTURE_PINCH_IN: number; /** Pinch out gesture */ declare var GESTURE_PINCH_OUT: number; -/** Custom camera */ +/** Camera custom, controlled by user (UpdateCamera() does nothing) */ declare var CAMERA_CUSTOM: number; -/** Free camera */ +/** Camera free mode */ declare var CAMERA_FREE: number; -/** Orbital camera */ +/** Camera orbital, around target, zoom supported */ declare var CAMERA_ORBITAL: number; -/** First person camera */ +/** Camera first person */ declare var CAMERA_FIRST_PERSON: number; -/** Third person camera */ +/** Camera third person */ declare var CAMERA_THIRD_PERSON: number; /** Perspective projection */ declare var CAMERA_PERSPECTIVE: number; @@ -2336,6 +2535,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 +2554,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 +2578,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 +2616,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 +2630,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 +2652,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 +2664,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; diff --git a/examples/textures/bunnymark_opt.js b/examples/textures/bunnymark_opt.js new file mode 100644 index 0000000..96575ff --- /dev/null +++ b/examples/textures/bunnymark_opt.js @@ -0,0 +1,92 @@ +// Optimized Bunnymark — Float32Array, no GC pressure +// Initialization +const screenWidth = 800; +const screenHeight = 450; +const MAX_BUNNIES = 50000; +const BUNNY_STRIDE = 8; // x, y, sx, sy, r, g, b, a + +setConfigFlags(FLAG_MSAA_4X_HINT); +initWindow(screenWidth, screenHeight, "raylib bunnymark [OPTIMIZED]"); + +// Load bunny texture once +const texBunny = loadTexture("resources/wabbit_alpha.png"); +const texW = texBunny.width; +const texH = texBunny.height; + +// Flat Float32Array — no JS object overhead, no GC +const bunny = new Float32Array(MAX_BUNNIES * BUNNY_STRIDE); +let count = 0; + +// Pre-allocate Color struct for drawing (reuse, no allocation per frame) +const drawColor = new Color(255, 255, 255, 255); + +// Cache screen size +let width = screenWidth; +let height = screenHeight; + +// Frame timing +let prevTime = getTime(); + +setTargetFPS(60); + +// Main loop +while (!windowShouldClose()) { + // === SPAWN === + if (isMouseButtonDown(MOUSE_BUTTON_LEFT)) { + const mx = getMouseX(); + const my = getMouseY(); + const limit = Math.min(count + 100, MAX_BUNNIES); + for (let i = count; i < limit; i++) { + const off = i * BUNNY_STRIDE; + bunny[off] = mx; // x + bunny[off + 1] = my; // y + bunny[off + 2] = getRandomValue(-250, 250) / 60.0; // sx + bunny[off + 3] = getRandomValue(-250, 250) / 60.0; // sy + bunny[off + 4] = getRandomValue(50, 240); // r + bunny[off + 5] = getRandomValue(80, 240); // g + bunny[off + 6] = getRandomValue(100, 240); // b + bunny[off + 7] = 255; // a + } + count = limit; + } + + // === UPDATE === + const hw = texW / 2; + const hh = texH / 2; + for (let i = 0; i < count; i++) { + const off = i * BUNNY_STRIDE; + bunny[off] += bunny[off + 2]; // x += sx + bunny[off + 1] += bunny[off + 3]; // y += sy + + if ((bunny[off] + hw) > width || (bunny[off] + hw) < 0) + bunny[off + 2] *= -1; // sx + if ((bunny[off + 1] + hh) > height || (bunny[off + 1] + hh - 40) < 0) + bunny[off + 3] *= -1; // sy + } + + // === DRAW === + beginDrawing(); + clearBackground(RAYWHITE); + + // Batch draw — reuse Color object, only update fields + for (let i = 0; i < count; i++) { + const off = i * BUNNY_STRIDE; + drawColor.r = bunny[off + 4]; + drawColor.g = bunny[off + 5]; + drawColor.b = bunny[off + 6]; + drawColor.a = bunny[off + 7]; + drawTexture(texBunny, bunny[off], bunny[off + 1], drawColor); + } + + // HUD + drawRectangle(0, 0, screenWidth, 40, BLACK); + const fps = getFPS(); + drawText(`bunnies: ${count} fps: ${fps}`, 120, 10, 20, GREEN); + drawText(`batched draws: ${1 + Math.floor(count / 8192)}`, 320, 10, 20, MAROON); + + endDrawing(); +} + +// Cleanup +unloadTexture(texBunny); +closeWindow(); \ No newline at end of file diff --git a/generate-bindings.js b/generate-bindings.js index 7b0b54a..5849137 100644 --- a/generate-bindings.js +++ b/generate-bindings.js @@ -1,1575 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/generation.ts": -/*!***************************!*\ - !*** ./src/generation.ts ***! - \***************************/ -/***/ ((__unused_webpack_module, exports) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.CodeGenerator = exports.GenericCodeGenerator = exports.CodeWriter = exports.StringWriter = void 0; -class StringWriter { - constructor() { - this.buffer = ''; - } - write(value) { - this.buffer += value; - } - writeLine(value = '') { - this.buffer += value + '\n'; - } - toString() { - return this.buffer; - } -} -exports.StringWriter = StringWriter; -class CodeWriter extends StringWriter { - constructor() { - super(...arguments); - this.indent = 0; - this.needsIndent = true; - } - writeGenerator(generator) { - const tokens = generator.iterateTokens(); - const text = generator.iterateText(); - const children = generator.iterateChildren(); - let result = tokens.next(); - while (!result.done) { - switch (result.value) { - case Token.STRING: - const str = text.next().value; - if (this.needsIndent) { - this.write(" ".repeat(this.indent)); - this.needsIndent = false; - } - this.write(str); - break; - case Token.GOSUB: - const sub = children.next().value; - this.writeGenerator(sub); - break; - case Token.INDENT: - this.indent++; - break; - case Token.UNINDENT: - this.indent = this.indent > 0 ? this.indent - 1 : 0; - break; - case Token.NEWLINE: - this.write("\n"); - this.needsIndent = true; - break; - default: - break; - } - result = tokens.next(); - } - } -} -exports.CodeWriter = CodeWriter; -var Token; -(function (Token) { - Token[Token["STRING"] = 0] = "STRING"; - Token[Token["NEWLINE"] = 1] = "NEWLINE"; - Token[Token["INDENT"] = 2] = "INDENT"; - Token[Token["UNINDENT"] = 3] = "UNINDENT"; - Token[Token["GOSUB"] = 4] = "GOSUB"; -})(Token || (Token = {})); -class GenericCodeGenerator { - constructor() { - this.children = []; - this.text = []; - this.tokens = []; - this.tags = {}; - } - getTag(key) { - return this.tags[key]; - } - setTag(key, value) { - this.tags[key] = value; - } - iterateTokens() { - return this.tokens[Symbol.iterator](); - } - iterateText() { - return this.text[Symbol.iterator](); - } - iterateChildren() { - return this.children[Symbol.iterator](); - } - line(text) { - this.tokens.push(Token.STRING, Token.NEWLINE); - this.text.push(text); - } - comment(text) { - this.line("// " + text); - } - call(name, params, returnVal = null) { - if (returnVal) - this.inline(`${returnVal.type} ${returnVal.name} = `); - this.inline(name + "("); - this.inline(params.join(", ")); - this.statement(")"); - } - declare(name, type, isStatic = false, initValue = null) { - if (isStatic) - this.inline("static "); - this.inline(type + " " + name); - if (initValue) - this.inline(" = " + initValue); - this.statement(""); - } - child(sub) { - if (!sub) - sub = this.createGenerator(); - this.tokens.push(Token.GOSUB); - this.children.push(sub); - return sub; - } - inline(str) { - this.tokens.push(Token.STRING); - this.text.push(str); - } - statement(str) { - this.line(str + ";"); - } - breakLine() { - this.tokens.push(Token.NEWLINE); - } - indent() { - this.tokens.push(Token.INDENT); - } - unindent() { - this.tokens.push(Token.UNINDENT); - } - function(name, returnType, args, isStatic, func) { - const sub = this.createGenerator(); - sub.setTag("_type", "function-body"); - sub.setTag("_name", name); - sub.setTag("_isStatic", isStatic); - sub.setTag("_returnType", returnType); - if (isStatic) - this.inline("static "); - this.inline(returnType + " " + name + "("); - this.inline(args.map(x => x.type + " " + x.name).join(", ")); - this.inline(") {"); - this.breakLine(); - this.indent(); - this.child(sub); - this.unindent(); - this.line("}"); - this.breakLine(); - if (func) - func(sub); - return sub; - } - if(condition, funIf) { - this.line("if(" + condition + ") {"); - this.indent(); - const sub = this.createGenerator(); - sub.setTag("_type", "if-body"); - sub.setTag("_condition", condition); - this.child(sub); - this.unindent(); - this.line("}"); - if (funIf) - funIf(sub); - return sub; - } - else(funElse) { - this.line("else {"); - this.indent(); - const sub = this.createGenerator(); - sub.setTag("_type", "else-body"); - this.child(sub); - this.unindent(); - this.line("}"); - if (funElse) - funElse(sub); - return sub; - } - returnExp(exp) { - this.statement("return " + exp); - } - include(name) { - this.line("#include <" + name + ">"); - } - for(indexVar, lengthVar) { - this.line(`for(int ${indexVar}; i < ${lengthVar}; i++){`); - this.indent(); - const child = this.child(); - this.unindent(); - this.line("}"); - return child; - } - header(guard, fun) { - this.line("#ifndef " + guard); - this.line("#define " + guard); - this.breakLine(); - const sub = this.child(); - sub.setTag("_type", "header-body"); - sub.setTag("_guardName", guard); - this.line("#endif // " + guard); - if (fun) - fun(sub); - return sub; - } - declareStruct(structName, varName, values, isStatic = false) { - if (isStatic) - this.inline("static "); - this.statement(`${structName} ${varName} = { ${values.join(', ')} }`); - } - switch(switchVar) { - this.line(`switch(${switchVar}) {`); - this.indent(); - const body = this.child(); - this.unindent(); - this.line("}"); - return body; - } - case(value) { - this.line(`case ${value}:`); - } - defaultBreak() { - this.line("default:"); - this.line("{"); - this.indent(); - const body = this.child(); - this.statement("break"); - this.unindent(); - this.line("}"); - return body; - } - caseBreak(value) { - this.case(value); - this.line("{"); - this.indent(); - const body = this.child(); - this.statement("break"); - this.unindent(); - this.line("}"); - return body; - } -} -exports.GenericCodeGenerator = GenericCodeGenerator; -class CodeGenerator extends GenericCodeGenerator { - createGenerator() { - return new CodeGenerator(); - } -} -exports.CodeGenerator = CodeGenerator; - - -/***/ }), - -/***/ "./src/header-parser.ts": -/*!******************************!*\ - !*** ./src/header-parser.ts ***! - \******************************/ -/***/ ((__unused_webpack_module, exports) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.HeaderParser = void 0; -class HeaderParser { - parseEnums(input) { - const matches = [...input.matchAll(/((?:\/\/.+\n)*)typedef enum {\n([^}]+)} ([^;]+)/gm)]; - return matches.map(groups => { - return { - description: this.parseComments(groups[1]), - values: this.parseEnumValues(groups[2]), - name: groups[3], - }; - }); - } - parseEnumValues(input) { - let lastNumber = 0; - return input.split('\n') - .map(line => line.trim().match(/([^ ,]+)(?: = ([0-9]+))?,?(?: *)(?:\/\/ (.+))?/)) - .filter(x => x !== null && !x[0].startsWith("/")) - .map(groups => { - let val = lastNumber = groups[2] ? parseInt(groups[2]) : lastNumber; - lastNumber++; - return { - name: groups[1], - description: groups[3] || "", - value: val - }; - }); - } - parseComments(input) { - return input.split('\n').map(x => x.replace("// ", "")).join('\n').trim(); - } - parseFunctionDefinitions(input) { - const matches = [...input.matchAll(/^[A-Z]+ (.+?)(\w+)\(([^\)]+)\);(?: +\/\/ (.+))?$/gm)]; - return matches.map(groups => ({ - returnType: groups[1].trim(), - name: groups[2], - params: this.parseFunctionArgs(groups[3]), - description: groups[4] || "" - })); - } - parseFunctions(input, noPrefix = false) { - const matches = noPrefix - ? [...input.matchAll(/((?:\/\/.+\n)+)^(.+?)(\w+)\(([^\)]+)\)/gm)] - : [...input.matchAll(/((?:\/\/.+\n)+)^[A-Z]+ (.+?)(\w+)\(([^\)]+)\)/gm)]; - return matches.map(groups => ({ - returnType: groups[2].trim(), - name: groups[3], - params: this.parseFunctionArgs(groups[4]), - description: groups[1] ? this.parseComments(groups[1]) : "" - })); - } - parseFunctionArgs(input) { - return input.split(',').filter(x => x !== 'void').map(arg => { - arg = arg.trim().replace(" *", "* "); - const frags = arg.split(' '); - const name = frags.pop(); - const type = frags.join(' ').replace("*", " *"); - return { name: name || "", type: type.trim() }; - }); - } - parseStructs(input) { - return [...input.matchAll(/((?:\/\/.+\n)+)typedef struct {([^}]+)} ([^;]+);/gm)].map(groups => ({ - name: groups[3], - fields: this.parseStructFields(groups[2]), - description: this.parseComments(groups[1]) - })); - } - parseStructFields(input) { - return input.trim().split("\n").map(x => x.trim()).filter(x => !x.startsWith("/") && x.endsWith(";")).map(x => { - const match = x.match(/([^ ]+(?: \*)?) ([^;]+);/); - return { - name: match[2], - type: match[1], - description: "" - }; - }); - } -} -exports.HeaderParser = HeaderParser; - - -/***/ }), - -/***/ "./src/quickjs.ts": -/*!************************!*\ - !*** ./src/quickjs.ts ***! - \************************/ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.QuickJsGenerator = exports.GenericQuickJsGenerator = exports.QuickJsHeader = void 0; -const fs_1 = __webpack_require__(/*! fs */ "fs"); -const generation_1 = __webpack_require__(/*! ./generation */ "./src/generation.ts"); -class QuickJsHeader { - constructor(name) { - this.name = name; - this.structLookup = {}; - const root = this.root = new QuickJsGenerator(); - const body = this.body = root.header("JS_" + this.name + "_GUARD"); - const includes = this.includes = body.child(); - includes.include("stdio.h"); - includes.include("stdlib.h"); - includes.include("string.h"); - includes.breakLine(); - includes.include("quickjs.h"); - body.breakLine(); - body.line("#ifndef countof"); - body.line("#define countof(x) (sizeof(x) / sizeof((x)[0]))"); - body.line("#endif"); - body.breakLine(); - this.definitions = body.child(); - body.breakLine(); - this.structs = body.child(); - this.functions = body.child(); - this.moduleFunctionList = body.jsFunctionList("js_" + name + "_funcs"); - const moduleInitFunc = body.function("js_" + this.name + "_init", "int", [{ type: "JSContext *", name: "ctx" }, { type: "JSModuleDef *", name: "m" }], true); - const moduleInit = this.moduleInit = moduleInitFunc.child(); - moduleInit.statement(`JS_SetModuleExportList(ctx, m,${this.moduleFunctionList.getTag("_name")},countof(${this.moduleFunctionList.getTag("_name")}))`); - moduleInitFunc.returnExp("0"); - const moduleEntryFunc = body.function("js_init_module_" + this.name, "JSModuleDef *", [{ type: "JSContext *", name: "ctx" }, { type: "const char *", name: "module_name" }], false); - const moduleEntry = this.moduleEntry = moduleEntryFunc.child(); - moduleEntry.statement("JSModuleDef *m"); - moduleEntry.statement(`m = JS_NewCModule(ctx, module_name, ${moduleInitFunc.getTag("_name")})`); - moduleEntry.statement("if(!m) return NULL"); - moduleEntry.statement(`JS_AddModuleExportList(ctx, m, ${this.moduleFunctionList.getTag("_name")}, countof(${this.moduleFunctionList.getTag("_name")}))`); - moduleEntryFunc.statement("return m"); - } - registerStruct(struct, classId) { - this.structLookup[struct] = classId; - } - writeTo(filename) { - const writer = new generation_1.CodeWriter(); - writer.writeGenerator(this.root); - (0, fs_1.writeFileSync)(filename, writer.toString()); - } -} -exports.QuickJsHeader = QuickJsHeader; -class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { - jsBindingFunction(jsName) { - const args = [ - { type: "JSContext *", name: "ctx" }, - { type: "JSValueConst", name: "this_val" }, - { type: "int", name: "argc" }, - { type: "JSValueConst *", name: "argv" }, - ]; - const sub = this.function("js_" + jsName, "JSValue", args, true); - return sub; - } - jsToC(type, name, src, classIds = {}, supressDeclaration = false, typeAlias) { - switch (typeAlias ?? type) { - // Array Buffer - case "const void *": - case "void *": - case "float *": - case "unsigned short *": - case "unsigned char *": - case "const unsigned char *": - 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"); - this.declare(name, type, false, "malloc(" + name + "_size)"); - this.call("memcpy", ["(void *)" + name, "(const void *)" + name + "_js", name + "_size"]); - break; - // String - case "const char *": - //case "char *": - if (!supressDeclaration) - 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}`); - 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}`); - else - this.statement(`${name} = (${type})_double_${name}`); - break; - case "int": - if (!supressDeclaration) - this.statement(`${type} ${name}`); - this.statement(`JS_ToInt32(ctx, &${name}, ${src})`); - break; - case "unsigned int": - if (!supressDeclaration) - 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}`); - else - this.statement(`${name} = (${type})_int_${name}`); - break; - case "bool": - if (!supressDeclaration) - 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); - const suffix = isPointer ? "" : "_ptr"; - this.jsOpqToStructPtr(type.replace(" *", ""), name + suffix, src, classId); - this.statement(`if(${name + suffix} == NULL) return JS_EXCEPTION`); - if (!isPointer) - this.declare(name, type, false, `*${name}_ptr`); - } - } - jsToJs(type, name, src, classIds = {}) { - switch (type) { - case "int": - case "long": - this.declare(name, 'JSValue', false, `JS_NewInt32(ctx, ${src})`); - break; - case "long": - this.declare(name, 'JSValue', false, `JS_NewInt64(ctx, ${src})`); - break; - case "unsigned int": - case "unsigned char": - this.declare(name, 'JSValue', false, `JS_NewUint32(ctx, ${src})`); - break; - case "bool": - this.declare(name, 'JSValue', false, `JS_NewBool(ctx, ${src})`); - break; - case "float": - case "double": - this.declare(name, 'JSValue', false, `JS_NewFloat64(ctx, ${src})`); - break; - case "const char *": - case "char *": - this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`); - break; - // case "unsigned char *": - // this.declare(name, 'JSValue', false, `JS_NewString(ctx, ${src})`) - // break; - default: - const classId = classIds[type]; - if (!classId) - throw new Error("Cannot convert parameter type to Javascript: " + type); - this.jsStructToOpq(type, name, src, classId); - } - } - jsStructToOpq(structType, jsVar, srcVar, classId) { - this.declare(jsVar + "_ptr", structType + "*", false, `(${structType}*)js_malloc(ctx, sizeof(${structType}))`); - this.statement("*" + jsVar + "_ptr = " + srcVar); - this.declare(jsVar, "JSValue", false, `JS_NewObjectClass(ctx, ${classId})`); - this.call("JS_SetOpaque", [jsVar, jsVar + "_ptr"]); - } - jsCleanUpParameter(type, name) { - switch (type) { - case "char *": - case "const char *": - this.statement(`JS_FreeCString(ctx, ${name})`); - break; - case "const void *": - case "void *": - case "float *": - case "unsigned short *": - case "unsigned char *": - case "const unsigned char *": - this.statement(`free((void *)${name})`); - break; - default: - break; - } - } - jsFunctionList(name) { - this.line("static const JSCFunctionListEntry " + name + "[] = {"); - this.indent(); - const sub = this.createGenerator(); - sub.setTag("_type", "js-function-list"); - sub.setTag("_name", name); - this.child(sub); - this.unindent(); - this.statement("}"); - this.breakLine(); - return sub; - } - jsFuncDef(jsName, numArgs, cName) { - this.line(`JS_CFUNC_DEF("${jsName}",${numArgs},${cName}),`); - } - jsClassId(id) { - this.declare(id, "JSClassID", true); - return id; - } - jsPropStringDef(key, value) { - this.line(`JS_PROP_STRING_DEF("${key}","${value}", JS_PROP_CONFIGURABLE),`); - } - jsGetSetDef(key, getFunc, setFunc) { - this.line(`JS_CGETSET_DEF("${key}",${getFunc || "NULL"},${setFunc || "NULL"}),`); - } - jsStructFinalizer(classId, structName, onFinalize) { - const args = [{ type: "JSRuntime *", name: "rt" }, { type: "JSValue", name: "val" }]; - const body = this.function(`js_${structName}_finalizer`, "void", args, true); - body.statement(`${structName}* ptr = JS_GetOpaque(val, ${classId})`); - body.if("ptr", cond => { - //cond.call("TraceLog", ["LOG_INFO",`"Finalize ${structName} %p"`,"ptr"]) - if (onFinalize) - onFinalize(cond, "ptr"); - cond.call("js_free_rt", ["rt", "ptr"]); - }); - return body; - } - jsClassDeclaration(structName, classId, finalizerName, funcListName) { - const body = this.function("js_declare_" + structName, "int", [{ type: "JSContext *", name: "ctx" }, { type: "JSModuleDef *", name: "m" }], true); - body.call("JS_NewClassID", ["&" + classId]); - const classDefName = `js_${structName}_def`; - body.declare(classDefName, "JSClassDef", false, `{ .class_name = "${structName}", .finalizer = ${finalizerName} }`); - body.call("JS_NewClass", ["JS_GetRuntime(ctx)", classId, "&" + classDefName]); - body.declare("proto", "JSValue", false, "JS_NewObject(ctx)"); - body.call("JS_SetPropertyFunctionList", ["ctx", "proto", funcListName, `countof(${funcListName})`]); - body.call("JS_SetClassProto", ["ctx", classId, "proto"]); - body.statement("return 0"); - return body; - } - jsStructGetter(structName, classId, field, type, classIds, overrideRead) { - const args = [{ type: "JSContext*", name: "ctx" }, { type: "JSValueConst", name: "this_val" }]; - const fun = this.function(`js_${structName}_get_${field}`, "JSValue", args, true); - fun.declare("ptr", structName + "*", false, `JS_GetOpaque2(ctx, this_val, ${classId})`); - if (overrideRead) { - overrideRead(fun); - } - else { - fun.declare(field, type, false, "ptr->" + field); - } - fun.jsToJs(type, "ret", field, classIds); - fun.returnExp("ret"); - return fun; - } - jsStructSetter(structName, classId, field, type, classIds, overrideWrite) { - const args = [{ type: "JSContext*", name: "ctx" }, { type: "JSValueConst", name: "this_val" }, { type: "JSValueConst", name: "v" }]; - const fun = this.function(`js_${structName}_set_${field}`, "JSValue", args, true); - fun.declare("ptr", structName + "*", false, `JS_GetOpaque2(ctx, this_val, ${classId})`); - fun.jsToC(type, "value", "v", classIds); - if (overrideWrite) { - overrideWrite(fun); - } - else { - fun.statement("ptr->" + field + " = value"); - } - fun.returnExp("JS_UNDEFINED"); - return fun; - } - jsOpqToStructPtr(structType, structVar, srcVar, classId) { - this.declare(structVar, structType + "*", false, `(${structType}*)JS_GetOpaque2(ctx, ${srcVar}, ${classId})`); - } - jsStructConstructor(structName, fields, classId, classIds) { - const body = this.jsBindingFunction(structName + "_constructor"); - for (let i = 0; i < fields.length; i++) { - const para = fields[i]; - body.jsToC(para.type, para.name, "argv[" + i + "]", classIds); - } - body.declareStruct(structName, "_struct", fields.map(x => x.name)); - body.jsStructToOpq(structName, "_return", "_struct", classId); - body.returnExp("_return"); - return body; - } -} -exports.GenericQuickJsGenerator = GenericQuickJsGenerator; -class QuickJsGenerator extends GenericQuickJsGenerator { - createGenerator() { - return new QuickJsGenerator(); - } -} -exports.QuickJsGenerator = QuickJsGenerator; - - -/***/ }), - -/***/ "./src/raylib-header.ts": -/*!******************************!*\ - !*** ./src/raylib-header.ts ***! - \******************************/ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.RayLibHeader = void 0; -const quickjs_1 = __webpack_require__(/*! ./quickjs */ "./src/quickjs.ts"); -const typescript_1 = __webpack_require__(/*! ./typescript */ "./src/typescript.ts"); -class RayLibHeader extends quickjs_1.QuickJsHeader { - constructor(name) { - super(name); - this.typings = new typescript_1.TypeScriptDeclaration(); - this.includes.include("raylib.h"); - //this.includes.line("#define RAYMATH_IMPLEMENTATION") - } - addApiFunction(api) { - const options = api.binding || {}; - if (options.ignore) - return; - const jName = options.jsName || api.name.charAt(0).toLowerCase() + api.name.slice(1); - console.log("Binding function " + api.name); - const fun = this.functions.jsBindingFunction(jName); - if (options.body) { - options.body(fun); - } - else { - if (options.before) - options.before(fun); - // read parameters - api.params = api.params || []; - const activeParams = api.params.filter(x => !x.binding?.ignore); - for (let i = 0; i < activeParams.length; i++) { - const para = activeParams[i]; - if (para.binding?.customConverter) - para.binding.customConverter(fun, "argv[" + i + "]"); - else - fun.jsToC(para.type, para.name, "argv[" + i + "]", this.structLookup, false, para.binding?.typeAlias); - } - // call c function - if (options.customizeCall) - fun.line(options.customizeCall); - else - fun.call(api.name, api.params.map(x => x.name), api.returnType === "void" ? null : { type: api.returnType, name: "returnVal" }); - // clean up parameters - for (let i = 0; i < activeParams.length; i++) { - const param = activeParams[i]; - if (param.binding?.customCleanup) - param.binding.customCleanup(fun, "argv[" + i + "]"); - else - fun.jsCleanUpParameter(param.type, param.name); - } - // return result - if (api.returnType === "void") { - if (options.after) - options.after(fun); - fun.statement("return JS_UNDEFINED"); - } - else { - fun.jsToJs(api.returnType, "ret", "returnVal", this.structLookup); - if (options.after) - options.after(fun); - fun.returnExp("ret"); - } - } - // add binding to function declaration - this.moduleFunctionList.jsFuncDef(jName, (api.params || []).filter(x => !x.binding?.ignore).length, fun.getTag("_name")); - this.typings.addFunction(jName, api); - } - addEnum(renum) { - console.log("Binding enum " + renum.name); - renum.values.forEach(x => this.exportGlobalInt(x.name, x.description)); - } - addApiStruct(struct) { - const options = struct.binding || {}; - console.log("Binding struct " + struct.name); - const classId = this.definitions.jsClassId(`js_${struct.name}_class_id`); - this.registerStruct(struct.name, classId); - options.aliases?.forEach(x => this.registerStruct(x, classId)); - const finalizer = this.structs.jsStructFinalizer(classId, struct.name, (gen, ptr) => options.destructor && gen.call(options.destructor.name, ["*" + ptr])); - const propDeclarations = this.structs.createGenerator(); - if (options && options.properties) { - for (const field of Object.keys(options.properties)) { - const type = struct.fields.find(x => x.name === field)?.type; - if (!type) - throw new Error(`Struct ${struct.name} does not contain field ${field}`); - const el = options.properties[field]; - let _get = undefined; - let _set = undefined; - if (el.get) - _get = this.structs.jsStructGetter(struct.name, classId, field, type, /*Be carefull when allocating memory in a getter*/ this.structLookup, el.overrideRead); - if (el.set) - _set = this.structs.jsStructSetter(struct.name, classId, field, type, this.structLookup, el.overrideWrite); - propDeclarations.jsGetSetDef(field, _get?.getTag("_name"), _set?.getTag("_name")); - } - } - const classFuncList = this.structs.jsFunctionList(`js_${struct.name}_proto_funcs`); - classFuncList.child(propDeclarations); - classFuncList.jsPropStringDef("[Symbol.toStringTag]", struct.name); - const classDecl = this.structs.jsClassDeclaration(struct.name, classId, finalizer.getTag("_name"), classFuncList.getTag("_name")); - this.moduleInit.call(classDecl.getTag("_name"), ["ctx", "m"]); - if (options?.createConstructor || options?.createEmptyConstructor) { - const body = this.functions.jsStructConstructor(struct.name, options?.createEmptyConstructor ? [] : struct.fields, classId, this.structLookup); - this.moduleInit.statement(`JSValue ${struct.name}_constr = JS_NewCFunction2(ctx, ${body.getTag("_name")},"${struct.name})", ${struct.fields.length}, JS_CFUNC_constructor_or_func, 0)`); - this.moduleInit.call("JS_SetModuleExport", ["ctx", "m", `"${struct.name}"`, struct.name + "_constr"]); - this.moduleEntry.call("JS_AddModuleExport", ["ctx", "m", '"' + struct.name + '"']); - } - this.typings.addStruct(struct); - } - exportGlobalStruct(structName, exportName, values, description) { - this.moduleInit.declareStruct(structName, exportName + "_struct", values); - const classId = this.structLookup[structName]; - if (!classId) - throw new Error("Struct " + structName + " not found in register"); - this.moduleInit.jsStructToOpq(structName, exportName + "_js", exportName + "_struct", classId); - this.moduleInit.call("JS_SetModuleExport", ["ctx", "m", `"${exportName}"`, exportName + "_js"]); - this.moduleEntry.call("JS_AddModuleExport", ["ctx", "m", `"${exportName}"`]); - this.typings.constants.tsDeclareConstant(exportName, structName, description); - } - exportGlobalInt(name, description) { - this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${name}", JS_NewInt32(ctx, ${name}))`); - this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${name}")`); - this.typings.constants.tsDeclareConstant(name, "number", description); - } - exportGlobalDouble(name, description) { - this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${name}", JS_NewFloat64(ctx, ${name}))`); - this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${name}")`); - this.typings.constants.tsDeclareConstant(name, "number", description); - } -} -exports.RayLibHeader = RayLibHeader; - - -/***/ }), - -/***/ "./src/typescript.ts": -/*!***************************!*\ - !*** ./src/typescript.ts ***! - \***************************/ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.TypescriptGenerator = exports.GenericTypescriptGenerator = exports.TypeScriptDeclaration = void 0; -const generation_1 = __webpack_require__(/*! ./generation */ "./src/generation.ts"); -const fs_1 = __webpack_require__(/*! fs */ "fs"); -class TypeScriptDeclaration { - constructor() { - this.root = new TypescriptGenerator(); - this.structs = this.root.child(); - this.functions = this.root.child(); - this.constants = this.root.child(); - } - addFunction(name, api) { - const options = api.binding || {}; - const para = (api.params || []).filter(x => !x.binding?.ignore).map(x => ({ name: x.name, type: x.binding?.jsType ?? this.toJsType(x.type) })); - const returnType = options.jsReturns ?? this.toJsType(api.returnType); - this.functions.tsDeclareFunction(name, para, returnType, api.description); - } - addStruct(api) { - const options = api.binding || {}; - var fields = api.fields.filter(x => !!(options.properties || {})[x.name]).map(x => ({ name: x.name, description: x.description, type: this.toJsType(x.type) })); - this.structs.tsDeclareInterface(api.name, fields); - this.structs.tsDeclareType(api.name, !!(options.createConstructor || options.createEmptyConstructor), options.createEmptyConstructor ? [] : fields); - } - toJsType(type) { - switch (type) { - case "int": - case "long": - case "unsigned int": - case "unsigned char": - case "float": - case "double": - return "number"; - case "const unsigned char *": - case "unsigned char *": - case "unsigned short *": - case "float *": - return "ArrayBuffer"; - case "bool": - return "boolean"; - case "const char *": - case "char *": - return "string | undefined | null"; - case "void *": - case "const void *": - return "any"; - case "Camera": - case "Camera *": - return "Camera3D"; - case "Texture2D": - case "Texture2D *": - case "TextureCubemap": - return "Texture"; - case "RenderTexture2D": - case "RenderTexture2D *": - return "RenderTexture"; - case "Quaternion": - return "Vector4"; - default: - return type.replace(" *", "").replace("const ", ""); - } - } - writeTo(filename) { - const writer = new generation_1.CodeWriter(); - writer.writeGenerator(this.root); - (0, fs_1.writeFileSync)(filename, writer.toString()); - } -} -exports.TypeScriptDeclaration = TypeScriptDeclaration; -class GenericTypescriptGenerator extends generation_1.GenericCodeGenerator { - tsDeclareFunction(name, parameters, returnType, description) { - this.tsDocComment(description); - this.statement(`declare function ${name}(${parameters.map(x => x.name + ': ' + x.type).join(', ')}): ${returnType}`); - } - tsDeclareConstant(name, type, description) { - this.tsDocComment(description); - this.statement(`declare var ${name}: ${type}`); - } - tsDeclareType(name, hasConstructor, parameters) { - this.line(`declare var ${name}: {`); - this.indent(); - this.statement("prototype: " + name); - if (hasConstructor) - this.statement(`new(${parameters.map(x => x.name + ": " + x.type).join(', ')}): ${name}`); - this.unindent(); - this.line("}"); - } - tsDeclareInterface(name, fields) { - this.line(`interface ${name} {`); - this.indent(); - for (const field of fields) { - if (field.description) - this.tsDocComment(field.description); - this.line(field.name + ": " + field.type + ","); - } - this.unindent(); - this.line("}"); - } - tsDocComment(comment) { - this.line(`/** ${comment} */`); - } -} -exports.GenericTypescriptGenerator = GenericTypescriptGenerator; -class TypescriptGenerator extends GenericTypescriptGenerator { - createGenerator() { - return new TypescriptGenerator(); - } -} -exports.TypescriptGenerator = TypescriptGenerator; - - -/***/ }), - -/***/ "fs": -/*!*********************!*\ - !*** external "fs" ***! - \*********************/ -/***/ ((module) => { - -module.exports = require("fs"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -var exports = __webpack_exports__; -/*!**********************!*\ - !*** ./src/index.ts ***! - \**********************/ - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const fs_1 = __webpack_require__(/*! fs */ "fs"); -const raylib_header_1 = __webpack_require__(/*! ./raylib-header */ "./src/raylib-header.ts"); -const header_parser_1 = __webpack_require__(/*! ./header-parser */ "./src/header-parser.ts"); -let api; -function getFunction(funList, name) { - return funList.find(x => x.name === name); -} -function getStruct(strList, name) { - return strList.find(x => x.name === name); -} -function getAliases(aliasList, name) { - return aliasList.filter(x => x.type === name).map(x => x.name); -} -function ignore(name) { - getFunction(api.functions, name).binding = { ignore: true }; -} -function main() { - // Load the pre-generated raylib api - api = JSON.parse((0, fs_1.readFileSync)("thirdparty/raylib/parser/output/raylib_api.json", 'utf8')); - const parser = new header_parser_1.HeaderParser(); - const rmathHeader = (0, fs_1.readFileSync)("thirdparty/raylib/src/raymath.h", "utf8"); - const mathApi = parser.parseFunctions(rmathHeader); - mathApi.forEach(x => api.functions.push(x)); - const rcameraHeader = (0, fs_1.readFileSync)("thirdparty/raylib/src/rcamera.h", "utf8"); - const cameraApi = parser.parseFunctionDefinitions(rcameraHeader); - cameraApi.forEach(x => api.functions.push(x)); - const rguiHeader = (0, fs_1.readFileSync)("thirdparty/raygui/src/raygui.h", "utf8"); - const rguiFunctions = parser.parseFunctionDefinitions(rguiHeader); - const rguiEnums = parser.parseEnums(rguiHeader); - //rguiApi.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) - rguiFunctions.forEach(x => api.functions.push(x)); - rguiEnums.forEach(x => api.enums.push(x)); - const rlightsHeader = (0, fs_1.readFileSync)("include/rlights.h", "utf8"); - const rlightsFunctions = parser.parseFunctions(rlightsHeader, true); - api.functions.push(rlightsFunctions[0]); - api.functions.push(rlightsFunctions[1]); - const rlightsEnums = parser.parseEnums(rlightsHeader); - rlightsEnums.forEach(x => api.enums.push(x)); - const rlightsStructs = parser.parseStructs(rlightsHeader); - rlightsStructs[0].binding = { - properties: { - type: { get: true, set: true }, - enabled: { get: true, set: true }, - position: { get: true, set: true }, - target: { get: true, set: true }, - color: { get: true, set: true }, - attenuation: { get: true, set: true }, - }, - }; - api.structs.push(rlightsStructs[0]); - const reasingsHeader = (0, fs_1.readFileSync)("include/reasings.h", "utf8"); - const reasingsFunctions = parser.parseFunctions(reasingsHeader); - reasingsFunctions.forEach(x => api.functions.push(x)); - const rlightmapperHeader = (0, fs_1.readFileSync)("src/rlightmapper.h", "utf8"); - const rlightmapperFunctions = parser.parseFunctionDefinitions(rlightmapperHeader); - const rlightmapperStructs = parser.parseStructs(rlightmapperHeader); - rlightmapperFunctions.forEach(x => api.functions.push(x)); - rlightmapperStructs.forEach(x => api.structs.push(x)); - rlightmapperStructs[0].binding = { - properties: { - w: { get: true }, - h: { get: true }, - progress: { get: true } - } - }; - rlightmapperStructs[1].binding = { - properties: { - hemisphereSize: { get: true, set: true }, - zNear: { get: true, set: true }, - zFar: { get: true, set: true }, - backgroundColor: { get: true, set: true }, - interpolationPasses: { get: true, set: true }, - interpolationThreshold: { get: true, set: true }, - cameraToSurfaceDistanceModifier: { get: true, set: true }, - } - }; - const rextensionsHeader = (0, fs_1.readFileSync)("src/rextensions.h", "utf8"); - const rextensionsFunctions = parser.parseFunctionDefinitions(rextensionsHeader); - console.log(rextensionsFunctions); - rextensionsFunctions.forEach(x => api.functions.push(x)); - // Define a new header - const core = new raylib_header_1.RayLibHeader("raylib_core"); - core.includes.include("raymath.h"); - core.includes.include("rcamera.h"); - core.includes.line("#define RAYGUI_IMPLEMENTATION"); - core.includes.include("raygui.h"); - core.includes.line("#define RLIGHTS_IMPLEMENTATION"); - core.includes.include("rlights.h"); - core.includes.include("reasings.h"); - core.includes.line("#define RLIGHTMAPPER_IMPLEMENTATION"); - core.includes.include("rlightmapper.h"); - getStruct(api.structs, "Color").binding = { - properties: { - r: { get: true, set: true }, - g: { get: true, set: true }, - b: { get: true, set: true }, - a: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Rectangle").binding = { - properties: { - x: { get: true, set: true }, - y: { get: true, set: true }, - width: { get: true, set: true }, - height: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Vector2").binding = { - properties: { - x: { get: true, set: true }, - y: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Vector3").binding = { - properties: { - x: { get: true, set: true }, - y: { get: true, set: true }, - z: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Vector4").binding = { - properties: { - x: { get: true, set: true }, - y: { get: true, set: true }, - z: { get: true, set: true }, - w: { get: true, set: true }, - }, - createConstructor: true, - aliases: getAliases(api.aliases, "Vector4") - }; - getStruct(api.structs, "Ray").binding = { - properties: { - position: { get: false, set: true }, - direction: { get: false, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "RayCollision").binding = { - properties: { - hit: { get: true, set: false }, - distance: { get: true, set: false }, - point: { get: true, set: false }, - normal: { get: true, set: false }, - }, - createConstructor: false - }; - getStruct(api.structs, "Camera2D").binding = { - properties: { - offset: { get: true, set: true }, - target: { get: true, set: true }, - rotation: { get: true, set: true }, - zoom: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Camera3D").binding = { - properties: { - position: { get: true, set: true }, - target: { get: true, set: true }, - up: { get: false, set: true }, - fovy: { get: true, set: true }, - projection: { get: true, set: true }, - }, - createConstructor: true, - aliases: getAliases(api.aliases, "Camera3D") - }; - getStruct(api.structs, "BoundingBox").binding = { - properties: { - min: { get: true, set: true }, - max: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Matrix").binding = { - properties: {}, - createConstructor: false - }; - getStruct(api.structs, "NPatchInfo").binding = { - properties: { - source: { get: true, set: true }, - left: { get: true, set: true }, - top: { get: true, set: true }, - right: { get: true, set: true }, - bottom: { get: true, set: true }, - layout: { get: true, set: true }, - }, - createConstructor: true - }; - getStruct(api.structs, "Image").binding = { - properties: { - data: { set: true }, - width: { get: true, set: true }, - height: { get: true, set: true }, - mipmaps: { get: true, set: true }, - format: { get: true, set: true } - }, - createEmptyConstructor: true - //destructor: "UnloadImage" - }; - getStruct(api.structs, "Wave").binding = { - properties: { - frameCount: { get: true }, - sampleRate: { get: true }, - sampleSize: { get: true }, - channels: { get: true } - }, - //destructor: "UnloadWave" - }; - getStruct(api.structs, "Sound").binding = { - properties: { - frameCount: { get: true } - }, - //destructor: "UnloadSound" - }; - getStruct(api.structs, "Music").binding = { - properties: { - frameCount: { get: true }, - looping: { get: true, set: true }, - ctxType: { get: true }, - }, - //destructor: "UnloadMusicStream" - }; - getStruct(api.structs, "Model").binding = { - properties: { - transform: { get: true, set: true }, - meshCount: { get: true }, - materialCount: { get: true }, - boneCount: { get: true }, - }, - //destructor: "UnloadModel" - }; - getStruct(api.structs, "Mesh").binding = { - properties: { - vertexCount: { get: true, set: true }, - triangleCount: { get: true, set: true }, - // TODO: Free previous pointers before overwriting - vertices: { set: true }, - texcoords: { set: true }, - texcoords2: { set: true }, - normals: { set: true }, - tangents: { set: true }, - colors: { set: true }, - indices: { set: true }, - animVertices: { set: true }, - animNormals: { set: true }, - boneIds: { set: true }, - boneWeights: { set: true }, - }, - createEmptyConstructor: true - //destructor: "UnloadMesh" - }; - getStruct(api.structs, "Shader").binding = { - properties: { - id: { get: true } - }, - //destructor: "UnloadShader" - }; - getStruct(api.structs, "Texture").binding = { - properties: { - width: { get: true }, - height: { get: true }, - mipmaps: { get: true }, - format: { get: true }, - }, - aliases: getAliases(api.aliases, "Texture") - //destructor: "UnloadTexture" - }; - getStruct(api.structs, "Font").binding = { - properties: { - baseSize: { get: true }, - glyphCount: { get: true }, - glyphPadding: { get: true }, - }, - //destructor: "UnloadFont" - }; - getStruct(api.structs, "RenderTexture").binding = { - properties: { - id: { get: true }, - texture: { get: true }, - depth: { get: true }, - }, - aliases: getAliases(api.aliases, "RenderTexture") - //destructor: "UnloadRenderTexture" - }; - getStruct(api.structs, "MaterialMap").binding = { - properties: { - texture: { set: true }, - color: { set: true, get: true }, - value: { get: true, set: true } - }, - //destructor: "UnloadMaterialMap" - }; - getStruct(api.structs, "Material").binding = { - properties: { - shader: { get: true, set: true } - }, - //destructor: "UnloadMaterial" - }; - const structDI = getStruct(api.structs, "VrDeviceInfo"); - structDI.fields.filter(x => x.name === "lensDistortionValues")[0].type = "Vector4"; - structDI.binding = { - createEmptyConstructor: true, - properties: { - hResolution: { set: true, get: true }, - 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 }, - // lensDistortionValues: { - // set: true, - // get: true, - // overrideRead(fn) { - // fn.line("// TODO") - // }, - // overrideWrite(fn) { - // fn.line("// TODO") - // }, - // }, - } - }; - getFunction(api.functions, "EndDrawing").binding = { after: gen => gen.call("app_update_quickjs", []) }; - ignore("SetWindowIcons"); - ignore("GetWindowHandle"); - // Custom frame control functions - // NOT SUPPORTED BECAUSE NEEDS COMPILER FLAG - ignore("SwapScreenBuffer"); - ignore("PollInputEvents"); - ignore("WaitTime"); - //ignore("BeginVrStereoMode") - //ignore("EndVrStereoMode") - //ignore("LoadVrStereoConfig") - //ignore("UnloadVrStereoConfig") - getFunction(api.functions, "SetShaderValue").binding = { body: (gen) => { - gen.jsToC("Shader", "shader", "argv[0]", core.structLookup); - gen.jsToC("int", "locIndex", "argv[1]", core.structLookup); - gen.declare("value", "void *", false, "NULL"); - gen.declare("valueFloat", "float"); - gen.declare("valueInt", "int"); - gen.jsToC("int", "uniformType", "argv[3]", core.structLookup); - const sw = gen.switch("uniformType"); - let b = sw.caseBreak("SHADER_UNIFORM_FLOAT"); - b.jsToC("float", "valueFloat", "argv[2]", core.structLookup, true); - b.statement("value = (void *)&valueFloat"); - b = sw.caseBreak("SHADER_UNIFORM_VEC2"); - b.jsToC("Vector2 *", "valueV2", "argv[2]", core.structLookup); - b.statement("value = (void*)valueV2"); - b = sw.caseBreak("SHADER_UNIFORM_VEC3"); - b.jsToC("Vector3 *", "valueV3", "argv[2]", core.structLookup); - b.statement("value = (void*)valueV3"); - b = sw.caseBreak("SHADER_UNIFORM_VEC4"); - b.jsToC("Vector4 *", "valueV4", "argv[2]", core.structLookup); - b.statement("value = (void*)valueV4"); - b = sw.caseBreak("SHADER_UNIFORM_INT"); - b.jsToC("int", "valueInt", "argv[2]", core.structLookup, true); - b.statement("value = (void*)&valueInt"); - b = sw.defaultBreak(); - b.returnExp("JS_EXCEPTION"); - gen.call("SetShaderValue", ["shader", "locIndex", "value", "uniformType"]); - gen.returnExp("JS_UNDEFINED"); - } }; - ignore("SetShaderValueV"); - const traceLog = getFunction(api.functions, "TraceLog"); - traceLog.params?.pop(); - // Memory functions not supported on JS, just use ArrayBuffer - ignore("MemAlloc"); - ignore("MemRealloc"); - ignore("MemFree"); - // Callbacks not supported on JS - ignore("SetTraceLogCallback"); - ignore("SetLoadFileDataCallback"); - ignore("SetSaveFileDataCallback"); - ignore("SetLoadFileTextCallback"); - ignore("SetSaveFileTextCallback"); - // Files management functions - const lfd = getFunction(api.functions, "LoadFileData"); - lfd.params[lfd.params.length - 1].binding = { ignore: true }; - lfd.binding = { - body: gen => { - gen.jsToC("const char *", "fileName", "argv[0]"); - gen.declare("bytesRead", "unsigned int"); - gen.call("LoadFileData", ["fileName", "&bytesRead"], { type: "unsigned char *", name: "retVal" }); - gen.statement("JSValue buffer = JS_NewArrayBufferCopy(ctx, (const uint8_t*)retVal, bytesRead)"); - gen.call("UnloadFileData", ["retVal"]); - gen.jsCleanUpParameter("const char*", "fileName"); - gen.returnExp("buffer"); - } - }; - ignore("UnloadFileData"); - // TODO: SaveFileData works but unnecessary makes copy of memory - getFunction(api.functions, "SaveFileData").binding = {}; - ignore("ExportDataAsCode"); - getFunction(api.functions, "LoadFileText").binding = { after: gen => gen.call("UnloadFileText", ["returnVal"]) }; - getFunction(api.functions, "SaveFileText").params[1].binding = { typeAlias: "const char *" }; - ignore("UnloadFileText"); - const createFileList = (gen, loadName, unloadName, args) => { - gen.call(loadName, args, { type: "FilePathList", name: "files" }); - gen.call("JS_NewArray", ["ctx"], { type: "JSValue", name: "ret" }); - const f = gen.for("i", "files.count"); - f.call("JS_SetPropertyUint32", ["ctx", "ret", "i", "JS_NewString(ctx,files.paths[i])"]); - gen.call(unloadName, ["files"]); - }; - getFunction(api.functions, "LoadDirectoryFiles").binding = { - jsReturns: "string[]", - body: gen => { - gen.jsToC("const char *", "dirPath", "argv[0]"); - createFileList(gen, "LoadDirectoryFiles", "UnloadDirectoryFiles", ["dirPath"]); - gen.jsCleanUpParameter("const char *", "dirPath"); - gen.returnExp("ret"); - } - }; - getFunction(api.functions, "LoadDirectoryFilesEx").binding = { - jsReturns: "string[]", - body: gen => { - gen.jsToC("const char *", "basePath", "argv[0]"); - gen.jsToC("const char *", "filter", "argv[1]"); - gen.jsToC("bool", "scanSubdirs", "argv[2]"); - createFileList(gen, "LoadDirectoryFilesEx", "UnloadDirectoryFiles", ["basePath", "filter", "scanSubdirs"]); - gen.jsCleanUpParameter("const char *", "basePath"); - gen.jsCleanUpParameter("const char *", "filter"); - gen.returnExp("ret"); - } - }; - ignore("UnloadDirectoryFiles"); - getFunction(api.functions, "LoadDroppedFiles").binding = { - jsReturns: "string[]", - body: gen => { - createFileList(gen, "LoadDroppedFiles", "UnloadDroppedFiles", []); - gen.returnExp("ret"); - } - }; - ignore("UnloadDroppedFiles"); - // Compression/encoding functionality - ignore("CompressData"); - ignore("DecompressData"); - ignore("EncodeDataBase64"); - ignore("DecodeDataBase64"); - ignore("DrawLineStrip"); - ignore("DrawTriangleFan"); - ignore("DrawTriangleStrip"); - ignore("CheckCollisionPointPoly"); - ignore("CheckCollisionLines"); - ignore("LoadImageAnim"); - ignore("ExportImageAsCode"); - getFunction(api.functions, "LoadImageColors").binding = { - jsReturns: "ArrayBuffer", - body: gen => { - gen.jsToC("Image", "image", "argv[0]", core.structLookup); - gen.call("LoadImageColors", ["image"], { name: "colors", type: "Color *" }); - gen.statement("JSValue retVal = JS_NewArrayBufferCopy(ctx, (const uint8_t*)colors, image.width*image.height*sizeof(Color))"); - gen.call("UnloadImageColors", ["colors"]); - gen.returnExp("retVal"); - } - }; - ignore("LoadImagePalette"); - ignore("UnloadImageColors"); - ignore("UnloadImagePalette"); - ignore("GetPixelColor"); - ignore("SetPixelColor"); - const lfx = getFunction(api.functions, "LoadFontEx"); - lfx.params[2].binding = { ignore: true }; - lfx.params[3].binding = { ignore: true }; - lfx.binding = { customizeCall: "Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0);" }; - ignore("LoadFontFromMemory"); - ignore("LoadFontData"); - ignore("GenImageFontAtlas"); - ignore("UnloadFontData"); - ignore("ExportFontAsCode"); - ignore("DrawTextCodepoints"); - ignore("GetGlyphInfo"); - ignore("LoadUTF8"); - ignore("UnloadUTF8"); - ignore("LoadCodepoints"); - ignore("UnloadCodepoints"); - ignore("GetCodepointCount"); - ignore("GetCodepoint"); - ignore("GetCodepointNext"); - ignore("GetCodepointPrevious"); - ignore("CodepointToUTF8"); - // Not supported, use JS Stdlib instead - api.functions.filter(x => x.name.startsWith("Text")).forEach(x => ignore(x.name)); - ignore("DrawTriangleStrip3D"); - ignore("LoadMaterials"); - ignore("LoadModelAnimations"); - ignore("UpdateModelAnimation"); - ignore("UnloadModelAnimation"); - ignore("UnloadModelAnimations"); - ignore("IsModelAnimationValid"); - ignore("ExportWaveAsCode"); - // Wave/Sound management functions - ignore("LoadWaveSamples"); - ignore("UnloadWaveSamples"); - ignore("LoadMusicStreamFromMemory"); - ignore("LoadAudioStream"); - ignore("IsAudioStreamReady"); - ignore("UnloadAudioStream"); - ignore("UpdateAudioStream"); - ignore("IsAudioStreamProcessed"); - ignore("PlayAudioStream"); - ignore("PauseAudioStream"); - ignore("ResumeAudioStream"); - ignore("IsAudioStreamPlaying"); - ignore("StopAudioStream"); - ignore("SetAudioStreamVolume"); - ignore("SetAudioStreamPitch"); - ignore("SetAudioStreamPan"); - ignore("SetAudioStreamBufferSizeDefault"); - ignore("SetAudioStreamCallback"); - ignore("AttachAudioStreamProcessor"); - ignore("DetachAudioStreamProcessor"); - ignore("AttachAudioMixedProcessor"); - ignore("DetachAudioMixedProcessor"); - ignore("Vector3OrthoNormalize"); - ignore("Vector3ToFloatV"); - ignore("MatrixToFloatV"); - ignore("QuaternionToAxisAngle"); - core.exportGlobalDouble("DEG2RAD", "(PI/180.0)"); - core.exportGlobalDouble("RAD2DEG", "(180.0/PI)"); - const setOutParam = (fun, index) => { - const param = fun.params[index]; - param.binding = { - jsType: `{ ${param.name}: number }`, - customConverter: (gen, src) => { - gen.declare(param.name, param.type, false, "NULL"); - gen.declare(param.name + "_out", param.type.replace(" *", "")); - const body = gen.if("!JS_IsNull(" + src + ")"); - body.statement(param.name + " = &" + param.name + "_out"); - body.call("JS_GetPropertyStr", ["ctx", src, '"' + param.name + '"'], { name: param.name + "_js", type: "JSValue" }); - body.call("JS_ToInt32", ["ctx", param.name, param.name + "_js"]); - }, - customCleanup: (gen, src) => { - const body = gen.if("!JS_IsNull(" + src + ")"); - body.call("JS_SetPropertyStr", ["ctx", src, `"${param.name}"`, "JS_NewInt32(ctx," + param.name + "_out)"]); - } - }; - }; - const setOutParamString = (fun, index, indexLen) => { - const lenParam = fun.params[indexLen]; - lenParam.binding = { ignore: true }; - const param = fun.params[index]; - param.binding = { - jsType: `{ ${param.name}: string }`, - customConverter: (gen, src) => { - gen.call("JS_GetPropertyStr", ["ctx", src, '"' + param.name + '"'], { name: param.name + "_js", type: "JSValue" }); - gen.declare(param.name + "_len", "size_t"); - gen.call("JS_ToCStringLen", ["ctx", "&" + param.name + "_len", param.name + "_js"], { name: param.name + "_val", type: "const char *" }); - gen.call("memcpy", ["(void *)textbuffer", param.name + "_val", param.name + "_len"]); - gen.statement("textbuffer[" + param.name + "_len] = 0"); - gen.declare(param.name, param.type, false, "textbuffer"); - gen.declare(lenParam.name, lenParam.type, false, "4096"); - }, - customCleanup: (gen, src) => { - gen.jsCleanUpParameter("const char *", param.name + "_val"); - gen.call("JS_SetPropertyStr", ["ctx", src, `"${param.name}"`, "JS_NewString(ctx," + param.name + ")"]); - } - }; - }; - core.definitions.declare("textbuffer[4096]", "char", true); - setOutParam(getFunction(api.functions, "GuiDropdownBox"), 2); - setOutParam(getFunction(api.functions, "GuiSpinner"), 2); - setOutParam(getFunction(api.functions, "GuiValueBox"), 2); - setOutParam(getFunction(api.functions, "GuiListView"), 2); - // const setStringListParam = (fun: RayLibFunction, index: number, indexLen: number) => { - // const lenParam = fun!.params![indexLen] - // lenParam.binding = { ignore: true } - // const param = fun!.params![index] - // fun.binding = { customizeCall: "int returnVal = GuiListViewEx(bounds, text, count, focus, scrollIndex, active);" } - // param.binding = { - // jsType: `{ ${param.name}: string[] }`, - // customConverter: (gen,src) => { - // gen.line("// TODO: Read string values") - // }, - // customCleanup: (gen, src) => { - // gen.line("// TODO: Dispose strings") - // } - // } - // } - //const glve = getFunction(api.functions, "GuiListViewEx")! - //setStringListParam(glve, 1,2) - //setOutParam(glve, 3) - //setOutParam(glve, 4) - ignore("GuiListViewEx"); - setOutParamString(getFunction(api.functions, "GuiTextBox"), 1, 2); - const gtib = getFunction(api.functions, "GuiTextInputBox"); - setOutParamString(gtib, 4, 5); - setOutParam(gtib, 6); - // needs string array - ignore("GuiTabBar"); - ignore("GuiGetIcons"); - ignore("GuiLoadIcons"); - api.structs.forEach(x => core.addApiStruct(x)); - api.functions.forEach(x => core.addApiFunction(x)); - api.defines.filter(x => x.type === "COLOR").map(x => ({ name: x.name, description: x.description, values: (x.value.match(/\{([^}]+)\}/) || "")[1].split(',').map(x => x.trim()) })).forEach(x => { - core.exportGlobalStruct("Color", x.name, x.values, x.description); - }); - api.enums.forEach(x => core.addEnum(x)); - core.exportGlobalInt("MATERIAL_MAP_DIFFUSE", "Albedo material (same as: MATERIAL_MAP_DIFFUSE"); - core.exportGlobalInt("MATERIAL_MAP_SPECULAR", "Metalness material (same as: MATERIAL_MAP_SPECULAR)"); - core.writeTo("src/bindings/js_raylib_core.h"); - core.typings.writeTo("examples/lib.raylib.d.ts"); - const ignored = api.functions.filter(x => x.binding?.ignore).length; - console.log(`Converted ${api.functions.length - ignored} function. ${ignored} ignored`); - console.log("Success!"); - // TODO: Expose PLatform defines -} -main(); - -})(); - -/******/ })() -; \ No newline at end of file +(()=>{"use strict";var t={208:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGenerator=e.GenericCodeGenerator=e.CodeWriter=e.StringWriter=void 0;class n{constructor(){this.buffer=""}write(t){this.buffer+=t}writeLine(t=""){this.buffer+=t+"\n"}toString(){return this.buffer}}var s;e.StringWriter=n,e.CodeWriter=class extends n{constructor(){super(...arguments),this.indent=0,this.needsIndent=!0}writeGenerator(t){const e=t.iterateTokens(),n=t.iterateText(),r=t.iterateChildren();let i=e.next();for(;!i.done;){switch(i.value){case s.STRING:const t=n.next().value;this.needsIndent&&(this.write(" ".repeat(this.indent)),this.needsIndent=!1),this.write(t);break;case s.GOSUB:const e=r.next().value;this.writeGenerator(e);break;case s.INDENT:this.indent++;break;case s.UNINDENT:this.indent=this.indent>0?this.indent-1:0;break;case s.NEWLINE:this.write("\n"),this.needsIndent=!0}i=e.next()}}},function(t){t[t.STRING=0]="STRING",t[t.NEWLINE=1]="NEWLINE",t[t.INDENT=2]="INDENT",t[t.UNINDENT=3]="UNINDENT",t[t.GOSUB=4]="GOSUB"}(s||(s={}));class r{constructor(){this.children=[],this.text=[],this.tokens=[],this.tags={}}getTag(t){return this.tags[t]}setTag(t,e){this.tags[t]=e}iterateTokens(){return this.tokens[Symbol.iterator]()}iterateText(){return this.text[Symbol.iterator]()}iterateChildren(){return this.children[Symbol.iterator]()}line(t){this.tokens.push(s.STRING,s.NEWLINE),this.text.push(t)}comment(t){this.line("// "+t)}call(t,e,n=null){n&&this.inline(`${n.type} ${n.name} = `),this.inline(t+"("),this.inline(e.join(", ")),this.statement(")")}declare(t,e,n=!1,s=null){n&&this.inline("static "),this.inline(e+" "+t),s&&this.inline(" = "+s),this.statement("")}child(t){return t||(t=this.createGenerator()),this.tokens.push(s.GOSUB),this.children.push(t),t}inline(t){this.tokens.push(s.STRING),this.text.push(t)}statement(t){this.line(t+";")}breakLine(){this.tokens.push(s.NEWLINE)}indent(){this.tokens.push(s.INDENT)}unindent(){this.tokens.push(s.UNINDENT)}function(t,e,n,s,r){const i=this.createGenerator();return i.setTag("_type","function-body"),i.setTag("_name",t),i.setTag("_isStatic",s),i.setTag("_returnType",e),s&&this.inline("static "),this.inline(e+" "+t+"("),this.inline(n.map((t=>t.type+" "+t.name)).join(", ")),this.inline(") {"),this.breakLine(),this.indent(),this.child(i),this.unindent(),this.line("}"),this.breakLine(),r&&r(i),i}if(t,e){this.line("if("+t+") {"),this.indent();const n=this.createGenerator();return n.setTag("_type","if-body"),n.setTag("_condition",t),this.child(n),this.unindent(),this.line("}"),e&&e(n),n}else(t){this.line("else {"),this.indent();const e=this.createGenerator();return e.setTag("_type","else-body"),this.child(e),this.unindent(),this.line("}"),t&&t(e),e}returnExp(t){this.statement("return "+t)}include(t){this.line("#include <"+t+">")}for(t,e){this.line(`for(int ${t}; i < ${e}; i++){`),this.indent();const n=this.child();return this.unindent(),this.line("}"),n}header(t,e){this.line("#ifndef "+t),this.line("#define "+t),this.breakLine();const n=this.child();return n.setTag("_type","header-body"),n.setTag("_guardName",t),this.line("#endif // "+t),e&&e(n),n}declareStruct(t,e,n,s=!1){s&&this.inline("static "),this.statement(`${t} ${e} = { ${n.join(", ")} }`)}switch(t){this.line(`switch(${t}) {`),this.indent();const e=this.child();return this.unindent(),this.line("}"),e}case(t){this.line(`case ${t}:`)}defaultBreak(){this.line("default:"),this.line("{"),this.indent();const t=this.child();return this.statement("break"),this.unindent(),this.line("}"),t}caseBreak(t){this.case(t),this.line("{"),this.indent();const e=this.child();return this.statement("break"),this.unindent(),this.line("}"),e}}e.GenericCodeGenerator=r;class i extends r{createGenerator(){return new i}}e.CodeGenerator=i},763:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HeaderParser=void 0,e.HeaderParser=class{parseEnums(t){return[...t.matchAll(/((?:\/\/.+\n)*)typedef enum {\n([^}]+)} ([^;]+)/gm)].map((t=>({description:this.parseComments(t[1]),values:this.parseEnumValues(t[2]),name:t[3]})))}parseEnumValues(t){let e=0;return t.split("\n").map((t=>t.trim().match(/([^ ,]+)(?: = ([0-9]+))?,?(?: *)(?:\/\/ (.+))?/))).filter((t=>null!==t&&!t[0].startsWith("/"))).map((t=>{let n=e=t[2]?parseInt(t[2]):e;return e++,{name:t[1],description:t[3]||"",value:n}}))}parseComments(t){return t.split("\n").map((t=>t.replace("// ",""))).join("\n").trim()}parseFunctionDefinitions(t){return[...t.matchAll(/^[A-Z]+ (.+?)(\w+)\(([^\)]+)\);(?: +\/\/ (.+))?$/gm)].map((t=>({returnType:t[1].trim(),name:t[2],params:this.parseFunctionArgs(t[3]),description:t[4]||""})))}parseFunctions(t,e=!1){return(e?[...t.matchAll(/((?:\/\/.+\n)+)^(.+?)(\w+)\(([^\)]+)\)/gm)]:[...t.matchAll(/((?:\/\/.+\n)+)^[A-Z]+ (.+?)(\w+)\(([^\)]+)\)/gm)]).map((t=>({returnType:t[2].trim(),name:t[3],params:this.parseFunctionArgs(t[4]),description:t[1]?this.parseComments(t[1]):""})))}parseFunctionArgs(t){return t.split(",").filter((t=>"void"!==t)).map((t=>{const e=(t=t.trim().replace(" *","* ")).split(" ");return{name:e.pop()||"",type:e.join(" ").replace("*"," *").trim()}}))}parseStructs(t){return[...t.matchAll(/((?:\/\/.+\n)+)typedef struct {([^}]+)} ([^;]+);/gm)].map((t=>({name:t[3],fields:this.parseStructFields(t[2]),description:this.parseComments(t[1])})))}parseStructFields(t){return t.trim().split("\n").map((t=>t.trim())).filter((t=>!t.startsWith("/")&&t.endsWith(";"))).map((t=>{const e=t.match(/([^ ]+(?: \*)?) ([^;]+);/);return{name:e[2],type:e[1],description:""}}))}}},986:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.QuickJsGenerator=e.GenericQuickJsGenerator=e.QuickJsHeader=void 0;const s=n(147),r=n(208);e.QuickJsHeader=class{constructor(t){this.name=t,this.structLookup={};const e=this.root=new a,n=this.body=e.header("JS_"+this.name+"_GUARD"),s=this.includes=n.child();s.include("stdio.h"),s.include("stdlib.h"),s.include("string.h"),s.breakLine(),s.include("quickjs.h"),n.breakLine(),n.line("#ifndef countof"),n.line("#define countof(x) (sizeof(x) / sizeof((x)[0]))"),n.line("#endif"),n.breakLine(),this.definitions=n.child(),n.breakLine(),this.structs=n.child(),this.functions=n.child(),this.moduleFunctionList=n.jsFunctionList("js_"+t+"_funcs");const r=n.function("js_"+this.name+"_init","int",[{type:"JSContext *",name:"ctx"},{type:"JSModuleDef *",name:"m"}],!0);(this.moduleInit=r.child()).statement(`JS_SetModuleExportList(ctx, m,${this.moduleFunctionList.getTag("_name")},countof(${this.moduleFunctionList.getTag("_name")}))`),r.returnExp("0");const i=n.function("js_init_module_"+this.name,"JSModuleDef *",[{type:"JSContext *",name:"ctx"},{type:"const char *",name:"module_name"}],!1),o=this.moduleEntry=i.child();o.statement("JSModuleDef *m"),o.statement(`m = JS_NewCModule(ctx, module_name, ${r.getTag("_name")})`),o.statement("if(!m) return NULL"),o.statement(`JS_AddModuleExportList(ctx, m, ${this.moduleFunctionList.getTag("_name")}, countof(${this.moduleFunctionList.getTag("_name")}))`),i.statement("return m")}registerStruct(t,e){this.structLookup[t]=e}writeTo(t){const e=new r.CodeWriter;e.writeGenerator(this.root),(0,s.writeFileSync)(t,e.toString())}};class i extends r.GenericCodeGenerator{jsBindingFunction(t){return this.function("js_"+t,"JSValue",[{type:"JSContext *",name:"ctx"},{type:"JSValueConst",name:"this_val"},{type:"int",name:"argc"},{type:"JSValueConst *",name:"argv"}],!0)}jsToC(t,e,n,s={},r=!1,i){switch(i??t){case"const void *":case"void *":case"float *":case"const float *":case"unsigned short *":case"unsigned char *":case"const unsigned char *":this.declare(e+"_size","size_t"),this.declare(e+"_js","void *",!1,`(void *)JS_GetArrayBuffer(ctx, &${e}_size, ${n})`),this.if(e+"_js == NULL").returnExp("JS_EXCEPTION"),this.declare(e,t,!1,"malloc("+e+"_size)"),this.call("memcpy",["(void *)"+e,"(const void *)"+e+"_js",e+"_size"]);break;case"const char *":case"char *":r?this.statement(`${e} = (JS_IsNull(${n}) || JS_IsUndefined(${n})) ? NULL : (${t})JS_ToCString(ctx, ${n})`):this.statement(`${t} ${e} = (JS_IsNull(${n}) || JS_IsUndefined(${n})) ? NULL : (${t})JS_ToCString(ctx, ${n})`);break;case"double":r||this.statement(`${t} ${e}`),this.statement(`JS_ToFloat64(ctx, &${e}, ${n})`);break;case"float":this.statement("double _double_"+e),this.statement(`JS_ToFloat64(ctx, &_double_${e}, ${n})`),r?this.statement(`${e} = (${t})_double_${e}`):this.statement(`${t} ${e} = (${t})_double_${e}`);break;case"char":r?this.statement(`${e} = (JS_IsNull(${n}) || JS_IsUndefined(${n})) ? 0 : JS_ToCString(ctx, ${n})[0]`):this.declare(e,t,!1,`(JS_IsNull(${n}) || JS_IsUndefined(${n})) ? 0 : JS_ToCString(ctx, ${n})[0]`);break;case"short":r||this.statement(`${t} ${e}`),this.statement(`{ int _tmp; JS_ToInt32(ctx, &_tmp, ${n}); ${e} = (short)_tmp; }`);break;case"int":r||this.statement(`${t} ${e}`),this.statement(`JS_ToInt32(ctx, &${e}, ${n})`);break;case"int *":r||this.statement(`int ${e}_int`),this.statement(`JS_ToInt32(ctx, &${e}_int, ${n})`),this.statement(`${t} ${e} = &${e}_int`);break;case"long":r||this.statement(`${t} ${e}`),this.statement(`JS_ToInt64(ctx, &${e}, ${n})`);break;case"unsigned int":r||this.statement(`${t} ${e}`),this.statement(`JS_ToUint32(ctx, &${e}, ${n})`);break;case"unsigned short":r||this.statement(`${t} ${e}`),this.statement(`{ unsigned int _tmp; JS_ToUint32(ctx, &_tmp, ${n}); ${e} = (unsigned short)_tmp; }`);break;case"unsigned long":r||this.statement(`${t} ${e}`),this.statement(`{ unsigned long long _tmp; JS_ToInt64(ctx, (int64_t *)&_tmp, ${n}); ${e} = (unsigned long)_tmp; }`);break;case"unsigned char":this.statement("unsigned int _int_"+e),this.statement(`JS_ToUint32(ctx, &_int_${e}, ${n})`),r?this.statement(`${e} = (${t})_int_${e}`):this.statement(`${t} ${e} = (${t})_int_${e}`);break;case"bool":r?this.statement(`${e} = JS_ToBool(ctx, ${n})`):this.statement(`${t} ${e} = JS_ToBool(ctx, ${n})`);break;case"bool *":r||this.statement(`bool ${e}_val`),this.statement(`${e}_val = JS_ToBool(ctx, ${n})`),this.statement(`${t} ${e} = &${e}_val`);break;default:t.startsWith("const");const i=t.endsWith(" *"),a=s[t.replace("const ","").replace(" *","")];if(!a)throw new Error("Cannot convert into parameter type: "+t);const o=i?"":"_ptr";this.jsOpqToStructPtr(t.replace(" *",""),e+o,n,a),this.statement(`if(${e+o} == NULL) return JS_EXCEPTION`),i||this.declare(e,t,!1,`*${e}_ptr`)}}jsToJs(t,e,n,s={}){switch(t){case"int":case"int *":case"long":this.declare(e,"JSValue",!1,`JS_NewInt32(ctx, ${n})`);break;case"long":this.declare(e,"JSValue",!1,`JS_NewInt64(ctx, ${n})`);break;case"unsigned int":case"unsigned char":this.declare(e,"JSValue",!1,`JS_NewUint32(ctx, ${n})`);break;case"unsigned int *":case"unsigned char *":this.declare(e,"JSValue",!1,`${n} ? JS_NewUint32(ctx, *${n}) : JS_NULL`);break;case"bool":this.declare(e,"JSValue",!1,`JS_NewBool(ctx, ${n})`);break;case"float":case"double":this.declare(e,"JSValue",!1,`JS_NewFloat64(ctx, ${n})`);break;case"const char *":case"char *":this.declare(e,"JSValue",!1,`JS_NewString(ctx, ${n})`);break;default:const r=s[t];if(!r)throw new Error("Cannot convert parameter type to Javascript: "+t);this.jsStructToOpq(t,e,n,r)}}jsStructToOpq(t,e,n,s){this.declare(e+"_ptr",t+"*",!1,`(${t}*)js_malloc(ctx, sizeof(${t}))`),this.statement("*"+e+"_ptr = "+n),this.declare(e,"JSValue",!1,`JS_NewObjectClass(ctx, ${s})`),this.call("JS_SetOpaque",[e,e+"_ptr"])}jsCleanUpParameter(t,e){switch(t){case"char *":case"const char *":this.statement(`JS_FreeCString(ctx, ${e})`);break;case"const void *":case"void *":case"float *":case"unsigned short *":case"unsigned char *":case"const unsigned char *":this.statement(`free((void *)${e})`)}}jsFunctionList(t){this.line("static const JSCFunctionListEntry "+t+"[] = {"),this.indent();const e=this.createGenerator();return e.setTag("_type","js-function-list"),e.setTag("_name",t),this.child(e),this.unindent(),this.statement("}"),this.breakLine(),e}jsFuncDef(t,e,n){this.line(`JS_CFUNC_DEF("${t}",${e},${n}),`)}jsClassId(t){return this.declare(t,"JSClassID",!0),t}jsPropStringDef(t,e){this.line(`JS_PROP_STRING_DEF("${t}","${e}", JS_PROP_CONFIGURABLE),`)}jsGetSetDef(t,e,n){this.line(`JS_CGETSET_DEF("${t}",${e||"NULL"},${n||"NULL"}),`)}jsStructFinalizer(t,e,n){const s=this.function(`js_${e}_finalizer`,"void",[{type:"JSRuntime *",name:"rt"},{type:"JSValue",name:"val"}],!0);return s.statement(`${e}* ptr = JS_GetOpaque(val, ${t})`),s.if("ptr",(t=>{n&&n(t,"ptr"),t.call("js_free_rt",["rt","ptr"])})),s}jsClassDeclaration(t,e,n,s){const r=this.function("js_declare_"+t,"int",[{type:"JSContext *",name:"ctx"},{type:"JSModuleDef *",name:"m"}],!0);r.call("JS_NewClassID",["&"+e]);const i=`js_${t}_def`;return r.declare(i,"JSClassDef",!1,`{ .class_name = "${t}", .finalizer = ${n} }`),r.call("JS_NewClass",["JS_GetRuntime(ctx)",e,"&"+i]),r.declare("proto","JSValue",!1,"JS_NewObject(ctx)"),r.call("JS_SetPropertyFunctionList",["ctx","proto",s,`countof(${s})`]),r.call("JS_SetClassProto",["ctx",e,"proto"]),r.statement("return 0"),r}jsStructGetter(t,e,n,s,r,i){const a=this.function(`js_${t}_get_${n}`,"JSValue",[{type:"JSContext*",name:"ctx"},{type:"JSValueConst",name:"this_val"}],!0);return a.declare("ptr",t+"*",!1,`JS_GetOpaque2(ctx, this_val, ${e})`),i?i(a):a.declare(n,s,!1,"ptr->"+n),a.jsToJs(s,"ret",n,r),a.returnExp("ret"),a}jsStructSetter(t,e,n,s,r,i){const a=this.function(`js_${t}_set_${n}`,"JSValue",[{type:"JSContext*",name:"ctx"},{type:"JSValueConst",name:"this_val"},{type:"JSValueConst",name:"v"}],!0);return a.declare("ptr",t+"*",!1,`JS_GetOpaque2(ctx, this_val, ${e})`),a.jsToC(s,"value","v",r),i?i(a):a.statement("ptr->"+n+" = value"),a.returnExp("JS_UNDEFINED"),a}jsOpqToStructPtr(t,e,n,s){this.declare(e,t+"*",!1,`(${t}*)JS_GetOpaque2(ctx, ${n}, ${s})`)}jsStructConstructor(t,e,n,s){const r=this.jsBindingFunction(t+"_constructor");for(let t=0;tt.name))),r.jsStructToOpq(t,"_return","_struct",n),r.returnExp("_return"),r}}e.GenericQuickJsGenerator=i;class a extends i{createGenerator(){return new a}}e.QuickJsGenerator=a},392:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RayLibHeader=void 0;const s=n(986),r=n(102);class i extends s.QuickJsHeader{constructor(t){super(t),this.typings=new r.TypeScriptDeclaration,this.includes.include("raylib.h")}addApiFunction(t){const e=t.binding||{};if(e.ignore)return;const n=e.jsName||t.name.charAt(0).toLowerCase()+t.name.slice(1);console.log("Binding function "+t.name);const s=this.functions.jsBindingFunction(n);if(e.body)e.body(s);else{e.before&&e.before(s),t.params=t.params||[];const n=t.params.filter((t=>!t.binding?.ignore));for(let t=0;tt.name)),"void"===t.returnType?null:{type:t.returnType,name:"returnVal"});for(let t=0;t!t.binding?.ignore)).length,s.getTag("_name")),this.typings.addFunction(n,t)}addEnum(t){console.log("Binding enum "+t.name),t.values.forEach((t=>this.exportGlobalInt(t.name,t.description)))}addApiStruct(t){const e=t.binding||{};console.log("Binding struct "+t.name);const n=this.definitions.jsClassId(`js_${t.name}_class_id`);this.registerStruct(t.name,n),e.aliases?.forEach((t=>this.registerStruct(t,n)));const s=this.structs.jsStructFinalizer(n,t.name,((t,n)=>e.destructor&&t.call(e.destructor.name,["*"+n]))),r=this.structs.createGenerator();if(e&&e.properties)for(const s of Object.keys(e.properties)){const i=t.fields.find((t=>t.name===s))?.type;if(!i)throw new Error(`Struct ${t.name} does not contain field ${s}`);const a=e.properties[s];let o,c;a.get&&(o=this.structs.jsStructGetter(t.name,n,s,i,this.structLookup,a.overrideRead)),a.set&&(c=this.structs.jsStructSetter(t.name,n,s,i,this.structLookup,a.overrideWrite)),r.jsGetSetDef(s,o?.getTag("_name"),c?.getTag("_name"))}const i=this.structs.jsFunctionList(`js_${t.name}_proto_funcs`);i.child(r),i.jsPropStringDef("[Symbol.toStringTag]",t.name);const a=this.structs.jsClassDeclaration(t.name,n,s.getTag("_name"),i.getTag("_name"));if(this.moduleInit.call(a.getTag("_name"),["ctx","m"]),e?.createConstructor||e?.createEmptyConstructor){const s=this.functions.jsStructConstructor(t.name,e?.createEmptyConstructor?[]:t.fields,n,this.structLookup);this.moduleInit.statement(`JSValue ${t.name}_constr = JS_NewCFunction2(ctx, ${s.getTag("_name")},"${t.name})", ${t.fields.length}, JS_CFUNC_constructor_or_func, 0)`),this.moduleInit.call("JS_SetModuleExport",["ctx","m",`"${t.name}"`,t.name+"_constr"]),this.moduleEntry.call("JS_AddModuleExport",["ctx","m",'"'+t.name+'"'])}this.typings.addStruct(t)}exportGlobalStruct(t,e,n,s){this.moduleInit.declareStruct(t,e+"_struct",n);const r=this.structLookup[t];if(!r)throw new Error("Struct "+t+" not found in register");this.moduleInit.jsStructToOpq(t,e+"_js",e+"_struct",r),this.moduleInit.call("JS_SetModuleExport",["ctx","m",`"${e}"`,e+"_js"]),this.moduleEntry.call("JS_AddModuleExport",["ctx","m",`"${e}"`]),this.typings.constants.tsDeclareConstant(e,t,s)}exportGlobalInt(t,e){this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${t}", JS_NewInt32(ctx, ${t}))`),this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${t}")`),this.typings.constants.tsDeclareConstant(t,"number",e)}exportGlobalDouble(t,e){this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${t}", JS_NewFloat64(ctx, ${t}))`),this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${t}")`),this.typings.constants.tsDeclareConstant(t,"number",e)}}e.RayLibHeader=i},102:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypescriptGenerator=e.GenericTypescriptGenerator=e.TypeScriptDeclaration=void 0;const s=n(208),r=n(147);e.TypeScriptDeclaration=class{constructor(){this.root=new a,this.structs=this.root.child(),this.functions=this.root.child(),this.constants=this.root.child()}addFunction(t,e){const n=e.binding||{},s=(e.params||[]).filter((t=>!t.binding?.ignore)).map((t=>({name:t.name,type:t.binding?.jsType??this.toJsType(t.type)}))),r=n.jsReturns??this.toJsType(e.returnType);this.functions.tsDeclareFunction(t,s,r,e.description)}addStruct(t){const e=t.binding||{};var n=t.fields.filter((t=>!!(e.properties||{})[t.name])).map((t=>({name:t.name,description:t.description,type:this.toJsType(t.type)})));this.structs.tsDeclareInterface(t.name,n),this.structs.tsDeclareType(t.name,!(!e.createConstructor&&!e.createEmptyConstructor),e.createEmptyConstructor?[]:n)}toJsType(t){switch(t){case"int":case"long":case"unsigned int":case"unsigned char":case"float":case"double":return"number";case"const unsigned char *":case"unsigned char *":case"unsigned short *":case"float *":return"ArrayBuffer";case"bool":return"boolean";case"const char *":case"char *":return"string | undefined | null";case"void *":case"const void *":return"any";case"Camera":case"Camera *":return"Camera3D";case"Texture2D":case"Texture2D *":case"TextureCubemap":return"Texture";case"RenderTexture2D":case"RenderTexture2D *":return"RenderTexture";case"Quaternion":return"Vector4";default:return t.replace(" *","").replace("const ","")}}writeTo(t){const e=new s.CodeWriter;e.writeGenerator(this.root),(0,r.writeFileSync)(t,e.toString())}};class i extends s.GenericCodeGenerator{tsDeclareFunction(t,e,n,s){this.tsDocComment(s),this.statement(`declare function ${t}(${e.map((t=>t.name+": "+t.type)).join(", ")}): ${n}`)}tsDeclareConstant(t,e,n){this.tsDocComment(n),this.statement(`declare var ${t}: ${e}`)}tsDeclareType(t,e,n){this.line(`declare var ${t}: {`),this.indent(),this.statement("prototype: "+t),e&&this.statement(`new(${n.map((t=>t.name+": "+t.type)).join(", ")}): ${t}`),this.unindent(),this.line("}")}tsDeclareInterface(t,e){this.line(`interface ${t} {`),this.indent();for(const t of e)t.description&&this.tsDocComment(t.description),this.line(t.name+": "+t.type+",");this.unindent(),this.line("}")}tsDocComment(t){this.line(`/** ${t} */`)}}e.GenericTypescriptGenerator=i;class a extends i{createGenerator(){return new a}}e.TypescriptGenerator=a},147:t=>{t.exports=require("fs")}},e={};function n(s){var r=e[s];if(void 0!==r)return r.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}(()=>{const t=n(147),e=n(392),s=n(763);let r;function i(t,e){return t.find((t=>t.name===e))}function a(t,e){return t.find((t=>t.name===e))}function o(t,e){return t.filter((t=>t.type===e)).map((t=>t.name))}function c(t){i(r.functions,t).binding={ignore:!0}}!function(){r=JSON.parse((0,t.readFileSync)("thirdparty/raylib/parser/output/raylib_api.json","utf8"));const n=new s.HeaderParser,l=(0,t.readFileSync)("thirdparty/raylib/src/raymath.h","utf8");n.parseFunctions(l).forEach((t=>r.functions.push(t)));const u=(0,t.readFileSync)("thirdparty/raylib/src/rcamera.h","utf8");n.parseFunctionDefinitions(u).forEach((t=>r.functions.push(t)));const d=(0,t.readFileSync)("thirdparty/raygui/src/raygui.h","utf8"),p=n.parseFunctionDefinitions(d),m=n.parseEnums(d);p.forEach((t=>r.functions.push(t))),m.forEach((t=>r.enums.push(t)));const h=(0,t.readFileSync)("include/rlights.h","utf8"),g=n.parseFunctions(h,!0);r.functions.push(g[0]),r.functions.push(g[1]),n.parseEnums(h).forEach((t=>r.enums.push(t)));const S=n.parseStructs(h);S[0].binding={properties:{type:{get:!0,set:!0},enabled:{get:!0,set:!0},position:{get:!0,set:!0},target:{get:!0,set:!0},color:{get:!0,set:!0},attenuation:{get:!0,set:!0}}},r.structs.push(S[0]);const f=(0,t.readFileSync)("include/reasings.h","utf8");n.parseFunctions(f).forEach((t=>r.functions.push(t)));const _=(0,t.readFileSync)("src/rlightmapper.h","utf8"),b=n.parseFunctionDefinitions(_),y=n.parseStructs(_);b.forEach((t=>r.functions.push(t))),y.forEach((t=>r.structs.push(t))),y[0].binding={properties:{w:{get:!0},h:{get:!0},progress:{get:!0}}},y[1].binding={properties:{hemisphereSize:{get:!0,set:!0},zNear:{get:!0,set:!0},zFar:{get:!0,set:!0},backgroundColor:{get:!0,set:!0},interpolationPasses:{get:!0,set:!0},interpolationThreshold:{get:!0,set:!0},cameraToSurfaceDistanceModifier:{get:!0,set:!0}}};const x=(0,t.readFileSync)("src/rextensions.h","utf8"),C=n.parseFunctionDefinitions(x);console.log(C),C.forEach((t=>r.functions.push(t)));const T=new e.RayLibHeader("raylib_core");T.includes.include("raymath.h"),T.includes.include("rcamera.h"),T.includes.line("#define RAYGUI_IMPLEMENTATION"),T.includes.include("raygui.h"),T.includes.line("#define RLIGHTS_IMPLEMENTATION"),T.includes.include("rlights.h"),T.includes.include("reasings.h"),T.includes.line("#define RLIGHTMAPPER_IMPLEMENTATION"),T.includes.include("rlightmapper.h"),a(r.structs,"Color").binding={properties:{r:{get:!0,set:!0},g:{get:!0,set:!0},b:{get:!0,set:!0},a:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Rectangle").binding={properties:{x:{get:!0,set:!0},y:{get:!0,set:!0},width:{get:!0,set:!0},height:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Vector2").binding={properties:{x:{get:!0,set:!0},y:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Vector3").binding={properties:{x:{get:!0,set:!0},y:{get:!0,set:!0},z:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Vector4").binding={properties:{x:{get:!0,set:!0},y:{get:!0,set:!0},z:{get:!0,set:!0},w:{get:!0,set:!0}},createConstructor:!0,aliases:o(r.aliases,"Vector4")},a(r.structs,"Ray").binding={properties:{position:{get:!1,set:!0},direction:{get:!1,set:!0}},createConstructor:!0},a(r.structs,"RayCollision").binding={properties:{hit:{get:!0,set:!1},distance:{get:!0,set:!1},point:{get:!0,set:!1},normal:{get:!0,set:!1}},createConstructor:!1},a(r.structs,"Camera2D").binding={properties:{offset:{get:!0,set:!0},target:{get:!0,set:!0},rotation:{get:!0,set:!0},zoom:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Camera3D").binding={properties:{position:{get:!0,set:!0},target:{get:!0,set:!0},up:{get:!1,set:!0},fovy:{get:!0,set:!0},projection:{get:!0,set:!0}},createConstructor:!0,aliases:o(r.aliases,"Camera3D")},a(r.structs,"BoundingBox").binding={properties:{min:{get:!0,set:!0},max:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Matrix").binding={properties:{},createConstructor:!1},a(r.structs,"NPatchInfo").binding={properties:{source:{get:!0,set:!0},left:{get:!0,set:!0},top:{get:!0,set:!0},right:{get:!0,set:!0},bottom:{get:!0,set:!0},layout:{get:!0,set:!0}},createConstructor:!0},a(r.structs,"Image").binding={properties:{data:{set:!0},width:{get:!0,set:!0},height:{get:!0,set:!0},mipmaps:{get:!0,set:!0},format:{get:!0,set:!0}},createEmptyConstructor:!0},a(r.structs,"Wave").binding={properties:{frameCount:{get:!0},sampleRate:{get:!0},sampleSize:{get:!0},channels:{get:!0}}},a(r.structs,"Sound").binding={properties:{frameCount:{get:!0}}},a(r.structs,"Music").binding={properties:{frameCount:{get:!0},looping:{get:!0,set:!0},ctxType:{get:!0}}},a(r.structs,"Model").binding={properties:{transform:{get:!0,set:!0},meshCount:{get:!0},materialCount:{get:!0},boneCount:{get:!0}}},a(r.structs,"Mesh").binding={properties:{vertexCount:{get:!0,set:!0},triangleCount:{get:!0,set:!0},vertices:{set:!0},texcoords:{set:!0},texcoords2:{set:!0},normals:{set:!0},tangents:{set:!0},colors:{set:!0},indices:{set:!0},animVertices:{set:!0},animNormals:{set:!0},boneIds:{set:!0},boneWeights:{set:!0}},createEmptyConstructor:!0},a(r.structs,"Shader").binding={properties:{id:{get:!0}}},a(r.structs,"Texture").binding={properties:{width:{get:!0},height:{get:!0},mipmaps:{get:!0},format:{get:!0}},aliases:o(r.aliases,"Texture")},a(r.structs,"Font").binding={properties:{baseSize:{get:!0},glyphCount:{get:!0},glyphPadding:{get:!0}}},a(r.structs,"RenderTexture").binding={properties:{id:{get:!0},texture:{get:!0},depth:{get:!0}},aliases:o(r.aliases,"RenderTexture")},a(r.structs,"MaterialMap").binding={properties:{texture:{set:!0},color:{set:!0,get:!0},value:{get:!0,set:!0}}},a(r.structs,"Material").binding={properties:{shader:{get:!0,set:!0}}};const $=a(r.structs,"VrDeviceInfo");$.fields.filter((t=>"lensDistortionValues"===t.name))[0].type="Vector4",$.binding={createEmptyConstructor:!0,properties:{hResolution:{set:!0,get:!0},vResolution:{set:!0,get:!0},hScreenSize:{set:!0,get:!0},vScreenSize:{set:!0,get:!0},eyeToScreenDistance:{set:!0,get:!0},lensSeparationDistance:{set:!0,get:!0},interpupillaryDistance:{set:!0,get:!0}}},i(r.functions,"EndDrawing").binding={after:t=>t.call("app_update_quickjs",[])},c("SetWindowIcons"),c("GetWindowHandle"),c("SwapScreenBuffer"),c("PollInputEvents"),c("WaitTime"),i(r.functions,"SetShaderValue").binding={body:t=>{t.jsToC("Shader","shader","argv[0]",T.structLookup),t.jsToC("int","locIndex","argv[1]",T.structLookup),t.declare("value","void *",!1,"NULL"),t.declare("valueFloat","float"),t.declare("valueInt","int"),t.jsToC("int","uniformType","argv[3]",T.structLookup);const e=t.switch("uniformType");let n=e.caseBreak("SHADER_UNIFORM_FLOAT");n.jsToC("float","valueFloat","argv[2]",T.structLookup,!0),n.statement("value = (void *)&valueFloat"),n=e.caseBreak("SHADER_UNIFORM_VEC2"),n.jsToC("Vector2 *","valueV2","argv[2]",T.structLookup),n.statement("value = (void*)valueV2"),n=e.caseBreak("SHADER_UNIFORM_VEC3"),n.jsToC("Vector3 *","valueV3","argv[2]",T.structLookup),n.statement("value = (void*)valueV3"),n=e.caseBreak("SHADER_UNIFORM_VEC4"),n.jsToC("Vector4 *","valueV4","argv[2]",T.structLookup),n.statement("value = (void*)valueV4"),n=e.caseBreak("SHADER_UNIFORM_INT"),n.jsToC("int","valueInt","argv[2]",T.structLookup,!0),n.statement("value = (void*)&valueInt"),n=e.defaultBreak(),n.returnExp("JS_EXCEPTION"),t.call("SetShaderValue",["shader","locIndex","value","uniformType"]),t.returnExp("JS_UNDEFINED")}},c("SetShaderValueV");const v=i(r.functions,"TraceLog");v.params?.pop();const J=new Set(["void","int","float","double","bool","unsigned int","unsigned char","long","char *","const char *","void *","const void *","unsigned char *","const unsigned char *","unsigned short *","float *","int *","unsigned int *","Color","Rectangle","Vector2","Vector3","Vector4","Matrix","Image","Texture","Texture2D","TextureCubemap","RenderTexture","RenderTexture2D","NPatchInfo","GlyphInfo","Font","Camera","Camera3D","Camera2D","Mesh","Shader","Material","MaterialMap","Transform","BoneInfo","Model","ModelAnimation","ModelAnimPose","Ray","RayCollision","BoundingBox","Wave","AudioStream","Sound","Music","VrDeviceInfo","VrStereoConfig","FilePathList","AutomationEvent","AutomationEventList","Light","Lightmapper","LightmapperConfig","Quaternion","ModelSkeleton","GestureEvent","TraceLogCallback","LoadFileDataCallback","SaveFileDataCallback","LoadFileTextCallback","SaveFileTextCallback"]);r.functions.forEach((t=>{if(t.binding?.ignore)return;const e=t=>t.replace(/^const /,"").replace(/\*+$/,"").replace(/ \*$/,"").trim(),n=(t.params||[]).every((t=>{const n=t.binding?.typeAlias||t.type;return J.has(n)||J.has(e(n))})),s=e(t.returnType);n&&(J.has(t.returnType)||J.has(s))||(t.name.startsWith("Text")||console.log(`Auto-ignoring ${t.name} (return: ${t.returnType}, params: [${(t.params||[]).map((t=>t.type)).join(", ")}])`),t.binding={ignore:!0})})),r.functions.filter((t=>{if("unsigned char *"!==t.returnType)return!1;const e=t.params?.[t.params.length-1];return e&&("int *"===e.type||"unsigned int *"===e.type)})).forEach((t=>{const e=t.params[t.params.length-1],n="CompressData"===t.name?"compData":"data";t.binding={body:s=>{for(let e=0;et.name)).slice(0,-1).concat(["&"+e.name]),{type:"unsigned char *",name:n}),s.statement(`JSValue buf = JS_NewArrayBufferCopy(ctx, (const uint8_t*)${n}, ${e.name})`),s.statement(`if (${n}) MemFree(${n})`),s.returnExp("buf")}},console.log(`Special buffer binding for ${t.name}`)})),c("MemAlloc"),c("MemRealloc"),c("MemFree"),c("SetTraceLogCallback"),c("SetLoadFileDataCallback"),c("SetSaveFileDataCallback"),c("SetLoadFileTextCallback"),c("SetSaveFileTextCallback");const E=i(r.functions,"LoadFileData");E.params[E.params.length-1].binding={ignore:!0},E.binding={body:t=>{t.jsToC("const char *","fileName","argv[0]"),t.declare("bytesRead","unsigned int"),t.call("LoadFileData",["fileName","&bytesRead"],{type:"unsigned char *",name:"retVal"}),t.statement("JSValue buffer = JS_NewArrayBufferCopy(ctx, (const uint8_t*)retVal, bytesRead)"),t.call("UnloadFileData",["retVal"]),t.jsCleanUpParameter("const char*","fileName"),t.returnExp("buffer")}},c("UnloadFileData"),i(r.functions,"SaveFileData").binding={},c("ExportDataAsCode"),c("LoadRandomSequence"),i(r.functions,"LoadFileText").binding={after:t=>t.call("UnloadFileText",["returnVal"])},i(r.functions,"SaveFileText").params[1].binding={typeAlias:"const char *"},c("UnloadFileText");const L=(t,e,n,s)=>{t.call(e,s,{type:"FilePathList",name:"files"}),t.call("JS_NewArray",["ctx"],{type:"JSValue",name:"ret"}),t.for("i","files.count").call("JS_SetPropertyUint32",["ctx","ret","i","JS_NewString(ctx,files.paths[i])"]),t.call(n,["files"])};i(r.functions,"LoadDirectoryFiles").binding={jsReturns:"string[]",body:t=>{t.jsToC("const char *","dirPath","argv[0]"),L(t,"LoadDirectoryFiles","UnloadDirectoryFiles",["dirPath"]),t.jsCleanUpParameter("const char *","dirPath"),t.returnExp("ret")}},i(r.functions,"LoadDirectoryFilesEx").binding={jsReturns:"string[]",body:t=>{t.jsToC("const char *","basePath","argv[0]"),t.jsToC("const char *","filter","argv[1]"),t.jsToC("bool","scanSubdirs","argv[2]"),L(t,"LoadDirectoryFilesEx","UnloadDirectoryFiles",["basePath","filter","scanSubdirs"]),t.jsCleanUpParameter("const char *","basePath"),t.jsCleanUpParameter("const char *","filter"),t.returnExp("ret")}},c("UnloadDirectoryFiles"),i(r.functions,"LoadDroppedFiles").binding={jsReturns:"string[]",body:t=>{L(t,"LoadDroppedFiles","UnloadDroppedFiles",[]),t.returnExp("ret")}},c("UnloadDroppedFiles"),c("CompressData"),c("DecompressData"),c("EncodeDataBase64"),c("DecodeDataBase64"),c("DrawLineStrip"),c("DrawTriangleFan"),c("DrawTriangleStrip"),c("CheckCollisionPointPoly"),c("CheckCollisionLines"),c("LoadImageAnim"),c("ExportImageAsCode"),i(r.functions,"LoadImageColors").binding={jsReturns:"ArrayBuffer",body:t=>{t.jsToC("Image","image","argv[0]",T.structLookup),t.call("LoadImageColors",["image"],{name:"colors",type:"Color *"}),t.statement("JSValue retVal = JS_NewArrayBufferCopy(ctx, (const uint8_t*)colors, image.width*image.height*sizeof(Color))"),t.call("UnloadImageColors",["colors"]),t.returnExp("retVal")}},c("LoadImagePalette"),c("UnloadImageColors"),c("UnloadImagePalette"),c("GetPixelColor"),c("SetPixelColor");const D=i(r.functions,"LoadFontEx");D.params[2].binding={ignore:!0},D.params[3].binding={ignore:!0},D.binding={customizeCall:"Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0);"},c("LoadFontFromMemory"),c("LoadFontData"),c("GenImageFontAtlas"),c("UnloadFontData"),c("ExportFontAsCode"),c("DrawTextCodepoints"),c("GetGlyphInfo"),c("LoadUTF8"),c("UnloadUTF8"),c("LoadCodepoints"),c("UnloadCodepoints"),c("GetCodepointCount"),c("GetCodepoint"),c("GetCodepointNext"),c("GetCodepointPrevious"),c("CodepointToUTF8"),r.functions.filter((t=>t.name.startsWith("Text"))).forEach((t=>c(t.name))),c("DrawTriangleStrip3D"),c("LoadMaterials"),c("LoadModelAnimations"),c("UpdateModelAnimation"),c("UnloadModelAnimation"),c("UnloadModelAnimations"),c("IsModelAnimationValid"),c("ExportWaveAsCode"),c("LoadWaveSamples"),c("UnloadWaveSamples"),c("LoadMusicStreamFromMemory"),c("LoadAudioStream"),c("UnloadAudioStream"),c("UpdateAudioStream"),c("IsAudioStreamProcessed"),c("PlayAudioStream"),c("PauseAudioStream"),c("ResumeAudioStream"),c("IsAudioStreamPlaying"),c("StopAudioStream"),c("SetAudioStreamVolume"),c("SetAudioStreamPitch"),c("SetAudioStreamPan"),c("SetAudioStreamBufferSizeDefault"),c("SetAudioStreamCallback"),c("AttachAudioStreamProcessor"),c("DetachAudioStreamProcessor"),c("AttachAudioMixedProcessor"),c("DetachAudioMixedProcessor"),T.exportGlobalDouble("DEG2RAD","(PI/180.0)"),T.exportGlobalDouble("RAD2DEG","(180.0/PI)");const I=(t,e)=>{const n=t.params[e];n.binding={jsType:`{ ${n.name}: number }`,customConverter:(t,e)=>{t.declare(n.name,n.type,!1,"NULL"),t.declare(n.name+"_out",n.type.replace(" *",""));const s=t.if("!JS_IsNull("+e+")");s.statement(n.name+" = &"+n.name+"_out"),s.call("JS_GetPropertyStr",["ctx",e,'"'+n.name+'"'],{name:n.name+"_js",type:"JSValue"}),s.call("JS_ToInt32",["ctx",n.name,n.name+"_js"])},customCleanup:(t,e)=>{t.if("!JS_IsNull("+e+")").call("JS_SetPropertyStr",["ctx",e,`"${n.name}"`,"JS_NewInt32(ctx,"+n.name+"_out)"])}}};T.definitions.declare("textbuffer[4096]","char",!0),I(i(r.functions,"GuiDropdownBox"),2),I(i(r.functions,"GuiSpinner"),2),I(i(r.functions,"GuiValueBox"),2),I(i(r.functions,"GuiListView"),2),I(i(r.functions,"GuiListView"),3),c("GuiListViewEx"),((t,e,n)=>{const s=t.params[2];s.binding={ignore:!0};const r=t.params[1];r.binding={jsType:`{ ${r.name}: string }`,customConverter:(t,e)=>{t.call("JS_GetPropertyStr",["ctx",e,'"'+r.name+'"'],{name:r.name+"_js",type:"JSValue"}),t.declare(r.name+"_len","size_t"),t.call("JS_ToCStringLen",["ctx","&"+r.name+"_len",r.name+"_js"],{name:r.name+"_val",type:"const char *"}),t.call("memcpy",["(void *)textbuffer",r.name+"_val",r.name+"_len"]),t.statement("textbuffer["+r.name+"_len] = 0"),t.declare(r.name,r.type,!1,"textbuffer"),t.declare(s.name,s.type,!1,"4096")},customCleanup:(t,e)=>{t.jsCleanUpParameter("const char *",r.name+"_val"),t.call("JS_SetPropertyStr",["ctx",e,`"${r.name}"`,"JS_NewString(ctx,"+r.name+")"])}}})(i(r.functions,"GuiTextBox")),i(r.functions,"GuiTextInputBox").binding={body:t=>{t.jsToC("Rectangle","bounds","argv[0]",T.structLookup),t.jsToC("const char *","title","argv[1]",T.structLookup),t.jsToC("const char *","message","argv[2]",T.structLookup),t.jsToC("const char *","buttons","argv[3]",T.structLookup),t.jsToC("char *","text","argv[4]",T.structLookup),t.jsToC("int","textMaxSize","argv[5]",T.structLookup),t.call("GuiTextInputBox",["bounds","title","message","buttons","text","textMaxSize","NULL"],{type:"int",name:"returnVal"}),t.jsCleanUpParameter("const char *","text"),t.statement("return JS_NewInt32(ctx, returnVal)")}},c("GuiTabBar"),c("GuiGetIcons"),c("GuiLoadIcons"),r.structs.forEach((t=>T.addApiStruct(t))),r.functions.forEach((t=>T.addApiFunction(t))),r.defines.filter((t=>"COLOR"===t.type)).map((t=>({name:t.name,description:t.description,values:(t.value.match(/\{([^}]+)\}/)||"")[1].split(",").map((t=>t.trim()))}))).forEach((t=>{T.exportGlobalStruct("Color",t.name,t.values,t.description)})),r.enums.forEach((t=>T.addEnum(t))),T.exportGlobalInt("MATERIAL_MAP_DIFFUSE","Albedo material (same as: MATERIAL_MAP_DIFFUSE"),T.exportGlobalInt("MATERIAL_MAP_SPECULAR","Metalness material (same as: MATERIAL_MAP_SPECULAR)"),T.writeTo("src/bindings/js_raylib_core.h"),T.typings.writeTo("examples/lib.raylib.d.ts");const F=r.functions.filter((t=>t.binding?.ignore)).length;console.log(`Converted ${r.functions.length-F} function. ${F} ignored`),console.log("Success!")}()})()})(); \ No newline at end of file diff --git a/readme.md b/readme.md index 61b5f26..8987821 100644 --- a/readme.md +++ b/readme.md @@ -1,22 +1,28 @@ ![rayjs logo](./doc/logo.png) -# rayjs - Javascript + Raylib -QuickJS based Javascript bindings for raylib in a single ~3mb executable +# rayjs - JavaScript + Raylib + +QuickJS based JavaScript bindings for raylib **5.5** 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. + +rayjs is a small ES2020 compliant JavaScript interpreter based on [QuickJS](https://bellard.org/quickjs/) with bindings for [Raylib](https://www.raylib.com/) (version **5.5**). 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. + +rayjs is not a binding for NodeJS nor is it running in the browser (yet). It 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 — all you need is the small rayjs executable. No installation, no DLLs or additional files required. ## 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 +* Use modern JavaScript features like classes and async/await +* Full auto-complete with TypeScript definitions for the entire raylib 5.5 API +* Built on raylib 5.5 (stable), raygui 4.0 ## 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 +3. Open the file with a text editor (e.g. Notepad) and add the following code: ```javascript const screenWidth = 800; const screenHeight = 450; @@ -36,25 +42,27 @@ 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. +5. Congratulations, you have created your first rayjs app! ## Running code -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 ` -3. It will look for a file called `main.js` in a folder given as a command line argument like this `rayjs ` -The directory of the main Javascript module will also be the working directory of the app. Modules and resources will be loaded relative to it. +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 passed as a command line argument: `rayjs ` +3. It will look for a file called `main.js` in a folder given as a command line argument: `rayjs ` + +The directory of the main JavaScript module will also be the working directory of the app. Modules and resources will be loaded relative to it. ## API support -The following raylib APIs are supported so far (with a few exceptions): +The following raylib 5.5 APIs are supported (with a few exceptions noted in `CHANGELOG_5.5.md`): - core (no VR support yet) - shapes - textures - text (no support for GlyphInfo yet) -- models (no animation support) +- models (no animation support yet) - shaders - audio - raymath @@ -63,13 +71,16 @@ The following raylib APIs are supported so far (with a few exceptions): - 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' +**718 functions bound** (105 intentionally ignored due to unsupported pointer types). -To check which API functions are not available (yet) check `/bindings/src/index.ts` for `ignore` statements. +All types and functions are provided globally for convenience. They are additionally available as a module called `'raylib'`. + +To check which API functions are not available, see `MIGRATION_TABLE.md` or the `ignore()` statements in `bindings/src/index.ts`. ## Additional APIs -Rayjs comes with some additional functionality on top of raylib to make writing raylib code with Javascript easier +rayjs comes with some additional functionality on top of raylib to make writing code with JavaScript easier: + ```typescript /** Replace material in slot materialIndex (Material is NOT unloaded) */ declare function setModelMaterial(model: Model, materialIndex: number, material: Material): void; @@ -87,85 +98,91 @@ declare function meshCopy(mesh: Mesh): Mesh; declare function meshMerge(a: Mesh, b: Mesh): Mesh; ``` -Additionally it also comes with bindings to [lightmapper.h](https://github.com/ands/lightmapper/tree/master). See below for more information. +Additionally it comes with bindings to [lightmapper.h](https://github.com/ands/lightmapper/tree/master). ## 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 +rayjs comes with full auto-complete support via the definitions file `lib.raylib.d.ts`. These work with TypeScript and JavaScript projects. To use with JavaScript, create a `tsconfig.json` in your project root: + ```json { "compilerOptions": { "allowJs": true, "target": "es2020", - "lib": [ - "ES2020" - ] + "lib": ["ES2020"] } } ``` -After that put the `lib.raylib.d.ts` file in the same folder and optionally restart your IDE. Auto-complete should be working: + +Place `lib.raylib.d.ts` in the same folder and restart your IDE. Auto-complete should work: + ![](doc/auto-complete.png) ## Examples -Some official raylib examples were already ported to Javascript and can be found in the `examples` folder. +Ported raylib examples can be found in the `examples` folder. -Additional examples are described here. - -``` +```bash ./rayjs examples/js_example_project ``` -Barebones example project on how to structure a project that uses Javascript +Barebones example project showing how to structure a JavaScript project. + +```bash +./rayjs examples/textures/bunnymark.js ``` -./rayjs examples/js_mesh_generation.js -``` -Shows how to create a mesh from Javascript ArrayBuffers +Classic bunnymark performance test. + +```bash +./rayjs examples/textures/bunnymark_opt.js ``` +Optimized bunnymark using Float32Array (higher performance, no GC pressure). + +```bash ./rayjs examples/shaders/js_shaders_gradient_lighting.js ``` -Creates a gradient and uses it as lighting for a 3d scene -``` +Creates a gradient and uses it as lighting for a 3D scene. + +```bash ./rayjs examples/ts_dungeon ``` -Small example game that uses Typescript with Webpack for transpilation and bundling -``` +Small example game using TypeScript with Webpack. + +```bash ./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. - +Example integrating existing JS libraries (Inkjs interactive fiction). ### 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. -``` + +rayjs integrates the [lightmapper.h](https://github.com/ands/lightmapper/tree/master) library for baked lighting: + +```bash ./rayjs examples/js_lightmapper.js ``` -Meshes must have unwrapped lightmap uvs in the second UV channel. +Meshes must have unwrapped lightmap UVs in the second UV channel. ![](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. -![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** +QuickJS is one of the [faster JS interpreters](https://bellard.org/quickjs/bench.html). The optimized bunnymark (`bunnymark_opt.js`) uses Float32Array for buffer-based object storage, significantly reducing GC pressure and improving frame rates. + +![Bunnymark](doc/bunny.png) + +## Building from source + +### Prerequisites + +- CMake +- C compiler (GCC, Clang, MSVC) +- Git + +### Build steps -### Check out required files ```bash 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 cd rayjs mkdir build cd build @@ -173,4 +190,10 @@ cmake .. make ``` +The executable will be placed in the project root directory. +## Migration from raylib 4.5 + +See `CHANGELOG_5.5.md` for a detailed changelog of all changes made during the migration from raylib 4.5 to 5.5. + +See `MIGRATION_TABLE.md` for a function-by-function comparison. \ No newline at end of file diff --git a/src/bindings/js_raylib_core.h b/src/bindings/js_raylib_core.h index 026c006..faef7c5 100644 --- a/src/bindings/js_raylib_core.h +++ b/src/bindings/js_raylib_core.h @@ -54,6 +54,8 @@ static JSClassID js_Music_class_id; static JSClassID js_VrDeviceInfo_class_id; static JSClassID js_VrStereoConfig_class_id; static JSClassID js_FilePathList_class_id; +static JSClassID js_AutomationEvent_class_id; +static JSClassID js_AutomationEventList_class_id; static JSClassID js_Light_class_id; static JSClassID js_Lightmapper_class_id; static JSClassID js_LightmapperConfig_class_id; @@ -1920,22 +1922,6 @@ static JSValue js_VrDeviceInfo_set_vScreenSize(JSContext* ctx, JSValueConst this return JS_UNDEFINED; } -static JSValue js_VrDeviceInfo_get_vScreenCenter(JSContext* ctx, JSValueConst this_val) { - VrDeviceInfo* ptr = JS_GetOpaque2(ctx, this_val, js_VrDeviceInfo_class_id); - float vScreenCenter = ptr->vScreenCenter; - JSValue ret = JS_NewFloat64(ctx, vScreenCenter); - return ret; -} - -static JSValue js_VrDeviceInfo_set_vScreenCenter(JSContext* ctx, JSValueConst this_val, JSValueConst v) { - VrDeviceInfo* ptr = JS_GetOpaque2(ctx, this_val, js_VrDeviceInfo_class_id); - double _double_value; - JS_ToFloat64(ctx, &_double_value, v); - float value = (float)_double_value; - ptr->vScreenCenter = value; - return JS_UNDEFINED; -} - static JSValue js_VrDeviceInfo_get_eyeToScreenDistance(JSContext* ctx, JSValueConst this_val) { VrDeviceInfo* ptr = JS_GetOpaque2(ctx, this_val, js_VrDeviceInfo_class_id); float eyeToScreenDistance = ptr->eyeToScreenDistance; @@ -1989,7 +1975,6 @@ static const JSCFunctionListEntry js_VrDeviceInfo_proto_funcs[] = { JS_CGETSET_DEF("vResolution",js_VrDeviceInfo_get_vResolution,js_VrDeviceInfo_set_vResolution), JS_CGETSET_DEF("hScreenSize",js_VrDeviceInfo_get_hScreenSize,js_VrDeviceInfo_set_hScreenSize), JS_CGETSET_DEF("vScreenSize",js_VrDeviceInfo_get_vScreenSize,js_VrDeviceInfo_set_vScreenSize), - JS_CGETSET_DEF("vScreenCenter",js_VrDeviceInfo_get_vScreenCenter,js_VrDeviceInfo_set_vScreenCenter), JS_CGETSET_DEF("eyeToScreenDistance",js_VrDeviceInfo_get_eyeToScreenDistance,js_VrDeviceInfo_set_eyeToScreenDistance), JS_CGETSET_DEF("lensSeparationDistance",js_VrDeviceInfo_get_lensSeparationDistance,js_VrDeviceInfo_set_lensSeparationDistance), JS_CGETSET_DEF("interpupillaryDistance",js_VrDeviceInfo_get_interpupillaryDistance,js_VrDeviceInfo_set_interpupillaryDistance), @@ -2048,6 +2033,48 @@ static int js_declare_FilePathList(JSContext * ctx, JSModuleDef * m) { return 0; } +static void js_AutomationEvent_finalizer(JSRuntime * rt, JSValue val) { + AutomationEvent* ptr = JS_GetOpaque(val, js_AutomationEvent_class_id); + if(ptr) { + js_free_rt(rt, ptr); + } +} + +static const JSCFunctionListEntry js_AutomationEvent_proto_funcs[] = { + JS_PROP_STRING_DEF("[Symbol.toStringTag]","AutomationEvent", JS_PROP_CONFIGURABLE), +}; + +static int js_declare_AutomationEvent(JSContext * ctx, JSModuleDef * m) { + JS_NewClassID(&js_AutomationEvent_class_id); + JSClassDef js_AutomationEvent_def = { .class_name = "AutomationEvent", .finalizer = js_AutomationEvent_finalizer }; + JS_NewClass(JS_GetRuntime(ctx), js_AutomationEvent_class_id, &js_AutomationEvent_def); + JSValue proto = JS_NewObject(ctx); + JS_SetPropertyFunctionList(ctx, proto, js_AutomationEvent_proto_funcs, countof(js_AutomationEvent_proto_funcs)); + JS_SetClassProto(ctx, js_AutomationEvent_class_id, proto); + return 0; +} + +static void js_AutomationEventList_finalizer(JSRuntime * rt, JSValue val) { + AutomationEventList* ptr = JS_GetOpaque(val, js_AutomationEventList_class_id); + if(ptr) { + js_free_rt(rt, ptr); + } +} + +static const JSCFunctionListEntry js_AutomationEventList_proto_funcs[] = { + JS_PROP_STRING_DEF("[Symbol.toStringTag]","AutomationEventList", JS_PROP_CONFIGURABLE), +}; + +static int js_declare_AutomationEventList(JSContext * ctx, JSModuleDef * m) { + JS_NewClassID(&js_AutomationEventList_class_id); + JSClassDef js_AutomationEventList_def = { .class_name = "AutomationEventList", .finalizer = js_AutomationEventList_finalizer }; + JS_NewClass(JS_GetRuntime(ctx), js_AutomationEventList_class_id, &js_AutomationEventList_def); + JSValue proto = JS_NewObject(ctx); + JS_SetPropertyFunctionList(ctx, proto, js_AutomationEventList_proto_funcs, countof(js_AutomationEventList_proto_funcs)); + JS_SetClassProto(ctx, js_AutomationEventList_class_id, proto); + return 0; +} + static void js_Light_finalizer(JSRuntime * rt, JSValue val) { Light* ptr = JS_GetOpaque(val, js_Light_class_id); if(ptr) { @@ -2593,17 +2620,17 @@ static JSValue js_initWindow(JSContext * ctx, JSValueConst this_val, int argc, J return JS_UNDEFINED; } +static JSValue js_closeWindow(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + CloseWindow(); + return JS_UNDEFINED; +} + static JSValue js_windowShouldClose(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { bool returnVal = WindowShouldClose(); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } -static JSValue js_closeWindow(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - CloseWindow(); - return JS_UNDEFINED; -} - static JSValue js_isWindowReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { bool returnVal = IsWindowReady(); JSValue ret = JS_NewBool(ctx, returnVal); @@ -2673,6 +2700,11 @@ static JSValue js_toggleFullscreen(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } +static JSValue js_toggleBorderlessWindowed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + ToggleBorderlessWindowed(); + return JS_UNDEFINED; +} + static JSValue js_maximizeWindow(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { MaximizeWindow(); return JS_UNDEFINED; @@ -2728,6 +2760,15 @@ static JSValue js_setWindowMinSize(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } +static JSValue js_setWindowMaxSize(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int width; + JS_ToInt32(ctx, &width, argv[0]); + int height; + JS_ToInt32(ctx, &height, argv[1]); + SetWindowMaxSize(width, height); + return JS_UNDEFINED; +} + static JSValue js_setWindowSize(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int width; JS_ToInt32(ctx, &width, argv[0]); @@ -2745,6 +2786,11 @@ static JSValue js_setWindowOpacity(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } +static JSValue js_setWindowFocused(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + SetWindowFocused(); + return JS_UNDEFINED; +} + static JSValue js_getScreenWidth(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int returnVal = GetScreenWidth(); JSValue ret = JS_NewInt32(ctx, returnVal); @@ -2871,6 +2917,15 @@ static JSValue js_getClipboardText(JSContext * ctx, JSValueConst this_val, int a return ret; } +static JSValue js_getClipboardImage(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image returnVal = GetClipboardImage(); + Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Image_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_enableEventWaiting(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { EnableEventWaiting(); return JS_UNDEFINED; @@ -3073,11 +3128,11 @@ static JSValue js_loadShaderFromMemory(JSContext * ctx, JSValueConst this_val, i return ret; } -static JSValue js_isShaderReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isShaderValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Shader* shader_ptr = (Shader*)JS_GetOpaque2(ctx, argv[0], js_Shader_class_id); if(shader_ptr == NULL) return JS_EXCEPTION; Shader shader = *shader_ptr; - bool returnVal = IsShaderReady(shader); + bool returnVal = IsShaderValid(shader); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -3195,14 +3250,14 @@ static JSValue js_unloadShader(JSContext * ctx, JSValueConst this_val, int argc, return JS_UNDEFINED; } -static JSValue js_getMouseRay(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Vector2* mousePosition_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); - if(mousePosition_ptr == NULL) return JS_EXCEPTION; - Vector2 mousePosition = *mousePosition_ptr; +static JSValue js_getScreenToWorldRay(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(position_ptr == NULL) return JS_EXCEPTION; + Vector2 position = *position_ptr; Camera* camera_ptr = (Camera*)JS_GetOpaque2(ctx, argv[1], js_Camera3D_class_id); if(camera_ptr == NULL) return JS_EXCEPTION; Camera camera = *camera_ptr; - Ray returnVal = GetMouseRay(mousePosition, camera); + Ray returnVal = GetScreenToWorldRay(position, camera); Ray* ret_ptr = (Ray*)js_malloc(ctx, sizeof(Ray)); *ret_ptr = returnVal; JSValue ret = JS_NewObjectClass(ctx, js_Ray_class_id); @@ -3210,26 +3265,21 @@ static JSValue js_getMouseRay(JSContext * ctx, JSValueConst this_val, int argc, return ret; } -static JSValue js_getCameraMatrix(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Camera* camera_ptr = (Camera*)JS_GetOpaque2(ctx, argv[0], js_Camera3D_class_id); +static JSValue js_getScreenToWorldRayEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(position_ptr == NULL) return JS_EXCEPTION; + Vector2 position = *position_ptr; + Camera* camera_ptr = (Camera*)JS_GetOpaque2(ctx, argv[1], js_Camera3D_class_id); if(camera_ptr == NULL) return JS_EXCEPTION; Camera camera = *camera_ptr; - Matrix returnVal = GetCameraMatrix(camera); - Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); + int width; + JS_ToInt32(ctx, &width, argv[2]); + int height; + JS_ToInt32(ctx, &height, argv[3]); + Ray returnVal = GetScreenToWorldRayEx(position, camera, width, height); + Ray* ret_ptr = (Ray*)js_malloc(ctx, sizeof(Ray)); *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - -static JSValue js_getCameraMatrix2D(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Camera2D* camera_ptr = (Camera2D*)JS_GetOpaque2(ctx, argv[0], js_Camera2D_class_id); - if(camera_ptr == NULL) return JS_EXCEPTION; - Camera2D camera = *camera_ptr; - Matrix returnVal = GetCameraMatrix2D(camera); - Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); + JSValue ret = JS_NewObjectClass(ctx, js_Ray_class_id); JS_SetOpaque(ret, ret_ptr); return ret; } @@ -3249,21 +3299,6 @@ static JSValue js_getWorldToScreen(JSContext * ctx, JSValueConst this_val, int a return ret; } -static JSValue js_getScreenToWorld2D(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); - if(position_ptr == NULL) return JS_EXCEPTION; - Vector2 position = *position_ptr; - Camera2D* camera_ptr = (Camera2D*)JS_GetOpaque2(ctx, argv[1], js_Camera2D_class_id); - if(camera_ptr == NULL) return JS_EXCEPTION; - Camera2D camera = *camera_ptr; - Vector2 returnVal = GetScreenToWorld2D(position, camera); - Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - static JSValue js_getWorldToScreenEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* position_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(position_ptr == NULL) return JS_EXCEPTION; @@ -3298,6 +3333,45 @@ static JSValue js_getWorldToScreen2D(JSContext * ctx, JSValueConst this_val, int return ret; } +static JSValue js_getScreenToWorld2D(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(position_ptr == NULL) return JS_EXCEPTION; + Vector2 position = *position_ptr; + Camera2D* camera_ptr = (Camera2D*)JS_GetOpaque2(ctx, argv[1], js_Camera2D_class_id); + if(camera_ptr == NULL) return JS_EXCEPTION; + Camera2D camera = *camera_ptr; + Vector2 returnVal = GetScreenToWorld2D(position, camera); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getCameraMatrix(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Camera* camera_ptr = (Camera*)JS_GetOpaque2(ctx, argv[0], js_Camera3D_class_id); + if(camera_ptr == NULL) return JS_EXCEPTION; + Camera camera = *camera_ptr; + Matrix returnVal = GetCameraMatrix(camera); + Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getCameraMatrix2D(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Camera2D* camera_ptr = (Camera2D*)JS_GetOpaque2(ctx, argv[0], js_Camera2D_class_id); + if(camera_ptr == NULL) return JS_EXCEPTION; + Camera2D camera = *camera_ptr; + Matrix returnVal = GetCameraMatrix2D(camera); + Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_setTargetFPS(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int fps; JS_ToInt32(ctx, &fps, argv[0]); @@ -3305,12 +3379,6 @@ static JSValue js_setTargetFPS(JSContext * ctx, JSValueConst this_val, int argc, return JS_UNDEFINED; } -static JSValue js_getFPS(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - int returnVal = GetFPS(); - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - static JSValue js_getFrameTime(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { float returnVal = GetFrameTime(); JSValue ret = JS_NewFloat64(ctx, returnVal); @@ -3323,6 +3391,19 @@ static JSValue js_getTime(JSContext * ctx, JSValueConst this_val, int argc, JSVa return ret; } +static JSValue js_getFPS(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int returnVal = GetFPS(); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_setRandomSeed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + unsigned int seed; + JS_ToUint32(ctx, &seed, argv[0]); + SetRandomSeed(seed); + return JS_UNDEFINED; +} + static JSValue js_getRandomValue(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int min; JS_ToInt32(ctx, &min, argv[0]); @@ -3333,10 +3414,11 @@ static JSValue js_getRandomValue(JSContext * ctx, JSValueConst this_val, int arg return ret; } -static JSValue js_setRandomSeed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - unsigned int seed; - JS_ToUint32(ctx, &seed, argv[0]); - SetRandomSeed(seed); +static JSValue js_unloadRandomSequence(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int sequence_int; + JS_ToInt32(ctx, &sequence_int, argv[0]); + int * sequence = &sequence_int; + UnloadRandomSequence(sequence); return JS_UNDEFINED; } @@ -3354,6 +3436,13 @@ static JSValue js_setConfigFlags(JSContext * ctx, JSValueConst this_val, int arg return JS_UNDEFINED; } +static JSValue js_openURL(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * url = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); + OpenURL(url); + JS_FreeCString(ctx, url); + return JS_UNDEFINED; +} + static JSValue js_traceLog(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int logLevel; JS_ToInt32(ctx, &logLevel, argv[0]); @@ -3370,13 +3459,6 @@ static JSValue js_setTraceLogLevel(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } -static JSValue js_openURL(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - const char * url = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); - OpenURL(url); - JS_FreeCString(ctx, url); - return JS_UNDEFINED; -} - static JSValue js_loadFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); unsigned int bytesRead; @@ -3395,9 +3477,9 @@ static JSValue js_saveFileData(JSContext * ctx, JSValueConst this_val, int argc, } void * data = malloc(data_size); memcpy((void *)data, (const void *)data_js, data_size); - unsigned int bytesToWrite; - JS_ToUint32(ctx, &bytesToWrite, argv[2]); - bool returnVal = SaveFileData(fileName, data, bytesToWrite); + int dataSize; + JS_ToInt32(ctx, &dataSize, argv[2]); + bool returnVal = SaveFileData(fileName, data, dataSize); JS_FreeCString(ctx, fileName); free((void *)data); JSValue ret = JS_NewBool(ctx, returnVal); @@ -3509,6 +3591,14 @@ static JSValue js_getApplicationDirectory(JSContext * ctx, JSValueConst this_val return ret; } +static JSValue js_makeDirectory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * dirPath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); + int returnVal = MakeDirectory(dirPath); + JS_FreeCString(ctx, dirPath); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + static JSValue js_changeDirectory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * dir = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); bool returnVal = ChangeDirectory(dir); @@ -3525,6 +3615,14 @@ static JSValue js_isPathFile(JSContext * ctx, JSValueConst this_val, int argc, J return ret; } +static JSValue js_isFileNameValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); + bool returnVal = IsFileNameValid(fileName); + JS_FreeCString(ctx, fileName); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_loadDirectoryFiles(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * dirPath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); FilePathList files = LoadDirectoryFiles(dirPath); @@ -3576,6 +3674,116 @@ static JSValue js_getFileModTime(JSContext * ctx, JSValueConst this_val, int arg return ret; } +static JSValue js_computeCRC32(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + size_t data_size; + void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[0]); + if(data_js == NULL) { + return JS_EXCEPTION; + } + unsigned char * data = malloc(data_size); + memcpy((void *)data, (const void *)data_js, data_size); + int dataSize; + JS_ToInt32(ctx, &dataSize, argv[1]); + unsigned int returnVal = ComputeCRC32(data, dataSize); + free((void *)data); + JSValue ret = JS_NewUint32(ctx, returnVal); + return ret; +} + +static JSValue js_computeMD5(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + size_t data_size; + void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[0]); + if(data_js == NULL) { + return JS_EXCEPTION; + } + unsigned char * data = malloc(data_size); + memcpy((void *)data, (const void *)data_js, data_size); + int dataSize; + JS_ToInt32(ctx, &dataSize, argv[1]); + unsigned int * returnVal = ComputeMD5(data, dataSize); + free((void *)data); + JSValue ret = returnVal ? JS_NewUint32(ctx, *returnVal) : JS_NULL; + return ret; +} + +static JSValue js_computeSHA1(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + size_t data_size; + void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[0]); + if(data_js == NULL) { + return JS_EXCEPTION; + } + unsigned char * data = malloc(data_size); + memcpy((void *)data, (const void *)data_js, data_size); + int dataSize; + JS_ToInt32(ctx, &dataSize, argv[1]); + unsigned int * returnVal = ComputeSHA1(data, dataSize); + free((void *)data); + JSValue ret = returnVal ? JS_NewUint32(ctx, *returnVal) : JS_NULL; + return ret; +} + +static JSValue js_loadAutomationEventList(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); + AutomationEventList returnVal = LoadAutomationEventList(fileName); + JS_FreeCString(ctx, fileName); + AutomationEventList* ret_ptr = (AutomationEventList*)js_malloc(ctx, sizeof(AutomationEventList)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_AutomationEventList_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_unloadAutomationEventList(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + AutomationEventList* list_ptr = (AutomationEventList*)JS_GetOpaque2(ctx, argv[0], js_AutomationEventList_class_id); + if(list_ptr == NULL) return JS_EXCEPTION; + AutomationEventList list = *list_ptr; + UnloadAutomationEventList(list); + return JS_UNDEFINED; +} + +static JSValue js_exportAutomationEventList(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + AutomationEventList* list_ptr = (AutomationEventList*)JS_GetOpaque2(ctx, argv[0], js_AutomationEventList_class_id); + if(list_ptr == NULL) return JS_EXCEPTION; + AutomationEventList list = *list_ptr; + const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = ExportAutomationEventList(list, fileName); + JS_FreeCString(ctx, fileName); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_setAutomationEventList(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + AutomationEventList* list = (AutomationEventList*)JS_GetOpaque2(ctx, argv[0], js_AutomationEventList_class_id); + if(list == NULL) return JS_EXCEPTION; + SetAutomationEventList(list); + return JS_UNDEFINED; +} + +static JSValue js_setAutomationEventBaseFrame(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int frame; + JS_ToInt32(ctx, &frame, argv[0]); + SetAutomationEventBaseFrame(frame); + return JS_UNDEFINED; +} + +static JSValue js_startAutomationEventRecording(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + StartAutomationEventRecording(); + return JS_UNDEFINED; +} + +static JSValue js_stopAutomationEventRecording(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + StopAutomationEventRecording(); + return JS_UNDEFINED; +} + +static JSValue js_playAutomationEvent(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + AutomationEvent* event_ptr = (AutomationEvent*)JS_GetOpaque2(ctx, argv[0], js_AutomationEvent_class_id); + if(event_ptr == NULL) return JS_EXCEPTION; + AutomationEvent event = *event_ptr; + PlayAutomationEvent(event); + return JS_UNDEFINED; +} + static JSValue js_isKeyPressed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int key; JS_ToInt32(ctx, &key, argv[0]); @@ -3584,6 +3792,14 @@ static JSValue js_isKeyPressed(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_isKeyPressedRepeat(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int key; + JS_ToInt32(ctx, &key, argv[0]); + bool returnVal = IsKeyPressedRepeat(key); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_isKeyDown(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int key; JS_ToInt32(ctx, &key, argv[0]); @@ -3608,13 +3824,6 @@ static JSValue js_isKeyUp(JSContext * ctx, JSValueConst this_val, int argc, JSVa return ret; } -static JSValue js_setExitKey(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - int key; - JS_ToInt32(ctx, &key, argv[0]); - SetExitKey(key); - return JS_UNDEFINED; -} - static JSValue js_getKeyPressed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int returnVal = GetKeyPressed(); JSValue ret = JS_NewInt32(ctx, returnVal); @@ -3627,6 +3836,13 @@ static JSValue js_getCharPressed(JSContext * ctx, JSValueConst this_val, int arg return ret; } +static JSValue js_setExitKey(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int key; + JS_ToInt32(ctx, &key, argv[0]); + SetExitKey(key); + return JS_UNDEFINED; +} + static JSValue js_isGamepadAvailable(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int gamepad; JS_ToInt32(ctx, &gamepad, argv[0]); @@ -3715,6 +3931,22 @@ static JSValue js_setGamepadMappings(JSContext * ctx, JSValueConst this_val, int return ret; } +static JSValue js_setGamepadVibration(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int gamepad; + JS_ToInt32(ctx, &gamepad, argv[0]); + double _double_leftMotor; + JS_ToFloat64(ctx, &_double_leftMotor, argv[1]); + float leftMotor = (float)_double_leftMotor; + double _double_rightMotor; + JS_ToFloat64(ctx, &_double_rightMotor, argv[2]); + float rightMotor = (float)_double_rightMotor; + double _double_duration; + JS_ToFloat64(ctx, &_double_duration, argv[3]); + float duration = (float)_double_duration; + SetGamepadVibration(gamepad, leftMotor, rightMotor, duration); + return JS_UNDEFINED; +} + static JSValue js_isMouseButtonPressed(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int button; JS_ToInt32(ctx, &button, argv[0]); @@ -3873,8 +4105,8 @@ static JSValue js_setGesturesEnabled(JSContext * ctx, JSValueConst this_val, int } static JSValue js_isGestureDetected(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - int gesture; - JS_ToInt32(ctx, &gesture, argv[0]); + unsigned int gesture; + JS_ToUint32(ctx, &gesture, argv[0]); bool returnVal = IsGestureDetected(gesture); JSValue ret = JS_NewBool(ctx, returnVal); return ret; @@ -3958,6 +4190,24 @@ static JSValue js_setShapesTexture(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } +static JSValue js_getShapesTexture(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Texture2D returnVal = GetShapesTexture(); + Texture2D* ret_ptr = (Texture2D*)js_malloc(ctx, sizeof(Texture2D)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Texture_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getShapesTextureRectangle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle returnVal = GetShapesTextureRectangle(); + Rectangle* ret_ptr = (Rectangle*)js_malloc(ctx, sizeof(Rectangle)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Rectangle_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_drawPixel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int posX; JS_ToInt32(ctx, &posX, argv[0]); @@ -4045,49 +4295,6 @@ static JSValue js_drawLineBezier(JSContext * ctx, JSValueConst this_val, int arg return JS_UNDEFINED; } -static JSValue js_drawLineBezierQuad(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Vector2* startPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); - if(startPos_ptr == NULL) return JS_EXCEPTION; - Vector2 startPos = *startPos_ptr; - Vector2* endPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); - if(endPos_ptr == NULL) return JS_EXCEPTION; - Vector2 endPos = *endPos_ptr; - Vector2* controlPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); - if(controlPos_ptr == NULL) return JS_EXCEPTION; - Vector2 controlPos = *controlPos_ptr; - double _double_thick; - JS_ToFloat64(ctx, &_double_thick, argv[3]); - float thick = (float)_double_thick; - Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); - if(color_ptr == NULL) return JS_EXCEPTION; - Color color = *color_ptr; - DrawLineBezierQuad(startPos, endPos, controlPos, thick, color); - return JS_UNDEFINED; -} - -static JSValue js_drawLineBezierCubic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Vector2* startPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); - if(startPos_ptr == NULL) return JS_EXCEPTION; - Vector2 startPos = *startPos_ptr; - Vector2* endPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); - if(endPos_ptr == NULL) return JS_EXCEPTION; - Vector2 endPos = *endPos_ptr; - Vector2* startControlPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); - if(startControlPos_ptr == NULL) return JS_EXCEPTION; - Vector2 startControlPos = *startControlPos_ptr; - Vector2* endControlPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); - if(endControlPos_ptr == NULL) return JS_EXCEPTION; - Vector2 endControlPos = *endControlPos_ptr; - double _double_thick; - JS_ToFloat64(ctx, &_double_thick, argv[4]); - float thick = (float)_double_thick; - Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); - if(color_ptr == NULL) return JS_EXCEPTION; - Color color = *color_ptr; - DrawLineBezierCubic(startPos, endPos, startControlPos, endControlPos, thick, color); - return JS_UNDEFINED; -} - static JSValue js_drawCircle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int centerX; JS_ToInt32(ctx, ¢erX, argv[0]); @@ -4155,13 +4362,13 @@ static JSValue js_drawCircleGradient(JSContext * ctx, JSValueConst this_val, int double _double_radius; JS_ToFloat64(ctx, &_double_radius, argv[2]); float radius = (float)_double_radius; - Color* color1_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); - if(color1_ptr == NULL) return JS_EXCEPTION; - Color color1 = *color1_ptr; - Color* color2_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); - if(color2_ptr == NULL) return JS_EXCEPTION; - Color color2 = *color2_ptr; - DrawCircleGradient(centerX, centerY, radius, color1, color2); + Color* inner_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(inner_ptr == NULL) return JS_EXCEPTION; + Color inner = *inner_ptr; + Color* outer_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(outer_ptr == NULL) return JS_EXCEPTION; + Color outer = *outer_ptr; + DrawCircleGradient(centerX, centerY, radius, inner, outer); return JS_UNDEFINED; } @@ -4194,6 +4401,20 @@ static JSValue js_drawCircleLines(JSContext * ctx, JSValueConst this_val, int ar return JS_UNDEFINED; } +static JSValue js_drawCircleLinesV(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* center_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(center_ptr == NULL) return JS_EXCEPTION; + Vector2 center = *center_ptr; + double _double_radius; + JS_ToFloat64(ctx, &_double_radius, argv[1]); + float radius = (float)_double_radius; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawCircleLinesV(center, radius, color); + return JS_UNDEFINED; +} + static JSValue js_drawEllipse(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int centerX; JS_ToInt32(ctx, ¢erX, argv[0]); @@ -4347,13 +4568,13 @@ static JSValue js_drawRectangleGradientV(JSContext * ctx, JSValueConst this_val, JS_ToInt32(ctx, &width, argv[2]); int height; JS_ToInt32(ctx, &height, argv[3]); - Color* color1_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); - if(color1_ptr == NULL) return JS_EXCEPTION; - Color color1 = *color1_ptr; - Color* color2_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); - if(color2_ptr == NULL) return JS_EXCEPTION; - Color color2 = *color2_ptr; - DrawRectangleGradientV(posX, posY, width, height, color1, color2); + Color* top_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(top_ptr == NULL) return JS_EXCEPTION; + Color top = *top_ptr; + Color* bottom_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(bottom_ptr == NULL) return JS_EXCEPTION; + Color bottom = *bottom_ptr; + DrawRectangleGradientV(posX, posY, width, height, top, bottom); return JS_UNDEFINED; } @@ -4366,13 +4587,13 @@ static JSValue js_drawRectangleGradientH(JSContext * ctx, JSValueConst this_val, JS_ToInt32(ctx, &width, argv[2]); int height; JS_ToInt32(ctx, &height, argv[3]); - Color* color1_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); - if(color1_ptr == NULL) return JS_EXCEPTION; - Color color1 = *color1_ptr; - Color* color2_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); - if(color2_ptr == NULL) return JS_EXCEPTION; - Color color2 = *color2_ptr; - DrawRectangleGradientH(posX, posY, width, height, color1, color2); + Color* left_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(left_ptr == NULL) return JS_EXCEPTION; + Color left = *left_ptr; + Color* right_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(right_ptr == NULL) return JS_EXCEPTION; + Color right = *right_ptr; + DrawRectangleGradientH(posX, posY, width, height, left, right); return JS_UNDEFINED; } @@ -4380,19 +4601,19 @@ static JSValue js_drawRectangleGradientEx(JSContext * ctx, JSValueConst this_val Rectangle* rec_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); if(rec_ptr == NULL) return JS_EXCEPTION; Rectangle rec = *rec_ptr; - Color* col1_ptr = (Color*)JS_GetOpaque2(ctx, argv[1], js_Color_class_id); - if(col1_ptr == NULL) return JS_EXCEPTION; - Color col1 = *col1_ptr; - Color* col2_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); - if(col2_ptr == NULL) return JS_EXCEPTION; - Color col2 = *col2_ptr; - Color* col3_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); - if(col3_ptr == NULL) return JS_EXCEPTION; - Color col3 = *col3_ptr; - Color* col4_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); - if(col4_ptr == NULL) return JS_EXCEPTION; - Color col4 = *col4_ptr; - DrawRectangleGradientEx(rec, col1, col2, col3, col4); + Color* topLeft_ptr = (Color*)JS_GetOpaque2(ctx, argv[1], js_Color_class_id); + if(topLeft_ptr == NULL) return JS_EXCEPTION; + Color topLeft = *topLeft_ptr; + Color* bottomLeft_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(bottomLeft_ptr == NULL) return JS_EXCEPTION; + Color bottomLeft = *bottomLeft_ptr; + Color* topRight_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(topRight_ptr == NULL) return JS_EXCEPTION; + Color topRight = *topRight_ptr; + Color* bottomRight_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(bottomRight_ptr == NULL) return JS_EXCEPTION; + Color bottomRight = *bottomRight_ptr; + DrawRectangleGradientEx(rec, topLeft, bottomLeft, topRight, bottomRight); return JS_UNDEFINED; } @@ -4443,6 +4664,22 @@ static JSValue js_drawRectangleRounded(JSContext * ctx, JSValueConst this_val, i } static JSValue js_drawRectangleRoundedLines(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* rec_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(rec_ptr == NULL) return JS_EXCEPTION; + Rectangle rec = *rec_ptr; + double _double_roundness; + JS_ToFloat64(ctx, &_double_roundness, argv[1]); + float roundness = (float)_double_roundness; + int segments; + JS_ToInt32(ctx, &segments, argv[2]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawRectangleRoundedLines(rec, roundness, segments, color); + return JS_UNDEFINED; +} + +static JSValue js_drawRectangleRoundedLinesEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Rectangle* rec_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); if(rec_ptr == NULL) return JS_EXCEPTION; Rectangle rec = *rec_ptr; @@ -4457,7 +4694,7 @@ static JSValue js_drawRectangleRoundedLines(JSContext * ctx, JSValueConst this_v Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); if(color_ptr == NULL) return JS_EXCEPTION; Color color = *color_ptr; - DrawRectangleRoundedLines(rec, roundness, segments, lineThick, color); + DrawRectangleRoundedLinesEx(rec, roundness, segments, lineThick, color); return JS_UNDEFINED; } @@ -4555,6 +4792,298 @@ static JSValue js_drawPolyLinesEx(JSContext * ctx, JSValueConst this_val, int ar return JS_UNDEFINED; } +static JSValue js_drawSplineLinear(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const Vector2* points = (const Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[1]); + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineLinear(points, pointCount, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineBasis(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const Vector2* points = (const Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[1]); + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineBasis(points, pointCount, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineCatmullRom(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const Vector2* points = (const Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[1]); + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineCatmullRom(points, pointCount, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineBezierQuadratic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const Vector2* points = (const Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[1]); + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineBezierQuadratic(points, pointCount, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineBezierCubic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const Vector2* points = (const Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[1]); + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineBezierCubic(points, pointCount, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineSegmentLinear(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[2]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineSegmentLinear(p1, p2, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineSegmentBasis(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[4]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineSegmentBasis(p1, p2, p3, p4, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineSegmentCatmullRom(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[4]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineSegmentCatmullRom(p1, p2, p3, p4, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineSegmentBezierQuadratic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* c2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(c2_ptr == NULL) return JS_EXCEPTION; + Vector2 c2 = *c2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[3]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineSegmentBezierQuadratic(p1, c2, p3, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_drawSplineSegmentBezierCubic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* c2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(c2_ptr == NULL) return JS_EXCEPTION; + Vector2 c2 = *c2_ptr; + Vector2* c3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(c3_ptr == NULL) return JS_EXCEPTION; + Vector2 c3 = *c3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_thick; + JS_ToFloat64(ctx, &_double_thick, argv[4]); + float thick = (float)_double_thick; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + DrawSplineSegmentBezierCubic(p1, c2, c3, p4, thick, color); + return JS_UNDEFINED; +} + +static JSValue js_getSplinePointLinear(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* startPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(startPos_ptr == NULL) return JS_EXCEPTION; + Vector2 startPos = *startPos_ptr; + Vector2* endPos_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(endPos_ptr == NULL) return JS_EXCEPTION; + Vector2 endPos = *endPos_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[2]); + float t = (float)_double_t; + Vector2 returnVal = GetSplinePointLinear(startPos, endPos, t); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getSplinePointBasis(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[4]); + float t = (float)_double_t; + Vector2 returnVal = GetSplinePointBasis(p1, p2, p3, p4, t); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getSplinePointCatmullRom(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[4]); + float t = (float)_double_t; + Vector2 returnVal = GetSplinePointCatmullRom(p1, p2, p3, p4, t); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getSplinePointBezierQuad(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* c2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(c2_ptr == NULL) return JS_EXCEPTION; + Vector2 c2 = *c2_ptr; + Vector2* p3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p3_ptr == NULL) return JS_EXCEPTION; + Vector2 p3 = *p3_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[3]); + float t = (float)_double_t; + Vector2 returnVal = GetSplinePointBezierQuad(p1, c2, p3, t); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_getSplinePointBezierCubic(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* c2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(c2_ptr == NULL) return JS_EXCEPTION; + Vector2 c2 = *c2_ptr; + Vector2* c3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(c3_ptr == NULL) return JS_EXCEPTION; + Vector2 c3 = *c3_ptr; + Vector2* p4_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p4_ptr == NULL) return JS_EXCEPTION; + Vector2 p4 = *p4_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[4]); + float t = (float)_double_t; + Vector2 returnVal = GetSplinePointBezierCubic(p1, c2, c3, p4, t); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_checkCollisionRecs(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Rectangle* rec1_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); if(rec1_ptr == NULL) return JS_EXCEPTION; @@ -4600,6 +5129,24 @@ static JSValue js_checkCollisionCircleRec(JSContext * ctx, JSValueConst this_val return ret; } +static JSValue js_checkCollisionCircleLine(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* center_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(center_ptr == NULL) return JS_EXCEPTION; + Vector2 center = *center_ptr; + double _double_radius; + JS_ToFloat64(ctx, &_double_radius, argv[1]); + float radius = (float)_double_radius; + Vector2* p1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(p1_ptr == NULL) return JS_EXCEPTION; + Vector2 p1 = *p1_ptr; + Vector2* p2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(p2_ptr == NULL) return JS_EXCEPTION; + Vector2 p2 = *p2_ptr; + bool returnVal = CheckCollisionCircleLine(center, radius, p1, p2); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_checkCollisionPointRec(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector2* point_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); if(point_ptr == NULL) return JS_EXCEPTION; @@ -4707,6 +5254,30 @@ static JSValue js_loadImageRaw(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_loadImageAnimFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileType = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); + size_t fileData_size; + void * fileData_js = (void *)JS_GetArrayBuffer(ctx, &fileData_size, argv[1]); + if(fileData_js == NULL) { + return JS_EXCEPTION; + } + const unsigned char * fileData = malloc(fileData_size); + memcpy((void *)fileData, (const void *)fileData_js, fileData_size); + int dataSize; + JS_ToInt32(ctx, &dataSize, argv[2]); + int frames_int; + JS_ToInt32(ctx, &frames_int, argv[3]); + int * frames = &frames_int; + Image returnVal = LoadImageAnimFromMemory(fileType, fileData, dataSize, frames); + JS_FreeCString(ctx, fileType); + free((void *)fileData); + Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Image_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_loadImageFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * fileType = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); size_t fileData_size; @@ -4749,11 +5320,11 @@ static JSValue js_loadImageFromScreen(JSContext * ctx, JSValueConst this_val, in return ret; } -static JSValue js_isImageReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isImageValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Image* image_ptr = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); if(image_ptr == NULL) return JS_EXCEPTION; Image image = *image_ptr; - bool returnVal = IsImageReady(image); + bool returnVal = IsImageValid(image); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -4777,6 +5348,18 @@ static JSValue js_exportImage(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_exportImageToMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* image_ptr = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(image_ptr == NULL) return JS_EXCEPTION; + Image image = *image_ptr; + const char * fileType = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int fileSize = 0; + unsigned char * data = ExportImageToMemory(image, fileType, &fileSize); + JSValue buf = JS_NewArrayBufferCopy(ctx, (const uint8_t*)data, fileSize); + if (data) MemFree(data); + return buf; +} + static JSValue js_genImageColor(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int width; JS_ToInt32(ctx, &width, argv[0]); @@ -4974,6 +5557,20 @@ static JSValue js_imageFromImage(JSContext * ctx, JSValueConst this_val, int arg return ret; } +static JSValue js_imageFromChannel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* image_ptr = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(image_ptr == NULL) return JS_EXCEPTION; + Image image = *image_ptr; + int selectedChannel; + JS_ToInt32(ctx, &selectedChannel, argv[1]); + Image returnVal = ImageFromChannel(image, selectedChannel); + Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Image_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_imageText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); int fontSize; @@ -5091,6 +5688,22 @@ static JSValue js_imageBlurGaussian(JSContext * ctx, JSValueConst this_val, int return JS_UNDEFINED; } +static JSValue js_imageKernelConvolution(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* image = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(image == NULL) return JS_EXCEPTION; + size_t kernel_size; + void * kernel_js = (void *)JS_GetArrayBuffer(ctx, &kernel_size, argv[1]); + if(kernel_js == NULL) { + return JS_EXCEPTION; + } + const float * kernel = malloc(kernel_size); + memcpy((void *)kernel, (const void *)kernel_js, kernel_size); + int kernelSize; + JS_ToInt32(ctx, &kernelSize, argv[2]); + ImageKernelConvolution(image, kernel, kernelSize); + return JS_UNDEFINED; +} + static JSValue js_imageResize(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Image* image = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); if(image == NULL) return JS_EXCEPTION; @@ -5358,6 +5971,24 @@ static JSValue js_imageDrawLineV(JSContext * ctx, JSValueConst this_val, int arg return JS_UNDEFINED; } +static JSValue js_imageDrawLineEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* start_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(start_ptr == NULL) return JS_EXCEPTION; + Vector2 start = *start_ptr; + Vector2* end_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(end_ptr == NULL) return JS_EXCEPTION; + Vector2 end = *end_ptr; + int thick; + JS_ToInt32(ctx, &thick, argv[3]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + ImageDrawLineEx(dst, start, end, thick, color); + return JS_UNDEFINED; +} + static JSValue js_imageDrawCircle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); if(dst == NULL) return JS_EXCEPTION; @@ -5482,6 +6113,97 @@ static JSValue js_imageDrawRectangleLines(JSContext * ctx, JSValueConst this_val return JS_UNDEFINED; } +static JSValue js_imageDrawTriangle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* v1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector2 v1 = *v1_ptr; + Vector2* v2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector2 v2 = *v2_ptr; + Vector2* v3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(v3_ptr == NULL) return JS_EXCEPTION; + Vector2 v3 = *v3_ptr; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + ImageDrawTriangle(dst, v1, v2, v3, color); + return JS_UNDEFINED; +} + +static JSValue js_imageDrawTriangleEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* v1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector2 v1 = *v1_ptr; + Vector2* v2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector2 v2 = *v2_ptr; + Vector2* v3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(v3_ptr == NULL) return JS_EXCEPTION; + Vector2 v3 = *v3_ptr; + Color* c1_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(c1_ptr == NULL) return JS_EXCEPTION; + Color c1 = *c1_ptr; + Color* c2_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(c2_ptr == NULL) return JS_EXCEPTION; + Color c2 = *c2_ptr; + Color* c3_ptr = (Color*)JS_GetOpaque2(ctx, argv[6], js_Color_class_id); + if(c3_ptr == NULL) return JS_EXCEPTION; + Color c3 = *c3_ptr; + ImageDrawTriangleEx(dst, v1, v2, v3, c1, c2, c3); + return JS_UNDEFINED; +} + +static JSValue js_imageDrawTriangleLines(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* v1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector2 v1 = *v1_ptr; + Vector2* v2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector2 v2 = *v2_ptr; + Vector2* v3_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(v3_ptr == NULL) return JS_EXCEPTION; + Vector2 v3 = *v3_ptr; + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + ImageDrawTriangleLines(dst, v1, v2, v3, color); + return JS_UNDEFINED; +} + +static JSValue js_imageDrawTriangleFan(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* points = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[2]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + ImageDrawTriangleFan(dst, points, pointCount, color); + return JS_UNDEFINED; +} + +static JSValue js_imageDrawTriangleStrip(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); + if(dst == NULL) return JS_EXCEPTION; + Vector2* points = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(points == NULL) return JS_EXCEPTION; + int pointCount; + JS_ToInt32(ctx, &pointCount, argv[2]); + Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(color_ptr == NULL) return JS_EXCEPTION; + Color color = *color_ptr; + ImageDrawTriangleStrip(dst, points, pointCount, color); + return JS_UNDEFINED; +} + static JSValue js_imageDraw(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); if(dst == NULL) return JS_EXCEPTION; @@ -5593,11 +6315,11 @@ static JSValue js_loadRenderTexture(JSContext * ctx, JSValueConst this_val, int return ret; } -static JSValue js_isTextureReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isTextureValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Texture2D* texture_ptr = (Texture2D*)JS_GetOpaque2(ctx, argv[0], js_Texture_class_id); if(texture_ptr == NULL) return JS_EXCEPTION; Texture2D texture = *texture_ptr; - bool returnVal = IsTextureReady(texture); + bool returnVal = IsTextureValid(texture); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -5610,11 +6332,11 @@ static JSValue js_unloadTexture(JSContext * ctx, JSValueConst this_val, int argc return JS_UNDEFINED; } -static JSValue js_isRenderTextureReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isRenderTextureValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { RenderTexture2D* target_ptr = (RenderTexture2D*)JS_GetOpaque2(ctx, argv[0], js_RenderTexture_class_id); if(target_ptr == NULL) return JS_EXCEPTION; RenderTexture2D target = *target_ptr; - bool returnVal = IsRenderTextureReady(target); + bool returnVal = IsRenderTextureValid(target); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -5801,6 +6523,18 @@ static JSValue js_drawTextureNPatch(JSContext * ctx, JSValueConst this_val, int return JS_UNDEFINED; } +static JSValue js_colorIsEqual(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Color* col1_ptr = (Color*)JS_GetOpaque2(ctx, argv[0], js_Color_class_id); + if(col1_ptr == NULL) return JS_EXCEPTION; + Color col1 = *col1_ptr; + Color* col2_ptr = (Color*)JS_GetOpaque2(ctx, argv[1], js_Color_class_id); + if(col2_ptr == NULL) return JS_EXCEPTION; + Color col2 = *col2_ptr; + bool returnVal = ColorIsEqual(col1, col2); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_fade(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[0], js_Color_class_id); if(color_ptr == NULL) return JS_EXCEPTION; @@ -5957,6 +6691,24 @@ static JSValue js_colorAlphaBlend(JSContext * ctx, JSValueConst this_val, int ar return ret; } +static JSValue js_colorLerp(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Color* color1_ptr = (Color*)JS_GetOpaque2(ctx, argv[0], js_Color_class_id); + if(color1_ptr == NULL) return JS_EXCEPTION; + Color color1 = *color1_ptr; + Color* color2_ptr = (Color*)JS_GetOpaque2(ctx, argv[1], js_Color_class_id); + if(color2_ptr == NULL) return JS_EXCEPTION; + Color color2 = *color2_ptr; + double _double_factor; + JS_ToFloat64(ctx, &_double_factor, argv[2]); + float factor = (float)_double_factor; + Color returnVal = ColorLerp(color1, color2, factor); + Color* ret_ptr = (Color*)js_malloc(ctx, sizeof(Color)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Color_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_getColor(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { unsigned int hexValue; JS_ToUint32(ctx, &hexValue, argv[0]); @@ -6030,11 +6782,11 @@ static JSValue js_loadFontFromImage(JSContext * ctx, JSValueConst this_val, int return ret; } -static JSValue js_isFontReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isFontValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); if(font_ptr == NULL) return JS_EXCEPTION; Font font = *font_ptr; - bool returnVal = IsFontReady(font); + bool returnVal = IsFontValid(font); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -6141,6 +6893,13 @@ static JSValue js_drawTextCodepoint(JSContext * ctx, JSValueConst this_val, int return JS_UNDEFINED; } +static JSValue js_setTextLineSpacing(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + int spacing; + JS_ToInt32(ctx, &spacing, argv[0]); + SetTextLineSpacing(spacing); + return JS_UNDEFINED; +} + static JSValue js_measureText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); int fontSize; @@ -6564,11 +7323,11 @@ static JSValue js_loadModelFromMesh(JSContext * ctx, JSValueConst this_val, int return ret; } -static JSValue js_isModelReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isModelValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Model* model_ptr = (Model*)JS_GetOpaque2(ctx, argv[0], js_Model_class_id); if(model_ptr == NULL) return JS_EXCEPTION; Model model = *model_ptr; - bool returnVal = IsModelReady(model); + bool returnVal = IsModelValid(model); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -6673,6 +7432,46 @@ static JSValue js_drawModelWiresEx(JSContext * ctx, JSValueConst this_val, int a return JS_UNDEFINED; } +static JSValue js_drawModelPoints(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Model* model_ptr = (Model*)JS_GetOpaque2(ctx, argv[0], js_Model_class_id); + if(model_ptr == NULL) return JS_EXCEPTION; + Model model = *model_ptr; + Vector3* position_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(position_ptr == NULL) return JS_EXCEPTION; + Vector3 position = *position_ptr; + double _double_scale; + JS_ToFloat64(ctx, &_double_scale, argv[2]); + float scale = (float)_double_scale; + Color* tint_ptr = (Color*)JS_GetOpaque2(ctx, argv[3], js_Color_class_id); + if(tint_ptr == NULL) return JS_EXCEPTION; + Color tint = *tint_ptr; + DrawModelPoints(model, position, scale, tint); + return JS_UNDEFINED; +} + +static JSValue js_drawModelPointsEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Model* model_ptr = (Model*)JS_GetOpaque2(ctx, argv[0], js_Model_class_id); + if(model_ptr == NULL) return JS_EXCEPTION; + Model model = *model_ptr; + Vector3* position_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(position_ptr == NULL) return JS_EXCEPTION; + Vector3 position = *position_ptr; + Vector3* rotationAxis_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[2], js_Vector3_class_id); + if(rotationAxis_ptr == NULL) return JS_EXCEPTION; + Vector3 rotationAxis = *rotationAxis_ptr; + double _double_rotationAngle; + JS_ToFloat64(ctx, &_double_rotationAngle, argv[3]); + float rotationAngle = (float)_double_rotationAngle; + Vector3* scale_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[4], js_Vector3_class_id); + if(scale_ptr == NULL) return JS_EXCEPTION; + Vector3 scale = *scale_ptr; + Color* tint_ptr = (Color*)JS_GetOpaque2(ctx, argv[5], js_Color_class_id); + if(tint_ptr == NULL) return JS_EXCEPTION; + Color tint = *tint_ptr; + DrawModelPointsEx(model, position, rotationAxis, rotationAngle, scale, tint); + return JS_UNDEFINED; +} + static JSValue js_drawBoundingBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { BoundingBox* box_ptr = (BoundingBox*)JS_GetOpaque2(ctx, argv[0], js_BoundingBox_class_id); if(box_ptr == NULL) return JS_EXCEPTION; @@ -6694,13 +7493,13 @@ static JSValue js_drawBillboard(JSContext * ctx, JSValueConst this_val, int argc Vector3* position_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[2], js_Vector3_class_id); if(position_ptr == NULL) return JS_EXCEPTION; Vector3 position = *position_ptr; - double _double_size; - JS_ToFloat64(ctx, &_double_size, argv[3]); - float size = (float)_double_size; + double _double_scale; + JS_ToFloat64(ctx, &_double_scale, argv[3]); + float scale = (float)_double_scale; Color* tint_ptr = (Color*)JS_GetOpaque2(ctx, argv[4], js_Color_class_id); if(tint_ptr == NULL) return JS_EXCEPTION; Color tint = *tint_ptr; - DrawBillboard(camera, texture, position, size, tint); + DrawBillboard(camera, texture, position, scale, tint); return JS_UNDEFINED; } @@ -6826,17 +7625,6 @@ static JSValue js_drawMeshInstanced(JSContext * ctx, JSValueConst this_val, int return JS_UNDEFINED; } -static JSValue js_exportMesh(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id); - if(mesh_ptr == NULL) return JS_EXCEPTION; - Mesh mesh = *mesh_ptr; - const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool returnVal = ExportMesh(mesh, fileName); - JS_FreeCString(ctx, fileName); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - static JSValue js_getMeshBoundingBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id); if(mesh_ptr == NULL) return JS_EXCEPTION; @@ -6856,6 +7644,28 @@ static JSValue js_genMeshTangents(JSContext * ctx, JSValueConst this_val, int ar return JS_UNDEFINED; } +static JSValue js_exportMesh(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id); + if(mesh_ptr == NULL) return JS_EXCEPTION; + Mesh mesh = *mesh_ptr; + const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = ExportMesh(mesh, fileName); + JS_FreeCString(ctx, fileName); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + +static JSValue js_exportMeshAsCode(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id); + if(mesh_ptr == NULL) return JS_EXCEPTION; + Mesh mesh = *mesh_ptr; + const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + bool returnVal = ExportMeshAsCode(mesh, fileName); + JS_FreeCString(ctx, fileName); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_genMeshPoly(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int sides; JS_ToInt32(ctx, &sides, argv[0]); @@ -7050,11 +7860,11 @@ static JSValue js_loadMaterialDefault(JSContext * ctx, JSValueConst this_val, in return ret; } -static JSValue js_isMaterialReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isMaterialValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Material* material_ptr = (Material*)JS_GetOpaque2(ctx, argv[0], js_Material_class_id); if(material_ptr == NULL) return JS_EXCEPTION; Material material = *material_ptr; - bool returnVal = IsMaterialReady(material); + bool returnVal = IsMaterialValid(material); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -7090,6 +7900,19 @@ static JSValue js_setModelMeshMaterial(JSContext * ctx, JSValueConst this_val, i return JS_UNDEFINED; } +static JSValue js_updateModelAnimationBones(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Model* model_ptr = (Model*)JS_GetOpaque2(ctx, argv[0], js_Model_class_id); + if(model_ptr == NULL) return JS_EXCEPTION; + Model model = *model_ptr; + ModelAnimation* anim_ptr = (ModelAnimation*)JS_GetOpaque2(ctx, argv[1], js_ModelAnimation_class_id); + if(anim_ptr == NULL) return JS_EXCEPTION; + ModelAnimation anim = *anim_ptr; + int frame; + JS_ToInt32(ctx, &frame, argv[2]); + UpdateModelAnimationBones(model, anim, frame); + return JS_UNDEFINED; +} + static JSValue js_checkCollisionSpheres(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* center1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(center1_ptr == NULL) return JS_EXCEPTION; @@ -7255,6 +8078,12 @@ static JSValue js_setMasterVolume(JSContext * ctx, JSValueConst this_val, int ar return JS_UNDEFINED; } +static JSValue js_getMasterVolume(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + float returnVal = GetMasterVolume(); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + static JSValue js_loadWave(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); Wave returnVal = LoadWave(fileName); @@ -7287,11 +8116,11 @@ static JSValue js_loadWaveFromMemory(JSContext * ctx, JSValueConst this_val, int return ret; } -static JSValue js_isWaveReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isWaveValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Wave* wave_ptr = (Wave*)JS_GetOpaque2(ctx, argv[0], js_Wave_class_id); if(wave_ptr == NULL) return JS_EXCEPTION; Wave wave = *wave_ptr; - bool returnVal = IsWaveReady(wave); + bool returnVal = IsWaveValid(wave); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -7319,11 +8148,23 @@ static JSValue js_loadSoundFromWave(JSContext * ctx, JSValueConst this_val, int return ret; } -static JSValue js_isSoundReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_loadSoundAlias(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Sound* source_ptr = (Sound*)JS_GetOpaque2(ctx, argv[0], js_Sound_class_id); + if(source_ptr == NULL) return JS_EXCEPTION; + Sound source = *source_ptr; + Sound returnVal = LoadSoundAlias(source); + Sound* ret_ptr = (Sound*)js_malloc(ctx, sizeof(Sound)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Sound_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_isSoundValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Sound* sound_ptr = (Sound*)JS_GetOpaque2(ctx, argv[0], js_Sound_class_id); if(sound_ptr == NULL) return JS_EXCEPTION; Sound sound = *sound_ptr; - bool returnVal = IsSoundReady(sound); + bool returnVal = IsSoundValid(sound); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -7362,6 +8203,14 @@ static JSValue js_unloadSound(JSContext * ctx, JSValueConst this_val, int argc, return JS_UNDEFINED; } +static JSValue js_unloadSoundAlias(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Sound* alias_ptr = (Sound*)JS_GetOpaque2(ctx, argv[0], js_Sound_class_id); + if(alias_ptr == NULL) return JS_EXCEPTION; + Sound alias = *alias_ptr; + UnloadSoundAlias(alias); + return JS_UNDEFINED; +} + static JSValue js_exportWave(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Wave* wave_ptr = (Wave*)JS_GetOpaque2(ctx, argv[0], js_Wave_class_id); if(wave_ptr == NULL) return JS_EXCEPTION; @@ -7462,11 +8311,11 @@ static JSValue js_waveCopy(JSContext * ctx, JSValueConst this_val, int argc, JSV static JSValue js_waveCrop(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Wave* wave = (Wave*)JS_GetOpaque2(ctx, argv[0], js_Wave_class_id); if(wave == NULL) return JS_EXCEPTION; - int initSample; - JS_ToInt32(ctx, &initSample, argv[1]); - int finalSample; - JS_ToInt32(ctx, &finalSample, argv[2]); - WaveCrop(wave, initSample, finalSample); + int initFrame; + JS_ToInt32(ctx, &initFrame, argv[1]); + int finalFrame; + JS_ToInt32(ctx, &finalFrame, argv[2]); + WaveCrop(wave, initFrame, finalFrame); return JS_UNDEFINED; } @@ -7494,11 +8343,11 @@ static JSValue js_loadMusicStream(JSContext * ctx, JSValueConst this_val, int ar return ret; } -static JSValue js_isMusicReady(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_isMusicValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Music* music_ptr = (Music*)JS_GetOpaque2(ctx, argv[0], js_Music_class_id); if(music_ptr == NULL) return JS_EXCEPTION; Music music = *music_ptr; - bool returnVal = IsMusicReady(music); + bool returnVal = IsMusicValid(music); JSValue ret = JS_NewBool(ctx, returnVal); return ret; } @@ -7622,6 +8471,15 @@ static JSValue js_getMusicTimePlayed(JSContext * ctx, JSValueConst this_val, int return ret; } +static JSValue js_isAudioStreamValid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + AudioStream* stream_ptr = (AudioStream*)JS_GetOpaque2(ctx, argv[0], js_AudioStream_class_id); + if(stream_ptr == NULL) return JS_EXCEPTION; + AudioStream stream = *stream_ptr; + bool returnVal = IsAudioStreamValid(stream); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_clamp(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { double _double_value; JS_ToFloat64(ctx, &_double_value, argv[0]); @@ -7988,6 +8846,36 @@ static JSValue js_vector2Reflect(JSContext * ctx, JSValueConst this_val, int arg return ret; } +static JSValue js_vector2Min(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* v1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector2 v1 = *v1_ptr; + Vector2* v2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector2 v2 = *v2_ptr; + Vector2 returnVal = Vector2Min(v1, v2); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector2Max(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* v1_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector2 v1 = *v1_ptr; + Vector2* v2_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector2 v2 = *v2_ptr; + Vector2 returnVal = Vector2Max(v1, v2); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_vector2Rotate(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector2* v_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); if(v_ptr == NULL) return JS_EXCEPTION; @@ -8081,6 +8969,24 @@ static JSValue js_vector2Equals(JSContext * ctx, JSValueConst this_val, int argc return ret; } +static JSValue js_vector2Refract(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector2* v_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[0], js_Vector2_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector2 v = *v_ptr; + Vector2* n_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[1], js_Vector2_class_id); + if(n_ptr == NULL) return JS_EXCEPTION; + Vector2 n = *n_ptr; + double _double_r; + JS_ToFloat64(ctx, &_double_r, argv[2]); + float r = (float)_double_r; + Vector2 returnVal = Vector2Refract(v, n, r); + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_vector3Zero(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3 returnVal = Vector3Zero(); Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); @@ -8321,6 +9227,45 @@ static JSValue js_vector3Normalize(JSContext * ctx, JSValueConst this_val, int a return ret; } +static JSValue js_vector3Project(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector3* v1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector3 v1 = *v1_ptr; + Vector3* v2_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector3 v2 = *v2_ptr; + Vector3 returnVal = Vector3Project(v1, v2); + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector3Reject(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector3* v1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector3 v1 = *v1_ptr; + Vector3* v2_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector3 v2 = *v2_ptr; + Vector3 returnVal = Vector3Reject(v1, v2); + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector3OrthoNormalize(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector3* v1 = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); + if(v1 == NULL) return JS_EXCEPTION; + Vector3* v2 = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(v2 == NULL) return JS_EXCEPTION; + Vector3OrthoNormalize(v1, v2); + return JS_UNDEFINED; +} + static JSValue js_vector3Transform(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* v_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(v_ptr == NULL) return JS_EXCEPTION; @@ -8369,6 +9314,24 @@ static JSValue js_vector3RotateByAxisAngle(JSContext * ctx, JSValueConst this_va return ret; } +static JSValue js_vector3MoveTowards(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector3* v_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector3 v = *v_ptr; + Vector3* target_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(target_ptr == NULL) return JS_EXCEPTION; + Vector3 target = *target_ptr; + double _double_maxDistance; + JS_ToFloat64(ctx, &_double_maxDistance, argv[2]); + float maxDistance = (float)_double_maxDistance; + Vector3 returnVal = Vector3MoveTowards(v, target, maxDistance); + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_vector3Lerp(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* v1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(v1_ptr == NULL) return JS_EXCEPTION; @@ -8387,6 +9350,30 @@ static JSValue js_vector3Lerp(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_vector3CubicHermite(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector3* v1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector3 v1 = *v1_ptr; + Vector3* tangent1_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(tangent1_ptr == NULL) return JS_EXCEPTION; + Vector3 tangent1 = *tangent1_ptr; + Vector3* v2_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[2], js_Vector3_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector3 v2 = *v2_ptr; + Vector3* tangent2_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[3], js_Vector3_class_id); + if(tangent2_ptr == NULL) return JS_EXCEPTION; + Vector3 tangent2 = *tangent2_ptr; + double _double_amount; + JS_ToFloat64(ctx, &_double_amount, argv[4]); + float amount = (float)_double_amount; + Vector3 returnVal = Vector3CubicHermite(v1, tangent1, v2, tangent2, amount); + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_vector3Reflect(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* v_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(v_ptr == NULL) return JS_EXCEPTION; @@ -8549,6 +9536,174 @@ static JSValue js_vector3Refract(JSContext * ctx, JSValueConst this_val, int arg return ret; } +static JSValue js_vector4Distance(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + float returnVal = Vector4Distance(v1, v2); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_vector4DistanceSqr(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + float returnVal = Vector4DistanceSqr(v1, v2); + JSValue ret = JS_NewFloat64(ctx, returnVal); + return ret; +} + +static JSValue js_vector4Multiply(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + Vector4 returnVal = Vector4Multiply(v1, v2); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Negate(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector4 v = *v_ptr; + Vector4 returnVal = Vector4Negate(v); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Divide(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + Vector4 returnVal = Vector4Divide(v1, v2); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Normalize(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector4 v = *v_ptr; + Vector4 returnVal = Vector4Normalize(v); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Min(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + Vector4 returnVal = Vector4Min(v1, v2); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Max(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + Vector4 returnVal = Vector4Max(v1, v2); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Lerp(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v1_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v1_ptr == NULL) return JS_EXCEPTION; + Vector4 v1 = *v1_ptr; + Vector4* v2_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(v2_ptr == NULL) return JS_EXCEPTION; + Vector4 v2 = *v2_ptr; + double _double_amount; + JS_ToFloat64(ctx, &_double_amount, argv[2]); + float amount = (float)_double_amount; + Vector4 returnVal = Vector4Lerp(v1, v2, amount); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4MoveTowards(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector4 v = *v_ptr; + Vector4* target_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(target_ptr == NULL) return JS_EXCEPTION; + Vector4 target = *target_ptr; + double _double_maxDistance; + JS_ToFloat64(ctx, &_double_maxDistance, argv[2]); + float maxDistance = (float)_double_maxDistance; + Vector4 returnVal = Vector4MoveTowards(v, target, maxDistance); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Invert(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* v_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(v_ptr == NULL) return JS_EXCEPTION; + Vector4 v = *v_ptr; + Vector4 returnVal = Vector4Invert(v); + Vector4* ret_ptr = (Vector4*)js_malloc(ctx, sizeof(Vector4)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_vector4Equals(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Vector4* p_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(p_ptr == NULL) return JS_EXCEPTION; + Vector4 p = *p_ptr; + Vector4* q_ptr = (Vector4*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(q_ptr == NULL) return JS_EXCEPTION; + Vector4 q = *q_ptr; + int returnVal = Vector4Equals(p, q); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + static JSValue js_matrixDeterminant(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Matrix* mat_ptr = (Matrix*)JS_GetOpaque2(ctx, argv[0], js_Matrix_class_id); if(mat_ptr == NULL) return JS_EXCEPTION; @@ -8765,11 +9920,11 @@ static JSValue js_matrixFrustum(JSContext * ctx, JSValueConst this_val, int argc JS_ToFloat64(ctx, &bottom, argv[2]); double top; JS_ToFloat64(ctx, &top, argv[3]); - double near; - JS_ToFloat64(ctx, &near, argv[4]); - double far; - JS_ToFloat64(ctx, &far, argv[5]); - Matrix returnVal = MatrixFrustum(left, right, bottom, top, near, far); + double nearPlane; + JS_ToFloat64(ctx, &nearPlane, argv[4]); + double farPlane; + JS_ToFloat64(ctx, &farPlane, argv[5]); + Matrix returnVal = MatrixFrustum(left, right, bottom, top, nearPlane, farPlane); Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); *ret_ptr = returnVal; JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); @@ -9034,6 +10189,30 @@ static JSValue js_quaternionSlerp(JSContext * ctx, JSValueConst this_val, int ar return ret; } +static JSValue js_quaternionCubicHermiteSpline(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Quaternion* q1_ptr = (Quaternion*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(q1_ptr == NULL) return JS_EXCEPTION; + Quaternion q1 = *q1_ptr; + Quaternion* outTangent1_ptr = (Quaternion*)JS_GetOpaque2(ctx, argv[1], js_Vector4_class_id); + if(outTangent1_ptr == NULL) return JS_EXCEPTION; + Quaternion outTangent1 = *outTangent1_ptr; + Quaternion* q2_ptr = (Quaternion*)JS_GetOpaque2(ctx, argv[2], js_Vector4_class_id); + if(q2_ptr == NULL) return JS_EXCEPTION; + Quaternion q2 = *q2_ptr; + Quaternion* inTangent2_ptr = (Quaternion*)JS_GetOpaque2(ctx, argv[3], js_Vector4_class_id); + if(inTangent2_ptr == NULL) return JS_EXCEPTION; + Quaternion inTangent2 = *inTangent2_ptr; + double _double_t; + JS_ToFloat64(ctx, &_double_t, argv[4]); + float t = (float)_double_t; + Quaternion returnVal = QuaternionCubicHermiteSpline(q1, outTangent1, q2, inTangent2, t); + Quaternion* ret_ptr = (Quaternion*)js_malloc(ctx, sizeof(Quaternion)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector4_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_quaternionFromVector3ToVector3(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Vector3* from_ptr = (Vector3*)JS_GetOpaque2(ctx, argv[0], js_Vector3_class_id); if(from_ptr == NULL) return JS_EXCEPTION; @@ -9088,6 +10267,24 @@ static JSValue js_quaternionFromAxisAngle(JSContext * ctx, JSValueConst this_val return ret; } +static JSValue js_quaternionToAxisAngle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Quaternion* q_ptr = (Quaternion*)JS_GetOpaque2(ctx, argv[0], js_Vector4_class_id); + if(q_ptr == NULL) return JS_EXCEPTION; + Quaternion q = *q_ptr; + Vector3* outAxis = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(outAxis == NULL) return JS_EXCEPTION; + size_t outAngle_size; + void * outAngle_js = (void *)JS_GetArrayBuffer(ctx, &outAngle_size, argv[2]); + if(outAngle_js == NULL) { + return JS_EXCEPTION; + } + float * outAngle = malloc(outAngle_size); + memcpy((void *)outAngle, (const void *)outAngle_js, outAngle_size); + QuaternionToAxisAngle(q, outAxis, outAngle); + free((void *)outAngle); + return JS_UNDEFINED; +} + static JSValue js_quaternionFromEuler(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { double _double_pitch; JS_ToFloat64(ctx, &_double_pitch, argv[0]); @@ -9145,6 +10342,20 @@ static JSValue js_quaternionEquals(JSContext * ctx, JSValueConst this_val, int a return ret; } +static JSValue js_matrixDecompose(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Matrix* mat_ptr = (Matrix*)JS_GetOpaque2(ctx, argv[0], js_Matrix_class_id); + if(mat_ptr == NULL) return JS_EXCEPTION; + Matrix mat = *mat_ptr; + Vector3* translation = (Vector3*)JS_GetOpaque2(ctx, argv[1], js_Vector3_class_id); + if(translation == NULL) return JS_EXCEPTION; + Quaternion* rotation = (Quaternion*)JS_GetOpaque2(ctx, argv[2], js_Vector4_class_id); + if(rotation == NULL) return JS_EXCEPTION; + Vector3* scale = (Vector3*)JS_GetOpaque2(ctx, argv[3], js_Vector3_class_id); + if(scale == NULL) return JS_EXCEPTION; + MatrixDecompose(mat, translation, rotation, scale); + return JS_UNDEFINED; +} + static JSValue js_getCameraForward(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Camera* camera = (Camera*)JS_GetOpaque2(ctx, argv[0], js_Camera3D_class_id); if(camera == NULL) return JS_EXCEPTION; @@ -9305,11 +10516,11 @@ static JSValue js_guiIsLocked(JSContext * ctx, JSValueConst this_val, int argc, return ret; } -static JSValue js_guiFade(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { +static JSValue js_guiSetAlpha(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { double _double_alpha; JS_ToFloat64(ctx, &_double_alpha, argv[0]); float alpha = (float)_double_alpha; - GuiFade(alpha); + GuiSetAlpha(alpha); return JS_UNDEFINED; } @@ -9364,480 +10575,6 @@ static JSValue js_guiGetStyle(JSContext * ctx, JSValueConst this_val, int argc, return ret; } -static JSValue js_guiWindowBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool returnVal = GuiWindowBox(bounds, title); - JS_FreeCString(ctx, title); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiGroupBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiGroupBox(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiLine(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiLine(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiPanel(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiScrollPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - Rectangle* content_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[2], js_Rectangle_class_id); - if(content_ptr == NULL) return JS_EXCEPTION; - Rectangle content = *content_ptr; - Vector2* scroll = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); - if(scroll == NULL) return JS_EXCEPTION; - Rectangle returnVal = GuiScrollPanel(bounds, text, content, scroll); - JS_FreeCString(ctx, text); - Rectangle* ret_ptr = (Rectangle*)js_malloc(ctx, sizeof(Rectangle)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Rectangle_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - -static JSValue js_guiLabel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiLabel(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool returnVal = GuiButton(bounds, text); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiLabelButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool returnVal = GuiLabelButton(bounds, text); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiToggle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool active = JS_ToBool(ctx, argv[2]); - bool returnVal = GuiToggle(bounds, text, active); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiToggleGroup(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int active; - JS_ToInt32(ctx, &active, argv[2]); - int returnVal = GuiToggleGroup(bounds, text, active); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - -static JSValue js_guiCheckBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - bool checked = JS_ToBool(ctx, argv[2]); - bool returnVal = GuiCheckBox(bounds, text, checked); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiComboBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int active; - JS_ToInt32(ctx, &active, argv[2]); - int returnVal = GuiComboBox(bounds, text, active); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - -static JSValue js_guiDropdownBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int * active = NULL; - int active_out; - if(!JS_IsNull(argv[2])) { - active = &active_out; - JSValue active_js = JS_GetPropertyStr(ctx, argv[2], "active"); - JS_ToInt32(ctx, active, active_js); - } - bool editMode = JS_ToBool(ctx, argv[3]); - bool returnVal = GuiDropdownBox(bounds, text, active, editMode); - JS_FreeCString(ctx, text); - if(!JS_IsNull(argv[2])) { - JS_SetPropertyStr(ctx, argv[2], "active", JS_NewInt32(ctx,active_out)); - } - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiSpinner(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int * value = NULL; - int value_out; - if(!JS_IsNull(argv[2])) { - value = &value_out; - JSValue value_js = JS_GetPropertyStr(ctx, argv[2], "value"); - JS_ToInt32(ctx, value, value_js); - } - int minValue; - JS_ToInt32(ctx, &minValue, argv[3]); - int maxValue; - JS_ToInt32(ctx, &maxValue, argv[4]); - bool editMode = JS_ToBool(ctx, argv[5]); - bool returnVal = GuiSpinner(bounds, text, value, minValue, maxValue, editMode); - JS_FreeCString(ctx, text); - if(!JS_IsNull(argv[2])) { - JS_SetPropertyStr(ctx, argv[2], "value", JS_NewInt32(ctx,value_out)); - } - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiValueBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int * value = NULL; - int value_out; - if(!JS_IsNull(argv[2])) { - value = &value_out; - JSValue value_js = JS_GetPropertyStr(ctx, argv[2], "value"); - JS_ToInt32(ctx, value, value_js); - } - int minValue; - JS_ToInt32(ctx, &minValue, argv[3]); - int maxValue; - JS_ToInt32(ctx, &maxValue, argv[4]); - bool editMode = JS_ToBool(ctx, argv[5]); - bool returnVal = GuiValueBox(bounds, text, value, minValue, maxValue, editMode); - JS_FreeCString(ctx, text); - if(!JS_IsNull(argv[2])) { - JS_SetPropertyStr(ctx, argv[2], "value", JS_NewInt32(ctx,value_out)); - } - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiTextBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - JSValue text_js = JS_GetPropertyStr(ctx, argv[1], "text"); - size_t text_len; - const char * text_val = JS_ToCStringLen(ctx, &text_len, text_js); - memcpy((void *)textbuffer, text_val, text_len); - textbuffer[text_len] = 0; - char * text = textbuffer; - int textSize = 4096; - bool editMode = JS_ToBool(ctx, argv[2]); - bool returnVal = GuiTextBox(bounds, text, textSize, editMode); - JS_FreeCString(ctx, text_val); - JS_SetPropertyStr(ctx, argv[1], "text", JS_NewString(ctx,text)); - JSValue ret = JS_NewBool(ctx, returnVal); - return ret; -} - -static JSValue js_guiSlider(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); - double _double_value; - JS_ToFloat64(ctx, &_double_value, argv[3]); - float value = (float)_double_value; - double _double_minValue; - JS_ToFloat64(ctx, &_double_minValue, argv[4]); - float minValue = (float)_double_minValue; - double _double_maxValue; - JS_ToFloat64(ctx, &_double_maxValue, argv[5]); - float maxValue = (float)_double_maxValue; - float returnVal = GuiSlider(bounds, textLeft, textRight, value, minValue, maxValue); - JS_FreeCString(ctx, textLeft); - JS_FreeCString(ctx, textRight); - JSValue ret = JS_NewFloat64(ctx, returnVal); - return ret; -} - -static JSValue js_guiSliderBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); - double _double_value; - JS_ToFloat64(ctx, &_double_value, argv[3]); - float value = (float)_double_value; - double _double_minValue; - JS_ToFloat64(ctx, &_double_minValue, argv[4]); - float minValue = (float)_double_minValue; - double _double_maxValue; - JS_ToFloat64(ctx, &_double_maxValue, argv[5]); - float maxValue = (float)_double_maxValue; - float returnVal = GuiSliderBar(bounds, textLeft, textRight, value, minValue, maxValue); - JS_FreeCString(ctx, textLeft); - JS_FreeCString(ctx, textRight); - JSValue ret = JS_NewFloat64(ctx, returnVal); - return ret; -} - -static JSValue js_guiProgressBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); - double _double_value; - JS_ToFloat64(ctx, &_double_value, argv[3]); - float value = (float)_double_value; - double _double_minValue; - JS_ToFloat64(ctx, &_double_minValue, argv[4]); - float minValue = (float)_double_minValue; - double _double_maxValue; - JS_ToFloat64(ctx, &_double_maxValue, argv[5]); - float maxValue = (float)_double_maxValue; - float returnVal = GuiProgressBar(bounds, textLeft, textRight, value, minValue, maxValue); - JS_FreeCString(ctx, textLeft); - JS_FreeCString(ctx, textRight); - JSValue ret = JS_NewFloat64(ctx, returnVal); - return ret; -} - -static JSValue js_guiStatusBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiStatusBar(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiDummyRec(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - GuiDummyRec(bounds, text); - JS_FreeCString(ctx, text); - return JS_UNDEFINED; -} - -static JSValue js_guiGrid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - double _double_spacing; - JS_ToFloat64(ctx, &_double_spacing, argv[2]); - float spacing = (float)_double_spacing; - int subdivs; - JS_ToInt32(ctx, &subdivs, argv[3]); - Vector2 returnVal = GuiGrid(bounds, text, spacing, subdivs); - JS_FreeCString(ctx, text); - Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - -static JSValue js_guiListView(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - int * scrollIndex = NULL; - int scrollIndex_out; - if(!JS_IsNull(argv[2])) { - scrollIndex = &scrollIndex_out; - JSValue scrollIndex_js = JS_GetPropertyStr(ctx, argv[2], "scrollIndex"); - JS_ToInt32(ctx, scrollIndex, scrollIndex_js); - } - int active; - JS_ToInt32(ctx, &active, argv[3]); - int returnVal = GuiListView(bounds, text, scrollIndex, active); - JS_FreeCString(ctx, text); - if(!JS_IsNull(argv[2])) { - JS_SetPropertyStr(ctx, argv[2], "scrollIndex", JS_NewInt32(ctx,scrollIndex_out)); - } - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - -static JSValue js_guiMessageBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); - const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); - int returnVal = GuiMessageBox(bounds, title, message, buttons); - JS_FreeCString(ctx, title); - JS_FreeCString(ctx, message); - JS_FreeCString(ctx, buttons); - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - -static JSValue js_guiTextInputBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); - const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); - JSValue text_js = JS_GetPropertyStr(ctx, argv[4], "text"); - size_t text_len; - const char * text_val = JS_ToCStringLen(ctx, &text_len, text_js); - memcpy((void *)textbuffer, text_val, text_len); - textbuffer[text_len] = 0; - char * text = textbuffer; - int textMaxSize = 4096; - int * secretViewActive = NULL; - int secretViewActive_out; - if(!JS_IsNull(argv[5])) { - secretViewActive = &secretViewActive_out; - JSValue secretViewActive_js = JS_GetPropertyStr(ctx, argv[5], "secretViewActive"); - JS_ToInt32(ctx, secretViewActive, secretViewActive_js); - } - int returnVal = GuiTextInputBox(bounds, title, message, buttons, text, textMaxSize, secretViewActive); - JS_FreeCString(ctx, title); - JS_FreeCString(ctx, message); - JS_FreeCString(ctx, buttons); - JS_FreeCString(ctx, text_val); - JS_SetPropertyStr(ctx, argv[4], "text", JS_NewString(ctx,text)); - if(!JS_IsNull(argv[5])) { - JS_SetPropertyStr(ctx, argv[5], "secretViewActive", JS_NewInt32(ctx,secretViewActive_out)); - } - JSValue ret = JS_NewInt32(ctx, returnVal); - return ret; -} - -static JSValue js_guiColorPicker(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); - if(color_ptr == NULL) return JS_EXCEPTION; - Color color = *color_ptr; - Color returnVal = GuiColorPicker(bounds, text, color); - JS_FreeCString(ctx, text); - Color* ret_ptr = (Color*)js_malloc(ctx, sizeof(Color)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Color_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - -static JSValue js_guiColorPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); - if(color_ptr == NULL) return JS_EXCEPTION; - Color color = *color_ptr; - Color returnVal = GuiColorPanel(bounds, text, color); - JS_FreeCString(ctx, text); - Color* ret_ptr = (Color*)js_malloc(ctx, sizeof(Color)); - *ret_ptr = returnVal; - JSValue ret = JS_NewObjectClass(ctx, js_Color_class_id); - JS_SetOpaque(ret, ret_ptr); - return ret; -} - -static JSValue js_guiColorBarAlpha(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - double _double_alpha; - JS_ToFloat64(ctx, &_double_alpha, argv[2]); - float alpha = (float)_double_alpha; - float returnVal = GuiColorBarAlpha(bounds, text, alpha); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewFloat64(ctx, returnVal); - return ret; -} - -static JSValue js_guiColorBarHue(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { - Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); - if(bounds_ptr == NULL) return JS_EXCEPTION; - Rectangle bounds = *bounds_ptr; - const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); - double _double_value; - JS_ToFloat64(ctx, &_double_value, argv[2]); - float value = (float)_double_value; - float returnVal = GuiColorBarHue(bounds, text, value); - JS_FreeCString(ctx, text); - JSValue ret = JS_NewFloat64(ctx, returnVal); - return ret; -} - static JSValue js_guiLoadStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); GuiLoadStyle(fileName); @@ -9900,6 +10637,536 @@ static JSValue js_guiDrawIcon(JSContext * ctx, JSValueConst this_val, int argc, return JS_UNDEFINED; } +static JSValue js_guiWindowBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiWindowBox(bounds, title); + JS_FreeCString(ctx, title); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiGroupBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiGroupBox(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiLine(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiLine(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiPanel(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiScrollPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + Rectangle* content_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[2], js_Rectangle_class_id); + if(content_ptr == NULL) return JS_EXCEPTION; + Rectangle content = *content_ptr; + Vector2* scroll = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); + if(scroll == NULL) return JS_EXCEPTION; + Rectangle* view = (Rectangle*)JS_GetOpaque2(ctx, argv[4], js_Rectangle_class_id); + if(view == NULL) return JS_EXCEPTION; + int returnVal = GuiScrollPanel(bounds, text, content, scroll, view); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiLabel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiLabel(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiButton(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiLabelButton(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiLabelButton(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiToggle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + bool active_val; + active_val = JS_ToBool(ctx, argv[2]); + bool * active = &active_val; + int returnVal = GuiToggle(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiToggleGroup(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int active_int; + JS_ToInt32(ctx, &active_int, argv[2]); + int * active = &active_int; + int returnVal = GuiToggleGroup(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiToggleSlider(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int active_int; + JS_ToInt32(ctx, &active_int, argv[2]); + int * active = &active_int; + int returnVal = GuiToggleSlider(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiCheckBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + bool checked_val; + checked_val = JS_ToBool(ctx, argv[2]); + bool * checked = &checked_val; + int returnVal = GuiCheckBox(bounds, text, checked); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiComboBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int active_int; + JS_ToInt32(ctx, &active_int, argv[2]); + int * active = &active_int; + int returnVal = GuiComboBox(bounds, text, active); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiDropdownBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int * active = NULL; + int active_out; + if(!JS_IsNull(argv[2])) { + active = &active_out; + JSValue active_js = JS_GetPropertyStr(ctx, argv[2], "active"); + JS_ToInt32(ctx, active, active_js); + } + bool editMode = JS_ToBool(ctx, argv[3]); + int returnVal = GuiDropdownBox(bounds, text, active, editMode); + JS_FreeCString(ctx, text); + if(!JS_IsNull(argv[2])) { + JS_SetPropertyStr(ctx, argv[2], "active", JS_NewInt32(ctx,active_out)); + } + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiSpinner(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int * value = NULL; + int value_out; + if(!JS_IsNull(argv[2])) { + value = &value_out; + JSValue value_js = JS_GetPropertyStr(ctx, argv[2], "value"); + JS_ToInt32(ctx, value, value_js); + } + int minValue; + JS_ToInt32(ctx, &minValue, argv[3]); + int maxValue; + JS_ToInt32(ctx, &maxValue, argv[4]); + bool editMode = JS_ToBool(ctx, argv[5]); + int returnVal = GuiSpinner(bounds, text, value, minValue, maxValue, editMode); + JS_FreeCString(ctx, text); + if(!JS_IsNull(argv[2])) { + JS_SetPropertyStr(ctx, argv[2], "value", JS_NewInt32(ctx,value_out)); + } + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiValueBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int * value = NULL; + int value_out; + if(!JS_IsNull(argv[2])) { + value = &value_out; + JSValue value_js = JS_GetPropertyStr(ctx, argv[2], "value"); + JS_ToInt32(ctx, value, value_js); + } + int minValue; + JS_ToInt32(ctx, &minValue, argv[3]); + int maxValue; + JS_ToInt32(ctx, &maxValue, argv[4]); + bool editMode = JS_ToBool(ctx, argv[5]); + int returnVal = GuiValueBox(bounds, text, value, minValue, maxValue, editMode); + JS_FreeCString(ctx, text); + if(!JS_IsNull(argv[2])) { + JS_SetPropertyStr(ctx, argv[2], "value", JS_NewInt32(ctx,value_out)); + } + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiTextBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + JSValue text_js = JS_GetPropertyStr(ctx, argv[1], "text"); + size_t text_len; + const char * text_val = JS_ToCStringLen(ctx, &text_len, text_js); + memcpy((void *)textbuffer, text_val, text_len); + textbuffer[text_len] = 0; + char * text = textbuffer; + int textSize = 4096; + bool editMode = JS_ToBool(ctx, argv[2]); + int returnVal = GuiTextBox(bounds, text, textSize, editMode); + JS_FreeCString(ctx, text_val); + JS_SetPropertyStr(ctx, argv[1], "text", JS_NewString(ctx,text)); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiSlider(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); + size_t value_size; + void * value_js = (void *)JS_GetArrayBuffer(ctx, &value_size, argv[3]); + if(value_js == NULL) { + return JS_EXCEPTION; + } + float * value = malloc(value_size); + memcpy((void *)value, (const void *)value_js, value_size); + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + int returnVal = GuiSlider(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + free((void *)value); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiSliderBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); + size_t value_size; + void * value_js = (void *)JS_GetArrayBuffer(ctx, &value_size, argv[3]); + if(value_js == NULL) { + return JS_EXCEPTION; + } + float * value = malloc(value_size); + memcpy((void *)value, (const void *)value_js, value_size); + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + int returnVal = GuiSliderBar(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + free((void *)value); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiProgressBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); + size_t value_size; + void * value_js = (void *)JS_GetArrayBuffer(ctx, &value_size, argv[3]); + if(value_js == NULL) { + return JS_EXCEPTION; + } + float * value = malloc(value_size); + memcpy((void *)value, (const void *)value_js, value_size); + double _double_minValue; + JS_ToFloat64(ctx, &_double_minValue, argv[4]); + float minValue = (float)_double_minValue; + double _double_maxValue; + JS_ToFloat64(ctx, &_double_maxValue, argv[5]); + float maxValue = (float)_double_maxValue; + int returnVal = GuiProgressBar(bounds, textLeft, textRight, value, minValue, maxValue); + JS_FreeCString(ctx, textLeft); + JS_FreeCString(ctx, textRight); + free((void *)value); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiStatusBar(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiStatusBar(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiDummyRec(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int returnVal = GuiDummyRec(bounds, text); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiGrid(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + double _double_spacing; + JS_ToFloat64(ctx, &_double_spacing, argv[2]); + float spacing = (float)_double_spacing; + int subdivs; + JS_ToInt32(ctx, &subdivs, argv[3]); + Vector2* mouseCell = (Vector2*)JS_GetOpaque2(ctx, argv[4], js_Vector2_class_id); + if(mouseCell == NULL) return JS_EXCEPTION; + int returnVal = GuiGrid(bounds, text, spacing, subdivs, mouseCell); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiListView(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + int * scrollIndex = NULL; + int scrollIndex_out; + if(!JS_IsNull(argv[2])) { + scrollIndex = &scrollIndex_out; + JSValue scrollIndex_js = JS_GetPropertyStr(ctx, argv[2], "scrollIndex"); + JS_ToInt32(ctx, scrollIndex, scrollIndex_js); + } + int * active = NULL; + int active_out; + if(!JS_IsNull(argv[3])) { + active = &active_out; + JSValue active_js = JS_GetPropertyStr(ctx, argv[3], "active"); + JS_ToInt32(ctx, active, active_js); + } + int returnVal = GuiListView(bounds, text, scrollIndex, active); + JS_FreeCString(ctx, text); + if(!JS_IsNull(argv[2])) { + JS_SetPropertyStr(ctx, argv[2], "scrollIndex", JS_NewInt32(ctx,scrollIndex_out)); + } + if(!JS_IsNull(argv[3])) { + JS_SetPropertyStr(ctx, argv[3], "active", JS_NewInt32(ctx,active_out)); + } + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiMessageBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); + const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); + int returnVal = GuiMessageBox(bounds, title, message, buttons); + JS_FreeCString(ctx, title); + JS_FreeCString(ctx, message); + JS_FreeCString(ctx, buttons); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiTextInputBox(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); + const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); + char * text = (JS_IsNull(argv[4]) || JS_IsUndefined(argv[4])) ? NULL : (char *)JS_ToCString(ctx, argv[4]); + int textMaxSize; + JS_ToInt32(ctx, &textMaxSize, argv[5]); + int returnVal = GuiTextInputBox(bounds, title, message, buttons, text, textMaxSize, NULL); + JS_FreeCString(ctx, text); + return JS_NewInt32(ctx, returnVal); +} + +static JSValue js_guiColorPicker(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + Color* color = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(color == NULL) return JS_EXCEPTION; + int returnVal = GuiColorPicker(bounds, text, color); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorPanel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + Color* color = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); + if(color == NULL) return JS_EXCEPTION; + int returnVal = GuiColorPanel(bounds, text, color); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorBarAlpha(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + size_t alpha_size; + void * alpha_js = (void *)JS_GetArrayBuffer(ctx, &alpha_size, argv[2]); + if(alpha_js == NULL) { + return JS_EXCEPTION; + } + float * alpha = malloc(alpha_size); + memcpy((void *)alpha, (const void *)alpha_js, alpha_size); + int returnVal = GuiColorBarAlpha(bounds, text, alpha); + JS_FreeCString(ctx, text); + free((void *)alpha); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorBarHue(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + size_t value_size; + void * value_js = (void *)JS_GetArrayBuffer(ctx, &value_size, argv[2]); + if(value_js == NULL) { + return JS_EXCEPTION; + } + float * value = malloc(value_size); + memcpy((void *)value, (const void *)value_js, value_size); + int returnVal = GuiColorBarHue(bounds, text, value); + JS_FreeCString(ctx, text); + free((void *)value); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorPickerHSV(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + Vector3* colorHsv = (Vector3*)JS_GetOpaque2(ctx, argv[2], js_Vector3_class_id); + if(colorHsv == NULL) return JS_EXCEPTION; + int returnVal = GuiColorPickerHSV(bounds, text, colorHsv); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + +static JSValue js_guiColorPanelHSV(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); + if(bounds_ptr == NULL) return JS_EXCEPTION; + Rectangle bounds = *bounds_ptr; + const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); + Vector3* colorHsv = (Vector3*)JS_GetOpaque2(ctx, argv[2], js_Vector3_class_id); + if(colorHsv == NULL) return JS_EXCEPTION; + int returnVal = GuiColorPanelHSV(bounds, text, colorHsv); + JS_FreeCString(ctx, text); + JSValue ret = JS_NewInt32(ctx, returnVal); + return ret; +} + static JSValue js_createLight(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int type; JS_ToInt32(ctx, &type, argv[0]); @@ -10529,8 +11796,8 @@ static JSValue js_meshMerge(JSContext * ctx, JSValueConst this_val, int argc, JS static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("initWindow",3,js_initWindow), - JS_CFUNC_DEF("windowShouldClose",0,js_windowShouldClose), JS_CFUNC_DEF("closeWindow",0,js_closeWindow), + JS_CFUNC_DEF("windowShouldClose",0,js_windowShouldClose), JS_CFUNC_DEF("isWindowReady",0,js_isWindowReady), JS_CFUNC_DEF("isWindowFullscreen",0,js_isWindowFullscreen), JS_CFUNC_DEF("isWindowHidden",0,js_isWindowHidden), @@ -10542,6 +11809,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("setWindowState",1,js_setWindowState), JS_CFUNC_DEF("clearWindowState",1,js_clearWindowState), JS_CFUNC_DEF("toggleFullscreen",0,js_toggleFullscreen), + JS_CFUNC_DEF("toggleBorderlessWindowed",0,js_toggleBorderlessWindowed), JS_CFUNC_DEF("maximizeWindow",0,js_maximizeWindow), JS_CFUNC_DEF("minimizeWindow",0,js_minimizeWindow), JS_CFUNC_DEF("restoreWindow",0,js_restoreWindow), @@ -10550,8 +11818,10 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("setWindowPosition",2,js_setWindowPosition), JS_CFUNC_DEF("setWindowMonitor",1,js_setWindowMonitor), JS_CFUNC_DEF("setWindowMinSize",2,js_setWindowMinSize), + JS_CFUNC_DEF("setWindowMaxSize",2,js_setWindowMaxSize), JS_CFUNC_DEF("setWindowSize",2,js_setWindowSize), JS_CFUNC_DEF("setWindowOpacity",1,js_setWindowOpacity), + JS_CFUNC_DEF("setWindowFocused",0,js_setWindowFocused), JS_CFUNC_DEF("getScreenWidth",0,js_getScreenWidth), JS_CFUNC_DEF("getScreenHeight",0,js_getScreenHeight), JS_CFUNC_DEF("getRenderWidth",0,js_getRenderWidth), @@ -10569,6 +11839,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("getMonitorName",1,js_getMonitorName), JS_CFUNC_DEF("setClipboardText",1,js_setClipboardText), JS_CFUNC_DEF("getClipboardText",0,js_getClipboardText), + JS_CFUNC_DEF("getClipboardImage",0,js_getClipboardImage), JS_CFUNC_DEF("enableEventWaiting",0,js_enableEventWaiting), JS_CFUNC_DEF("disableEventWaiting",0,js_disableEventWaiting), JS_CFUNC_DEF("showCursor",0,js_showCursor), @@ -10598,31 +11869,33 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("unloadVrStereoConfig",1,js_unloadVrStereoConfig), JS_CFUNC_DEF("loadShader",2,js_loadShader), JS_CFUNC_DEF("loadShaderFromMemory",2,js_loadShaderFromMemory), - JS_CFUNC_DEF("isShaderReady",1,js_isShaderReady), + JS_CFUNC_DEF("isShaderValid",1,js_isShaderValid), JS_CFUNC_DEF("getShaderLocation",2,js_getShaderLocation), JS_CFUNC_DEF("getShaderLocationAttrib",2,js_getShaderLocationAttrib), JS_CFUNC_DEF("setShaderValue",4,js_setShaderValue), JS_CFUNC_DEF("setShaderValueMatrix",3,js_setShaderValueMatrix), JS_CFUNC_DEF("setShaderValueTexture",3,js_setShaderValueTexture), JS_CFUNC_DEF("unloadShader",1,js_unloadShader), - JS_CFUNC_DEF("getMouseRay",2,js_getMouseRay), - JS_CFUNC_DEF("getCameraMatrix",1,js_getCameraMatrix), - JS_CFUNC_DEF("getCameraMatrix2D",1,js_getCameraMatrix2D), + JS_CFUNC_DEF("getScreenToWorldRay",2,js_getScreenToWorldRay), + JS_CFUNC_DEF("getScreenToWorldRayEx",4,js_getScreenToWorldRayEx), JS_CFUNC_DEF("getWorldToScreen",2,js_getWorldToScreen), - JS_CFUNC_DEF("getScreenToWorld2D",2,js_getScreenToWorld2D), JS_CFUNC_DEF("getWorldToScreenEx",4,js_getWorldToScreenEx), JS_CFUNC_DEF("getWorldToScreen2D",2,js_getWorldToScreen2D), + JS_CFUNC_DEF("getScreenToWorld2D",2,js_getScreenToWorld2D), + JS_CFUNC_DEF("getCameraMatrix",1,js_getCameraMatrix), + JS_CFUNC_DEF("getCameraMatrix2D",1,js_getCameraMatrix2D), JS_CFUNC_DEF("setTargetFPS",1,js_setTargetFPS), - JS_CFUNC_DEF("getFPS",0,js_getFPS), JS_CFUNC_DEF("getFrameTime",0,js_getFrameTime), JS_CFUNC_DEF("getTime",0,js_getTime), - JS_CFUNC_DEF("getRandomValue",2,js_getRandomValue), + JS_CFUNC_DEF("getFPS",0,js_getFPS), JS_CFUNC_DEF("setRandomSeed",1,js_setRandomSeed), + JS_CFUNC_DEF("getRandomValue",2,js_getRandomValue), + JS_CFUNC_DEF("unloadRandomSequence",1,js_unloadRandomSequence), JS_CFUNC_DEF("takeScreenshot",1,js_takeScreenshot), JS_CFUNC_DEF("setConfigFlags",1,js_setConfigFlags), + JS_CFUNC_DEF("openURL",1,js_openURL), JS_CFUNC_DEF("traceLog",2,js_traceLog), JS_CFUNC_DEF("setTraceLogLevel",1,js_setTraceLogLevel), - JS_CFUNC_DEF("openURL",1,js_openURL), JS_CFUNC_DEF("loadFileData",1,js_loadFileData), JS_CFUNC_DEF("saveFileData",3,js_saveFileData), JS_CFUNC_DEF("loadFileText",1,js_loadFileText), @@ -10638,20 +11911,34 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("getPrevDirectoryPath",1,js_getPrevDirectoryPath), JS_CFUNC_DEF("getWorkingDirectory",0,js_getWorkingDirectory), JS_CFUNC_DEF("getApplicationDirectory",0,js_getApplicationDirectory), + JS_CFUNC_DEF("makeDirectory",1,js_makeDirectory), JS_CFUNC_DEF("changeDirectory",1,js_changeDirectory), JS_CFUNC_DEF("isPathFile",1,js_isPathFile), + JS_CFUNC_DEF("isFileNameValid",1,js_isFileNameValid), JS_CFUNC_DEF("loadDirectoryFiles",1,js_loadDirectoryFiles), JS_CFUNC_DEF("loadDirectoryFilesEx",3,js_loadDirectoryFilesEx), JS_CFUNC_DEF("isFileDropped",0,js_isFileDropped), JS_CFUNC_DEF("loadDroppedFiles",0,js_loadDroppedFiles), JS_CFUNC_DEF("getFileModTime",1,js_getFileModTime), + JS_CFUNC_DEF("computeCRC32",2,js_computeCRC32), + JS_CFUNC_DEF("computeMD5",2,js_computeMD5), + JS_CFUNC_DEF("computeSHA1",2,js_computeSHA1), + JS_CFUNC_DEF("loadAutomationEventList",1,js_loadAutomationEventList), + JS_CFUNC_DEF("unloadAutomationEventList",1,js_unloadAutomationEventList), + JS_CFUNC_DEF("exportAutomationEventList",2,js_exportAutomationEventList), + JS_CFUNC_DEF("setAutomationEventList",1,js_setAutomationEventList), + JS_CFUNC_DEF("setAutomationEventBaseFrame",1,js_setAutomationEventBaseFrame), + JS_CFUNC_DEF("startAutomationEventRecording",0,js_startAutomationEventRecording), + JS_CFUNC_DEF("stopAutomationEventRecording",0,js_stopAutomationEventRecording), + JS_CFUNC_DEF("playAutomationEvent",1,js_playAutomationEvent), JS_CFUNC_DEF("isKeyPressed",1,js_isKeyPressed), + JS_CFUNC_DEF("isKeyPressedRepeat",1,js_isKeyPressedRepeat), JS_CFUNC_DEF("isKeyDown",1,js_isKeyDown), JS_CFUNC_DEF("isKeyReleased",1,js_isKeyReleased), JS_CFUNC_DEF("isKeyUp",1,js_isKeyUp), - JS_CFUNC_DEF("setExitKey",1,js_setExitKey), JS_CFUNC_DEF("getKeyPressed",0,js_getKeyPressed), JS_CFUNC_DEF("getCharPressed",0,js_getCharPressed), + JS_CFUNC_DEF("setExitKey",1,js_setExitKey), JS_CFUNC_DEF("isGamepadAvailable",1,js_isGamepadAvailable), JS_CFUNC_DEF("getGamepadName",1,js_getGamepadName), JS_CFUNC_DEF("isGamepadButtonPressed",2,js_isGamepadButtonPressed), @@ -10662,6 +11949,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("getGamepadAxisCount",1,js_getGamepadAxisCount), JS_CFUNC_DEF("getGamepadAxisMovement",2,js_getGamepadAxisMovement), JS_CFUNC_DEF("setGamepadMappings",1,js_setGamepadMappings), + JS_CFUNC_DEF("setGamepadVibration",4,js_setGamepadVibration), JS_CFUNC_DEF("isMouseButtonPressed",1,js_isMouseButtonPressed), JS_CFUNC_DEF("isMouseButtonDown",1,js_isMouseButtonDown), JS_CFUNC_DEF("isMouseButtonReleased",1,js_isMouseButtonReleased), @@ -10692,20 +11980,21 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("updateCamera",2,js_updateCamera), JS_CFUNC_DEF("updateCameraPro",4,js_updateCameraPro), JS_CFUNC_DEF("setShapesTexture",2,js_setShapesTexture), + JS_CFUNC_DEF("getShapesTexture",0,js_getShapesTexture), + JS_CFUNC_DEF("getShapesTextureRectangle",0,js_getShapesTextureRectangle), JS_CFUNC_DEF("drawPixel",3,js_drawPixel), JS_CFUNC_DEF("drawPixelV",2,js_drawPixelV), JS_CFUNC_DEF("drawLine",5,js_drawLine), JS_CFUNC_DEF("drawLineV",3,js_drawLineV), JS_CFUNC_DEF("drawLineEx",4,js_drawLineEx), JS_CFUNC_DEF("drawLineBezier",4,js_drawLineBezier), - JS_CFUNC_DEF("drawLineBezierQuad",5,js_drawLineBezierQuad), - JS_CFUNC_DEF("drawLineBezierCubic",6,js_drawLineBezierCubic), JS_CFUNC_DEF("drawCircle",4,js_drawCircle), JS_CFUNC_DEF("drawCircleSector",6,js_drawCircleSector), JS_CFUNC_DEF("drawCircleSectorLines",6,js_drawCircleSectorLines), JS_CFUNC_DEF("drawCircleGradient",5,js_drawCircleGradient), JS_CFUNC_DEF("drawCircleV",3,js_drawCircleV), JS_CFUNC_DEF("drawCircleLines",4,js_drawCircleLines), + JS_CFUNC_DEF("drawCircleLinesV",3,js_drawCircleLinesV), JS_CFUNC_DEF("drawEllipse",5,js_drawEllipse), JS_CFUNC_DEF("drawEllipseLines",5,js_drawEllipseLines), JS_CFUNC_DEF("drawRing",7,js_drawRing), @@ -10720,15 +12009,32 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("drawRectangleLines",5,js_drawRectangleLines), JS_CFUNC_DEF("drawRectangleLinesEx",3,js_drawRectangleLinesEx), JS_CFUNC_DEF("drawRectangleRounded",4,js_drawRectangleRounded), - JS_CFUNC_DEF("drawRectangleRoundedLines",5,js_drawRectangleRoundedLines), + JS_CFUNC_DEF("drawRectangleRoundedLines",4,js_drawRectangleRoundedLines), + JS_CFUNC_DEF("drawRectangleRoundedLinesEx",5,js_drawRectangleRoundedLinesEx), JS_CFUNC_DEF("drawTriangle",4,js_drawTriangle), JS_CFUNC_DEF("drawTriangleLines",4,js_drawTriangleLines), JS_CFUNC_DEF("drawPoly",5,js_drawPoly), JS_CFUNC_DEF("drawPolyLines",5,js_drawPolyLines), JS_CFUNC_DEF("drawPolyLinesEx",6,js_drawPolyLinesEx), + JS_CFUNC_DEF("drawSplineLinear",4,js_drawSplineLinear), + JS_CFUNC_DEF("drawSplineBasis",4,js_drawSplineBasis), + JS_CFUNC_DEF("drawSplineCatmullRom",4,js_drawSplineCatmullRom), + JS_CFUNC_DEF("drawSplineBezierQuadratic",4,js_drawSplineBezierQuadratic), + JS_CFUNC_DEF("drawSplineBezierCubic",4,js_drawSplineBezierCubic), + JS_CFUNC_DEF("drawSplineSegmentLinear",4,js_drawSplineSegmentLinear), + JS_CFUNC_DEF("drawSplineSegmentBasis",6,js_drawSplineSegmentBasis), + JS_CFUNC_DEF("drawSplineSegmentCatmullRom",6,js_drawSplineSegmentCatmullRom), + JS_CFUNC_DEF("drawSplineSegmentBezierQuadratic",5,js_drawSplineSegmentBezierQuadratic), + JS_CFUNC_DEF("drawSplineSegmentBezierCubic",6,js_drawSplineSegmentBezierCubic), + JS_CFUNC_DEF("getSplinePointLinear",3,js_getSplinePointLinear), + JS_CFUNC_DEF("getSplinePointBasis",5,js_getSplinePointBasis), + JS_CFUNC_DEF("getSplinePointCatmullRom",5,js_getSplinePointCatmullRom), + JS_CFUNC_DEF("getSplinePointBezierQuad",4,js_getSplinePointBezierQuad), + JS_CFUNC_DEF("getSplinePointBezierCubic",5,js_getSplinePointBezierCubic), JS_CFUNC_DEF("checkCollisionRecs",2,js_checkCollisionRecs), JS_CFUNC_DEF("checkCollisionCircles",4,js_checkCollisionCircles), JS_CFUNC_DEF("checkCollisionCircleRec",3,js_checkCollisionCircleRec), + JS_CFUNC_DEF("checkCollisionCircleLine",4,js_checkCollisionCircleLine), JS_CFUNC_DEF("checkCollisionPointRec",2,js_checkCollisionPointRec), JS_CFUNC_DEF("checkCollisionPointCircle",3,js_checkCollisionPointCircle), JS_CFUNC_DEF("checkCollisionPointTriangle",4,js_checkCollisionPointTriangle), @@ -10736,12 +12042,14 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("getCollisionRec",2,js_getCollisionRec), JS_CFUNC_DEF("loadImage",1,js_loadImage), JS_CFUNC_DEF("loadImageRaw",5,js_loadImageRaw), + JS_CFUNC_DEF("loadImageAnimFromMemory",4,js_loadImageAnimFromMemory), JS_CFUNC_DEF("loadImageFromMemory",3,js_loadImageFromMemory), JS_CFUNC_DEF("loadImageFromTexture",1,js_loadImageFromTexture), JS_CFUNC_DEF("loadImageFromScreen",0,js_loadImageFromScreen), - JS_CFUNC_DEF("isImageReady",1,js_isImageReady), + JS_CFUNC_DEF("isImageValid",1,js_isImageValid), JS_CFUNC_DEF("unloadImage",1,js_unloadImage), JS_CFUNC_DEF("exportImage",2,js_exportImage), + JS_CFUNC_DEF("exportImageToMemory",3,js_exportImageToMemory), JS_CFUNC_DEF("genImageColor",3,js_genImageColor), JS_CFUNC_DEF("genImageGradientLinear",5,js_genImageGradientLinear), JS_CFUNC_DEF("genImageGradientRadial",5,js_genImageGradientRadial), @@ -10753,6 +12061,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("genImageText",3,js_genImageText), JS_CFUNC_DEF("imageCopy",1,js_imageCopy), JS_CFUNC_DEF("imageFromImage",2,js_imageFromImage), + JS_CFUNC_DEF("imageFromChannel",2,js_imageFromChannel), JS_CFUNC_DEF("imageText",3,js_imageText), JS_CFUNC_DEF("imageTextEx",5,js_imageTextEx), JS_CFUNC_DEF("imageFormat",2,js_imageFormat), @@ -10763,6 +12072,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("imageAlphaMask",2,js_imageAlphaMask), JS_CFUNC_DEF("imageAlphaPremultiply",1,js_imageAlphaPremultiply), JS_CFUNC_DEF("imageBlurGaussian",2,js_imageBlurGaussian), + JS_CFUNC_DEF("imageKernelConvolution",3,js_imageKernelConvolution), JS_CFUNC_DEF("imageResize",3,js_imageResize), JS_CFUNC_DEF("imageResizeNN",3,js_imageResizeNN), JS_CFUNC_DEF("imageResizeCanvas",6,js_imageResizeCanvas), @@ -10787,6 +12097,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("imageDrawPixelV",3,js_imageDrawPixelV), JS_CFUNC_DEF("imageDrawLine",6,js_imageDrawLine), JS_CFUNC_DEF("imageDrawLineV",4,js_imageDrawLineV), + JS_CFUNC_DEF("imageDrawLineEx",5,js_imageDrawLineEx), JS_CFUNC_DEF("imageDrawCircle",5,js_imageDrawCircle), JS_CFUNC_DEF("imageDrawCircleV",4,js_imageDrawCircleV), JS_CFUNC_DEF("imageDrawCircleLines",5,js_imageDrawCircleLines), @@ -10795,6 +12106,11 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("imageDrawRectangleV",4,js_imageDrawRectangleV), JS_CFUNC_DEF("imageDrawRectangleRec",3,js_imageDrawRectangleRec), JS_CFUNC_DEF("imageDrawRectangleLines",4,js_imageDrawRectangleLines), + JS_CFUNC_DEF("imageDrawTriangle",5,js_imageDrawTriangle), + JS_CFUNC_DEF("imageDrawTriangleEx",7,js_imageDrawTriangleEx), + JS_CFUNC_DEF("imageDrawTriangleLines",5,js_imageDrawTriangleLines), + JS_CFUNC_DEF("imageDrawTriangleFan",4,js_imageDrawTriangleFan), + JS_CFUNC_DEF("imageDrawTriangleStrip",4,js_imageDrawTriangleStrip), JS_CFUNC_DEF("imageDraw",5,js_imageDraw), JS_CFUNC_DEF("imageDrawText",6,js_imageDrawText), JS_CFUNC_DEF("imageDrawTextEx",7,js_imageDrawTextEx), @@ -10802,9 +12118,9 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("loadTextureFromImage",1,js_loadTextureFromImage), JS_CFUNC_DEF("loadTextureCubemap",2,js_loadTextureCubemap), JS_CFUNC_DEF("loadRenderTexture",2,js_loadRenderTexture), - JS_CFUNC_DEF("isTextureReady",1,js_isTextureReady), + JS_CFUNC_DEF("isTextureValid",1,js_isTextureValid), JS_CFUNC_DEF("unloadTexture",1,js_unloadTexture), - JS_CFUNC_DEF("isRenderTextureReady",1,js_isRenderTextureReady), + JS_CFUNC_DEF("isRenderTextureValid",1,js_isRenderTextureValid), JS_CFUNC_DEF("unloadRenderTexture",1,js_unloadRenderTexture), JS_CFUNC_DEF("updateTexture",2,js_updateTexture), JS_CFUNC_DEF("updateTextureRec",3,js_updateTextureRec), @@ -10817,6 +12133,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("drawTextureRec",4,js_drawTextureRec), JS_CFUNC_DEF("drawTexturePro",6,js_drawTexturePro), JS_CFUNC_DEF("drawTextureNPatch",6,js_drawTextureNPatch), + JS_CFUNC_DEF("colorIsEqual",2,js_colorIsEqual), JS_CFUNC_DEF("fade",2,js_fade), JS_CFUNC_DEF("colorToInt",1,js_colorToInt), JS_CFUNC_DEF("colorNormalize",1,js_colorNormalize), @@ -10828,19 +12145,21 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("colorContrast",2,js_colorContrast), JS_CFUNC_DEF("colorAlpha",2,js_colorAlpha), JS_CFUNC_DEF("colorAlphaBlend",3,js_colorAlphaBlend), + JS_CFUNC_DEF("colorLerp",3,js_colorLerp), JS_CFUNC_DEF("getColor",1,js_getColor), JS_CFUNC_DEF("getPixelDataSize",3,js_getPixelDataSize), JS_CFUNC_DEF("getFontDefault",0,js_getFontDefault), JS_CFUNC_DEF("loadFont",1,js_loadFont), JS_CFUNC_DEF("loadFontEx",2,js_loadFontEx), JS_CFUNC_DEF("loadFontFromImage",3,js_loadFontFromImage), - JS_CFUNC_DEF("isFontReady",1,js_isFontReady), + JS_CFUNC_DEF("isFontValid",1,js_isFontValid), JS_CFUNC_DEF("unloadFont",1,js_unloadFont), JS_CFUNC_DEF("drawFPS",2,js_drawFPS), JS_CFUNC_DEF("drawText",5,js_drawText), JS_CFUNC_DEF("drawTextEx",6,js_drawTextEx), JS_CFUNC_DEF("drawTextPro",8,js_drawTextPro), JS_CFUNC_DEF("drawTextCodepoint",5,js_drawTextCodepoint), + JS_CFUNC_DEF("setTextLineSpacing",1,js_setTextLineSpacing), JS_CFUNC_DEF("measureText",2,js_measureText), JS_CFUNC_DEF("measureTextEx",4,js_measureTextEx), JS_CFUNC_DEF("getGlyphIndex",2,js_getGlyphIndex), @@ -10867,13 +12186,15 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("drawGrid",2,js_drawGrid), JS_CFUNC_DEF("loadModel",1,js_loadModel), JS_CFUNC_DEF("loadModelFromMesh",1,js_loadModelFromMesh), - JS_CFUNC_DEF("isModelReady",1,js_isModelReady), + JS_CFUNC_DEF("isModelValid",1,js_isModelValid), JS_CFUNC_DEF("unloadModel",1,js_unloadModel), JS_CFUNC_DEF("getModelBoundingBox",1,js_getModelBoundingBox), JS_CFUNC_DEF("drawModel",4,js_drawModel), JS_CFUNC_DEF("drawModelEx",6,js_drawModelEx), JS_CFUNC_DEF("drawModelWires",4,js_drawModelWires), JS_CFUNC_DEF("drawModelWiresEx",6,js_drawModelWiresEx), + JS_CFUNC_DEF("drawModelPoints",4,js_drawModelPoints), + JS_CFUNC_DEF("drawModelPointsEx",6,js_drawModelPointsEx), JS_CFUNC_DEF("drawBoundingBox",2,js_drawBoundingBox), JS_CFUNC_DEF("drawBillboard",5,js_drawBillboard), JS_CFUNC_DEF("drawBillboardRec",6,js_drawBillboardRec), @@ -10883,9 +12204,10 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("unloadMesh",1,js_unloadMesh), JS_CFUNC_DEF("drawMesh",3,js_drawMesh), JS_CFUNC_DEF("drawMeshInstanced",4,js_drawMeshInstanced), - JS_CFUNC_DEF("exportMesh",2,js_exportMesh), JS_CFUNC_DEF("getMeshBoundingBox",1,js_getMeshBoundingBox), JS_CFUNC_DEF("genMeshTangents",1,js_genMeshTangents), + JS_CFUNC_DEF("exportMesh",2,js_exportMesh), + JS_CFUNC_DEF("exportMeshAsCode",2,js_exportMeshAsCode), JS_CFUNC_DEF("genMeshPoly",2,js_genMeshPoly), JS_CFUNC_DEF("genMeshPlane",4,js_genMeshPlane), JS_CFUNC_DEF("genMeshCube",3,js_genMeshCube), @@ -10898,10 +12220,11 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("genMeshHeightmap",2,js_genMeshHeightmap), JS_CFUNC_DEF("genMeshCubicmap",2,js_genMeshCubicmap), JS_CFUNC_DEF("loadMaterialDefault",0,js_loadMaterialDefault), - JS_CFUNC_DEF("isMaterialReady",1,js_isMaterialReady), + JS_CFUNC_DEF("isMaterialValid",1,js_isMaterialValid), JS_CFUNC_DEF("unloadMaterial",1,js_unloadMaterial), JS_CFUNC_DEF("setMaterialTexture",3,js_setMaterialTexture), JS_CFUNC_DEF("setModelMeshMaterial",3,js_setModelMeshMaterial), + JS_CFUNC_DEF("updateModelAnimationBones",3,js_updateModelAnimationBones), JS_CFUNC_DEF("checkCollisionSpheres",4,js_checkCollisionSpheres), JS_CFUNC_DEF("checkCollisionBoxes",2,js_checkCollisionBoxes), JS_CFUNC_DEF("checkCollisionBoxSphere",3,js_checkCollisionBoxSphere), @@ -10914,15 +12237,18 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("closeAudioDevice",0,js_closeAudioDevice), JS_CFUNC_DEF("isAudioDeviceReady",0,js_isAudioDeviceReady), JS_CFUNC_DEF("setMasterVolume",1,js_setMasterVolume), + JS_CFUNC_DEF("getMasterVolume",0,js_getMasterVolume), JS_CFUNC_DEF("loadWave",1,js_loadWave), JS_CFUNC_DEF("loadWaveFromMemory",3,js_loadWaveFromMemory), - JS_CFUNC_DEF("isWaveReady",1,js_isWaveReady), + JS_CFUNC_DEF("isWaveValid",1,js_isWaveValid), JS_CFUNC_DEF("loadSound",1,js_loadSound), JS_CFUNC_DEF("loadSoundFromWave",1,js_loadSoundFromWave), - JS_CFUNC_DEF("isSoundReady",1,js_isSoundReady), + JS_CFUNC_DEF("loadSoundAlias",1,js_loadSoundAlias), + JS_CFUNC_DEF("isSoundValid",1,js_isSoundValid), JS_CFUNC_DEF("updateSound",3,js_updateSound), JS_CFUNC_DEF("unloadWave",1,js_unloadWave), JS_CFUNC_DEF("unloadSound",1,js_unloadSound), + JS_CFUNC_DEF("unloadSoundAlias",1,js_unloadSoundAlias), JS_CFUNC_DEF("exportWave",2,js_exportWave), JS_CFUNC_DEF("playSound",1,js_playSound), JS_CFUNC_DEF("stopSound",1,js_stopSound), @@ -10936,7 +12262,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("waveCrop",3,js_waveCrop), JS_CFUNC_DEF("waveFormat",4,js_waveFormat), JS_CFUNC_DEF("loadMusicStream",1,js_loadMusicStream), - JS_CFUNC_DEF("isMusicReady",1,js_isMusicReady), + JS_CFUNC_DEF("isMusicValid",1,js_isMusicValid), JS_CFUNC_DEF("unloadMusicStream",1,js_unloadMusicStream), JS_CFUNC_DEF("playMusicStream",1,js_playMusicStream), JS_CFUNC_DEF("isMusicStreamPlaying",1,js_isMusicStreamPlaying), @@ -10950,6 +12276,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("setMusicPan",2,js_setMusicPan), JS_CFUNC_DEF("getMusicTimeLength",1,js_getMusicTimeLength), JS_CFUNC_DEF("getMusicTimePlayed",1,js_getMusicTimePlayed), + JS_CFUNC_DEF("isAudioStreamValid",1,js_isAudioStreamValid), JS_CFUNC_DEF("clamp",3,js_clamp), JS_CFUNC_DEF("lerp",3,js_lerp), JS_CFUNC_DEF("normalize",3,js_normalize), @@ -10977,12 +12304,15 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("vector2Transform",2,js_vector2Transform), JS_CFUNC_DEF("vector2Lerp",3,js_vector2Lerp), JS_CFUNC_DEF("vector2Reflect",2,js_vector2Reflect), + JS_CFUNC_DEF("vector2Min",2,js_vector2Min), + JS_CFUNC_DEF("vector2Max",2,js_vector2Max), JS_CFUNC_DEF("vector2Rotate",2,js_vector2Rotate), JS_CFUNC_DEF("vector2MoveTowards",3,js_vector2MoveTowards), JS_CFUNC_DEF("vector2Invert",1,js_vector2Invert), JS_CFUNC_DEF("vector2Clamp",3,js_vector2Clamp), JS_CFUNC_DEF("vector2ClampValue",3,js_vector2ClampValue), JS_CFUNC_DEF("vector2Equals",2,js_vector2Equals), + JS_CFUNC_DEF("vector2Refract",3,js_vector2Refract), JS_CFUNC_DEF("vector3Zero",0,js_vector3Zero), JS_CFUNC_DEF("vector3One",0,js_vector3One), JS_CFUNC_DEF("vector3Add",2,js_vector3Add), @@ -11002,10 +12332,15 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("vector3Negate",1,js_vector3Negate), JS_CFUNC_DEF("vector3Divide",2,js_vector3Divide), JS_CFUNC_DEF("vector3Normalize",1,js_vector3Normalize), + JS_CFUNC_DEF("vector3Project",2,js_vector3Project), + JS_CFUNC_DEF("vector3Reject",2,js_vector3Reject), + JS_CFUNC_DEF("vector3OrthoNormalize",2,js_vector3OrthoNormalize), JS_CFUNC_DEF("vector3Transform",2,js_vector3Transform), JS_CFUNC_DEF("vector3RotateByQuaternion",2,js_vector3RotateByQuaternion), JS_CFUNC_DEF("vector3RotateByAxisAngle",3,js_vector3RotateByAxisAngle), + JS_CFUNC_DEF("vector3MoveTowards",3,js_vector3MoveTowards), JS_CFUNC_DEF("vector3Lerp",3,js_vector3Lerp), + JS_CFUNC_DEF("vector3CubicHermite",5,js_vector3CubicHermite), JS_CFUNC_DEF("vector3Reflect",2,js_vector3Reflect), JS_CFUNC_DEF("vector3Min",2,js_vector3Min), JS_CFUNC_DEF("vector3Max",2,js_vector3Max), @@ -11016,6 +12351,18 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("vector3ClampValue",3,js_vector3ClampValue), JS_CFUNC_DEF("vector3Equals",2,js_vector3Equals), JS_CFUNC_DEF("vector3Refract",3,js_vector3Refract), + JS_CFUNC_DEF("vector4Distance",2,js_vector4Distance), + JS_CFUNC_DEF("vector4DistanceSqr",2,js_vector4DistanceSqr), + JS_CFUNC_DEF("vector4Multiply",2,js_vector4Multiply), + JS_CFUNC_DEF("vector4Negate",1,js_vector4Negate), + JS_CFUNC_DEF("vector4Divide",2,js_vector4Divide), + JS_CFUNC_DEF("vector4Normalize",1,js_vector4Normalize), + JS_CFUNC_DEF("vector4Min",2,js_vector4Min), + JS_CFUNC_DEF("vector4Max",2,js_vector4Max), + JS_CFUNC_DEF("vector4Lerp",3,js_vector4Lerp), + JS_CFUNC_DEF("vector4MoveTowards",3,js_vector4MoveTowards), + JS_CFUNC_DEF("vector4Invert",1,js_vector4Invert), + JS_CFUNC_DEF("vector4Equals",2,js_vector4Equals), JS_CFUNC_DEF("matrixDeterminant",1,js_matrixDeterminant), JS_CFUNC_DEF("matrixTrace",1,js_matrixTrace), JS_CFUNC_DEF("matrixTranspose",1,js_matrixTranspose), @@ -11050,14 +12397,17 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("quaternionLerp",3,js_quaternionLerp), JS_CFUNC_DEF("quaternionNlerp",3,js_quaternionNlerp), JS_CFUNC_DEF("quaternionSlerp",3,js_quaternionSlerp), + JS_CFUNC_DEF("quaternionCubicHermiteSpline",5,js_quaternionCubicHermiteSpline), JS_CFUNC_DEF("quaternionFromVector3ToVector3",2,js_quaternionFromVector3ToVector3), JS_CFUNC_DEF("quaternionFromMatrix",1,js_quaternionFromMatrix), JS_CFUNC_DEF("quaternionToMatrix",1,js_quaternionToMatrix), JS_CFUNC_DEF("quaternionFromAxisAngle",2,js_quaternionFromAxisAngle), + JS_CFUNC_DEF("quaternionToAxisAngle",3,js_quaternionToAxisAngle), JS_CFUNC_DEF("quaternionFromEuler",3,js_quaternionFromEuler), JS_CFUNC_DEF("quaternionToEuler",1,js_quaternionToEuler), JS_CFUNC_DEF("quaternionTransform",2,js_quaternionTransform), JS_CFUNC_DEF("quaternionEquals",2,js_quaternionEquals), + JS_CFUNC_DEF("matrixDecompose",4,js_matrixDecompose), JS_CFUNC_DEF("getCameraForward",1,js_getCameraForward), JS_CFUNC_DEF("getCameraUp",1,js_getCameraUp), JS_CFUNC_DEF("getCameraRight",1,js_getCameraRight), @@ -11075,23 +12425,32 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("guiLock",0,js_guiLock), JS_CFUNC_DEF("guiUnlock",0,js_guiUnlock), JS_CFUNC_DEF("guiIsLocked",0,js_guiIsLocked), - JS_CFUNC_DEF("guiFade",1,js_guiFade), + JS_CFUNC_DEF("guiSetAlpha",1,js_guiSetAlpha), JS_CFUNC_DEF("guiSetState",1,js_guiSetState), JS_CFUNC_DEF("guiGetState",0,js_guiGetState), JS_CFUNC_DEF("guiSetFont",1,js_guiSetFont), JS_CFUNC_DEF("guiGetFont",0,js_guiGetFont), JS_CFUNC_DEF("guiSetStyle",3,js_guiSetStyle), JS_CFUNC_DEF("guiGetStyle",2,js_guiGetStyle), + JS_CFUNC_DEF("guiLoadStyle",1,js_guiLoadStyle), + JS_CFUNC_DEF("guiLoadStyleDefault",0,js_guiLoadStyleDefault), + JS_CFUNC_DEF("guiEnableTooltip",0,js_guiEnableTooltip), + JS_CFUNC_DEF("guiDisableTooltip",0,js_guiDisableTooltip), + JS_CFUNC_DEF("guiSetTooltip",1,js_guiSetTooltip), + JS_CFUNC_DEF("guiIconText",2,js_guiIconText), + JS_CFUNC_DEF("guiSetIconScale",1,js_guiSetIconScale), + JS_CFUNC_DEF("guiDrawIcon",5,js_guiDrawIcon), JS_CFUNC_DEF("guiWindowBox",2,js_guiWindowBox), JS_CFUNC_DEF("guiGroupBox",2,js_guiGroupBox), JS_CFUNC_DEF("guiLine",2,js_guiLine), JS_CFUNC_DEF("guiPanel",2,js_guiPanel), - JS_CFUNC_DEF("guiScrollPanel",4,js_guiScrollPanel), + JS_CFUNC_DEF("guiScrollPanel",5,js_guiScrollPanel), JS_CFUNC_DEF("guiLabel",2,js_guiLabel), JS_CFUNC_DEF("guiButton",2,js_guiButton), JS_CFUNC_DEF("guiLabelButton",2,js_guiLabelButton), JS_CFUNC_DEF("guiToggle",3,js_guiToggle), JS_CFUNC_DEF("guiToggleGroup",3,js_guiToggleGroup), + JS_CFUNC_DEF("guiToggleSlider",3,js_guiToggleSlider), JS_CFUNC_DEF("guiCheckBox",3,js_guiCheckBox), JS_CFUNC_DEF("guiComboBox",3,js_guiComboBox), JS_CFUNC_DEF("guiDropdownBox",4,js_guiDropdownBox), @@ -11103,22 +12462,16 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("guiProgressBar",6,js_guiProgressBar), JS_CFUNC_DEF("guiStatusBar",2,js_guiStatusBar), JS_CFUNC_DEF("guiDummyRec",2,js_guiDummyRec), - JS_CFUNC_DEF("guiGrid",4,js_guiGrid), + JS_CFUNC_DEF("guiGrid",5,js_guiGrid), JS_CFUNC_DEF("guiListView",4,js_guiListView), JS_CFUNC_DEF("guiMessageBox",4,js_guiMessageBox), - JS_CFUNC_DEF("guiTextInputBox",6,js_guiTextInputBox), + JS_CFUNC_DEF("guiTextInputBox",7,js_guiTextInputBox), JS_CFUNC_DEF("guiColorPicker",3,js_guiColorPicker), JS_CFUNC_DEF("guiColorPanel",3,js_guiColorPanel), JS_CFUNC_DEF("guiColorBarAlpha",3,js_guiColorBarAlpha), JS_CFUNC_DEF("guiColorBarHue",3,js_guiColorBarHue), - JS_CFUNC_DEF("guiLoadStyle",1,js_guiLoadStyle), - JS_CFUNC_DEF("guiLoadStyleDefault",0,js_guiLoadStyleDefault), - JS_CFUNC_DEF("guiEnableTooltip",0,js_guiEnableTooltip), - JS_CFUNC_DEF("guiDisableTooltip",0,js_guiDisableTooltip), - JS_CFUNC_DEF("guiSetTooltip",1,js_guiSetTooltip), - JS_CFUNC_DEF("guiIconText",2,js_guiIconText), - JS_CFUNC_DEF("guiSetIconScale",1,js_guiSetIconScale), - JS_CFUNC_DEF("guiDrawIcon",5,js_guiDrawIcon), + JS_CFUNC_DEF("guiColorPickerHSV",3,js_guiColorPickerHSV), + JS_CFUNC_DEF("guiColorPanelHSV",3,js_guiColorPanelHSV), JS_CFUNC_DEF("createLight",5,js_createLight), JS_CFUNC_DEF("updateLightValues",2,js_updateLightValues), JS_CFUNC_DEF("easeLinearNone",4,js_easeLinearNone), @@ -11199,7 +12552,7 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JSValue Camera2D_constr = JS_NewCFunction2(ctx, js_Camera2D_constructor,"Camera2D)", 4, JS_CFUNC_constructor_or_func, 0); JS_SetModuleExport(ctx, m, "Camera2D", Camera2D_constr); js_declare_Mesh(ctx, m); - JSValue Mesh_constr = JS_NewCFunction2(ctx, js_Mesh_constructor,"Mesh)", 15, JS_CFUNC_constructor_or_func, 0); + JSValue Mesh_constr = JS_NewCFunction2(ctx, js_Mesh_constructor,"Mesh)", 17, JS_CFUNC_constructor_or_func, 0); JS_SetModuleExport(ctx, m, "Mesh", Mesh_constr); js_declare_Shader(ctx, m); js_declare_MaterialMap(ctx, m); @@ -11220,10 +12573,12 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { js_declare_Sound(ctx, m); js_declare_Music(ctx, m); js_declare_VrDeviceInfo(ctx, m); - JSValue VrDeviceInfo_constr = JS_NewCFunction2(ctx, js_VrDeviceInfo_constructor,"VrDeviceInfo)", 10, JS_CFUNC_constructor_or_func, 0); + JSValue VrDeviceInfo_constr = JS_NewCFunction2(ctx, js_VrDeviceInfo_constructor,"VrDeviceInfo)", 9, JS_CFUNC_constructor_or_func, 0); JS_SetModuleExport(ctx, m, "VrDeviceInfo", VrDeviceInfo_constr); js_declare_VrStereoConfig(ctx, m); js_declare_FilePathList(ctx, m); + js_declare_AutomationEvent(ctx, m); + js_declare_AutomationEventList(ctx, m); js_declare_Light(ctx, m); js_declare_Lightmapper(ctx, m); js_declare_LightmapperConfig(ctx, m); @@ -11396,6 +12751,7 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "FLAG_WINDOW_TRANSPARENT", JS_NewInt32(ctx, FLAG_WINDOW_TRANSPARENT)); JS_SetModuleExport(ctx, m, "FLAG_WINDOW_HIGHDPI", JS_NewInt32(ctx, FLAG_WINDOW_HIGHDPI)); JS_SetModuleExport(ctx, m, "FLAG_WINDOW_MOUSE_PASSTHROUGH", JS_NewInt32(ctx, FLAG_WINDOW_MOUSE_PASSTHROUGH)); + JS_SetModuleExport(ctx, m, "FLAG_BORDERLESS_WINDOWED_MODE", JS_NewInt32(ctx, FLAG_BORDERLESS_WINDOWED_MODE)); JS_SetModuleExport(ctx, m, "FLAG_MSAA_4X_HINT", JS_NewInt32(ctx, FLAG_MSAA_4X_HINT)); JS_SetModuleExport(ctx, m, "FLAG_INTERLACED_HINT", JS_NewInt32(ctx, FLAG_INTERLACED_HINT)); JS_SetModuleExport(ctx, m, "LOG_ALL", JS_NewInt32(ctx, LOG_ALL)); @@ -11595,6 +12951,9 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "SHADER_LOC_MAP_IRRADIANCE", JS_NewInt32(ctx, SHADER_LOC_MAP_IRRADIANCE)); JS_SetModuleExport(ctx, m, "SHADER_LOC_MAP_PREFILTER", JS_NewInt32(ctx, SHADER_LOC_MAP_PREFILTER)); JS_SetModuleExport(ctx, m, "SHADER_LOC_MAP_BRDF", JS_NewInt32(ctx, SHADER_LOC_MAP_BRDF)); + JS_SetModuleExport(ctx, m, "SHADER_LOC_VERTEX_BONEIDS", JS_NewInt32(ctx, SHADER_LOC_VERTEX_BONEIDS)); + JS_SetModuleExport(ctx, m, "SHADER_LOC_VERTEX_BONEWEIGHTS", JS_NewInt32(ctx, SHADER_LOC_VERTEX_BONEWEIGHTS)); + JS_SetModuleExport(ctx, m, "SHADER_LOC_BONE_MATRICES", JS_NewInt32(ctx, SHADER_LOC_BONE_MATRICES)); JS_SetModuleExport(ctx, m, "SHADER_UNIFORM_FLOAT", JS_NewInt32(ctx, SHADER_UNIFORM_FLOAT)); JS_SetModuleExport(ctx, m, "SHADER_UNIFORM_VEC2", JS_NewInt32(ctx, SHADER_UNIFORM_VEC2)); JS_SetModuleExport(ctx, m, "SHADER_UNIFORM_VEC3", JS_NewInt32(ctx, SHADER_UNIFORM_VEC3)); @@ -11618,6 +12977,9 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R32)); JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32G32B32", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R32G32B32)); JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32G32B32A32", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R32G32B32A32)); + JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R16)); + JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16G16B16", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R16G16B16)); + JS_SetModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16G16B16A16", JS_NewInt32(ctx, PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)); JS_SetModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT1_RGB", JS_NewInt32(ctx, PIXELFORMAT_COMPRESSED_DXT1_RGB)); JS_SetModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT1_RGBA", JS_NewInt32(ctx, PIXELFORMAT_COMPRESSED_DXT1_RGBA)); JS_SetModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT3_RGBA", JS_NewInt32(ctx, PIXELFORMAT_COMPRESSED_DXT3_RGBA)); @@ -11644,7 +13006,6 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "CUBEMAP_LAYOUT_LINE_HORIZONTAL", JS_NewInt32(ctx, CUBEMAP_LAYOUT_LINE_HORIZONTAL)); JS_SetModuleExport(ctx, m, "CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR", JS_NewInt32(ctx, CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR)); JS_SetModuleExport(ctx, m, "CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE", JS_NewInt32(ctx, CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE)); - JS_SetModuleExport(ctx, m, "CUBEMAP_LAYOUT_PANORAMA", JS_NewInt32(ctx, CUBEMAP_LAYOUT_PANORAMA)); JS_SetModuleExport(ctx, m, "FONT_DEFAULT", JS_NewInt32(ctx, FONT_DEFAULT)); JS_SetModuleExport(ctx, m, "FONT_BITMAP", JS_NewInt32(ctx, FONT_BITMAP)); JS_SetModuleExport(ctx, m, "FONT_SDF", JS_NewInt32(ctx, FONT_SDF)); @@ -11684,6 +13045,12 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "TEXT_ALIGN_LEFT", JS_NewInt32(ctx, TEXT_ALIGN_LEFT)); JS_SetModuleExport(ctx, m, "TEXT_ALIGN_CENTER", JS_NewInt32(ctx, TEXT_ALIGN_CENTER)); JS_SetModuleExport(ctx, m, "TEXT_ALIGN_RIGHT", JS_NewInt32(ctx, TEXT_ALIGN_RIGHT)); + JS_SetModuleExport(ctx, m, "TEXT_ALIGN_TOP", JS_NewInt32(ctx, TEXT_ALIGN_TOP)); + JS_SetModuleExport(ctx, m, "TEXT_ALIGN_MIDDLE", JS_NewInt32(ctx, TEXT_ALIGN_MIDDLE)); + JS_SetModuleExport(ctx, m, "TEXT_ALIGN_BOTTOM", JS_NewInt32(ctx, TEXT_ALIGN_BOTTOM)); + JS_SetModuleExport(ctx, m, "TEXT_WRAP_NONE", JS_NewInt32(ctx, TEXT_WRAP_NONE)); + JS_SetModuleExport(ctx, m, "TEXT_WRAP_CHAR", JS_NewInt32(ctx, TEXT_WRAP_CHAR)); + JS_SetModuleExport(ctx, m, "TEXT_WRAP_WORD", JS_NewInt32(ctx, TEXT_WRAP_WORD)); JS_SetModuleExport(ctx, m, "DEFAULT", JS_NewInt32(ctx, DEFAULT)); JS_SetModuleExport(ctx, m, "LABEL", JS_NewInt32(ctx, LABEL)); JS_SetModuleExport(ctx, m, "BUTTON", JS_NewInt32(ctx, BUTTON)); @@ -11715,11 +13082,13 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "BORDER_WIDTH", JS_NewInt32(ctx, BORDER_WIDTH)); JS_SetModuleExport(ctx, m, "TEXT_PADDING", JS_NewInt32(ctx, TEXT_PADDING)); JS_SetModuleExport(ctx, m, "TEXT_ALIGNMENT", JS_NewInt32(ctx, TEXT_ALIGNMENT)); - JS_SetModuleExport(ctx, m, "RESERVED", JS_NewInt32(ctx, RESERVED)); JS_SetModuleExport(ctx, m, "TEXT_SIZE", JS_NewInt32(ctx, TEXT_SIZE)); JS_SetModuleExport(ctx, m, "TEXT_SPACING", JS_NewInt32(ctx, TEXT_SPACING)); JS_SetModuleExport(ctx, m, "LINE_COLOR", JS_NewInt32(ctx, LINE_COLOR)); JS_SetModuleExport(ctx, m, "BACKGROUND_COLOR", JS_NewInt32(ctx, BACKGROUND_COLOR)); + JS_SetModuleExport(ctx, m, "TEXT_LINE_SPACING", JS_NewInt32(ctx, TEXT_LINE_SPACING)); + JS_SetModuleExport(ctx, m, "TEXT_ALIGNMENT_VERTICAL", JS_NewInt32(ctx, TEXT_ALIGNMENT_VERTICAL)); + JS_SetModuleExport(ctx, m, "TEXT_WRAP_MODE", JS_NewInt32(ctx, TEXT_WRAP_MODE)); JS_SetModuleExport(ctx, m, "GROUP_PADDING", JS_NewInt32(ctx, GROUP_PADDING)); JS_SetModuleExport(ctx, m, "SLIDER_WIDTH", JS_NewInt32(ctx, SLIDER_WIDTH)); JS_SetModuleExport(ctx, m, "SLIDER_PADDING", JS_NewInt32(ctx, SLIDER_PADDING)); @@ -11735,11 +13104,7 @@ static int js_raylib_core_init(JSContext * ctx, JSModuleDef * m) { JS_SetModuleExport(ctx, m, "COMBO_BUTTON_SPACING", JS_NewInt32(ctx, COMBO_BUTTON_SPACING)); JS_SetModuleExport(ctx, m, "ARROW_PADDING", JS_NewInt32(ctx, ARROW_PADDING)); JS_SetModuleExport(ctx, m, "DROPDOWN_ITEMS_SPACING", JS_NewInt32(ctx, DROPDOWN_ITEMS_SPACING)); - JS_SetModuleExport(ctx, m, "TEXT_INNER_PADDING", JS_NewInt32(ctx, TEXT_INNER_PADDING)); - JS_SetModuleExport(ctx, m, "TEXT_LINES_SPACING", JS_NewInt32(ctx, TEXT_LINES_SPACING)); - JS_SetModuleExport(ctx, m, "TEXT_ALIGNMENT_VERTICAL", JS_NewInt32(ctx, TEXT_ALIGNMENT_VERTICAL)); - JS_SetModuleExport(ctx, m, "TEXT_MULTILINE", JS_NewInt32(ctx, TEXT_MULTILINE)); - JS_SetModuleExport(ctx, m, "TEXT_WRAP_MODE", JS_NewInt32(ctx, TEXT_WRAP_MODE)); + JS_SetModuleExport(ctx, m, "TEXT_READONLY", JS_NewInt32(ctx, TEXT_READONLY)); JS_SetModuleExport(ctx, m, "SPIN_BUTTON_WIDTH", JS_NewInt32(ctx, SPIN_BUTTON_WIDTH)); JS_SetModuleExport(ctx, m, "SPIN_BUTTON_SPACING", JS_NewInt32(ctx, SPIN_BUTTON_SPACING)); JS_SetModuleExport(ctx, m, "LIST_ITEMS_HEIGHT", JS_NewInt32(ctx, LIST_ITEMS_HEIGHT)); @@ -12073,6 +13438,7 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "FLAG_WINDOW_TRANSPARENT"); JS_AddModuleExport(ctx, m, "FLAG_WINDOW_HIGHDPI"); JS_AddModuleExport(ctx, m, "FLAG_WINDOW_MOUSE_PASSTHROUGH"); + JS_AddModuleExport(ctx, m, "FLAG_BORDERLESS_WINDOWED_MODE"); JS_AddModuleExport(ctx, m, "FLAG_MSAA_4X_HINT"); JS_AddModuleExport(ctx, m, "FLAG_INTERLACED_HINT"); JS_AddModuleExport(ctx, m, "LOG_ALL"); @@ -12272,6 +13638,9 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "SHADER_LOC_MAP_IRRADIANCE"); JS_AddModuleExport(ctx, m, "SHADER_LOC_MAP_PREFILTER"); JS_AddModuleExport(ctx, m, "SHADER_LOC_MAP_BRDF"); + JS_AddModuleExport(ctx, m, "SHADER_LOC_VERTEX_BONEIDS"); + JS_AddModuleExport(ctx, m, "SHADER_LOC_VERTEX_BONEWEIGHTS"); + JS_AddModuleExport(ctx, m, "SHADER_LOC_BONE_MATRICES"); JS_AddModuleExport(ctx, m, "SHADER_UNIFORM_FLOAT"); JS_AddModuleExport(ctx, m, "SHADER_UNIFORM_VEC2"); JS_AddModuleExport(ctx, m, "SHADER_UNIFORM_VEC3"); @@ -12295,6 +13664,9 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32"); JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32G32B32"); JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R32G32B32A32"); + JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16"); + JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16G16B16"); + JS_AddModuleExport(ctx, m, "PIXELFORMAT_UNCOMPRESSED_R16G16B16A16"); JS_AddModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT1_RGB"); JS_AddModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT1_RGBA"); JS_AddModuleExport(ctx, m, "PIXELFORMAT_COMPRESSED_DXT3_RGBA"); @@ -12321,7 +13693,6 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "CUBEMAP_LAYOUT_LINE_HORIZONTAL"); JS_AddModuleExport(ctx, m, "CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR"); JS_AddModuleExport(ctx, m, "CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE"); - JS_AddModuleExport(ctx, m, "CUBEMAP_LAYOUT_PANORAMA"); JS_AddModuleExport(ctx, m, "FONT_DEFAULT"); JS_AddModuleExport(ctx, m, "FONT_BITMAP"); JS_AddModuleExport(ctx, m, "FONT_SDF"); @@ -12361,6 +13732,12 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "TEXT_ALIGN_LEFT"); JS_AddModuleExport(ctx, m, "TEXT_ALIGN_CENTER"); JS_AddModuleExport(ctx, m, "TEXT_ALIGN_RIGHT"); + JS_AddModuleExport(ctx, m, "TEXT_ALIGN_TOP"); + JS_AddModuleExport(ctx, m, "TEXT_ALIGN_MIDDLE"); + JS_AddModuleExport(ctx, m, "TEXT_ALIGN_BOTTOM"); + JS_AddModuleExport(ctx, m, "TEXT_WRAP_NONE"); + JS_AddModuleExport(ctx, m, "TEXT_WRAP_CHAR"); + JS_AddModuleExport(ctx, m, "TEXT_WRAP_WORD"); JS_AddModuleExport(ctx, m, "DEFAULT"); JS_AddModuleExport(ctx, m, "LABEL"); JS_AddModuleExport(ctx, m, "BUTTON"); @@ -12392,11 +13769,13 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "BORDER_WIDTH"); JS_AddModuleExport(ctx, m, "TEXT_PADDING"); JS_AddModuleExport(ctx, m, "TEXT_ALIGNMENT"); - JS_AddModuleExport(ctx, m, "RESERVED"); JS_AddModuleExport(ctx, m, "TEXT_SIZE"); JS_AddModuleExport(ctx, m, "TEXT_SPACING"); JS_AddModuleExport(ctx, m, "LINE_COLOR"); JS_AddModuleExport(ctx, m, "BACKGROUND_COLOR"); + JS_AddModuleExport(ctx, m, "TEXT_LINE_SPACING"); + JS_AddModuleExport(ctx, m, "TEXT_ALIGNMENT_VERTICAL"); + JS_AddModuleExport(ctx, m, "TEXT_WRAP_MODE"); JS_AddModuleExport(ctx, m, "GROUP_PADDING"); JS_AddModuleExport(ctx, m, "SLIDER_WIDTH"); JS_AddModuleExport(ctx, m, "SLIDER_PADDING"); @@ -12412,11 +13791,7 @@ JSModuleDef * js_init_module_raylib_core(JSContext * ctx, const char * module_na JS_AddModuleExport(ctx, m, "COMBO_BUTTON_SPACING"); JS_AddModuleExport(ctx, m, "ARROW_PADDING"); JS_AddModuleExport(ctx, m, "DROPDOWN_ITEMS_SPACING"); - JS_AddModuleExport(ctx, m, "TEXT_INNER_PADDING"); - JS_AddModuleExport(ctx, m, "TEXT_LINES_SPACING"); - JS_AddModuleExport(ctx, m, "TEXT_ALIGNMENT_VERTICAL"); - JS_AddModuleExport(ctx, m, "TEXT_MULTILINE"); - JS_AddModuleExport(ctx, m, "TEXT_WRAP_MODE"); + JS_AddModuleExport(ctx, m, "TEXT_READONLY"); JS_AddModuleExport(ctx, m, "SPIN_BUTTON_WIDTH"); JS_AddModuleExport(ctx, m, "SPIN_BUTTON_SPACING"); JS_AddModuleExport(ctx, m, "LIST_ITEMS_HEIGHT"); diff --git a/src/quickjs.c b/src/quickjs.c index 8e4fec4..7873fd3 100644 --- a/src/quickjs.c +++ b/src/quickjs.c @@ -100,8 +100,6 @@ int app_update_quickjs(){ } } if(IsKeyPressed(KEY_F5)){ - GLFWwindow* window = glfwGetCurrentContext(); - glfwSetWindowShouldClose(window, GLFW_TRUE); shouldReload = true; }