mirror of https://github.com/mode777/rayjs.git
refactor binding generation
This commit is contained in:
parent
8049204120
commit
13f74bf5a1
|
@ -3,6 +3,9 @@ import { RayLibApi, RayLibFunction, RayLibStruct } from "./interfaces";
|
|||
import { RayLibHeader } from "./raylib-header";
|
||||
import { HeaderParser } from "./header-parser";
|
||||
import { RayLibAlias } from "./interfaces";
|
||||
import { QuickJsGenerator } from "./quickjs";
|
||||
|
||||
let api: RayLibApi
|
||||
|
||||
function getFunction(funList: RayLibFunction[], name: string){
|
||||
return funList.find(x => x.name === name)
|
||||
|
@ -16,10 +19,14 @@ function getAliases(aliasList: RayLibAlias[], name: string) {
|
|||
return aliasList.filter(x => x.type === name).map(x => x.name)
|
||||
}
|
||||
|
||||
function ignore(name: string){
|
||||
getFunction(api.functions, name)!.binding = { ignore: true }
|
||||
}
|
||||
|
||||
function main(){
|
||||
|
||||
// Load the pre-generated raylib api
|
||||
const api = <RayLibApi>JSON.parse(readFileSync("thirdparty/raylib/parser/output/raylib_api.json", 'utf8'))
|
||||
api = <RayLibApi>JSON.parse(readFileSync("thirdparty/raylib/parser/output/raylib_api.json", 'utf8'))
|
||||
|
||||
const parser = new HeaderParser()
|
||||
|
||||
|
@ -274,19 +281,19 @@ function main(){
|
|||
//destructor: "UnloadMaterial"
|
||||
}
|
||||
|
||||
getFunction(api.functions, "SetWindowIcons")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "GetWindowHandle")!.binding = { ignore: true }
|
||||
ignore("SetWindowIcons")
|
||||
ignore("GetWindowHandle")
|
||||
|
||||
// Custom frame control functions
|
||||
// NOT SUPPORTED BECAUSE NEEDS COMPILER FLAG
|
||||
getFunction(api.functions, "SwapScreenBuffer")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "PollInputEvents")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "WaitTime")!.binding = { ignore: true }
|
||||
ignore("SwapScreenBuffer")
|
||||
ignore("PollInputEvents")
|
||||
ignore("WaitTime")
|
||||
|
||||
getFunction(api.functions, "BeginVrStereoMode")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "EndVrStereoMode")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "LoadVrStereoConfig")!.binding = { ignore: true }
|
||||
getFunction(api.functions, "UnloadVrStereoConfig")!.binding = { ignore: true }
|
||||
ignore("BeginVrStereoMode")
|
||||
ignore("EndVrStereoMode")
|
||||
ignore("LoadVrStereoConfig")
|
||||
ignore("UnloadVrStereoConfig")
|
||||
|
||||
getFunction(api.functions, "SetShaderValue")!.binding = { body: (gen) => {
|
||||
gen.jsToC("Shader","shader","argv[0]", core.structLookup)
|
||||
|
@ -316,23 +323,28 @@ function main(){
|
|||
gen.call("SetShaderValue", ["shader","locIndex","value","uniformType"])
|
||||
gen.returnExp("JS_UNDEFINED")
|
||||
}}
|
||||
getFunction(api.functions, "SetShaderValueV")!.binding = { ignore: true }
|
||||
ignore("SetShaderValueV")
|
||||
|
||||
const traceLog = getFunction(api.functions, "TraceLog")!
|
||||
traceLog.params?.pop()
|
||||
|
||||
const traceLog = apiDesc.getFunction("TraceLog")
|
||||
if(!traceLog) throw new Error("TraceLog not found")
|
||||
traceLog.params.pop()
|
||||
core.addApiFunction(traceLog)
|
||||
core.addApiFunctionByName("SetTraceLogLevel")
|
||||
// Memory functions not supported on JS
|
||||
core.addApiFunctionByName("OpenURL")
|
||||
// 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 = apiDesc.getFunction("LoadFileData")
|
||||
lfd?.params.pop()
|
||||
core.addApiFunctionByName("LoadFileData", null, { body: gen => {
|
||||
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" })
|
||||
|
@ -340,744 +352,176 @@ function main(){
|
|||
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")
|
||||
core.addApiFunctionByName("GetFileLength")
|
||||
// TODO: Who needs to clean memory here?
|
||||
core.addApiFunctionByName("GetFileExtension")
|
||||
core.addApiFunctionByName("GetFileName")
|
||||
core.addApiFunctionByName("GetFileNameWithoutExt")
|
||||
core.addApiFunctionByName("GetDirectoryPath")
|
||||
core.addApiFunctionByName("GetPrevDirectoryPath")
|
||||
core.addApiFunctionByName("GetWorkingDirectory")
|
||||
core.addApiFunctionByName("GetApplicationDirectory")
|
||||
core.addApiFunctionByName("ChangeDirectory")
|
||||
core.addApiFunctionByName("IsPathFile")
|
||||
//core.addApiFunctionByName("LoadDirectoryFiles")
|
||||
//core.addApiFunctionByName("LoadDirectoryFilesEx")
|
||||
// UnloadDirectoryFiles
|
||||
core.addApiFunctionByName("IsFileDropped")
|
||||
const ldf = apiDesc.getFunction("LoadDroppedFiles")
|
||||
ldf!.returnType = "string[]"
|
||||
core.addApiFunction(ldf!, null, {
|
||||
body: gen => {
|
||||
gen.call("LoadDroppedFiles", [], { type: "FilePathList", name: "files" })
|
||||
}
|
||||
}
|
||||
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"]) }
|
||||
ignore("UnloadFileText")
|
||||
|
||||
const createFileList = (gen: QuickJsGenerator, loadName: string, unloadName: string, args: string[]) => {
|
||||
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("UnloadDroppedFiles", ["files"])
|
||||
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")
|
||||
}
|
||||
})
|
||||
// UnloadDroppedFiles
|
||||
core.addApiFunctionByName("GetFileModTime")
|
||||
}
|
||||
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
|
||||
//core.addApiFunctionByName("CompressData")
|
||||
//core.addApiFunctionByName("DecompressData")
|
||||
//core.addApiFunctionByName("EncodeDataBase64")
|
||||
//core.addApiFunctionByName("DecodeDataBase64")
|
||||
ignore("CompressData")
|
||||
ignore("DecompressData")
|
||||
ignore("EncodeDataBase64")
|
||||
ignore("DecodeDataBase64")
|
||||
|
||||
// input handling functions
|
||||
core.addApiFunctionByName("IsKeyPressed")
|
||||
core.addApiFunctionByName("IsKeyDown")
|
||||
core.addApiFunctionByName("IsKeyReleased")
|
||||
core.addApiFunctionByName("IsKeyUp")
|
||||
core.addApiFunctionByName("SetExitKey")
|
||||
core.addApiFunctionByName("GetKeyPressed")
|
||||
core.addApiFunctionByName("GetCharPressed")
|
||||
ignore("DrawLineStrip")
|
||||
ignore("DrawTriangleFan")
|
||||
ignore("DrawTriangleStrip")
|
||||
ignore("CheckCollisionPointPoly")
|
||||
ignore("CheckCollisionLines")
|
||||
ignore("LoadImageAnim")
|
||||
ignore("ExportImageAsCode")
|
||||
|
||||
// input-related functions: gamepads
|
||||
core.addApiFunctionByName("IsGamepadAvailable")
|
||||
core.addApiFunctionByName("GetGamepadName")
|
||||
core.addApiFunctionByName("IsGamepadButtonPressed")
|
||||
core.addApiFunctionByName("IsGamepadButtonDown")
|
||||
core.addApiFunctionByName("IsGamepadButtonReleased")
|
||||
core.addApiFunctionByName("IsGamepadButtonUp")
|
||||
core.addApiFunctionByName("GetGamepadButtonPressed")
|
||||
core.addApiFunctionByName("GetGamepadAxisCount")
|
||||
core.addApiFunctionByName("GetGamepadAxisMovement")
|
||||
core.addApiFunctionByName("SetGamepadMappings")
|
||||
|
||||
// input-related functions: mouse
|
||||
core.addApiFunctionByName("IsMouseButtonPressed")
|
||||
core.addApiFunctionByName("IsMouseButtonDown")
|
||||
core.addApiFunctionByName("IsMouseButtonReleased")
|
||||
core.addApiFunctionByName("IsMouseButtonUp")
|
||||
core.addApiFunctionByName("GetMouseX")
|
||||
core.addApiFunctionByName("GetMouseY")
|
||||
core.addApiFunctionByName("GetMousePosition")
|
||||
core.addApiFunctionByName("GetMouseDelta")
|
||||
core.addApiFunctionByName("SetMousePosition")
|
||||
core.addApiFunctionByName("SetMouseOffset")
|
||||
core.addApiFunctionByName("SetMouseScale")
|
||||
core.addApiFunctionByName("GetMouseWheelMove")
|
||||
core.addApiFunctionByName("GetMouseWheelMoveV")
|
||||
core.addApiFunctionByName("SetMouseCursor")
|
||||
|
||||
// input-related functions: touch
|
||||
core.addApiFunctionByName("GetTouchX")
|
||||
core.addApiFunctionByName("GetTouchY")
|
||||
core.addApiFunctionByName("GetTouchPosition")
|
||||
core.addApiFunctionByName("GetTouchPointId")
|
||||
core.addApiFunctionByName("GetTouchPointCount")
|
||||
|
||||
// Gesture and touch handling functions
|
||||
core.addApiFunctionByName("SetGesturesEnabled")
|
||||
core.addApiFunctionByName("IsGestureDetected")
|
||||
core.addApiFunctionByName("GetGestureDetected")
|
||||
core.addApiFunctionByName("GetGestureHoldDuration")
|
||||
core.addApiFunctionByName("GetGestureDragVector")
|
||||
core.addApiFunctionByName("GetGestureDragAngle")
|
||||
core.addApiFunctionByName("GetGesturePinchVector")
|
||||
core.addApiFunctionByName("GetGesturePinchAngle")
|
||||
|
||||
// Camera system functions
|
||||
core.addApiFunctionByName("UpdateCamera")
|
||||
core.addApiFunctionByName("UpdateCameraPro")
|
||||
|
||||
//api.functions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`))
|
||||
|
||||
// module: rshapes
|
||||
core.addApiFunctionByName("SetShapesTexture")
|
||||
|
||||
// Basic shapes drawing functions
|
||||
core.addApiFunctionByName("DrawPixel")
|
||||
core.addApiFunctionByName("DrawPixelV")
|
||||
core.addApiFunctionByName("DrawLine")
|
||||
core.addApiFunctionByName("DrawLineV")
|
||||
core.addApiFunctionByName("DrawLineEx")
|
||||
core.addApiFunctionByName("DrawLineBezier")
|
||||
core.addApiFunctionByName("DrawLineBezierQuad")
|
||||
core.addApiFunctionByName("DrawLineBezierCubic")
|
||||
// core.addApiFunctionByName("DrawLineStrip")
|
||||
core.addApiFunctionByName("DrawCircle")
|
||||
core.addApiFunctionByName("DrawCircleSector")
|
||||
core.addApiFunctionByName("DrawCircleSectorLines")
|
||||
core.addApiFunctionByName("DrawCircleGradient")
|
||||
core.addApiFunctionByName("DrawCircleV")
|
||||
core.addApiFunctionByName("DrawCircleLines")
|
||||
core.addApiFunctionByName("DrawEllipse")
|
||||
core.addApiFunctionByName("DrawEllipseLines")
|
||||
core.addApiFunctionByName("DrawRing")
|
||||
core.addApiFunctionByName("DrawRingLines")
|
||||
core.addApiFunctionByName("DrawRectangle")
|
||||
core.addApiFunctionByName("DrawRectangleV")
|
||||
core.addApiFunctionByName("DrawRectangleRec")
|
||||
core.addApiFunctionByName("DrawRectanglePro")
|
||||
core.addApiFunctionByName("DrawRectangleGradientV")
|
||||
core.addApiFunctionByName("DrawRectangleGradientH")
|
||||
core.addApiFunctionByName("DrawRectangleGradientEx")
|
||||
core.addApiFunctionByName("DrawRectangleLines")
|
||||
core.addApiFunctionByName("DrawRectangleLinesEx")
|
||||
core.addApiFunctionByName("DrawRectangleRounded")
|
||||
core.addApiFunctionByName("DrawRectangleRoundedLines")
|
||||
core.addApiFunctionByName("DrawTriangle")
|
||||
core.addApiFunctionByName("DrawTriangleLines")
|
||||
//core.addApiFunctionByName("DrawTriangleFan")
|
||||
//core.addApiFunctionByName("DrawTriangleStrip")
|
||||
core.addApiFunctionByName("DrawPoly")
|
||||
core.addApiFunctionByName("DrawPolyLines")
|
||||
core.addApiFunctionByName("DrawPolyLinesEx")
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
core.addApiFunctionByName("CheckCollisionRecs")
|
||||
core.addApiFunctionByName("CheckCollisionCircles")
|
||||
core.addApiFunctionByName("CheckCollisionCircleRec")
|
||||
core.addApiFunctionByName("CheckCollisionPointRec")
|
||||
core.addApiFunctionByName("CheckCollisionPointCircle")
|
||||
core.addApiFunctionByName("CheckCollisionPointTriangle")
|
||||
// core.addApiFunctionByName("CheckCollisionPointPoly")
|
||||
// core.addApiFunctionByName("CheckCollisionLines")
|
||||
core.addApiFunctionByName("CheckCollisionPointLine")
|
||||
core.addApiFunctionByName("GetCollisionRec")
|
||||
|
||||
// Image loading functions
|
||||
core.addApiFunctionByName("LoadImage")
|
||||
core.addApiFunctionByName("LoadImageRaw")
|
||||
// core.addApiFunctionByName("LoadImageAnim")
|
||||
core.addApiFunctionByName("LoadImageFromMemory")
|
||||
core.addApiFunctionByName("LoadImageFromTexture")
|
||||
core.addApiFunctionByName("LoadImageFromScreen")
|
||||
core.addApiFunctionByName("IsImageReady")
|
||||
core.addApiFunctionByName("UnloadImage")
|
||||
core.addApiFunctionByName("ExportImage")
|
||||
// needed?
|
||||
// core.addApiFunctionByName("ExportImageAsCode")
|
||||
|
||||
// Image generation functions
|
||||
core.addApiFunctionByName("GenImageColor")
|
||||
core.addApiFunctionByName("GenImageGradientV")
|
||||
core.addApiFunctionByName("GenImageGradientH")
|
||||
core.addApiFunctionByName("GenImageGradientRadial")
|
||||
core.addApiFunctionByName("GenImageChecked")
|
||||
core.addApiFunctionByName("GenImageWhiteNoise")
|
||||
core.addApiFunctionByName("GenImagePerlinNoise")
|
||||
core.addApiFunctionByName("GenImageCellular")
|
||||
core.addApiFunctionByName("GenImageText")
|
||||
|
||||
// Image manipulations functions
|
||||
core.addApiFunctionByName("ImageCopy")
|
||||
core.addApiFunctionByName("ImageFromImage")
|
||||
core.addApiFunctionByName("ImageText")
|
||||
core.addApiFunctionByName("ImageTextEx")
|
||||
core.addApiFunctionByName("ImageFormat")
|
||||
core.addApiFunctionByName("ImageToPOT")
|
||||
core.addApiFunctionByName("ImageCrop")
|
||||
core.addApiFunctionByName("ImageAlphaCrop")
|
||||
core.addApiFunctionByName("ImageAlphaClear")
|
||||
core.addApiFunctionByName("ImageAlphaMask")
|
||||
core.addApiFunctionByName("ImageAlphaPremultiply")
|
||||
core.addApiFunctionByName("ImageBlurGaussian")
|
||||
core.addApiFunctionByName("ImageResize")
|
||||
core.addApiFunctionByName("ImageResizeNN")
|
||||
core.addApiFunctionByName("ImageResizeCanvas")
|
||||
core.addApiFunctionByName("ImageMipmaps")
|
||||
core.addApiFunctionByName("ImageDither")
|
||||
core.addApiFunctionByName("ImageFlipVertical")
|
||||
core.addApiFunctionByName("ImageFlipHorizontal")
|
||||
core.addApiFunctionByName("ImageRotateCW")
|
||||
core.addApiFunctionByName("ImageRotateCCW")
|
||||
core.addApiFunctionByName("ImageColorTint")
|
||||
core.addApiFunctionByName("ImageColorInvert")
|
||||
core.addApiFunctionByName("ImageColorGrayscale")
|
||||
core.addApiFunctionByName("ImageColorContrast")
|
||||
core.addApiFunctionByName("ImageColorBrightness")
|
||||
core.addApiFunctionByName("ImageColorReplace")
|
||||
const lic = <ApiFunction>apiDesc.getFunction("LoadImageColors")
|
||||
lic.returnType = "unsigned char *"
|
||||
core.addApiFunction(lic, null, { body: (gen) => {
|
||||
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")
|
||||
}})
|
||||
//core.addApiFunctionByName("LoadImagePalette")
|
||||
//core.addApiFunctionByName("UnloadImageColors")
|
||||
//core.addApiFunctionByName("UnloadImagePalette")
|
||||
core.addApiFunctionByName("GetImageAlphaBorder")
|
||||
core.addApiFunctionByName("GetImageColor")
|
||||
}
|
||||
}
|
||||
|
||||
// Image drawing functions
|
||||
core.addApiFunctionByName("ImageClearBackground")
|
||||
core.addApiFunctionByName("ImageDrawPixel")
|
||||
core.addApiFunctionByName("ImageDrawPixelV")
|
||||
core.addApiFunctionByName("ImageDrawLine")
|
||||
core.addApiFunctionByName("ImageDrawLineV")
|
||||
core.addApiFunctionByName("ImageDrawCircle")
|
||||
core.addApiFunctionByName("ImageDrawCircleV")
|
||||
core.addApiFunctionByName("ImageDrawCircleLines")
|
||||
core.addApiFunctionByName("ImageDrawCircleLinesV")
|
||||
core.addApiFunctionByName("ImageDrawRectangle")
|
||||
core.addApiFunctionByName("ImageDrawRectangleV")
|
||||
core.addApiFunctionByName("ImageDrawRectangleRec")
|
||||
core.addApiFunctionByName("ImageDrawRectangleLines")
|
||||
core.addApiFunctionByName("ImageDraw")
|
||||
core.addApiFunctionByName("ImageDrawText")
|
||||
core.addApiFunctionByName("ImageDrawTextEx")
|
||||
ignore("LoadImagePalette")
|
||||
ignore("UnloadImageColors")
|
||||
ignore("UnloadImagePalette")
|
||||
ignore("GetPixelColor")
|
||||
ignore("SetPixelColor")
|
||||
|
||||
// Texture loading functions
|
||||
core.addApiFunctionByName("LoadTexture")
|
||||
core.addApiFunctionByName("LoadTextureFromImage")
|
||||
core.addApiFunctionByName("LoadTextureCubemap")
|
||||
core.addApiFunctionByName("LoadRenderTexture")
|
||||
core.addApiFunctionByName("IsTextureReady")
|
||||
core.addApiFunctionByName("UnloadTexture")
|
||||
core.addApiFunctionByName("IsRenderTextureReady")
|
||||
core.addApiFunctionByName("UnloadRenderTexture")
|
||||
core.addApiFunctionByName("UpdateTexture")
|
||||
core.addApiFunctionByName("UpdateTextureRec")
|
||||
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);" }
|
||||
|
||||
// Texture configuration functions
|
||||
core.addApiFunctionByName("GenTextureMipmaps")
|
||||
core.addApiFunctionByName("SetTextureFilter")
|
||||
core.addApiFunctionByName("SetTextureWrap")
|
||||
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")
|
||||
|
||||
// Texture drawing functions
|
||||
core.addApiFunctionByName("DrawTexture")
|
||||
core.addApiFunctionByName("DrawTextureV")
|
||||
core.addApiFunctionByName("DrawTextureEx")
|
||||
core.addApiFunctionByName("DrawTextureRec")
|
||||
core.addApiFunctionByName("DrawTexturePro")
|
||||
core.addApiFunctionByName("DrawTextureNPatch")
|
||||
|
||||
// Color/pixel related functions
|
||||
core.addApiFunctionByName("Fade")
|
||||
core.addApiFunctionByName("ColorToInt")
|
||||
core.addApiFunctionByName("ColorNormalize")
|
||||
core.addApiFunctionByName("ColorFromNormalized")
|
||||
core.addApiFunctionByName("ColorToHSV")
|
||||
core.addApiFunctionByName("ColorFromHSV")
|
||||
core.addApiFunctionByName("ColorTint")
|
||||
core.addApiFunctionByName("ColorBrightness")
|
||||
core.addApiFunctionByName("ColorContrast")
|
||||
core.addApiFunctionByName("ColorAlpha")
|
||||
core.addApiFunctionByName("ColorAlphaBlend")
|
||||
core.addApiFunctionByName("GetColor")
|
||||
// core.addApiFunctionByName("GetPixelColor")
|
||||
// core.addApiFunctionByName("SetPixelColor")
|
||||
core.addApiFunctionByName("GetPixelDataSize")
|
||||
|
||||
// module: rtext
|
||||
|
||||
// Font loading/unloading
|
||||
core.addApiFunctionByName("GetFontDefault")
|
||||
core.addApiFunctionByName("LoadFont")
|
||||
const lfx = apiDesc.getFunction("LoadFontEx")
|
||||
lfx?.params!.pop()
|
||||
lfx?.params!.pop()
|
||||
core.addApiFunction(lfx!, null, { customizeCall: "Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0);" })
|
||||
core.addApiFunctionByName("LoadFontFromImage")
|
||||
// core.addApiFunctionByName("LoadFontFromMemory")
|
||||
core.addApiFunctionByName("IsFontReady")
|
||||
// core.addApiFunctionByName("LoadFontData")
|
||||
// core.addApiFunctionByName("GenImageFontAtlas")
|
||||
// core.addApiFunctionByName("UnloadFontData")
|
||||
core.addApiFunctionByName("UnloadFont")
|
||||
// core.addApiFunctionByName("ExportFontAsCode")
|
||||
|
||||
// Text drawing functions
|
||||
core.addApiFunctionByName("DrawFPS")
|
||||
core.addApiFunctionByName("DrawText")
|
||||
core.addApiFunctionByName("DrawTextEx")
|
||||
core.addApiFunctionByName("DrawTextPro")
|
||||
core.addApiFunctionByName("DrawTextCodepoint")
|
||||
//core.addApiFunctionByName("DrawTextCodepoints")
|
||||
|
||||
// Text font info functions
|
||||
core.addApiFunctionByName("MeasureText")
|
||||
core.addApiFunctionByName("MeasureTextEx")
|
||||
core.addApiFunctionByName("GetGlyphIndex")
|
||||
// core.addApiFunctionByName("GetGlyphInfo")
|
||||
core.addApiFunctionByName("GetGlyphAtlasRec")
|
||||
|
||||
// Text codepoints management functions (unicode characters)
|
||||
// Is this needed?
|
||||
// core.addApiFunctionByName("LoadUTF8")
|
||||
// core.addApiFunctionByName("UnloadUTF8")
|
||||
// core.addApiFunctionByName("LoadCodepoints")
|
||||
// core.addApiFunctionByName("UnloadCodepoints")
|
||||
// core.addApiFunctionByName("GetCodepointCount")
|
||||
// core.addApiFunctionByName("GetCodepoint")
|
||||
// core.addApiFunctionByName("GetCodepointNext")
|
||||
// core.addApiFunctionByName("GetCodepointPrevious")
|
||||
// core.addApiFunctionByName("CodepointToUTF8")
|
||||
|
||||
// Text strings management functions (no UTF-8 strings, only byte chars)
|
||||
// Not supported, use JS Stdlib instead
|
||||
api.functions.filter(x => x.name.startsWith("Text")).forEach(x => ignore(x.name))
|
||||
|
||||
// module: rmodels
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
core.addApiFunctionByName("DrawLine3D")
|
||||
core.addApiFunctionByName("DrawPoint3D")
|
||||
core.addApiFunctionByName("DrawCircle3D")
|
||||
core.addApiFunctionByName("DrawTriangle3D")
|
||||
//core.addApiFunctionByName("DrawTriangleStrip3D")
|
||||
core.addApiFunctionByName("DrawCube")
|
||||
core.addApiFunctionByName("DrawCubeV")
|
||||
core.addApiFunctionByName("DrawCubeWires")
|
||||
core.addApiFunctionByName("DrawCubeWiresV")
|
||||
core.addApiFunctionByName("DrawSphere")
|
||||
core.addApiFunctionByName("DrawSphereEx")
|
||||
core.addApiFunctionByName("DrawSphereWires")
|
||||
core.addApiFunctionByName("DrawCylinder")
|
||||
core.addApiFunctionByName("DrawCylinderEx")
|
||||
core.addApiFunctionByName("DrawCylinderWires")
|
||||
core.addApiFunctionByName("DrawCylinderWiresEx")
|
||||
core.addApiFunctionByName("DrawCapsule")
|
||||
core.addApiFunctionByName("DrawCapsuleWires")
|
||||
core.addApiFunctionByName("DrawPlane")
|
||||
core.addApiFunctionByName("DrawRay")
|
||||
core.addApiFunctionByName("DrawGrid")
|
||||
|
||||
// model management functions
|
||||
core.addApiFunctionByName("LoadModel")
|
||||
core.addApiFunctionByName("LoadModelFromMesh")
|
||||
core.addApiFunctionByName("IsModelReady")
|
||||
core.addApiFunctionByName("UnloadModel")
|
||||
core.addApiFunctionByName("GetModelBoundingBox")
|
||||
|
||||
// model drawing functions
|
||||
core.addApiFunctionByName("DrawModel")
|
||||
core.addApiFunctionByName("DrawModelEx")
|
||||
core.addApiFunctionByName("DrawModelWires")
|
||||
core.addApiFunctionByName("DrawModelWiresEx")
|
||||
core.addApiFunctionByName("DrawBoundingBox")
|
||||
core.addApiFunctionByName("DrawBillboard")
|
||||
core.addApiFunctionByName("DrawBillboardRec")
|
||||
core.addApiFunctionByName("DrawBillboardPro")
|
||||
|
||||
// Mesh management functions
|
||||
core.addApiFunctionByName("UploadMesh")
|
||||
core.addApiFunctionByName("UpdateMeshBuffer")
|
||||
core.addApiFunctionByName("UnloadMesh")
|
||||
core.addApiFunctionByName("DrawMesh")
|
||||
core.addApiFunctionByName("DrawMeshInstanced")
|
||||
core.addApiFunctionByName("ExportMesh")
|
||||
core.addApiFunctionByName("GetMeshBoundingBox")
|
||||
core.addApiFunctionByName("GenMeshTangents")
|
||||
|
||||
// Mesh generation functions
|
||||
core.addApiFunctionByName("GenMeshPoly")
|
||||
core.addApiFunctionByName("GenMeshPlane")
|
||||
core.addApiFunctionByName("GenMeshCube")
|
||||
core.addApiFunctionByName("GenMeshSphere")
|
||||
core.addApiFunctionByName("GenMeshHemiSphere")
|
||||
core.addApiFunctionByName("GenMeshCylinder")
|
||||
core.addApiFunctionByName("GenMeshCone")
|
||||
core.addApiFunctionByName("GenMeshTorus")
|
||||
core.addApiFunctionByName("GenMeshKnot")
|
||||
core.addApiFunctionByName("GenMeshHeightmap")
|
||||
core.addApiFunctionByName("GenMeshCubicmap")
|
||||
|
||||
// Material loading/unloading functions
|
||||
// core.addApiFunctionByName("LoadMaterials")
|
||||
core.addApiFunctionByName("LoadMaterialDefault")
|
||||
core.addApiFunctionByName("IsMaterialReady")
|
||||
core.addApiFunctionByName("UnloadMaterial")
|
||||
core.addApiFunctionByName("SetMaterialTexture")
|
||||
core.addApiFunctionByName("SetModelMaterial")
|
||||
core.addApiFunctionByName("SetModelMeshMaterial")
|
||||
|
||||
// Model animations loading/unloading functions
|
||||
// core.addApiFunctionByName("LoadModelAnimations")
|
||||
// core.addApiFunctionByName("UpdateModelAnimation")
|
||||
// core.addApiFunctionByName("UnloadModelAnimation")
|
||||
// core.addApiFunctionByName("UnloadModelAnimations")
|
||||
// core.addApiFunctionByName("IsModelAnimationValid")
|
||||
|
||||
// Collision detection functions
|
||||
core.addApiFunctionByName("CheckCollisionSpheres")
|
||||
core.addApiFunctionByName("CheckCollisionBoxes")
|
||||
core.addApiFunctionByName("CheckCollisionBoxSphere")
|
||||
core.addApiFunctionByName("GetRayCollisionSphere")
|
||||
core.addApiFunctionByName("GetRayCollisionBox")
|
||||
core.addApiFunctionByName("GetRayCollisionMesh")
|
||||
core.addApiFunctionByName("GetRayCollisionTriangle")
|
||||
core.addApiFunctionByName("GetRayCollisionQuad")
|
||||
|
||||
// module: raudio
|
||||
|
||||
// Audio device management functions
|
||||
core.addApiFunctionByName("InitAudioDevice")
|
||||
core.addApiFunctionByName("CloseAudioDevice")
|
||||
core.addApiFunctionByName("IsAudioDeviceReady")
|
||||
core.addApiFunctionByName("SetMasterVolume")
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
core.addApiFunctionByName("LoadWave")
|
||||
core.addApiFunctionByName("LoadWaveFromMemory")
|
||||
core.addApiFunctionByName("IsWaveReady")
|
||||
core.addApiFunctionByName("LoadSound")
|
||||
core.addApiFunctionByName("LoadSoundFromWave")
|
||||
core.addApiFunctionByName("IsSoundReady")
|
||||
core.addApiFunctionByName("UpdateSound")
|
||||
core.addApiFunctionByName("UnloadWave")
|
||||
core.addApiFunctionByName("UnloadSound")
|
||||
core.addApiFunctionByName("ExportWave")
|
||||
// core.addApiFunctionByName("ExportWaveAsCode")
|
||||
ignore("DrawTriangleStrip3D")
|
||||
ignore("LoadMaterials")
|
||||
ignore("LoadModelAnimations")
|
||||
ignore("UpdateModelAnimation")
|
||||
ignore("UnloadModelAnimation")
|
||||
ignore("UnloadModelAnimations")
|
||||
ignore("IsModelAnimationValid")
|
||||
ignore("ExportWaveAsCode")
|
||||
|
||||
// Wave/Sound management functions
|
||||
core.addApiFunctionByName("PlaySound")
|
||||
core.addApiFunctionByName("StopSound")
|
||||
core.addApiFunctionByName("PauseSound")
|
||||
core.addApiFunctionByName("ResumeSound")
|
||||
core.addApiFunctionByName("IsSoundPlaying")
|
||||
core.addApiFunctionByName("SetSoundVolume")
|
||||
core.addApiFunctionByName("SetSoundPitch")
|
||||
core.addApiFunctionByName("SetSoundPan")
|
||||
core.addApiFunctionByName("WaveCopy")
|
||||
core.addApiFunctionByName("WaveCrop")
|
||||
core.addApiFunctionByName("WaveFormat")
|
||||
// core.addApiFunctionByName("LoadWaveSamples")
|
||||
// core.addApiFunctionByName("UnloadWaveSamples")
|
||||
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")
|
||||
|
||||
// Music management functions
|
||||
core.addApiFunctionByName("LoadMusicStream")
|
||||
// core.addApiFunctionByName("LoadMusicStreamFromMemory")
|
||||
core.addApiFunctionByName("IsMusicReady")
|
||||
core.addApiFunctionByName("UnloadMusicStream")
|
||||
core.addApiFunctionByName("PlayMusicStream")
|
||||
core.addApiFunctionByName("IsMusicStreamPlaying")
|
||||
core.addApiFunctionByName("UpdateMusicStream")
|
||||
core.addApiFunctionByName("StopMusicStream")
|
||||
core.addApiFunctionByName("PauseMusicStream")
|
||||
core.addApiFunctionByName("ResumeMusicStream")
|
||||
core.addApiFunctionByName("SeekMusicStream")
|
||||
core.addApiFunctionByName("SetMusicVolume")
|
||||
core.addApiFunctionByName("SetMusicPitch")
|
||||
core.addApiFunctionByName("SetMusicPan")
|
||||
core.addApiFunctionByName("GetMusicTimeLength")
|
||||
core.addApiFunctionByName("GetMusicTimePlayed")
|
||||
|
||||
// AudioStream management functions
|
||||
// core.addApiFunctionByName("LoadAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamReady")
|
||||
// core.addApiFunctionByName("UnloadAudioStream")
|
||||
// core.addApiFunctionByName("UpdateAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamProcessed")
|
||||
// core.addApiFunctionByName("PlayAudioStream")
|
||||
// core.addApiFunctionByName("PauseAudioStream")
|
||||
// core.addApiFunctionByName("ResumeAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamPlaying")
|
||||
// core.addApiFunctionByName("StopAudioStream")
|
||||
// core.addApiFunctionByName("SetAudioStreamVolume")
|
||||
// core.addApiFunctionByName("SetAudioStreamPitch")
|
||||
// core.addApiFunctionByName("SetAudioStreamPan")
|
||||
// core.addApiFunctionByName("SetAudioStreamBufferSizeDefault")
|
||||
// core.addApiFunctionByName("SetAudioStreamCallback")
|
||||
|
||||
// core.addApiFunctionByName("AttachAudioStreamProcessor")
|
||||
// core.addApiFunctionByName("DetachAudioStreamProcessor")
|
||||
|
||||
// core.addApiFunctionByName("AttachAudioMixedProcessor")
|
||||
// core.addApiFunctionByName("DetachAudioMixedProcessor")
|
||||
|
||||
// module: raymath
|
||||
|
||||
core.addApiFunctionByName("Clamp")
|
||||
core.addApiFunctionByName("Lerp")
|
||||
core.addApiFunctionByName("Normalize")
|
||||
core.addApiFunctionByName("Remap")
|
||||
core.addApiFunctionByName("Wrap")
|
||||
core.addApiFunctionByName("FloatEquals")
|
||||
core.addApiFunctionByName("Vector2Zero")
|
||||
core.addApiFunctionByName("Vector2One")
|
||||
core.addApiFunctionByName("Vector2Add")
|
||||
core.addApiFunctionByName("Vector2AddValue")
|
||||
core.addApiFunctionByName("Vector2Subtract")
|
||||
core.addApiFunctionByName("Vector2SubtractValue")
|
||||
core.addApiFunctionByName("Vector2Length")
|
||||
core.addApiFunctionByName("Vector2LengthSqr")
|
||||
core.addApiFunctionByName("Vector2DotProduct")
|
||||
core.addApiFunctionByName("Vector2Distance")
|
||||
core.addApiFunctionByName("Vector2DistanceSqr")
|
||||
core.addApiFunctionByName("Vector2Angle")
|
||||
core.addApiFunctionByName("Vector2LineAngle")
|
||||
core.addApiFunctionByName("Vector2Scale")
|
||||
core.addApiFunctionByName("Vector2Multiply")
|
||||
core.addApiFunctionByName("Vector2Negate")
|
||||
core.addApiFunctionByName("Vector2Divide")
|
||||
core.addApiFunctionByName("Vector2Normalize")
|
||||
core.addApiFunctionByName("Vector2Transform")
|
||||
core.addApiFunctionByName("Vector2Lerp")
|
||||
core.addApiFunctionByName("Vector2Reflect")
|
||||
core.addApiFunctionByName("Vector2Rotate")
|
||||
core.addApiFunctionByName("Vector2MoveTowards")
|
||||
core.addApiFunctionByName("Vector2Invert")
|
||||
core.addApiFunctionByName("Vector2Clamp")
|
||||
core.addApiFunctionByName("Vector2ClampValue")
|
||||
core.addApiFunctionByName("Vector2Equals")
|
||||
core.addApiFunctionByName("Vector3Zero")
|
||||
core.addApiFunctionByName("Vector3One")
|
||||
core.addApiFunctionByName("Vector3Add")
|
||||
core.addApiFunctionByName("Vector3AddValue")
|
||||
core.addApiFunctionByName("Vector3Subtract")
|
||||
core.addApiFunctionByName("Vector3SubtractValue")
|
||||
core.addApiFunctionByName("Vector3Scale")
|
||||
core.addApiFunctionByName("Vector3Multiply")
|
||||
core.addApiFunctionByName("Vector3CrossProduct")
|
||||
core.addApiFunctionByName("Vector3Perpendicular")
|
||||
core.addApiFunctionByName("Vector3Length")
|
||||
core.addApiFunctionByName("Vector3LengthSqr")
|
||||
core.addApiFunctionByName("Vector3DotProduct")
|
||||
core.addApiFunctionByName("Vector3Distance")
|
||||
core.addApiFunctionByName("Vector3DistanceSqr")
|
||||
core.addApiFunctionByName("Vector3Angle")
|
||||
core.addApiFunctionByName("Vector3Negate")
|
||||
core.addApiFunctionByName("Vector3Divide")
|
||||
core.addApiFunctionByName("Vector3Normalize")
|
||||
//core.addApiFunctionByName("Vector3OrthoNormalize")
|
||||
core.addApiFunctionByName("Vector3Transform")
|
||||
core.addApiFunctionByName("Vector3RotateByQuaternion")
|
||||
core.addApiFunctionByName("Vector3RotateByAxisAngle")
|
||||
core.addApiFunctionByName("Vector3Lerp")
|
||||
core.addApiFunctionByName("Vector3Reflect")
|
||||
core.addApiFunctionByName("Vector3Min")
|
||||
core.addApiFunctionByName("Vector3Max")
|
||||
core.addApiFunctionByName("Vector3Barycenter")
|
||||
core.addApiFunctionByName("Vector3Unproject")
|
||||
//core.addApiFunctionByName("Vector3ToFloatV")
|
||||
core.addApiFunctionByName("Vector3Invert")
|
||||
core.addApiFunctionByName("Vector3Clamp")
|
||||
core.addApiFunctionByName("Vector3ClampValue")
|
||||
core.addApiFunctionByName("Vector3Equals")
|
||||
core.addApiFunctionByName("Vector3Refract")
|
||||
core.addApiFunctionByName("MatrixDeterminant")
|
||||
core.addApiFunctionByName("MatrixTrace")
|
||||
core.addApiFunctionByName("MatrixTranspose")
|
||||
core.addApiFunctionByName("MatrixInvert")
|
||||
core.addApiFunctionByName("MatrixIdentity")
|
||||
core.addApiFunctionByName("MatrixAdd")
|
||||
core.addApiFunctionByName("MatrixSubtract")
|
||||
core.addApiFunctionByName("MatrixMultiply")
|
||||
core.addApiFunctionByName("MatrixTranslate")
|
||||
core.addApiFunctionByName("MatrixRotate")
|
||||
core.addApiFunctionByName("MatrixRotateX")
|
||||
core.addApiFunctionByName("MatrixRotateY")
|
||||
core.addApiFunctionByName("MatrixRotateZ")
|
||||
core.addApiFunctionByName("MatrixRotateXYZ")
|
||||
core.addApiFunctionByName("MatrixRotateZYX")
|
||||
core.addApiFunctionByName("MatrixScale")
|
||||
core.addApiFunctionByName("MatrixFrustum")
|
||||
core.addApiFunctionByName("MatrixPerspective")
|
||||
core.addApiFunctionByName("MatrixOrtho")
|
||||
core.addApiFunctionByName("MatrixLookAt")
|
||||
//core.addApiFunctionByName("MatrixToFloatV")
|
||||
core.addApiFunctionByName("QuaternionAdd")
|
||||
core.addApiFunctionByName("QuaternionAddValue")
|
||||
core.addApiFunctionByName("QuaternionSubtract")
|
||||
core.addApiFunctionByName("QuaternionSubtractValue")
|
||||
core.addApiFunctionByName("QuaternionIdentity")
|
||||
core.addApiFunctionByName("QuaternionLength")
|
||||
core.addApiFunctionByName("QuaternionNormalize")
|
||||
core.addApiFunctionByName("QuaternionInvert")
|
||||
core.addApiFunctionByName("QuaternionMultiply")
|
||||
core.addApiFunctionByName("QuaternionScale")
|
||||
core.addApiFunctionByName("QuaternionDivide")
|
||||
core.addApiFunctionByName("QuaternionLerp")
|
||||
core.addApiFunctionByName("QuaternionNlerp")
|
||||
core.addApiFunctionByName("QuaternionSlerp")
|
||||
core.addApiFunctionByName("QuaternionFromVector3ToVector3")
|
||||
core.addApiFunctionByName("QuaternionFromMatrix")
|
||||
core.addApiFunctionByName("QuaternionToMatrix")
|
||||
core.addApiFunctionByName("QuaternionFromAxisAngle")
|
||||
//core.addApiFunctionByName("QuaternionToAxisAngle")
|
||||
core.addApiFunctionByName("QuaternionFromEuler")
|
||||
core.addApiFunctionByName("QuaternionToEuler")
|
||||
core.addApiFunctionByName("QuaternionTransform")
|
||||
core.addApiFunctionByName("QuaternionEquals")
|
||||
ignore("Vector3OrthoNormalize")
|
||||
ignore("Vector3ToFloatV")
|
||||
ignore("MatrixToFloatV")
|
||||
ignore("QuaternionToAxisAngle")
|
||||
core.exportGlobalConstant("DEG2RAD", "(PI/180.0)")
|
||||
core.exportGlobalConstant("RAD2DEG", "(180.0/PI)")
|
||||
|
||||
// module: rcamera
|
||||
core.addApiFunctionByName("GetCameraForward")
|
||||
core.addApiFunctionByName("GetCameraUp")
|
||||
core.addApiFunctionByName("GetCameraRight")
|
||||
core.addApiFunctionByName("CameraMoveForward")
|
||||
core.addApiFunctionByName("CameraMoveUp")
|
||||
core.addApiFunctionByName("CameraMoveRight")
|
||||
core.addApiFunctionByName("CameraMoveToTarget")
|
||||
core.addApiFunctionByName("CameraYaw")
|
||||
core.addApiFunctionByName("CameraPitch")
|
||||
core.addApiFunctionByName("CameraRoll")
|
||||
core.addApiFunctionByName("GetCameraViewMatrix")
|
||||
core.addApiFunctionByName("GetCameraProjectionMatrix")
|
||||
|
||||
// module: rgui
|
||||
core.addApiFunctionByName("GuiEnable")
|
||||
core.addApiFunctionByName("GuiDisable")
|
||||
core.addApiFunctionByName("GuiLock")
|
||||
core.addApiFunctionByName("GuiUnlock")
|
||||
core.addApiFunctionByName("GuiIsLocked")
|
||||
core.addApiFunctionByName("GuiFade")
|
||||
core.addApiFunctionByName("GuiSetState")
|
||||
core.addApiFunctionByName("GuiGetState")
|
||||
core.addApiFunctionByName("GuiSetFont")
|
||||
core.addApiFunctionByName("GuiGetFont")
|
||||
core.addApiFunctionByName("GuiSetStyle")
|
||||
core.addApiFunctionByName("GuiGetStyle")
|
||||
core.addApiFunctionByName("GuiWindowBox")
|
||||
core.addApiFunctionByName("GuiGroupBox")
|
||||
core.addApiFunctionByName("GuiLine")
|
||||
core.addApiFunctionByName("GuiPanel")
|
||||
core.addApiFunctionByName("GuiScrollPanel")
|
||||
core.addApiFunctionByName("GuiLabel")
|
||||
core.addApiFunctionByName("GuiButton")
|
||||
core.addApiFunctionByName("GuiLabelButton")
|
||||
core.addApiFunctionByName("GuiToggle")
|
||||
core.addApiFunctionByName("GuiToggleGroup")
|
||||
core.addApiFunctionByName("GuiCheckBox")
|
||||
core.addApiFunctionByName("GuiComboBox")
|
||||
//core.addApiFunctionByName("GuiDropdownBox")
|
||||
//core.addApiFunctionByName("GuiSpinner")
|
||||
//core.addApiFunctionByName("GuiValueBox")
|
||||
core.addApiFunctionByName("GuiTextBox")
|
||||
//core.addApiFunctionByName("GuiTextBoxMulti")
|
||||
core.addApiFunctionByName("GuiSlider")
|
||||
core.addApiFunctionByName("GuiSliderBar")
|
||||
core.addApiFunctionByName("GuiProgressBar")
|
||||
core.addApiFunctionByName("GuiStatusBar")
|
||||
core.addApiFunctionByName("GuiDummyRec")
|
||||
core.addApiFunctionByName("GuiGrid")
|
||||
//core.addApiFunctionByName("GuiListView")
|
||||
//core.addApiFunctionByName("GuiListViewEx")
|
||||
core.addApiFunctionByName("GuiMessageBox")
|
||||
//core.addApiFunctionByName("GuiTextInputBox")
|
||||
core.addApiFunctionByName("GuiColorPicker")
|
||||
core.addApiFunctionByName("GuiColorPanel")
|
||||
core.addApiFunctionByName("GuiColorBarAlpha")
|
||||
core.addApiFunctionByName("GuiColorBarHue")
|
||||
core.addApiFunctionByName("GuiLoadStyle")
|
||||
core.addApiFunctionByName("GuiLoadStyleDefault")
|
||||
core.addApiFunctionByName("GuiIconText")
|
||||
core.addApiFunctionByName("GuiDrawIcon")
|
||||
//core.addApiFunctionByName("GuiGetIcons")
|
||||
//core.addApiFunctionByName("GuiGetIconData")
|
||||
//core.addApiFunctionByName("GuiSetIconData")
|
||||
core.addApiFunctionByName("GuiSetIconScale")
|
||||
|
||||
// module: rlights
|
||||
ignore("GuiDropdownBox")
|
||||
ignore("GuiSpinner")
|
||||
ignore("GuiValueBox")
|
||||
ignore("GuiListView")
|
||||
ignore("GuiListViewEx")
|
||||
ignore("GuiTextInputBox")
|
||||
ignore("GuiGetIcons")
|
||||
ignore("GuiTabBar")
|
||||
ignore("GuiLoadIcons")
|
||||
// TODO: Parse and support light struct
|
||||
// core.addApiFunctionByName("CreateLight")
|
||||
// core.addApiFunctionByName("UpdateLightValues")
|
||||
|
||||
// module: reasings
|
||||
core.addApiFunctionByName("EaseLinearNone")
|
||||
core.addApiFunctionByName("EaseLinearIn")
|
||||
core.addApiFunctionByName("EaseLinearOut")
|
||||
core.addApiFunctionByName("EaseLinearInOut")
|
||||
core.addApiFunctionByName("EaseSineIn")
|
||||
core.addApiFunctionByName("EaseSineOut")
|
||||
core.addApiFunctionByName("EaseSineInOut")
|
||||
core.addApiFunctionByName("EaseCircIn")
|
||||
core.addApiFunctionByName("EaseCircOut")
|
||||
core.addApiFunctionByName("EaseCircInOut")
|
||||
core.addApiFunctionByName("EaseCubicIn")
|
||||
core.addApiFunctionByName("EaseCubicOut")
|
||||
core.addApiFunctionByName("EaseCubicInOut")
|
||||
core.addApiFunctionByName("EaseQuadIn")
|
||||
core.addApiFunctionByName("EaseQuadOut")
|
||||
core.addApiFunctionByName("EaseQuadInOut")
|
||||
core.addApiFunctionByName("EaseExpoIn")
|
||||
core.addApiFunctionByName("EaseExpoOut")
|
||||
core.addApiFunctionByName("EaseExpoInOut")
|
||||
core.addApiFunctionByName("EaseBackIn")
|
||||
core.addApiFunctionByName("EaseBounceOut")
|
||||
core.addApiFunctionByName("EaseBounceInOut")
|
||||
core.addApiFunctionByName("EaseElasticIn")
|
||||
ignore("CreateLight")
|
||||
ignore("UpdateLightValues")
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
core.addAllEnums()
|
||||
// api.enums.find(x => x.name === "KeyboardKey")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MouseButton")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ConfigFlags")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "BlendMode")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "TraceLogLevel")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MouseCursor")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "PixelFormat")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "CameraProjection")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "CameraMode")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ShaderLocationIndex")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ShaderUniformDataType")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MaterialMapIndex")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
api.enums.forEach(x => core.addEnum(x))
|
||||
core.exportGlobalConstant("MATERIAL_MAP_DIFFUSE", "Albedo material (same as: MATERIAL_MAP_DIFFUSE")
|
||||
core.exportGlobalConstant("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!")
|
||||
}
|
||||
|
||||
main()
|
||||
|
|
|
@ -15,6 +15,11 @@ export interface FuncBindingOptions {
|
|||
customizeCall?: string,
|
||||
body?: (gen: QuickJsGenerator) => void,
|
||||
jsName?: string,
|
||||
ignore?: boolean,
|
||||
jsReturns?: string
|
||||
}
|
||||
|
||||
export interface ParamBindingOptions {
|
||||
ignore?: boolean
|
||||
}
|
||||
|
||||
|
@ -54,7 +59,8 @@ export interface RayLibEnum {
|
|||
|
||||
export interface RayLibParamDescription {
|
||||
type: RayLibType | string,
|
||||
name: string
|
||||
name: string,
|
||||
binding?: ParamBindingOptions
|
||||
}
|
||||
|
||||
export interface RayLibFunction {
|
||||
|
|
|
@ -22,6 +22,7 @@ export class RayLibHeader extends QuickJsHeader {
|
|||
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) {
|
||||
|
@ -31,6 +32,7 @@ export class RayLibHeader extends QuickJsHeader {
|
|||
// read parameters
|
||||
api.params = api.params || []
|
||||
for (let i = 0; i < api.params.length; i++) {
|
||||
if(api.params[i]?.binding?.ignore) continue;
|
||||
const para = api.params[i]
|
||||
fun.jsToC(para.type,para.name,"argv["+i+"]", this.structLookup)
|
||||
}
|
||||
|
@ -53,16 +55,18 @@ export class RayLibHeader extends QuickJsHeader {
|
|||
}
|
||||
|
||||
// add binding to function declaration
|
||||
this.moduleFunctionList.jsFuncDef(jName, api.params?.length ?? 0, fun.getTag("_name"))
|
||||
this.moduleFunctionList.jsFuncDef(jName, (api.params || []).filter(x => !x.binding?.ignore).length, fun.getTag("_name"))
|
||||
this.typings.addFunction(jName,api)
|
||||
}
|
||||
|
||||
addEnum(renum: RayLibEnum){
|
||||
console.log("Binding enum "+ renum.name)
|
||||
renum.values.forEach(x => this.exportGlobalConstant(x.name, x.description))
|
||||
}
|
||||
|
||||
addApiStruct(struct: RayLibStruct){
|
||||
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))
|
||||
|
@ -97,7 +101,7 @@ export class RayLibHeader extends QuickJsHeader {
|
|||
|
||||
this.moduleEntry.call("JS_AddModuleExport", ["ctx","m",'"'+struct.name+'"'])
|
||||
}
|
||||
this.typings.addStruct(struct, options || {})
|
||||
this.typings.addStruct(struct)
|
||||
}
|
||||
|
||||
exportGlobalStruct(structName: string, exportName: string, values: string[], description: string){
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { ApiFunction, ApiStruct } from "./api";
|
||||
import { GenericCodeGenerator, FunctionArgument, CodeWriter } from "./generation"
|
||||
import { writeFileSync } from "fs";
|
||||
import { StructBindingOptions } from "./raylib-header";
|
||||
import { RayLibFunction, RayLibStruct } from "./interfaces";
|
||||
|
||||
export class TypeScriptDeclaration {
|
||||
root = new TypescriptGenerator()
|
||||
|
@ -17,13 +16,15 @@ export class TypeScriptDeclaration {
|
|||
|
||||
|
||||
|
||||
addFunction(name: string, api: ApiFunction){
|
||||
const para = api.params.map(x => ({ name: x.name, type: this.toJsType(x.type)}))
|
||||
const returnType = this.toJsType(api.returnType)
|
||||
addFunction(name: string, api: RayLibFunction){
|
||||
const options = api.binding || {}
|
||||
const para = (api.params || []).filter(x => !x.binding?.ignore).map(x => ({ name: x.name, type: this.toJsType(x.type)}))
|
||||
const returnType = options.jsReturns ?? this.toJsType(api.returnType)
|
||||
this.functions.tsDeclareFunction(name, para, returnType, api.description)
|
||||
}
|
||||
|
||||
addStruct(api: ApiStruct, options: StructBindingOptions){
|
||||
addStruct(api: RayLibStruct){
|
||||
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)
|
||||
|
|
|
@ -1,31 +1,3 @@
|
|||
interface Color {
|
||||
/** Color red value */
|
||||
r: number,
|
||||
/** Color green value */
|
||||
g: number,
|
||||
/** Color blue value */
|
||||
b: number,
|
||||
/** Color alpha value */
|
||||
a: number,
|
||||
}
|
||||
declare var Color: {
|
||||
prototype: Color;
|
||||
new(r: number, g: number, b: number, a: number): Color;
|
||||
}
|
||||
interface Rectangle {
|
||||
/** Rectangle top-left corner position x */
|
||||
x: number,
|
||||
/** Rectangle top-left corner position y */
|
||||
y: number,
|
||||
/** Rectangle width */
|
||||
width: number,
|
||||
/** Rectangle height */
|
||||
height: number,
|
||||
}
|
||||
declare var Rectangle: {
|
||||
prototype: Rectangle;
|
||||
new(x: number, y: number, width: number, height: number): Rectangle;
|
||||
}
|
||||
interface Vector2 {
|
||||
/** Vector x component */
|
||||
x: number,
|
||||
|
@ -62,74 +34,72 @@ declare var Vector4: {
|
|||
prototype: Vector4;
|
||||
new(x: number, y: number, z: number, w: number): Vector4;
|
||||
}
|
||||
interface Ray {
|
||||
/** Ray position (origin) */
|
||||
position: Vector3,
|
||||
/** Ray direction */
|
||||
direction: Vector3,
|
||||
}
|
||||
declare var Ray: {
|
||||
prototype: Ray;
|
||||
new(position: Vector3, direction: Vector3): Ray;
|
||||
}
|
||||
interface RayCollision {
|
||||
/** Did the ray hit something? */
|
||||
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;
|
||||
}
|
||||
interface Camera2D {
|
||||
/** Camera offset (displacement from target) */
|
||||
offset: Vector2,
|
||||
/** Camera target (rotation and zoom origin) */
|
||||
target: Vector2,
|
||||
/** Camera rotation in degrees */
|
||||
rotation: number,
|
||||
/** Camera zoom (scaling), should be 1.0f by default */
|
||||
zoom: number,
|
||||
}
|
||||
declare var Camera2D: {
|
||||
prototype: Camera2D;
|
||||
new(offset: Vector2, target: Vector2, rotation: number, zoom: number): Camera2D;
|
||||
}
|
||||
interface Camera3D {
|
||||
/** Camera position */
|
||||
position: Vector3,
|
||||
/** Camera target it looks-at */
|
||||
target: Vector3,
|
||||
/** Camera up vector (rotation over its axis) */
|
||||
up: Vector3,
|
||||
/** Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic */
|
||||
fovy: number,
|
||||
/** Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC */
|
||||
projection: number,
|
||||
}
|
||||
declare var Camera3D: {
|
||||
prototype: 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(min: Vector3, max: Vector3): BoundingBox;
|
||||
}
|
||||
interface Matrix {
|
||||
}
|
||||
declare var Matrix: {
|
||||
prototype: Matrix;
|
||||
}
|
||||
interface Color {
|
||||
/** Color red value */
|
||||
r: number,
|
||||
/** Color green value */
|
||||
g: number,
|
||||
/** Color blue value */
|
||||
b: number,
|
||||
/** Color alpha value */
|
||||
a: number,
|
||||
}
|
||||
declare var Color: {
|
||||
prototype: Color;
|
||||
new(r: number, g: number, b: number, a: number): Color;
|
||||
}
|
||||
interface Rectangle {
|
||||
/** Rectangle top-left corner position x */
|
||||
x: number,
|
||||
/** Rectangle top-left corner position y */
|
||||
y: number,
|
||||
/** Rectangle width */
|
||||
width: number,
|
||||
/** Rectangle height */
|
||||
height: number,
|
||||
}
|
||||
declare var Rectangle: {
|
||||
prototype: Rectangle;
|
||||
new(x: number, y: number, width: number, height: number): Rectangle;
|
||||
}
|
||||
interface Image {
|
||||
/** Image base width */
|
||||
width: number,
|
||||
/** Image base height */
|
||||
height: number,
|
||||
/** Mipmap levels, 1 by default */
|
||||
mipmaps: number,
|
||||
/** Data format (PixelFormat type) */
|
||||
format: number,
|
||||
}
|
||||
declare var Image: {
|
||||
prototype: Image;
|
||||
}
|
||||
interface Texture {
|
||||
/** Texture base width */
|
||||
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;
|
||||
}
|
||||
interface RenderTexture {
|
||||
/** OpenGL framebuffer object id */
|
||||
id: number,
|
||||
}
|
||||
declare var RenderTexture: {
|
||||
prototype: RenderTexture;
|
||||
}
|
||||
interface NPatchInfo {
|
||||
/** Texture source rectangle */
|
||||
source: Rectangle,
|
||||
|
@ -148,62 +118,51 @@ declare var NPatchInfo: {
|
|||
prototype: NPatchInfo;
|
||||
new(source: Rectangle, left: number, top: number, right: number, bottom: number, layout: number): NPatchInfo;
|
||||
}
|
||||
interface Image {
|
||||
/** Image base width */
|
||||
width: number,
|
||||
/** Image base height */
|
||||
height: number,
|
||||
/** Mipmap levels, 1 by default */
|
||||
mipmaps: number,
|
||||
/** Data format (PixelFormat type) */
|
||||
format: number,
|
||||
interface GlyphInfo {
|
||||
}
|
||||
declare var Image: {
|
||||
prototype: Image;
|
||||
declare var GlyphInfo: {
|
||||
prototype: GlyphInfo;
|
||||
}
|
||||
interface Wave {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
/** Frequency (samples per second) */
|
||||
sampleRate: number,
|
||||
/** Bit depth (bits per sample): 8, 16, 32 (24 not supported) */
|
||||
sampleSize: number,
|
||||
/** Number of channels (1-mono, 2-stereo, ...) */
|
||||
channels: number,
|
||||
interface Font {
|
||||
/** Base size (default chars height) */
|
||||
baseSize: number,
|
||||
/** Number of glyph characters */
|
||||
glyphCount: number,
|
||||
/** Padding around the glyph characters */
|
||||
glyphPadding: number,
|
||||
}
|
||||
declare var Wave: {
|
||||
prototype: Wave;
|
||||
declare var Font: {
|
||||
prototype: Font;
|
||||
}
|
||||
interface Sound {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
interface Camera3D {
|
||||
/** Camera position */
|
||||
position: Vector3,
|
||||
/** Camera target it looks-at */
|
||||
target: Vector3,
|
||||
/** Camera up vector (rotation over its axis) */
|
||||
up: Vector3,
|
||||
/** Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic */
|
||||
fovy: number,
|
||||
/** Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC */
|
||||
projection: number,
|
||||
}
|
||||
declare var Sound: {
|
||||
prototype: Sound;
|
||||
declare var Camera3D: {
|
||||
prototype: Camera3D;
|
||||
new(position: Vector3, target: Vector3, up: Vector3, fovy: number, projection: number): Camera3D;
|
||||
}
|
||||
interface Music {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
/** Music looping enable */
|
||||
looping: boolean,
|
||||
/** Type of music context (audio filetype) */
|
||||
ctxType: number,
|
||||
interface Camera2D {
|
||||
/** Camera offset (displacement from target) */
|
||||
offset: Vector2,
|
||||
/** Camera target (rotation and zoom origin) */
|
||||
target: Vector2,
|
||||
/** Camera rotation in degrees */
|
||||
rotation: number,
|
||||
/** Camera zoom (scaling), should be 1.0f by default */
|
||||
zoom: 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;
|
||||
declare var Camera2D: {
|
||||
prototype: Camera2D;
|
||||
new(offset: Vector2, target: Vector2, rotation: number, zoom: number): Camera2D;
|
||||
}
|
||||
interface Mesh {
|
||||
/** Number of vertices stored in arrays */
|
||||
|
@ -244,37 +203,6 @@ interface Shader {
|
|||
declare var Shader: {
|
||||
prototype: Shader;
|
||||
}
|
||||
interface Texture {
|
||||
/** Texture base width */
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
interface MaterialMap {
|
||||
/** Material map texture */
|
||||
texture: Texture,
|
||||
|
@ -293,6 +221,118 @@ interface Material {
|
|||
declare var Material: {
|
||||
prototype: Material;
|
||||
}
|
||||
interface Transform {
|
||||
}
|
||||
declare var Transform: {
|
||||
prototype: Transform;
|
||||
}
|
||||
interface BoneInfo {
|
||||
}
|
||||
declare var BoneInfo: {
|
||||
prototype: BoneInfo;
|
||||
}
|
||||
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;
|
||||
}
|
||||
interface ModelAnimation {
|
||||
}
|
||||
declare var ModelAnimation: {
|
||||
prototype: ModelAnimation;
|
||||
}
|
||||
interface Ray {
|
||||
/** Ray position (origin) */
|
||||
position: Vector3,
|
||||
/** Ray direction */
|
||||
direction: Vector3,
|
||||
}
|
||||
declare var Ray: {
|
||||
prototype: Ray;
|
||||
new(position: Vector3, direction: Vector3): Ray;
|
||||
}
|
||||
interface RayCollision {
|
||||
/** Did the ray hit something? */
|
||||
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;
|
||||
}
|
||||
interface BoundingBox {
|
||||
/** Minimum vertex box-corner */
|
||||
min: Vector3,
|
||||
/** Maximum vertex box-corner */
|
||||
max: Vector3,
|
||||
}
|
||||
declare var BoundingBox: {
|
||||
prototype: BoundingBox;
|
||||
new(min: Vector3, max: Vector3): BoundingBox;
|
||||
}
|
||||
interface Wave {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
/** Frequency (samples per second) */
|
||||
sampleRate: number,
|
||||
/** Bit depth (bits per sample): 8, 16, 32 (24 not supported) */
|
||||
sampleSize: number,
|
||||
/** Number of channels (1-mono, 2-stereo, ...) */
|
||||
channels: number,
|
||||
}
|
||||
declare var Wave: {
|
||||
prototype: Wave;
|
||||
}
|
||||
interface AudioStream {
|
||||
}
|
||||
declare var AudioStream: {
|
||||
prototype: AudioStream;
|
||||
}
|
||||
interface Sound {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
}
|
||||
declare var Sound: {
|
||||
prototype: Sound;
|
||||
}
|
||||
interface Music {
|
||||
/** Total number of frames (considering channels) */
|
||||
frameCount: number,
|
||||
/** Music looping enable */
|
||||
looping: boolean,
|
||||
/** Type of music context (audio filetype) */
|
||||
ctxType: number,
|
||||
}
|
||||
declare var Music: {
|
||||
prototype: Music;
|
||||
}
|
||||
interface VrDeviceInfo {
|
||||
}
|
||||
declare var VrDeviceInfo: {
|
||||
prototype: VrDeviceInfo;
|
||||
}
|
||||
interface VrStereoConfig {
|
||||
}
|
||||
declare var VrStereoConfig: {
|
||||
prototype: VrStereoConfig;
|
||||
}
|
||||
interface FilePathList {
|
||||
}
|
||||
declare var FilePathList: {
|
||||
prototype: FilePathList;
|
||||
}
|
||||
/** Initialize window and OpenGL context */
|
||||
declare function initWindow(width: number, height: number, title: string): void;
|
||||
/** Check if KEY_ESCAPE pressed or Close icon pressed */
|
||||
|
@ -509,6 +549,10 @@ declare function getApplicationDirectory(): string;
|
|||
declare function changeDirectory(dir: string): boolean;
|
||||
/** Check if a given path is a file or a directory */
|
||||
declare function isPathFile(path: string): boolean;
|
||||
/** Load directory filepaths */
|
||||
declare function loadDirectoryFiles(dirPath: string): string[];
|
||||
/** Load directory filepaths with extension filtering and recursive directory scan */
|
||||
declare function loadDirectoryFilesEx(basePath: string, filter: string, scanSubdirs: boolean): string[];
|
||||
/** Check if a file has been dropped into window */
|
||||
declare function isFileDropped(): boolean;
|
||||
/** Load dropped filepaths */
|
||||
|
@ -1025,8 +1069,6 @@ declare function isMaterialReady(material: Material): boolean;
|
|||
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;
|
||||
/** Replace material in slot materialIndex */
|
||||
declare function setModelMaterial(model: Model, materialIndex: number, material: Material): void;
|
||||
/** Set material for a mesh */
|
||||
declare function setModelMeshMaterial(model: Model, meshId: number, materialId: number): void;
|
||||
/** Check collision between two spheres */
|
||||
|
@ -1464,12 +1506,18 @@ declare function guiColorBarHue(bounds: Rectangle, text: string, value: number):
|
|||
declare function guiLoadStyle(fileName: string): void;
|
||||
/** Load style default over global style */
|
||||
declare function guiLoadStyleDefault(): void;
|
||||
/** Enable gui tooltips (global state) */
|
||||
declare function guiEnableTooltip(): void;
|
||||
/** Disable gui tooltips (global state) */
|
||||
declare function guiDisableTooltip(): void;
|
||||
/** Set tooltip string */
|
||||
declare function guiSetTooltip(tooltip: string): void;
|
||||
/** Get text with icon id prepended (if supported) */
|
||||
declare function guiIconText(iconId: number, text: string): string;
|
||||
/** Draw icon using pixel size at specified position */
|
||||
declare function guiDrawIcon(iconId: number, posX: number, posY: number, pixelSize: number, color: Color): void;
|
||||
/** Set default icon drawing size */
|
||||
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;
|
||||
/** Linear Easing functions */
|
||||
declare function easeLinearNone(t: number, b: number, c: number, d: number): number;
|
||||
/** Ease: Linear */
|
||||
|
@ -1516,6 +1564,8 @@ declare function easeBounceOut(t: number, b: number, c: number, d: number): numb
|
|||
declare function easeBounceInOut(t: number, b: number, c: number, d: number): number;
|
||||
/** Elastic Easing functions */
|
||||
declare function easeElasticIn(t: number, b: number, c: number, d: number): number;
|
||||
/** Replace material in slot materialIndex */
|
||||
declare function setModelMaterial(model: Model, materialIndex: number, material: Material): void;
|
||||
/** (PI/180.0) */
|
||||
declare var DEG2RAD: number;
|
||||
/** (180.0/PI) */
|
||||
|
|
|
@ -651,6 +651,7 @@ class RayLibHeader extends quickjs_1.QuickJsHeader {
|
|||
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);
|
||||
|
@ -661,6 +662,8 @@ class RayLibHeader extends quickjs_1.QuickJsHeader {
|
|||
// read parameters
|
||||
api.params = api.params || [];
|
||||
for (let i = 0; i < api.params.length; i++) {
|
||||
if (api.params[i]?.binding?.ignore)
|
||||
continue;
|
||||
const para = api.params[i];
|
||||
fun.jsToC(para.type, para.name, "argv[" + i + "]", this.structLookup);
|
||||
}
|
||||
|
@ -687,14 +690,16 @@ class RayLibHeader extends quickjs_1.QuickJsHeader {
|
|||
}
|
||||
}
|
||||
// add binding to function declaration
|
||||
this.moduleFunctionList.jsFuncDef(jName, api.params?.length ?? 0, fun.getTag("_name"));
|
||||
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.exportGlobalConstant(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));
|
||||
|
@ -726,7 +731,7 @@ class RayLibHeader extends quickjs_1.QuickJsHeader {
|
|||
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, options || {});
|
||||
this.typings.addStruct(struct);
|
||||
}
|
||||
exportGlobalStruct(structName, exportName, values, description) {
|
||||
this.moduleInit.declareStruct(structName, exportName + "_struct", values);
|
||||
|
@ -768,11 +773,13 @@ class TypeScriptDeclaration {
|
|||
this.constants = this.root.child();
|
||||
}
|
||||
addFunction(name, api) {
|
||||
const para = api.params.map(x => ({ name: x.name, type: this.toJsType(x.type) }));
|
||||
const returnType = this.toJsType(api.returnType);
|
||||
const options = api.binding || {};
|
||||
const para = (api.params || []).filter(x => !x.binding?.ignore).map(x => ({ name: x.name, type: this.toJsType(x.type) }));
|
||||
const returnType = options.jsReturns ?? this.toJsType(api.returnType);
|
||||
this.functions.tsDeclareFunction(name, para, returnType, api.description);
|
||||
}
|
||||
addStruct(api, options) {
|
||||
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);
|
||||
|
@ -915,6 +922,7 @@ 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);
|
||||
}
|
||||
|
@ -924,9 +932,12 @@ function getStruct(strList, 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
|
||||
const api = JSON.parse((0, fs_1.readFileSync)("thirdparty/raylib/parser/output/raylib_api.json", 'utf8'));
|
||||
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);
|
||||
|
@ -1171,17 +1182,17 @@ function main() {
|
|||
},
|
||||
//destructor: "UnloadMaterial"
|
||||
};
|
||||
getFunction(api.functions, "SetWindowIcons").binding = { ignore: true };
|
||||
getFunction(api.functions, "GetWindowHandle").binding = { ignore: true };
|
||||
ignore("SetWindowIcons");
|
||||
ignore("GetWindowHandle");
|
||||
// Custom frame control functions
|
||||
// NOT SUPPORTED BECAUSE NEEDS COMPILER FLAG
|
||||
getFunction(api.functions, "SwapScreenBuffer").binding = { ignore: true };
|
||||
getFunction(api.functions, "PollInputEvents").binding = { ignore: true };
|
||||
getFunction(api.functions, "WaitTime").binding = { ignore: true };
|
||||
getFunction(api.functions, "BeginVrStereoMode").binding = { ignore: true };
|
||||
getFunction(api.functions, "EndVrStereoMode").binding = { ignore: true };
|
||||
getFunction(api.functions, "LoadVrStereoConfig").binding = { ignore: true };
|
||||
getFunction(api.functions, "UnloadVrStereoConfig").binding = { ignore: true };
|
||||
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);
|
||||
|
@ -1210,20 +1221,24 @@ function main() {
|
|||
gen.call("SetShaderValue", ["shader", "locIndex", "value", "uniformType"]);
|
||||
gen.returnExp("JS_UNDEFINED");
|
||||
} };
|
||||
getFunction(api.functions, "SetShaderValueV").binding = { ignore: true };
|
||||
const traceLog = apiDesc.getFunction("TraceLog");
|
||||
if (!traceLog)
|
||||
throw new Error("TraceLog not found");
|
||||
traceLog.params.pop();
|
||||
core.addApiFunction(traceLog);
|
||||
core.addApiFunctionByName("SetTraceLogLevel");
|
||||
// Memory functions not supported on JS
|
||||
core.addApiFunctionByName("OpenURL");
|
||||
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 = apiDesc.getFunction("LoadFileData");
|
||||
lfd?.params.pop();
|
||||
core.addApiFunctionByName("LoadFileData", null, { body: gen => {
|
||||
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" });
|
||||
|
@ -1231,694 +1246,162 @@ function main() {
|
|||
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");
|
||||
core.addApiFunctionByName("GetFileLength");
|
||||
// TODO: Who needs to clean memory here?
|
||||
core.addApiFunctionByName("GetFileExtension");
|
||||
core.addApiFunctionByName("GetFileName");
|
||||
core.addApiFunctionByName("GetFileNameWithoutExt");
|
||||
core.addApiFunctionByName("GetDirectoryPath");
|
||||
core.addApiFunctionByName("GetPrevDirectoryPath");
|
||||
core.addApiFunctionByName("GetWorkingDirectory");
|
||||
core.addApiFunctionByName("GetApplicationDirectory");
|
||||
core.addApiFunctionByName("ChangeDirectory");
|
||||
core.addApiFunctionByName("IsPathFile");
|
||||
//core.addApiFunctionByName("LoadDirectoryFiles")
|
||||
//core.addApiFunctionByName("LoadDirectoryFilesEx")
|
||||
// UnloadDirectoryFiles
|
||||
core.addApiFunctionByName("IsFileDropped");
|
||||
const ldf = apiDesc.getFunction("LoadDroppedFiles");
|
||||
ldf.returnType = "string[]";
|
||||
core.addApiFunction(ldf, null, {
|
||||
body: gen => {
|
||||
gen.call("LoadDroppedFiles", [], { type: "FilePathList", name: "files" });
|
||||
}
|
||||
};
|
||||
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"]) };
|
||||
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("UnloadDroppedFiles", ["files"]);
|
||||
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");
|
||||
}
|
||||
});
|
||||
// UnloadDroppedFiles
|
||||
core.addApiFunctionByName("GetFileModTime");
|
||||
};
|
||||
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
|
||||
//core.addApiFunctionByName("CompressData")
|
||||
//core.addApiFunctionByName("DecompressData")
|
||||
//core.addApiFunctionByName("EncodeDataBase64")
|
||||
//core.addApiFunctionByName("DecodeDataBase64")
|
||||
// input handling functions
|
||||
core.addApiFunctionByName("IsKeyPressed");
|
||||
core.addApiFunctionByName("IsKeyDown");
|
||||
core.addApiFunctionByName("IsKeyReleased");
|
||||
core.addApiFunctionByName("IsKeyUp");
|
||||
core.addApiFunctionByName("SetExitKey");
|
||||
core.addApiFunctionByName("GetKeyPressed");
|
||||
core.addApiFunctionByName("GetCharPressed");
|
||||
// input-related functions: gamepads
|
||||
core.addApiFunctionByName("IsGamepadAvailable");
|
||||
core.addApiFunctionByName("GetGamepadName");
|
||||
core.addApiFunctionByName("IsGamepadButtonPressed");
|
||||
core.addApiFunctionByName("IsGamepadButtonDown");
|
||||
core.addApiFunctionByName("IsGamepadButtonReleased");
|
||||
core.addApiFunctionByName("IsGamepadButtonUp");
|
||||
core.addApiFunctionByName("GetGamepadButtonPressed");
|
||||
core.addApiFunctionByName("GetGamepadAxisCount");
|
||||
core.addApiFunctionByName("GetGamepadAxisMovement");
|
||||
core.addApiFunctionByName("SetGamepadMappings");
|
||||
// input-related functions: mouse
|
||||
core.addApiFunctionByName("IsMouseButtonPressed");
|
||||
core.addApiFunctionByName("IsMouseButtonDown");
|
||||
core.addApiFunctionByName("IsMouseButtonReleased");
|
||||
core.addApiFunctionByName("IsMouseButtonUp");
|
||||
core.addApiFunctionByName("GetMouseX");
|
||||
core.addApiFunctionByName("GetMouseY");
|
||||
core.addApiFunctionByName("GetMousePosition");
|
||||
core.addApiFunctionByName("GetMouseDelta");
|
||||
core.addApiFunctionByName("SetMousePosition");
|
||||
core.addApiFunctionByName("SetMouseOffset");
|
||||
core.addApiFunctionByName("SetMouseScale");
|
||||
core.addApiFunctionByName("GetMouseWheelMove");
|
||||
core.addApiFunctionByName("GetMouseWheelMoveV");
|
||||
core.addApiFunctionByName("SetMouseCursor");
|
||||
// input-related functions: touch
|
||||
core.addApiFunctionByName("GetTouchX");
|
||||
core.addApiFunctionByName("GetTouchY");
|
||||
core.addApiFunctionByName("GetTouchPosition");
|
||||
core.addApiFunctionByName("GetTouchPointId");
|
||||
core.addApiFunctionByName("GetTouchPointCount");
|
||||
// Gesture and touch handling functions
|
||||
core.addApiFunctionByName("SetGesturesEnabled");
|
||||
core.addApiFunctionByName("IsGestureDetected");
|
||||
core.addApiFunctionByName("GetGestureDetected");
|
||||
core.addApiFunctionByName("GetGestureHoldDuration");
|
||||
core.addApiFunctionByName("GetGestureDragVector");
|
||||
core.addApiFunctionByName("GetGestureDragAngle");
|
||||
core.addApiFunctionByName("GetGesturePinchVector");
|
||||
core.addApiFunctionByName("GetGesturePinchAngle");
|
||||
// Camera system functions
|
||||
core.addApiFunctionByName("UpdateCamera");
|
||||
core.addApiFunctionByName("UpdateCameraPro");
|
||||
//api.functions.forEach(x => console.log(`core.addApiFunctionByName("${x.name}")`))
|
||||
// module: rshapes
|
||||
core.addApiFunctionByName("SetShapesTexture");
|
||||
// Basic shapes drawing functions
|
||||
core.addApiFunctionByName("DrawPixel");
|
||||
core.addApiFunctionByName("DrawPixelV");
|
||||
core.addApiFunctionByName("DrawLine");
|
||||
core.addApiFunctionByName("DrawLineV");
|
||||
core.addApiFunctionByName("DrawLineEx");
|
||||
core.addApiFunctionByName("DrawLineBezier");
|
||||
core.addApiFunctionByName("DrawLineBezierQuad");
|
||||
core.addApiFunctionByName("DrawLineBezierCubic");
|
||||
// core.addApiFunctionByName("DrawLineStrip")
|
||||
core.addApiFunctionByName("DrawCircle");
|
||||
core.addApiFunctionByName("DrawCircleSector");
|
||||
core.addApiFunctionByName("DrawCircleSectorLines");
|
||||
core.addApiFunctionByName("DrawCircleGradient");
|
||||
core.addApiFunctionByName("DrawCircleV");
|
||||
core.addApiFunctionByName("DrawCircleLines");
|
||||
core.addApiFunctionByName("DrawEllipse");
|
||||
core.addApiFunctionByName("DrawEllipseLines");
|
||||
core.addApiFunctionByName("DrawRing");
|
||||
core.addApiFunctionByName("DrawRingLines");
|
||||
core.addApiFunctionByName("DrawRectangle");
|
||||
core.addApiFunctionByName("DrawRectangleV");
|
||||
core.addApiFunctionByName("DrawRectangleRec");
|
||||
core.addApiFunctionByName("DrawRectanglePro");
|
||||
core.addApiFunctionByName("DrawRectangleGradientV");
|
||||
core.addApiFunctionByName("DrawRectangleGradientH");
|
||||
core.addApiFunctionByName("DrawRectangleGradientEx");
|
||||
core.addApiFunctionByName("DrawRectangleLines");
|
||||
core.addApiFunctionByName("DrawRectangleLinesEx");
|
||||
core.addApiFunctionByName("DrawRectangleRounded");
|
||||
core.addApiFunctionByName("DrawRectangleRoundedLines");
|
||||
core.addApiFunctionByName("DrawTriangle");
|
||||
core.addApiFunctionByName("DrawTriangleLines");
|
||||
//core.addApiFunctionByName("DrawTriangleFan")
|
||||
//core.addApiFunctionByName("DrawTriangleStrip")
|
||||
core.addApiFunctionByName("DrawPoly");
|
||||
core.addApiFunctionByName("DrawPolyLines");
|
||||
core.addApiFunctionByName("DrawPolyLinesEx");
|
||||
// Basic shapes collision detection functions
|
||||
core.addApiFunctionByName("CheckCollisionRecs");
|
||||
core.addApiFunctionByName("CheckCollisionCircles");
|
||||
core.addApiFunctionByName("CheckCollisionCircleRec");
|
||||
core.addApiFunctionByName("CheckCollisionPointRec");
|
||||
core.addApiFunctionByName("CheckCollisionPointCircle");
|
||||
core.addApiFunctionByName("CheckCollisionPointTriangle");
|
||||
// core.addApiFunctionByName("CheckCollisionPointPoly")
|
||||
// core.addApiFunctionByName("CheckCollisionLines")
|
||||
core.addApiFunctionByName("CheckCollisionPointLine");
|
||||
core.addApiFunctionByName("GetCollisionRec");
|
||||
// Image loading functions
|
||||
core.addApiFunctionByName("LoadImage");
|
||||
core.addApiFunctionByName("LoadImageRaw");
|
||||
// core.addApiFunctionByName("LoadImageAnim")
|
||||
core.addApiFunctionByName("LoadImageFromMemory");
|
||||
core.addApiFunctionByName("LoadImageFromTexture");
|
||||
core.addApiFunctionByName("LoadImageFromScreen");
|
||||
core.addApiFunctionByName("IsImageReady");
|
||||
core.addApiFunctionByName("UnloadImage");
|
||||
core.addApiFunctionByName("ExportImage");
|
||||
// needed?
|
||||
// core.addApiFunctionByName("ExportImageAsCode")
|
||||
// Image generation functions
|
||||
core.addApiFunctionByName("GenImageColor");
|
||||
core.addApiFunctionByName("GenImageGradientV");
|
||||
core.addApiFunctionByName("GenImageGradientH");
|
||||
core.addApiFunctionByName("GenImageGradientRadial");
|
||||
core.addApiFunctionByName("GenImageChecked");
|
||||
core.addApiFunctionByName("GenImageWhiteNoise");
|
||||
core.addApiFunctionByName("GenImagePerlinNoise");
|
||||
core.addApiFunctionByName("GenImageCellular");
|
||||
core.addApiFunctionByName("GenImageText");
|
||||
// Image manipulations functions
|
||||
core.addApiFunctionByName("ImageCopy");
|
||||
core.addApiFunctionByName("ImageFromImage");
|
||||
core.addApiFunctionByName("ImageText");
|
||||
core.addApiFunctionByName("ImageTextEx");
|
||||
core.addApiFunctionByName("ImageFormat");
|
||||
core.addApiFunctionByName("ImageToPOT");
|
||||
core.addApiFunctionByName("ImageCrop");
|
||||
core.addApiFunctionByName("ImageAlphaCrop");
|
||||
core.addApiFunctionByName("ImageAlphaClear");
|
||||
core.addApiFunctionByName("ImageAlphaMask");
|
||||
core.addApiFunctionByName("ImageAlphaPremultiply");
|
||||
core.addApiFunctionByName("ImageBlurGaussian");
|
||||
core.addApiFunctionByName("ImageResize");
|
||||
core.addApiFunctionByName("ImageResizeNN");
|
||||
core.addApiFunctionByName("ImageResizeCanvas");
|
||||
core.addApiFunctionByName("ImageMipmaps");
|
||||
core.addApiFunctionByName("ImageDither");
|
||||
core.addApiFunctionByName("ImageFlipVertical");
|
||||
core.addApiFunctionByName("ImageFlipHorizontal");
|
||||
core.addApiFunctionByName("ImageRotateCW");
|
||||
core.addApiFunctionByName("ImageRotateCCW");
|
||||
core.addApiFunctionByName("ImageColorTint");
|
||||
core.addApiFunctionByName("ImageColorInvert");
|
||||
core.addApiFunctionByName("ImageColorGrayscale");
|
||||
core.addApiFunctionByName("ImageColorContrast");
|
||||
core.addApiFunctionByName("ImageColorBrightness");
|
||||
core.addApiFunctionByName("ImageColorReplace");
|
||||
const lic = apiDesc.getFunction("LoadImageColors");
|
||||
lic.returnType = "unsigned char *";
|
||||
core.addApiFunction(lic, null, { body: (gen) => {
|
||||
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");
|
||||
} });
|
||||
//core.addApiFunctionByName("LoadImagePalette")
|
||||
//core.addApiFunctionByName("UnloadImageColors")
|
||||
//core.addApiFunctionByName("UnloadImagePalette")
|
||||
core.addApiFunctionByName("GetImageAlphaBorder");
|
||||
core.addApiFunctionByName("GetImageColor");
|
||||
// Image drawing functions
|
||||
core.addApiFunctionByName("ImageClearBackground");
|
||||
core.addApiFunctionByName("ImageDrawPixel");
|
||||
core.addApiFunctionByName("ImageDrawPixelV");
|
||||
core.addApiFunctionByName("ImageDrawLine");
|
||||
core.addApiFunctionByName("ImageDrawLineV");
|
||||
core.addApiFunctionByName("ImageDrawCircle");
|
||||
core.addApiFunctionByName("ImageDrawCircleV");
|
||||
core.addApiFunctionByName("ImageDrawCircleLines");
|
||||
core.addApiFunctionByName("ImageDrawCircleLinesV");
|
||||
core.addApiFunctionByName("ImageDrawRectangle");
|
||||
core.addApiFunctionByName("ImageDrawRectangleV");
|
||||
core.addApiFunctionByName("ImageDrawRectangleRec");
|
||||
core.addApiFunctionByName("ImageDrawRectangleLines");
|
||||
core.addApiFunctionByName("ImageDraw");
|
||||
core.addApiFunctionByName("ImageDrawText");
|
||||
core.addApiFunctionByName("ImageDrawTextEx");
|
||||
// Texture loading functions
|
||||
core.addApiFunctionByName("LoadTexture");
|
||||
core.addApiFunctionByName("LoadTextureFromImage");
|
||||
core.addApiFunctionByName("LoadTextureCubemap");
|
||||
core.addApiFunctionByName("LoadRenderTexture");
|
||||
core.addApiFunctionByName("IsTextureReady");
|
||||
core.addApiFunctionByName("UnloadTexture");
|
||||
core.addApiFunctionByName("IsRenderTextureReady");
|
||||
core.addApiFunctionByName("UnloadRenderTexture");
|
||||
core.addApiFunctionByName("UpdateTexture");
|
||||
core.addApiFunctionByName("UpdateTextureRec");
|
||||
// Texture configuration functions
|
||||
core.addApiFunctionByName("GenTextureMipmaps");
|
||||
core.addApiFunctionByName("SetTextureFilter");
|
||||
core.addApiFunctionByName("SetTextureWrap");
|
||||
// Texture drawing functions
|
||||
core.addApiFunctionByName("DrawTexture");
|
||||
core.addApiFunctionByName("DrawTextureV");
|
||||
core.addApiFunctionByName("DrawTextureEx");
|
||||
core.addApiFunctionByName("DrawTextureRec");
|
||||
core.addApiFunctionByName("DrawTexturePro");
|
||||
core.addApiFunctionByName("DrawTextureNPatch");
|
||||
// Color/pixel related functions
|
||||
core.addApiFunctionByName("Fade");
|
||||
core.addApiFunctionByName("ColorToInt");
|
||||
core.addApiFunctionByName("ColorNormalize");
|
||||
core.addApiFunctionByName("ColorFromNormalized");
|
||||
core.addApiFunctionByName("ColorToHSV");
|
||||
core.addApiFunctionByName("ColorFromHSV");
|
||||
core.addApiFunctionByName("ColorTint");
|
||||
core.addApiFunctionByName("ColorBrightness");
|
||||
core.addApiFunctionByName("ColorContrast");
|
||||
core.addApiFunctionByName("ColorAlpha");
|
||||
core.addApiFunctionByName("ColorAlphaBlend");
|
||||
core.addApiFunctionByName("GetColor");
|
||||
// core.addApiFunctionByName("GetPixelColor")
|
||||
// core.addApiFunctionByName("SetPixelColor")
|
||||
core.addApiFunctionByName("GetPixelDataSize");
|
||||
// module: rtext
|
||||
// Font loading/unloading
|
||||
core.addApiFunctionByName("GetFontDefault");
|
||||
core.addApiFunctionByName("LoadFont");
|
||||
const lfx = apiDesc.getFunction("LoadFontEx");
|
||||
lfx?.params.pop();
|
||||
lfx?.params.pop();
|
||||
core.addApiFunction(lfx, null, { customizeCall: "Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0);" });
|
||||
core.addApiFunctionByName("LoadFontFromImage");
|
||||
// core.addApiFunctionByName("LoadFontFromMemory")
|
||||
core.addApiFunctionByName("IsFontReady");
|
||||
// core.addApiFunctionByName("LoadFontData")
|
||||
// core.addApiFunctionByName("GenImageFontAtlas")
|
||||
// core.addApiFunctionByName("UnloadFontData")
|
||||
core.addApiFunctionByName("UnloadFont");
|
||||
// core.addApiFunctionByName("ExportFontAsCode")
|
||||
// Text drawing functions
|
||||
core.addApiFunctionByName("DrawFPS");
|
||||
core.addApiFunctionByName("DrawText");
|
||||
core.addApiFunctionByName("DrawTextEx");
|
||||
core.addApiFunctionByName("DrawTextPro");
|
||||
core.addApiFunctionByName("DrawTextCodepoint");
|
||||
//core.addApiFunctionByName("DrawTextCodepoints")
|
||||
// Text font info functions
|
||||
core.addApiFunctionByName("MeasureText");
|
||||
core.addApiFunctionByName("MeasureTextEx");
|
||||
core.addApiFunctionByName("GetGlyphIndex");
|
||||
// core.addApiFunctionByName("GetGlyphInfo")
|
||||
core.addApiFunctionByName("GetGlyphAtlasRec");
|
||||
// Text codepoints management functions (unicode characters)
|
||||
// Is this needed?
|
||||
// core.addApiFunctionByName("LoadUTF8")
|
||||
// core.addApiFunctionByName("UnloadUTF8")
|
||||
// core.addApiFunctionByName("LoadCodepoints")
|
||||
// core.addApiFunctionByName("UnloadCodepoints")
|
||||
// core.addApiFunctionByName("GetCodepointCount")
|
||||
// core.addApiFunctionByName("GetCodepoint")
|
||||
// core.addApiFunctionByName("GetCodepointNext")
|
||||
// core.addApiFunctionByName("GetCodepointPrevious")
|
||||
// core.addApiFunctionByName("CodepointToUTF8")
|
||||
// Text strings management functions (no UTF-8 strings, only byte chars)
|
||||
}
|
||||
};
|
||||
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
|
||||
// module: rmodels
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
core.addApiFunctionByName("DrawLine3D");
|
||||
core.addApiFunctionByName("DrawPoint3D");
|
||||
core.addApiFunctionByName("DrawCircle3D");
|
||||
core.addApiFunctionByName("DrawTriangle3D");
|
||||
//core.addApiFunctionByName("DrawTriangleStrip3D")
|
||||
core.addApiFunctionByName("DrawCube");
|
||||
core.addApiFunctionByName("DrawCubeV");
|
||||
core.addApiFunctionByName("DrawCubeWires");
|
||||
core.addApiFunctionByName("DrawCubeWiresV");
|
||||
core.addApiFunctionByName("DrawSphere");
|
||||
core.addApiFunctionByName("DrawSphereEx");
|
||||
core.addApiFunctionByName("DrawSphereWires");
|
||||
core.addApiFunctionByName("DrawCylinder");
|
||||
core.addApiFunctionByName("DrawCylinderEx");
|
||||
core.addApiFunctionByName("DrawCylinderWires");
|
||||
core.addApiFunctionByName("DrawCylinderWiresEx");
|
||||
core.addApiFunctionByName("DrawCapsule");
|
||||
core.addApiFunctionByName("DrawCapsuleWires");
|
||||
core.addApiFunctionByName("DrawPlane");
|
||||
core.addApiFunctionByName("DrawRay");
|
||||
core.addApiFunctionByName("DrawGrid");
|
||||
// model management functions
|
||||
core.addApiFunctionByName("LoadModel");
|
||||
core.addApiFunctionByName("LoadModelFromMesh");
|
||||
core.addApiFunctionByName("IsModelReady");
|
||||
core.addApiFunctionByName("UnloadModel");
|
||||
core.addApiFunctionByName("GetModelBoundingBox");
|
||||
// model drawing functions
|
||||
core.addApiFunctionByName("DrawModel");
|
||||
core.addApiFunctionByName("DrawModelEx");
|
||||
core.addApiFunctionByName("DrawModelWires");
|
||||
core.addApiFunctionByName("DrawModelWiresEx");
|
||||
core.addApiFunctionByName("DrawBoundingBox");
|
||||
core.addApiFunctionByName("DrawBillboard");
|
||||
core.addApiFunctionByName("DrawBillboardRec");
|
||||
core.addApiFunctionByName("DrawBillboardPro");
|
||||
// Mesh management functions
|
||||
core.addApiFunctionByName("UploadMesh");
|
||||
core.addApiFunctionByName("UpdateMeshBuffer");
|
||||
core.addApiFunctionByName("UnloadMesh");
|
||||
core.addApiFunctionByName("DrawMesh");
|
||||
core.addApiFunctionByName("DrawMeshInstanced");
|
||||
core.addApiFunctionByName("ExportMesh");
|
||||
core.addApiFunctionByName("GetMeshBoundingBox");
|
||||
core.addApiFunctionByName("GenMeshTangents");
|
||||
// Mesh generation functions
|
||||
core.addApiFunctionByName("GenMeshPoly");
|
||||
core.addApiFunctionByName("GenMeshPlane");
|
||||
core.addApiFunctionByName("GenMeshCube");
|
||||
core.addApiFunctionByName("GenMeshSphere");
|
||||
core.addApiFunctionByName("GenMeshHemiSphere");
|
||||
core.addApiFunctionByName("GenMeshCylinder");
|
||||
core.addApiFunctionByName("GenMeshCone");
|
||||
core.addApiFunctionByName("GenMeshTorus");
|
||||
core.addApiFunctionByName("GenMeshKnot");
|
||||
core.addApiFunctionByName("GenMeshHeightmap");
|
||||
core.addApiFunctionByName("GenMeshCubicmap");
|
||||
// Material loading/unloading functions
|
||||
// core.addApiFunctionByName("LoadMaterials")
|
||||
core.addApiFunctionByName("LoadMaterialDefault");
|
||||
core.addApiFunctionByName("IsMaterialReady");
|
||||
core.addApiFunctionByName("UnloadMaterial");
|
||||
core.addApiFunctionByName("SetMaterialTexture");
|
||||
core.addApiFunctionByName("SetModelMaterial");
|
||||
core.addApiFunctionByName("SetModelMeshMaterial");
|
||||
// Model animations loading/unloading functions
|
||||
// core.addApiFunctionByName("LoadModelAnimations")
|
||||
// core.addApiFunctionByName("UpdateModelAnimation")
|
||||
// core.addApiFunctionByName("UnloadModelAnimation")
|
||||
// core.addApiFunctionByName("UnloadModelAnimations")
|
||||
// core.addApiFunctionByName("IsModelAnimationValid")
|
||||
// Collision detection functions
|
||||
core.addApiFunctionByName("CheckCollisionSpheres");
|
||||
core.addApiFunctionByName("CheckCollisionBoxes");
|
||||
core.addApiFunctionByName("CheckCollisionBoxSphere");
|
||||
core.addApiFunctionByName("GetRayCollisionSphere");
|
||||
core.addApiFunctionByName("GetRayCollisionBox");
|
||||
core.addApiFunctionByName("GetRayCollisionMesh");
|
||||
core.addApiFunctionByName("GetRayCollisionTriangle");
|
||||
core.addApiFunctionByName("GetRayCollisionQuad");
|
||||
// module: raudio
|
||||
// Audio device management functions
|
||||
core.addApiFunctionByName("InitAudioDevice");
|
||||
core.addApiFunctionByName("CloseAudioDevice");
|
||||
core.addApiFunctionByName("IsAudioDeviceReady");
|
||||
core.addApiFunctionByName("SetMasterVolume");
|
||||
// Wave/Sound loading/unloading functions
|
||||
core.addApiFunctionByName("LoadWave");
|
||||
core.addApiFunctionByName("LoadWaveFromMemory");
|
||||
core.addApiFunctionByName("IsWaveReady");
|
||||
core.addApiFunctionByName("LoadSound");
|
||||
core.addApiFunctionByName("LoadSoundFromWave");
|
||||
core.addApiFunctionByName("IsSoundReady");
|
||||
core.addApiFunctionByName("UpdateSound");
|
||||
core.addApiFunctionByName("UnloadWave");
|
||||
core.addApiFunctionByName("UnloadSound");
|
||||
core.addApiFunctionByName("ExportWave");
|
||||
// core.addApiFunctionByName("ExportWaveAsCode")
|
||||
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
|
||||
core.addApiFunctionByName("PlaySound");
|
||||
core.addApiFunctionByName("StopSound");
|
||||
core.addApiFunctionByName("PauseSound");
|
||||
core.addApiFunctionByName("ResumeSound");
|
||||
core.addApiFunctionByName("IsSoundPlaying");
|
||||
core.addApiFunctionByName("SetSoundVolume");
|
||||
core.addApiFunctionByName("SetSoundPitch");
|
||||
core.addApiFunctionByName("SetSoundPan");
|
||||
core.addApiFunctionByName("WaveCopy");
|
||||
core.addApiFunctionByName("WaveCrop");
|
||||
core.addApiFunctionByName("WaveFormat");
|
||||
// core.addApiFunctionByName("LoadWaveSamples")
|
||||
// core.addApiFunctionByName("UnloadWaveSamples")
|
||||
// Music management functions
|
||||
core.addApiFunctionByName("LoadMusicStream");
|
||||
// core.addApiFunctionByName("LoadMusicStreamFromMemory")
|
||||
core.addApiFunctionByName("IsMusicReady");
|
||||
core.addApiFunctionByName("UnloadMusicStream");
|
||||
core.addApiFunctionByName("PlayMusicStream");
|
||||
core.addApiFunctionByName("IsMusicStreamPlaying");
|
||||
core.addApiFunctionByName("UpdateMusicStream");
|
||||
core.addApiFunctionByName("StopMusicStream");
|
||||
core.addApiFunctionByName("PauseMusicStream");
|
||||
core.addApiFunctionByName("ResumeMusicStream");
|
||||
core.addApiFunctionByName("SeekMusicStream");
|
||||
core.addApiFunctionByName("SetMusicVolume");
|
||||
core.addApiFunctionByName("SetMusicPitch");
|
||||
core.addApiFunctionByName("SetMusicPan");
|
||||
core.addApiFunctionByName("GetMusicTimeLength");
|
||||
core.addApiFunctionByName("GetMusicTimePlayed");
|
||||
// AudioStream management functions
|
||||
// core.addApiFunctionByName("LoadAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamReady")
|
||||
// core.addApiFunctionByName("UnloadAudioStream")
|
||||
// core.addApiFunctionByName("UpdateAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamProcessed")
|
||||
// core.addApiFunctionByName("PlayAudioStream")
|
||||
// core.addApiFunctionByName("PauseAudioStream")
|
||||
// core.addApiFunctionByName("ResumeAudioStream")
|
||||
// core.addApiFunctionByName("IsAudioStreamPlaying")
|
||||
// core.addApiFunctionByName("StopAudioStream")
|
||||
// core.addApiFunctionByName("SetAudioStreamVolume")
|
||||
// core.addApiFunctionByName("SetAudioStreamPitch")
|
||||
// core.addApiFunctionByName("SetAudioStreamPan")
|
||||
// core.addApiFunctionByName("SetAudioStreamBufferSizeDefault")
|
||||
// core.addApiFunctionByName("SetAudioStreamCallback")
|
||||
// core.addApiFunctionByName("AttachAudioStreamProcessor")
|
||||
// core.addApiFunctionByName("DetachAudioStreamProcessor")
|
||||
// core.addApiFunctionByName("AttachAudioMixedProcessor")
|
||||
// core.addApiFunctionByName("DetachAudioMixedProcessor")
|
||||
// module: raymath
|
||||
core.addApiFunctionByName("Clamp");
|
||||
core.addApiFunctionByName("Lerp");
|
||||
core.addApiFunctionByName("Normalize");
|
||||
core.addApiFunctionByName("Remap");
|
||||
core.addApiFunctionByName("Wrap");
|
||||
core.addApiFunctionByName("FloatEquals");
|
||||
core.addApiFunctionByName("Vector2Zero");
|
||||
core.addApiFunctionByName("Vector2One");
|
||||
core.addApiFunctionByName("Vector2Add");
|
||||
core.addApiFunctionByName("Vector2AddValue");
|
||||
core.addApiFunctionByName("Vector2Subtract");
|
||||
core.addApiFunctionByName("Vector2SubtractValue");
|
||||
core.addApiFunctionByName("Vector2Length");
|
||||
core.addApiFunctionByName("Vector2LengthSqr");
|
||||
core.addApiFunctionByName("Vector2DotProduct");
|
||||
core.addApiFunctionByName("Vector2Distance");
|
||||
core.addApiFunctionByName("Vector2DistanceSqr");
|
||||
core.addApiFunctionByName("Vector2Angle");
|
||||
core.addApiFunctionByName("Vector2LineAngle");
|
||||
core.addApiFunctionByName("Vector2Scale");
|
||||
core.addApiFunctionByName("Vector2Multiply");
|
||||
core.addApiFunctionByName("Vector2Negate");
|
||||
core.addApiFunctionByName("Vector2Divide");
|
||||
core.addApiFunctionByName("Vector2Normalize");
|
||||
core.addApiFunctionByName("Vector2Transform");
|
||||
core.addApiFunctionByName("Vector2Lerp");
|
||||
core.addApiFunctionByName("Vector2Reflect");
|
||||
core.addApiFunctionByName("Vector2Rotate");
|
||||
core.addApiFunctionByName("Vector2MoveTowards");
|
||||
core.addApiFunctionByName("Vector2Invert");
|
||||
core.addApiFunctionByName("Vector2Clamp");
|
||||
core.addApiFunctionByName("Vector2ClampValue");
|
||||
core.addApiFunctionByName("Vector2Equals");
|
||||
core.addApiFunctionByName("Vector3Zero");
|
||||
core.addApiFunctionByName("Vector3One");
|
||||
core.addApiFunctionByName("Vector3Add");
|
||||
core.addApiFunctionByName("Vector3AddValue");
|
||||
core.addApiFunctionByName("Vector3Subtract");
|
||||
core.addApiFunctionByName("Vector3SubtractValue");
|
||||
core.addApiFunctionByName("Vector3Scale");
|
||||
core.addApiFunctionByName("Vector3Multiply");
|
||||
core.addApiFunctionByName("Vector3CrossProduct");
|
||||
core.addApiFunctionByName("Vector3Perpendicular");
|
||||
core.addApiFunctionByName("Vector3Length");
|
||||
core.addApiFunctionByName("Vector3LengthSqr");
|
||||
core.addApiFunctionByName("Vector3DotProduct");
|
||||
core.addApiFunctionByName("Vector3Distance");
|
||||
core.addApiFunctionByName("Vector3DistanceSqr");
|
||||
core.addApiFunctionByName("Vector3Angle");
|
||||
core.addApiFunctionByName("Vector3Negate");
|
||||
core.addApiFunctionByName("Vector3Divide");
|
||||
core.addApiFunctionByName("Vector3Normalize");
|
||||
//core.addApiFunctionByName("Vector3OrthoNormalize")
|
||||
core.addApiFunctionByName("Vector3Transform");
|
||||
core.addApiFunctionByName("Vector3RotateByQuaternion");
|
||||
core.addApiFunctionByName("Vector3RotateByAxisAngle");
|
||||
core.addApiFunctionByName("Vector3Lerp");
|
||||
core.addApiFunctionByName("Vector3Reflect");
|
||||
core.addApiFunctionByName("Vector3Min");
|
||||
core.addApiFunctionByName("Vector3Max");
|
||||
core.addApiFunctionByName("Vector3Barycenter");
|
||||
core.addApiFunctionByName("Vector3Unproject");
|
||||
//core.addApiFunctionByName("Vector3ToFloatV")
|
||||
core.addApiFunctionByName("Vector3Invert");
|
||||
core.addApiFunctionByName("Vector3Clamp");
|
||||
core.addApiFunctionByName("Vector3ClampValue");
|
||||
core.addApiFunctionByName("Vector3Equals");
|
||||
core.addApiFunctionByName("Vector3Refract");
|
||||
core.addApiFunctionByName("MatrixDeterminant");
|
||||
core.addApiFunctionByName("MatrixTrace");
|
||||
core.addApiFunctionByName("MatrixTranspose");
|
||||
core.addApiFunctionByName("MatrixInvert");
|
||||
core.addApiFunctionByName("MatrixIdentity");
|
||||
core.addApiFunctionByName("MatrixAdd");
|
||||
core.addApiFunctionByName("MatrixSubtract");
|
||||
core.addApiFunctionByName("MatrixMultiply");
|
||||
core.addApiFunctionByName("MatrixTranslate");
|
||||
core.addApiFunctionByName("MatrixRotate");
|
||||
core.addApiFunctionByName("MatrixRotateX");
|
||||
core.addApiFunctionByName("MatrixRotateY");
|
||||
core.addApiFunctionByName("MatrixRotateZ");
|
||||
core.addApiFunctionByName("MatrixRotateXYZ");
|
||||
core.addApiFunctionByName("MatrixRotateZYX");
|
||||
core.addApiFunctionByName("MatrixScale");
|
||||
core.addApiFunctionByName("MatrixFrustum");
|
||||
core.addApiFunctionByName("MatrixPerspective");
|
||||
core.addApiFunctionByName("MatrixOrtho");
|
||||
core.addApiFunctionByName("MatrixLookAt");
|
||||
//core.addApiFunctionByName("MatrixToFloatV")
|
||||
core.addApiFunctionByName("QuaternionAdd");
|
||||
core.addApiFunctionByName("QuaternionAddValue");
|
||||
core.addApiFunctionByName("QuaternionSubtract");
|
||||
core.addApiFunctionByName("QuaternionSubtractValue");
|
||||
core.addApiFunctionByName("QuaternionIdentity");
|
||||
core.addApiFunctionByName("QuaternionLength");
|
||||
core.addApiFunctionByName("QuaternionNormalize");
|
||||
core.addApiFunctionByName("QuaternionInvert");
|
||||
core.addApiFunctionByName("QuaternionMultiply");
|
||||
core.addApiFunctionByName("QuaternionScale");
|
||||
core.addApiFunctionByName("QuaternionDivide");
|
||||
core.addApiFunctionByName("QuaternionLerp");
|
||||
core.addApiFunctionByName("QuaternionNlerp");
|
||||
core.addApiFunctionByName("QuaternionSlerp");
|
||||
core.addApiFunctionByName("QuaternionFromVector3ToVector3");
|
||||
core.addApiFunctionByName("QuaternionFromMatrix");
|
||||
core.addApiFunctionByName("QuaternionToMatrix");
|
||||
core.addApiFunctionByName("QuaternionFromAxisAngle");
|
||||
//core.addApiFunctionByName("QuaternionToAxisAngle")
|
||||
core.addApiFunctionByName("QuaternionFromEuler");
|
||||
core.addApiFunctionByName("QuaternionToEuler");
|
||||
core.addApiFunctionByName("QuaternionTransform");
|
||||
core.addApiFunctionByName("QuaternionEquals");
|
||||
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.exportGlobalConstant("DEG2RAD", "(PI/180.0)");
|
||||
core.exportGlobalConstant("RAD2DEG", "(180.0/PI)");
|
||||
// module: rcamera
|
||||
core.addApiFunctionByName("GetCameraForward");
|
||||
core.addApiFunctionByName("GetCameraUp");
|
||||
core.addApiFunctionByName("GetCameraRight");
|
||||
core.addApiFunctionByName("CameraMoveForward");
|
||||
core.addApiFunctionByName("CameraMoveUp");
|
||||
core.addApiFunctionByName("CameraMoveRight");
|
||||
core.addApiFunctionByName("CameraMoveToTarget");
|
||||
core.addApiFunctionByName("CameraYaw");
|
||||
core.addApiFunctionByName("CameraPitch");
|
||||
core.addApiFunctionByName("CameraRoll");
|
||||
core.addApiFunctionByName("GetCameraViewMatrix");
|
||||
core.addApiFunctionByName("GetCameraProjectionMatrix");
|
||||
// module: rgui
|
||||
core.addApiFunctionByName("GuiEnable");
|
||||
core.addApiFunctionByName("GuiDisable");
|
||||
core.addApiFunctionByName("GuiLock");
|
||||
core.addApiFunctionByName("GuiUnlock");
|
||||
core.addApiFunctionByName("GuiIsLocked");
|
||||
core.addApiFunctionByName("GuiFade");
|
||||
core.addApiFunctionByName("GuiSetState");
|
||||
core.addApiFunctionByName("GuiGetState");
|
||||
core.addApiFunctionByName("GuiSetFont");
|
||||
core.addApiFunctionByName("GuiGetFont");
|
||||
core.addApiFunctionByName("GuiSetStyle");
|
||||
core.addApiFunctionByName("GuiGetStyle");
|
||||
core.addApiFunctionByName("GuiWindowBox");
|
||||
core.addApiFunctionByName("GuiGroupBox");
|
||||
core.addApiFunctionByName("GuiLine");
|
||||
core.addApiFunctionByName("GuiPanel");
|
||||
core.addApiFunctionByName("GuiScrollPanel");
|
||||
core.addApiFunctionByName("GuiLabel");
|
||||
core.addApiFunctionByName("GuiButton");
|
||||
core.addApiFunctionByName("GuiLabelButton");
|
||||
core.addApiFunctionByName("GuiToggle");
|
||||
core.addApiFunctionByName("GuiToggleGroup");
|
||||
core.addApiFunctionByName("GuiCheckBox");
|
||||
core.addApiFunctionByName("GuiComboBox");
|
||||
//core.addApiFunctionByName("GuiDropdownBox")
|
||||
//core.addApiFunctionByName("GuiSpinner")
|
||||
//core.addApiFunctionByName("GuiValueBox")
|
||||
core.addApiFunctionByName("GuiTextBox");
|
||||
//core.addApiFunctionByName("GuiTextBoxMulti")
|
||||
core.addApiFunctionByName("GuiSlider");
|
||||
core.addApiFunctionByName("GuiSliderBar");
|
||||
core.addApiFunctionByName("GuiProgressBar");
|
||||
core.addApiFunctionByName("GuiStatusBar");
|
||||
core.addApiFunctionByName("GuiDummyRec");
|
||||
core.addApiFunctionByName("GuiGrid");
|
||||
//core.addApiFunctionByName("GuiListView")
|
||||
//core.addApiFunctionByName("GuiListViewEx")
|
||||
core.addApiFunctionByName("GuiMessageBox");
|
||||
//core.addApiFunctionByName("GuiTextInputBox")
|
||||
core.addApiFunctionByName("GuiColorPicker");
|
||||
core.addApiFunctionByName("GuiColorPanel");
|
||||
core.addApiFunctionByName("GuiColorBarAlpha");
|
||||
core.addApiFunctionByName("GuiColorBarHue");
|
||||
core.addApiFunctionByName("GuiLoadStyle");
|
||||
core.addApiFunctionByName("GuiLoadStyleDefault");
|
||||
core.addApiFunctionByName("GuiIconText");
|
||||
core.addApiFunctionByName("GuiDrawIcon");
|
||||
//core.addApiFunctionByName("GuiGetIcons")
|
||||
//core.addApiFunctionByName("GuiGetIconData")
|
||||
//core.addApiFunctionByName("GuiSetIconData")
|
||||
core.addApiFunctionByName("GuiSetIconScale");
|
||||
// module: rlights
|
||||
ignore("GuiDropdownBox");
|
||||
ignore("GuiSpinner");
|
||||
ignore("GuiValueBox");
|
||||
ignore("GuiListView");
|
||||
ignore("GuiListViewEx");
|
||||
ignore("GuiTextInputBox");
|
||||
ignore("GuiGetIcons");
|
||||
ignore("GuiTabBar");
|
||||
ignore("GuiLoadIcons");
|
||||
// TODO: Parse and support light struct
|
||||
// core.addApiFunctionByName("CreateLight")
|
||||
// core.addApiFunctionByName("UpdateLightValues")
|
||||
// module: reasings
|
||||
core.addApiFunctionByName("EaseLinearNone");
|
||||
core.addApiFunctionByName("EaseLinearIn");
|
||||
core.addApiFunctionByName("EaseLinearOut");
|
||||
core.addApiFunctionByName("EaseLinearInOut");
|
||||
core.addApiFunctionByName("EaseSineIn");
|
||||
core.addApiFunctionByName("EaseSineOut");
|
||||
core.addApiFunctionByName("EaseSineInOut");
|
||||
core.addApiFunctionByName("EaseCircIn");
|
||||
core.addApiFunctionByName("EaseCircOut");
|
||||
core.addApiFunctionByName("EaseCircInOut");
|
||||
core.addApiFunctionByName("EaseCubicIn");
|
||||
core.addApiFunctionByName("EaseCubicOut");
|
||||
core.addApiFunctionByName("EaseCubicInOut");
|
||||
core.addApiFunctionByName("EaseQuadIn");
|
||||
core.addApiFunctionByName("EaseQuadOut");
|
||||
core.addApiFunctionByName("EaseQuadInOut");
|
||||
core.addApiFunctionByName("EaseExpoIn");
|
||||
core.addApiFunctionByName("EaseExpoOut");
|
||||
core.addApiFunctionByName("EaseExpoInOut");
|
||||
core.addApiFunctionByName("EaseBackIn");
|
||||
core.addApiFunctionByName("EaseBounceOut");
|
||||
core.addApiFunctionByName("EaseBounceInOut");
|
||||
core.addApiFunctionByName("EaseElasticIn");
|
||||
ignore("CreateLight");
|
||||
ignore("UpdateLightValues");
|
||||
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);
|
||||
});
|
||||
core.addAllEnums();
|
||||
// api.enums.find(x => x.name === "KeyboardKey")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MouseButton")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ConfigFlags")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "BlendMode")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "TraceLogLevel")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MouseCursor")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "PixelFormat")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "CameraProjection")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "CameraMode")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ShaderLocationIndex")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "ShaderUniformDataType")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
// api.enums.find(x => x.name === "MaterialMapIndex")?.values.forEach(x => core.exportGlobalConstant(x.name, x.description))
|
||||
api.enums.forEach(x => core.addEnum(x));
|
||||
core.exportGlobalConstant("MATERIAL_MAP_DIFFUSE", "Albedo material (same as: MATERIAL_MAP_DIFFUSE");
|
||||
core.exportGlobalConstant("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!");
|
||||
}
|
||||
main();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue