diff --git a/bindings/src/index.ts b/bindings/src/index.ts index 98ef997..a9c59a9 100644 --- a/bindings/src/index.ts +++ b/bindings/src/index.ts @@ -96,15 +96,15 @@ function main(){ properties: { hit: { get: true, set: false }, distance: { get: true, set: false }, - //point: { get: true, set: false }, - //normal: { get: true, set: false }, + point: { get: true, set: false }, + normal: { get: true, set: false }, }, createConstructor: false }) core.addApiStructByName("Camera2D",{ properties: { - offset: { get: false, set: true }, - target: { get: false, set: true }, + offset: { get: true, set: true }, + target: { get: true, set: true }, rotation: { get: true, set: true }, zoom: { get: true, set: true }, }, @@ -121,7 +121,10 @@ function main(){ createConstructor: true }) core.addApiStructByName("BoundingBox",{ - properties: {}, + properties: { + min: { get: true, set: true }, + max: { get: true, set: true }, + }, createConstructor: true }) core.addApiStructByName("Matrix",{ @@ -141,6 +144,7 @@ function main(){ }) core.addApiStructByName("Image", { properties: { + //data: { set: true }, width: { get: true }, height: { get: true }, mipmaps: { get: true }, @@ -166,12 +170,18 @@ function main(){ core.addApiStructByName("Music", { properties: { frameCount: { get: true }, - looping: { get: true, set: true } + looping: { get: true, set: true }, + ctxType: { get: true }, }, //destructor: "UnloadMusicStream" }) core.addApiStructByName("Model", { - properties: {}, + properties: { + transform: { get: true, set: true }, + meshCount: { get: true }, + materialCount: { get: true }, + boneCount: { get: true }, + }, //destructor: "UnloadModel" }) core.addApiStructByName("Mesh", { @@ -195,24 +205,32 @@ function main(){ //destructor: "UnloadMesh" }) core.addApiStructByName("Shader", { - properties: {}, + properties: { + id: { get: true } + }, //destructor: "UnloadShader" }) core.addApiStructByName("Texture", { properties: { width: { get: true }, - height: { get: true } + height: { get: true }, + mipmaps: { get: true }, + format: { get: true }, }, //destructor: "UnloadTexture" }) core.addApiStructByName("Font", { properties: { - baseSize: { get: true } + baseSize: { get: true }, + glyphCount: { get: true }, + glyphPadding: { get: true }, }, //destructor: "UnloadFont" }) core.addApiStructByName("RenderTexture", { - properties: { }, + properties: { + id: { get: true } + }, //destructor: "UnloadRenderTexture" }) core.addApiStructByName("MaterialMap", { @@ -313,7 +331,7 @@ function main(){ // Shader Management core.addApiFunctionByName("LoadShader") - // core.addApiFunctionByName("LoadShaderFromMemory") + core.addApiFunctionByName("LoadShaderFromMemory") core.addApiFunctionByName("IsShaderReady") core.addApiFunctionByName("GetShaderLocation") core.addApiFunctionByName("GetShaderLocationAttrib") @@ -382,17 +400,28 @@ function main(){ // Callbacks not supported on JS // Files management functions - //core.addApiFunctionByName("LoadFileData") - //core.addApiFunctionByName("UnloadLoadFileData") - //core.addApiFunctionByName("SaveFileData") + const lfd = apiDesc.getFunction("LoadFileData") + lfd?.params.pop() + core.addApiFunctionByName("LoadFileData", null, { 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") + } }) + //UnloadLoadFileData not needed, data is copied + // TODO: Works but unnecessary makes copy of memory + core.addApiFunctionByName("SaveFileData") // Export data as code not needed core.addApiFunctionByName("LoadFileText", null, { after: gen => gen.call("UnloadFileText", ["returnVal"]) }) core.addApiFunctionByName("SaveFileText") core.addApiFunctionByName("FileExists") core.addApiFunctionByName("DirectoryExists") core.addApiFunctionByName("IsFileExtension") - // TODO: Who needs to clean memory here? core.addApiFunctionByName("GetFileLength") + // TODO: Who needs to clean memory here? core.addApiFunctionByName("GetFileExtension") core.addApiFunctionByName("GetFileName") core.addApiFunctionByName("GetFileNameWithoutExt") @@ -402,15 +431,15 @@ function main(){ core.addApiFunctionByName("GetApplicationDirectory") core.addApiFunctionByName("ChangeDirectory") core.addApiFunctionByName("IsPathFile") - //core.addApiFunctionByName("LoadPathFiles") - //core.addApiFunctionByName("LoadPathFilesEx") + //core.addApiFunctionByName("LoadDirectoryFiles") + //core.addApiFunctionByName("LoadDirectoryFilesEx") // UnloadDirectoryFiles core.addApiFunctionByName("IsFileDropped") //core.addApiFunctionByName("LoadDroppedFiles") // UnloadDroppedFiles core.addApiFunctionByName("GetFileModTime") - // Compression/encodeing functionality + // Compression/encoding functionality //core.addApiFunctionByName("CompressData") //core.addApiFunctionByName("DecompressData") //core.addApiFunctionByName("EncodeDataBase64") @@ -477,8 +506,7 @@ function main(){ //api.functions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) // module: rshapes - // TODO: Do we need ref-counting here? - //core.addApiFunctionByName("SetShapesTexture") + core.addApiFunctionByName("SetShapesTexture") // Basic shapes drawing functions core.addApiFunctionByName("DrawPixel") @@ -535,7 +563,7 @@ function main(){ core.addApiFunctionByName("LoadImage") core.addApiFunctionByName("LoadImageRaw") // core.addApiFunctionByName("LoadImageAnim") - // core.addApiFunctionByName("LoadImageFromMemory") + core.addApiFunctionByName("LoadImageFromMemory") core.addApiFunctionByName("LoadImageFromTexture") core.addApiFunctionByName("LoadImageFromScreen") core.addApiFunctionByName("IsImageReady") @@ -625,8 +653,8 @@ function main(){ core.addApiFunctionByName("UnloadTexture") core.addApiFunctionByName("IsRenderTextureReady") core.addApiFunctionByName("UnloadRenderTexture") - // core.addApiFunctionByName("UpdateTexture") - // core.addApiFunctionByName("UpdateTextureRec") + core.addApiFunctionByName("UpdateTexture") + core.addApiFunctionByName("UpdateTextureRec") // Texture configuration functions core.addApiFunctionByName("GenTextureMipmaps") @@ -746,7 +774,6 @@ function main(){ core.addApiFunctionByName("DrawBillboardPro") // Mesh management functions - // TODO: Refcounting needed? core.addApiFunctionByName("UploadMesh") core.addApiFunctionByName("UpdateMeshBuffer") core.addApiFunctionByName("UnloadMesh") @@ -805,12 +832,12 @@ function main(){ // Wave/Sound loading/unloading functions core.addApiFunctionByName("LoadWave") - // core.addApiFunctionByName("LoadWaveFromMemory") + core.addApiFunctionByName("LoadWaveFromMemory") core.addApiFunctionByName("IsWaveReady") core.addApiFunctionByName("LoadSound") core.addApiFunctionByName("LoadSoundFromWave") core.addApiFunctionByName("IsSoundReady") - // core.addApiFunctionByName("UpdateSound") + core.addApiFunctionByName("UpdateSound") core.addApiFunctionByName("UnloadWave") core.addApiFunctionByName("UnloadSound") core.addApiFunctionByName("ExportWave") diff --git a/bindings/src/quickjs.ts b/bindings/src/quickjs.ts index 1cba716..cf2be79 100644 --- a/bindings/src/quickjs.ts +++ b/bindings/src/quickjs.ts @@ -84,6 +84,7 @@ export abstract class GenericQuickJsGenerator extend 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") @@ -161,6 +162,9 @@ 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) @@ -186,6 +190,7 @@ export abstract class GenericQuickJsGenerator extend case "float *": case "unsigned short *": case "unsigned char *": + case "const unsigned char *": this.statement(`free((void *)${name})`) break; default: diff --git a/bindings/src/typescript.ts b/bindings/src/typescript.ts index b48a3dc..f499b6f 100644 --- a/bindings/src/typescript.ts +++ b/bindings/src/typescript.ts @@ -38,6 +38,7 @@ export class TypeScriptDeclaration { case "float": case "double": return "number" + case "const unsigned char *": case "unsigned char *": case "unsigned short *": case "float *": diff --git a/examples/lib.raylib.d.ts b/examples/lib.raylib.d.ts index 85602a1..efeb351 100644 --- a/examples/lib.raylib.d.ts +++ b/examples/lib.raylib.d.ts @@ -77,6 +77,10 @@ interface RayCollision { hit: boolean, /** Distance to the nearest hit */ distance: number, + /** Point of the nearest hit */ + point: Vector3, + /** Surface normal of hit */ + normal: Vector3, } declare var RayCollision: { prototype: RayCollision; @@ -112,10 +116,14 @@ declare var Camera3D: { new(position: Vector3, target: Vector3, up: Vector3, fovy: number, projection: number): Camera3D; } interface BoundingBox { + /** Minimum vertex box-corner */ + min: Vector3, + /** Maximum vertex box-corner */ + max: Vector3, } declare var BoundingBox: { prototype: BoundingBox; - new(): BoundingBox; + new(min: Vector3, max: Vector3): BoundingBox; } interface Matrix { } @@ -178,11 +186,21 @@ interface Music { frameCount: number, /** Music looping enable */ looping: boolean, + /** Type of music context (audio filetype) */ + ctxType: number, } declare var Music: { prototype: Music; } interface Model { + /** Local transform matrix */ + transform: Matrix, + /** Number of meshes */ + meshCount: number, + /** Number of materials */ + materialCount: number, + /** Number of bones */ + boneCount: number, } declare var Model: { prototype: Model; @@ -220,6 +238,8 @@ declare var Mesh: { new(): Mesh; } interface Shader { + /** Shader program id */ + id: number, } declare var Shader: { prototype: Shader; @@ -229,6 +249,10 @@ interface Texture { width: number, /** Texture base height */ height: number, + /** Mipmap levels, 1 by default */ + mipmaps: number, + /** Data format (PixelFormat type) */ + format: number, } declare var Texture: { prototype: Texture; @@ -236,11 +260,17 @@ declare var Texture: { interface Font { /** Base size (default chars height) */ baseSize: number, + /** Number of glyph characters */ + glyphCount: number, + /** Padding around the glyph characters */ + glyphPadding: number, } declare var Font: { prototype: Font; } interface RenderTexture { + /** OpenGL framebuffer object id */ + id: number, } declare var RenderTexture: { prototype: RenderTexture; @@ -393,6 +423,8 @@ declare function beginScissorMode(x: number, y: number, width: number, height: n declare function endScissorMode(): void; /** Load shader from files and bind default locations */ declare function loadShader(vsFileName: string, fsFileName: string): Shader; +/** Load shader from code strings and bind default locations */ +declare function loadShaderFromMemory(vsCode: string, fsCode: string): Shader; /** Check if a shader is ready */ declare function isShaderReady(shader: Shader): boolean; /** Get shader uniform location */ @@ -443,6 +475,10 @@ declare function traceLog(logLevel: number, text: string): void; declare function setTraceLogLevel(logLevel: number): void; /** Open URL with default system browser (if available) */ declare function openURL(url: string): void; +/** Load file data as byte array (read) */ +declare function loadFileData(fileName: string): ArrayBuffer; +/** Save data to file from byte array (write), returns true on success */ +declare function saveFileData(fileName: string, data: any, bytesToWrite: number): boolean; /** Load text data from file (read), returns a '\0' terminated string */ declare function loadFileText(fileName: string): string; /** Save text data to file (write), string must be '\0' terminated, returns true on success */ @@ -569,6 +605,8 @@ declare function getGesturePinchAngle(): number; declare function updateCamera(camera: Camera3D, mode: number): void; /** Update camera movement/rotation */ 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 */ declare function drawPixel(posX: number, posY: number, color: Color): void; /** Draw a pixel (Vector version) */ @@ -657,6 +695,8 @@ declare function getCollisionRec(rec1: Rectangle, rec2: Rectangle): Rectangle; declare function loadImage(fileName: string): Image; /** Load image from RAW file data */ declare function loadImageRaw(fileName: string, width: number, height: number, format: number, headerSize: number): Image; +/** Load image from memory buffer, fileType refers to extension: i.e. '.png' */ +declare function loadImageFromMemory(fileType: string, fileData: ArrayBuffer, dataSize: number): Image; /** Load image from GPU texture data */ declare function loadImageFromTexture(texture: Texture): Image; /** Load image from screen buffer and (screenshot) */ @@ -793,6 +833,10 @@ declare function unloadTexture(texture: Texture): void; declare function isRenderTextureReady(target: RenderTexture): boolean; /** Unload render texture from GPU memory (VRAM) */ declare function unloadRenderTexture(target: RenderTexture): void; +/** Update GPU texture with new data */ +declare function updateTexture(texture: Texture, pixels: any): void; +/** Update GPU texture rectangle with new data */ +declare function updateTextureRec(texture: Texture, rec: Rectangle, pixels: any): void; /** Generate GPU mipmaps for a texture */ declare function genTextureMipmaps(texture: Texture): void; /** Set texture scaling filter mode */ @@ -1007,6 +1051,8 @@ declare function isAudioDeviceReady(): boolean; declare function setMasterVolume(volume: number): void; /** Load wave data from file */ declare function loadWave(fileName: string): Wave; +/** Load wave from memory buffer, fileType refers to extension: i.e. '.wav' */ +declare function loadWaveFromMemory(fileType: string, fileData: ArrayBuffer, dataSize: number): Wave; /** Checks if wave data is ready */ declare function isWaveReady(wave: Wave): boolean; /** Load sound from file */ @@ -1015,6 +1061,8 @@ declare function loadSound(fileName: string): Sound; declare function loadSoundFromWave(wave: Wave): Sound; /** Checks if a sound is ready */ declare function isSoundReady(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 */ diff --git a/generate-bindings.js b/generate-bindings.js index f5ccccc..67f1e1e 100644 --- a/generate-bindings.js +++ b/generate-bindings.js @@ -385,6 +385,7 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { 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"); @@ -474,6 +475,9 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { 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) @@ -498,6 +502,7 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { case "float *": case "unsigned short *": case "unsigned char *": + case "const unsigned char *": this.statement(`free((void *)${name})`); break; default: @@ -762,6 +767,7 @@ class TypeScriptDeclaration { case "float": case "double": return "number"; + case "const unsigned char *": case "unsigned char *": case "unsigned short *": case "float *": @@ -979,15 +985,15 @@ function main() { properties: { hit: { get: true, set: false }, distance: { get: true, set: false }, - //point: { get: true, set: false }, - //normal: { get: true, set: false }, + point: { get: true, set: false }, + normal: { get: true, set: false }, }, createConstructor: false }); core.addApiStructByName("Camera2D", { properties: { - offset: { get: false, set: true }, - target: { get: false, set: true }, + offset: { get: true, set: true }, + target: { get: true, set: true }, rotation: { get: true, set: true }, zoom: { get: true, set: true }, }, @@ -1004,7 +1010,10 @@ function main() { createConstructor: true }); core.addApiStructByName("BoundingBox", { - properties: {}, + properties: { + min: { get: true, set: true }, + max: { get: true, set: true }, + }, createConstructor: true }); core.addApiStructByName("Matrix", { @@ -1024,6 +1033,7 @@ function main() { }); core.addApiStructByName("Image", { properties: { + //data: { set: true }, width: { get: true }, height: { get: true }, mipmaps: { get: true }, @@ -1049,12 +1059,18 @@ function main() { core.addApiStructByName("Music", { properties: { frameCount: { get: true }, - looping: { get: true, set: true } + looping: { get: true, set: true }, + ctxType: { get: true }, }, //destructor: "UnloadMusicStream" }); core.addApiStructByName("Model", { - properties: {}, + properties: { + transform: { get: true, set: true }, + meshCount: { get: true }, + materialCount: { get: true }, + boneCount: { get: true }, + }, //destructor: "UnloadModel" }); core.addApiStructByName("Mesh", { @@ -1078,24 +1094,32 @@ function main() { //destructor: "UnloadMesh" }); core.addApiStructByName("Shader", { - properties: {}, + properties: { + id: { get: true } + }, //destructor: "UnloadShader" }); core.addApiStructByName("Texture", { properties: { width: { get: true }, - height: { get: true } + height: { get: true }, + mipmaps: { get: true }, + format: { get: true }, }, //destructor: "UnloadTexture" }); core.addApiStructByName("Font", { properties: { - baseSize: { get: true } + baseSize: { get: true }, + glyphCount: { get: true }, + glyphPadding: { get: true }, }, //destructor: "UnloadFont" }); core.addApiStructByName("RenderTexture", { - properties: {}, + properties: { + id: { get: true } + }, //destructor: "UnloadRenderTexture" }); core.addApiStructByName("MaterialMap", { @@ -1190,7 +1214,7 @@ function main() { //core.addApiFunctionByName("UnloadVrStereoConfig") // Shader Management core.addApiFunctionByName("LoadShader"); - // core.addApiFunctionByName("LoadShaderFromMemory") + core.addApiFunctionByName("LoadShaderFromMemory"); core.addApiFunctionByName("IsShaderReady"); core.addApiFunctionByName("GetShaderLocation"); core.addApiFunctionByName("GetShaderLocationAttrib"); @@ -1254,17 +1278,28 @@ function main() { core.addApiFunctionByName("OpenURL"); // Callbacks not supported on JS // Files management functions - //core.addApiFunctionByName("LoadFileData") - //core.addApiFunctionByName("UnloadLoadFileData") - //core.addApiFunctionByName("SaveFileData") + const lfd = apiDesc.getFunction("LoadFileData"); + lfd?.params.pop(); + core.addApiFunctionByName("LoadFileData", null, { 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"); + } }); + //UnloadLoadFileData not needed, data is copied + // TODO: Works but unnecessary makes copy of memory + core.addApiFunctionByName("SaveFileData"); // Export data as code not needed core.addApiFunctionByName("LoadFileText", null, { after: gen => gen.call("UnloadFileText", ["returnVal"]) }); core.addApiFunctionByName("SaveFileText"); core.addApiFunctionByName("FileExists"); core.addApiFunctionByName("DirectoryExists"); core.addApiFunctionByName("IsFileExtension"); - // TODO: Who needs to clean memory here? core.addApiFunctionByName("GetFileLength"); + // TODO: Who needs to clean memory here? core.addApiFunctionByName("GetFileExtension"); core.addApiFunctionByName("GetFileName"); core.addApiFunctionByName("GetFileNameWithoutExt"); @@ -1274,14 +1309,14 @@ function main() { core.addApiFunctionByName("GetApplicationDirectory"); core.addApiFunctionByName("ChangeDirectory"); core.addApiFunctionByName("IsPathFile"); - //core.addApiFunctionByName("LoadPathFiles") - //core.addApiFunctionByName("LoadPathFilesEx") + //core.addApiFunctionByName("LoadDirectoryFiles") + //core.addApiFunctionByName("LoadDirectoryFilesEx") // UnloadDirectoryFiles core.addApiFunctionByName("IsFileDropped"); //core.addApiFunctionByName("LoadDroppedFiles") // UnloadDroppedFiles core.addApiFunctionByName("GetFileModTime"); - // Compression/encodeing functionality + // Compression/encoding functionality //core.addApiFunctionByName("CompressData") //core.addApiFunctionByName("DecompressData") //core.addApiFunctionByName("EncodeDataBase64") @@ -1340,8 +1375,7 @@ function main() { core.addApiFunctionByName("UpdateCameraPro"); //api.functions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`)) // module: rshapes - // TODO: Do we need ref-counting here? - //core.addApiFunctionByName("SetShapesTexture") + core.addApiFunctionByName("SetShapesTexture"); // Basic shapes drawing functions core.addApiFunctionByName("DrawPixel"); core.addApiFunctionByName("DrawPixelV"); @@ -1395,7 +1429,7 @@ function main() { core.addApiFunctionByName("LoadImage"); core.addApiFunctionByName("LoadImageRaw"); // core.addApiFunctionByName("LoadImageAnim") - // core.addApiFunctionByName("LoadImageFromMemory") + core.addApiFunctionByName("LoadImageFromMemory"); core.addApiFunctionByName("LoadImageFromTexture"); core.addApiFunctionByName("LoadImageFromScreen"); core.addApiFunctionByName("IsImageReady"); @@ -1481,8 +1515,8 @@ function main() { core.addApiFunctionByName("UnloadTexture"); core.addApiFunctionByName("IsRenderTextureReady"); core.addApiFunctionByName("UnloadRenderTexture"); - // core.addApiFunctionByName("UpdateTexture") - // core.addApiFunctionByName("UpdateTextureRec") + core.addApiFunctionByName("UpdateTexture"); + core.addApiFunctionByName("UpdateTextureRec"); // Texture configuration functions core.addApiFunctionByName("GenTextureMipmaps"); core.addApiFunctionByName("SetTextureFilter"); @@ -1588,7 +1622,6 @@ function main() { core.addApiFunctionByName("DrawBillboardRec"); core.addApiFunctionByName("DrawBillboardPro"); // Mesh management functions - // TODO: Refcounting needed? core.addApiFunctionByName("UploadMesh"); core.addApiFunctionByName("UpdateMeshBuffer"); core.addApiFunctionByName("UnloadMesh"); @@ -1640,12 +1673,12 @@ function main() { core.addApiFunctionByName("SetMasterVolume"); // Wave/Sound loading/unloading functions core.addApiFunctionByName("LoadWave"); - // core.addApiFunctionByName("LoadWaveFromMemory") + core.addApiFunctionByName("LoadWaveFromMemory"); core.addApiFunctionByName("IsWaveReady"); core.addApiFunctionByName("LoadSound"); core.addApiFunctionByName("LoadSoundFromWave"); core.addApiFunctionByName("IsSoundReady"); - // core.addApiFunctionByName("UpdateSound") + core.addApiFunctionByName("UpdateSound"); core.addApiFunctionByName("UnloadWave"); core.addApiFunctionByName("UnloadSound"); core.addApiFunctionByName("ExportWave"); diff --git a/src/bindings/js_raylib_core.h b/src/bindings/js_raylib_core.h index 284bd43..164ec54 100644 --- a/src/bindings/js_raylib_core.h +++ b/src/bindings/js_raylib_core.h @@ -494,9 +494,31 @@ static JSValue js_RayCollision_get_distance(JSContext* ctx, JSValueConst this_va return ret; } +static JSValue js_RayCollision_get_point(JSContext* ctx, JSValueConst this_val) { + RayCollision* ptr = JS_GetOpaque2(ctx, this_val, js_RayCollision_class_id); + Vector3 point = ptr->point; + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = point; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_RayCollision_get_normal(JSContext* ctx, JSValueConst this_val) { + RayCollision* ptr = JS_GetOpaque2(ctx, this_val, js_RayCollision_class_id); + Vector3 normal = ptr->normal; + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = normal; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static const JSCFunctionListEntry js_RayCollision_proto_funcs[] = { JS_CGETSET_DEF("hit",js_RayCollision_get_hit,NULL), JS_CGETSET_DEF("distance",js_RayCollision_get_distance,NULL), + JS_CGETSET_DEF("point",js_RayCollision_get_point,NULL), + JS_CGETSET_DEF("normal",js_RayCollision_get_normal,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","RayCollision", JS_PROP_CONFIGURABLE), }; @@ -517,6 +539,16 @@ static void js_Camera2D_finalizer(JSRuntime * rt, JSValue val) { } } +static JSValue js_Camera2D_get_offset(JSContext* ctx, JSValueConst this_val) { + Camera2D* ptr = JS_GetOpaque2(ctx, this_val, js_Camera2D_class_id); + Vector2 offset = ptr->offset; + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = offset; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_Camera2D_set_offset(JSContext* ctx, JSValueConst this_val, JSValueConst v) { Camera2D* ptr = JS_GetOpaque2(ctx, this_val, js_Camera2D_class_id); Vector2* value_ptr = (Vector2*)JS_GetOpaque2(ctx, v, js_Vector2_class_id); @@ -526,6 +558,16 @@ static JSValue js_Camera2D_set_offset(JSContext* ctx, JSValueConst this_val, JSV return JS_UNDEFINED; } +static JSValue js_Camera2D_get_target(JSContext* ctx, JSValueConst this_val) { + Camera2D* ptr = JS_GetOpaque2(ctx, this_val, js_Camera2D_class_id); + Vector2 target = ptr->target; + Vector2* ret_ptr = (Vector2*)js_malloc(ctx, sizeof(Vector2)); + *ret_ptr = target; + JSValue ret = JS_NewObjectClass(ctx, js_Vector2_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_Camera2D_set_target(JSContext* ctx, JSValueConst this_val, JSValueConst v) { Camera2D* ptr = JS_GetOpaque2(ctx, this_val, js_Camera2D_class_id); Vector2* value_ptr = (Vector2*)JS_GetOpaque2(ctx, v, js_Vector2_class_id); @@ -568,8 +610,8 @@ static JSValue js_Camera2D_set_zoom(JSContext* ctx, JSValueConst this_val, JSVal } static const JSCFunctionListEntry js_Camera2D_proto_funcs[] = { - JS_CGETSET_DEF("offset",NULL,js_Camera2D_set_offset), - JS_CGETSET_DEF("target",NULL,js_Camera2D_set_target), + JS_CGETSET_DEF("offset",js_Camera2D_get_offset,js_Camera2D_set_offset), + JS_CGETSET_DEF("target",js_Camera2D_get_target,js_Camera2D_set_target), JS_CGETSET_DEF("rotation",js_Camera2D_get_rotation,js_Camera2D_set_rotation), JS_CGETSET_DEF("zoom",js_Camera2D_get_zoom,js_Camera2D_set_zoom), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Camera2D", JS_PROP_CONFIGURABLE), @@ -696,7 +738,47 @@ static void js_BoundingBox_finalizer(JSRuntime * rt, JSValue val) { } } +static JSValue js_BoundingBox_get_min(JSContext* ctx, JSValueConst this_val) { + BoundingBox* ptr = JS_GetOpaque2(ctx, this_val, js_BoundingBox_class_id); + Vector3 min = ptr->min; + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = min; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_BoundingBox_set_min(JSContext* ctx, JSValueConst this_val, JSValueConst v) { + BoundingBox* ptr = JS_GetOpaque2(ctx, this_val, js_BoundingBox_class_id); + Vector3* value_ptr = (Vector3*)JS_GetOpaque2(ctx, v, js_Vector3_class_id); + if(value_ptr == NULL) return JS_EXCEPTION; + Vector3 value = *value_ptr; + ptr->min = value; + return JS_UNDEFINED; +} + +static JSValue js_BoundingBox_get_max(JSContext* ctx, JSValueConst this_val) { + BoundingBox* ptr = JS_GetOpaque2(ctx, this_val, js_BoundingBox_class_id); + Vector3 max = ptr->max; + Vector3* ret_ptr = (Vector3*)js_malloc(ctx, sizeof(Vector3)); + *ret_ptr = max; + JSValue ret = JS_NewObjectClass(ctx, js_Vector3_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_BoundingBox_set_max(JSContext* ctx, JSValueConst this_val, JSValueConst v) { + BoundingBox* ptr = JS_GetOpaque2(ctx, this_val, js_BoundingBox_class_id); + Vector3* value_ptr = (Vector3*)JS_GetOpaque2(ctx, v, js_Vector3_class_id); + if(value_ptr == NULL) return JS_EXCEPTION; + Vector3 value = *value_ptr; + ptr->max = value; + return JS_UNDEFINED; +} + static const JSCFunctionListEntry js_BoundingBox_proto_funcs[] = { + JS_CGETSET_DEF("min",js_BoundingBox_get_min,js_BoundingBox_set_min), + JS_CGETSET_DEF("max",js_BoundingBox_get_max,js_BoundingBox_set_max), JS_PROP_STRING_DEF("[Symbol.toStringTag]","BoundingBox", JS_PROP_CONFIGURABLE), }; @@ -1015,9 +1097,17 @@ static JSValue js_Music_set_looping(JSContext* ctx, JSValueConst this_val, JSVal return JS_UNDEFINED; } +static JSValue js_Music_get_ctxType(JSContext* ctx, JSValueConst this_val) { + Music* ptr = JS_GetOpaque2(ctx, this_val, js_Music_class_id); + int ctxType = ptr->ctxType; + JSValue ret = JS_NewInt32(ctx, ctxType); + return ret; +} + static const JSCFunctionListEntry js_Music_proto_funcs[] = { JS_CGETSET_DEF("frameCount",js_Music_get_frameCount,NULL), JS_CGETSET_DEF("looping",js_Music_get_looping,js_Music_set_looping), + JS_CGETSET_DEF("ctxType",js_Music_get_ctxType,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Music", JS_PROP_CONFIGURABLE), }; @@ -1038,7 +1128,51 @@ static void js_Model_finalizer(JSRuntime * rt, JSValue val) { } } +static JSValue js_Model_get_transform(JSContext* ctx, JSValueConst this_val) { + Model* ptr = JS_GetOpaque2(ctx, this_val, js_Model_class_id); + Matrix transform = ptr->transform; + Matrix* ret_ptr = (Matrix*)js_malloc(ctx, sizeof(Matrix)); + *ret_ptr = transform; + JSValue ret = JS_NewObjectClass(ctx, js_Matrix_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + +static JSValue js_Model_set_transform(JSContext* ctx, JSValueConst this_val, JSValueConst v) { + Model* ptr = JS_GetOpaque2(ctx, this_val, js_Model_class_id); + Matrix* value_ptr = (Matrix*)JS_GetOpaque2(ctx, v, js_Matrix_class_id); + if(value_ptr == NULL) return JS_EXCEPTION; + Matrix value = *value_ptr; + ptr->transform = value; + return JS_UNDEFINED; +} + +static JSValue js_Model_get_meshCount(JSContext* ctx, JSValueConst this_val) { + Model* ptr = JS_GetOpaque2(ctx, this_val, js_Model_class_id); + int meshCount = ptr->meshCount; + JSValue ret = JS_NewInt32(ctx, meshCount); + return ret; +} + +static JSValue js_Model_get_materialCount(JSContext* ctx, JSValueConst this_val) { + Model* ptr = JS_GetOpaque2(ctx, this_val, js_Model_class_id); + int materialCount = ptr->materialCount; + JSValue ret = JS_NewInt32(ctx, materialCount); + return ret; +} + +static JSValue js_Model_get_boneCount(JSContext* ctx, JSValueConst this_val) { + Model* ptr = JS_GetOpaque2(ctx, this_val, js_Model_class_id); + int boneCount = ptr->boneCount; + JSValue ret = JS_NewInt32(ctx, boneCount); + return ret; +} + static const JSCFunctionListEntry js_Model_proto_funcs[] = { + JS_CGETSET_DEF("transform",js_Model_get_transform,js_Model_set_transform), + JS_CGETSET_DEF("meshCount",js_Model_get_meshCount,NULL), + JS_CGETSET_DEF("materialCount",js_Model_get_materialCount,NULL), + JS_CGETSET_DEF("boneCount",js_Model_get_boneCount,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Model", JS_PROP_CONFIGURABLE), }; @@ -1266,7 +1400,15 @@ static void js_Shader_finalizer(JSRuntime * rt, JSValue val) { } } +static JSValue js_Shader_get_id(JSContext* ctx, JSValueConst this_val) { + Shader* ptr = JS_GetOpaque2(ctx, this_val, js_Shader_class_id); + unsigned int id = ptr->id; + JSValue ret = JS_NewUint32(ctx, id); + return ret; +} + static const JSCFunctionListEntry js_Shader_proto_funcs[] = { + JS_CGETSET_DEF("id",js_Shader_get_id,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Shader", JS_PROP_CONFIGURABLE), }; @@ -1301,9 +1443,25 @@ static JSValue js_Texture_get_height(JSContext* ctx, JSValueConst this_val) { return ret; } +static JSValue js_Texture_get_mipmaps(JSContext* ctx, JSValueConst this_val) { + Texture* ptr = JS_GetOpaque2(ctx, this_val, js_Texture_class_id); + int mipmaps = ptr->mipmaps; + JSValue ret = JS_NewInt32(ctx, mipmaps); + return ret; +} + +static JSValue js_Texture_get_format(JSContext* ctx, JSValueConst this_val) { + Texture* ptr = JS_GetOpaque2(ctx, this_val, js_Texture_class_id); + int format = ptr->format; + JSValue ret = JS_NewInt32(ctx, format); + return ret; +} + static const JSCFunctionListEntry js_Texture_proto_funcs[] = { JS_CGETSET_DEF("width",js_Texture_get_width,NULL), JS_CGETSET_DEF("height",js_Texture_get_height,NULL), + JS_CGETSET_DEF("mipmaps",js_Texture_get_mipmaps,NULL), + JS_CGETSET_DEF("format",js_Texture_get_format,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Texture", JS_PROP_CONFIGURABLE), }; @@ -1331,8 +1489,24 @@ static JSValue js_Font_get_baseSize(JSContext* ctx, JSValueConst this_val) { return ret; } +static JSValue js_Font_get_glyphCount(JSContext* ctx, JSValueConst this_val) { + Font* ptr = JS_GetOpaque2(ctx, this_val, js_Font_class_id); + int glyphCount = ptr->glyphCount; + JSValue ret = JS_NewInt32(ctx, glyphCount); + return ret; +} + +static JSValue js_Font_get_glyphPadding(JSContext* ctx, JSValueConst this_val) { + Font* ptr = JS_GetOpaque2(ctx, this_val, js_Font_class_id); + int glyphPadding = ptr->glyphPadding; + JSValue ret = JS_NewInt32(ctx, glyphPadding); + return ret; +} + static const JSCFunctionListEntry js_Font_proto_funcs[] = { JS_CGETSET_DEF("baseSize",js_Font_get_baseSize,NULL), + JS_CGETSET_DEF("glyphCount",js_Font_get_glyphCount,NULL), + JS_CGETSET_DEF("glyphPadding",js_Font_get_glyphPadding,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Font", JS_PROP_CONFIGURABLE), }; @@ -1353,7 +1527,15 @@ static void js_RenderTexture_finalizer(JSRuntime * rt, JSValue val) { } } +static JSValue js_RenderTexture_get_id(JSContext* ctx, JSValueConst this_val) { + RenderTexture* ptr = JS_GetOpaque2(ctx, this_val, js_RenderTexture_class_id); + unsigned int id = ptr->id; + JSValue ret = JS_NewUint32(ctx, id); + return ret; +} + static const JSCFunctionListEntry js_RenderTexture_proto_funcs[] = { + JS_CGETSET_DEF("id",js_RenderTexture_get_id,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","RenderTexture", JS_PROP_CONFIGURABLE), }; @@ -2112,6 +2294,19 @@ static JSValue js_loadShader(JSContext * ctx, JSValueConst this_val, int argc, J return ret; } +static JSValue js_loadShaderFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * vsCode = (const char *)JS_ToCString(ctx, argv[0]); + const char * fsCode = (const char *)JS_ToCString(ctx, argv[1]); + Shader returnVal = LoadShaderFromMemory(vsCode, fsCode); + JS_FreeCString(ctx, vsCode); + JS_FreeCString(ctx, fsCode); + Shader* ret_ptr = (Shader*)js_malloc(ctx, sizeof(Shader)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Shader_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_isShaderReady(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; @@ -2416,6 +2611,33 @@ static JSValue js_openURL(JSContext * ctx, JSValueConst this_val, int argc, JSVa return JS_UNDEFINED; } +static JSValue js_loadFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileName = (const char *)JS_ToCString(ctx, argv[0]); + unsigned int bytesRead; + unsigned char * retVal = LoadFileData(fileName, &bytesRead); + JSValue buffer = JS_NewArrayBufferCopy(ctx, (const uint8_t*)retVal, bytesRead); + UnloadFileData(retVal); + return buffer; +} + +static JSValue js_saveFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileName = (const char *)JS_ToCString(ctx, argv[0]); + size_t data_size; + void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[1]); + if(data_js == NULL) { + return JS_EXCEPTION; + } + 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); + JS_FreeCString(ctx, fileName); + free((void *)data); + JSValue ret = JS_NewBool(ctx, returnVal); + return ret; +} + static JSValue js_loadFileText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { const char * fileName = (const char *)JS_ToCString(ctx, argv[0]); char * returnVal = LoadFileText(fileName); @@ -2922,6 +3144,17 @@ static JSValue js_updateCameraPro(JSContext * ctx, JSValueConst this_val, int ar return JS_UNDEFINED; } +static JSValue js_setShapesTexture(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; + Rectangle* source_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[1], js_Rectangle_class_id); + if(source_ptr == NULL) return JS_EXCEPTION; + Rectangle source = *source_ptr; + SetShapesTexture(texture, source); + return JS_UNDEFINED; +} + static JSValue js_drawPixel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { int posX; JS_ToInt32(ctx, &posX, argv[0]); @@ -3671,6 +3904,27 @@ static JSValue js_loadImageRaw(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_loadImageFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileType = (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]); + Image returnVal = LoadImageFromMemory(fileType, fileData, dataSize); + 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_loadImageFromTexture(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; @@ -4556,6 +4810,41 @@ static JSValue js_unloadRenderTexture(JSContext * ctx, JSValueConst this_val, in return JS_UNDEFINED; } +static JSValue js_updateTexture(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; + size_t pixels_size; + void * pixels_js = (void *)JS_GetArrayBuffer(ctx, &pixels_size, argv[1]); + if(pixels_js == NULL) { + return JS_EXCEPTION; + } + const void * pixels = malloc(pixels_size); + memcpy((void *)pixels, (const void *)pixels_js, pixels_size); + UpdateTexture(texture, pixels); + free((void *)pixels); + return JS_UNDEFINED; +} + +static JSValue js_updateTextureRec(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; + Rectangle* rec_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[1], js_Rectangle_class_id); + if(rec_ptr == NULL) return JS_EXCEPTION; + Rectangle rec = *rec_ptr; + size_t pixels_size; + void * pixels_js = (void *)JS_GetArrayBuffer(ctx, &pixels_size, argv[2]); + if(pixels_js == NULL) { + return JS_EXCEPTION; + } + const void * pixels = malloc(pixels_size); + memcpy((void *)pixels, (const void *)pixels_js, pixels_size); + UpdateTextureRec(texture, rec, pixels); + free((void *)pixels); + return JS_UNDEFINED; +} + static JSValue js_genTextureMipmaps(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { Texture2D* texture = (Texture2D*)JS_GetOpaque2(ctx, argv[0], js_Texture_class_id); if(texture == NULL) return JS_EXCEPTION; @@ -6159,6 +6448,27 @@ static JSValue js_loadWave(JSContext * ctx, JSValueConst this_val, int argc, JSV return ret; } +static JSValue js_loadWaveFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { + const char * fileType = (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]); + Wave returnVal = LoadWaveFromMemory(fileType, fileData, dataSize); + JS_FreeCString(ctx, fileType); + free((void *)fileData); + Wave* ret_ptr = (Wave*)js_malloc(ctx, sizeof(Wave)); + *ret_ptr = returnVal; + JSValue ret = JS_NewObjectClass(ctx, js_Wave_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static JSValue js_isWaveReady(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; @@ -6200,6 +6510,24 @@ static JSValue js_isSoundReady(JSContext * ctx, JSValueConst this_val, int argc, return ret; } +static JSValue js_updateSound(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; + size_t data_size; + void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[1]); + if(data_js == NULL) { + return JS_EXCEPTION; + } + const void * data = malloc(data_size); + memcpy((void *)data, (const void *)data_js, data_size); + int sampleCount; + JS_ToInt32(ctx, &sampleCount, argv[2]); + UpdateSound(sound, data, sampleCount); + free((void *)data); + return JS_UNDEFINED; +} + static JSValue js_unloadWave(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; @@ -8065,6 +8393,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("beginScissorMode",4,js_beginScissorMode), JS_CFUNC_DEF("endScissorMode",0,js_endScissorMode), JS_CFUNC_DEF("loadShader",2,js_loadShader), + JS_CFUNC_DEF("loadShaderFromMemory",2,js_loadShaderFromMemory), JS_CFUNC_DEF("isShaderReady",1,js_isShaderReady), JS_CFUNC_DEF("getShaderLocation",2,js_getShaderLocation), JS_CFUNC_DEF("getShaderLocationAttrib",2,js_getShaderLocationAttrib), @@ -8090,6 +8419,8 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { 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), JS_CFUNC_DEF("saveFileText",2,js_saveFileText), JS_CFUNC_DEF("fileExists",1,js_fileExists), @@ -8153,6 +8484,7 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("getGesturePinchAngle",0,js_getGesturePinchAngle), JS_CFUNC_DEF("updateCamera",2,js_updateCamera), JS_CFUNC_DEF("updateCameraPro",4,js_updateCameraPro), + JS_CFUNC_DEF("setShapesTexture",2,js_setShapesTexture), JS_CFUNC_DEF("drawPixel",3,js_drawPixel), JS_CFUNC_DEF("drawPixelV",2,js_drawPixelV), JS_CFUNC_DEF("drawLine",5,js_drawLine), @@ -8197,6 +8529,7 @@ 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("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), @@ -8265,6 +8598,8 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("unloadTexture",1,js_unloadTexture), JS_CFUNC_DEF("isRenderTextureReady",1,js_isRenderTextureReady), JS_CFUNC_DEF("unloadRenderTexture",1,js_unloadRenderTexture), + JS_CFUNC_DEF("updateTexture",2,js_updateTexture), + JS_CFUNC_DEF("updateTextureRec",3,js_updateTextureRec), JS_CFUNC_DEF("genTextureMipmaps",1,js_genTextureMipmaps), JS_CFUNC_DEF("setTextureFilter",2,js_setTextureFilter), JS_CFUNC_DEF("setTextureWrap",2,js_setTextureWrap), @@ -8372,10 +8707,12 @@ static const JSCFunctionListEntry js_raylib_core_funcs[] = { JS_CFUNC_DEF("isAudioDeviceReady",0,js_isAudioDeviceReady), JS_CFUNC_DEF("setMasterVolume",1,js_setMasterVolume), JS_CFUNC_DEF("loadWave",1,js_loadWave), + JS_CFUNC_DEF("loadWaveFromMemory",3,js_loadWaveFromMemory), JS_CFUNC_DEF("isWaveReady",1,js_isWaveReady), JS_CFUNC_DEF("loadSound",1,js_loadSound), JS_CFUNC_DEF("loadSoundFromWave",1,js_loadSoundFromWave), JS_CFUNC_DEF("isSoundReady",1,js_isSoundReady), + JS_CFUNC_DEF("updateSound",3,js_updateSound), JS_CFUNC_DEF("unloadWave",1,js_unloadWave), JS_CFUNC_DEF("unloadSound",1,js_unloadSound), JS_CFUNC_DEF("exportWave",2,js_exportWave),