diff --git a/raylib/external/scripts/emcc-generate-js.sh b/raylib/external/scripts/emcc-generate-js.sh new file mode 100755 index 0000000..be71a38 --- /dev/null +++ b/raylib/external/scripts/emcc-generate-js.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +EMCC_EXPORT="['_InitWindow','_CloseWindow','_WindowShouldClose','_IsWindowMinimized','_ToggleFullscreen','_SetWindowIcon','_SetWindowTitle','_SetWindowPosition','_SetWindowMonitor','_SetWindowMinSize','_GetScreenWidth','_GetScreenHeight','_ShowCursor','_HideCursor','_IsCursorHidden','_EnableCursor','_DisableCursor','_ClearBackground','_BeginDrawing','_EndDrawing','_Begin2dMode','_End2dMode','_Begin3dMode','_End3dMode','_BeginTextureMode','_EndTextureMode','_GetMouseRay','_GetWorldToScreen','_GetCameraMatrix','_SetTargetFPS','_GetFPS','_GetFrameTime','_GetHexValue','_GetColor','_ColorToFloat','_Vector3ToFloat','_MatrixToFloat','_Vector3Zero','_Vector3One','_MatrixIdentity','_ShowLogo','_SetConfigFlags','_TraceLog','_TakeScreenshot','_GetRandomValue','_StorageSaveValue','_StorageLoadValue','_IsKeyPressed','_IsKeyDown','_IsKeyReleased','_IsKeyUp','_GetKeyPressed','_SetExitKey','_IsGamepadAvailable','_IsGamepadName','_IsGamepadButtonPressed','_IsGamepadButtonDown','_IsGamepadButtonReleased','_IsGamepadButtonUp','_GetGamepadButtonPressed','_GetGamepadAxisCount','_GetGamepadAxisMovement','_IsMouseButtonPressed','_IsMouseButtonDown','_IsMouseButtonReleased','_IsMouseButtonUp','_GetMouseX','_GetMouseY','_GetMousePosition','_SetMousePosition','_GetMouseWheelMove','_GetTouchX','_GetTouchY','_GetTouchPosition','_SetGesturesEnabled','_IsGestureDetected','_GetGestureDetected','_GetTouchPointsCount','_GetGestureHoldDuration','_GetGestureDragVector','_GetGestureDragAngle','_GetGesturePinchVector','_GetGesturePinchAngle','_SetCameraMode','_UpdateCamera','_SetCameraPanControl','_SetCameraAltControl','_SetCameraSmoothZoomControl','_SetCameraMoveControls','_DrawPixel','_DrawPixelV','_DrawLine','_DrawLineV','_DrawLineEx','_DrawLineBezier','_DrawCircle','_DrawCircleGradient','_DrawCircleV','_DrawCircleLines','_DrawRectangle','_DrawRectangleRec','_DrawRectanglePro','_DrawRectangleGradientV','_DrawRectangleGradientH','_DrawRectangleGradientEx','_DrawRectangleV','_DrawRectangleLines','_DrawRectangleT','_DrawTriangle','_DrawTriangleLines','_DrawPoly','_DrawPolyEx','_DrawPolyExLines','_CheckCollisionRecs','_CheckCollisionCircles','_CheckCollisionCircleRec','_GetCollisionRec','_CheckCollisionPointRec','_CheckCollisionPointCircle','_CheckCollisionPointTriangle','_LoadImage','_LoadImageEx','_LoadImagePro','_LoadImageRaw','_LoadTexture','_LoadTextureFromImage','_LoadRenderTexture','_UnloadImage','_UnloadTexture','_UnloadRenderTexture','_GetImageData','_GetTextureData','_UpdateTexture','_SaveImageAs','_ImageToPOT','_ImageFormat','_ImageAlphaMask','_ImageDither','_ImageCopy','_ImageCrop','_ImageResize','_ImageResizeNN','_ImageText','_ImageTextEx','_ImageDraw','_ImageDrawText','_ImageDrawTextEx','_ImageFlipVertical','_ImageFlipHorizontal','_ImageColorTint','_ImageColorInvert','_ImageColorGrayscale','_ImageColorContrast','_ImageColorBrightness','_GenImageColor','_GenImageGradientV','_GenImageGradientH','_GenImageGradientRadial','_GenImageChecked','_GenImageWhiteNoise','_GenImagePerlinNoise','_GenImageCellular','_GenTextureMipmaps','_SetTextureFilter','_SetTextureWrap','_DrawTexture','_DrawTextureV','_DrawTextureEx','_DrawTextureRec','_DrawTexturePro','_GetDefaultFont','_LoadSpriteFont','_LoadSpriteFontEx','_UnloadSpriteFont','_DrawFPS','_DrawText','_DrawTextEx','_MeasureText','_MeasureTextEx','_DrawLine3D','_DrawCircle3D','_DrawCube','_DrawCubeV','_DrawCubeWires','_DrawCubeTexture','_DrawSphere','_DrawSphereEx','_DrawSphereWires','_DrawCylinder','_DrawCylinderWires','_DrawPlane','_DrawRay','_DrawGrid','_DrawGizmo','_LoadModel','_LoadModelFromMesh','_UnloadModel','_LoadMesh','_UnloadMesh','_GenMeshPlane','_GenMeshCube','_GenMeshSphere','_GenMeshHemiSphere','_GenMeshCylinder','_GenMeshTorus','_GenMeshKnot','_GenMeshHeightmap','_GenMeshCubicmap','_LoadMaterial','_LoadMaterialDefault','_UnloadMaterial','_DrawModel','_DrawModelEx','_DrawModelWires','_DrawModelWiresEx','_DrawBoundingBox','_DrawBillboard','_DrawBillboardRec','_CalculateBoundingBox','_CheckCollisionSpheres','_CheckCollisionBoxes','_CheckCollisionBoxSphere','_CheckCollisionRaySphere','_CheckCollisionRaySphereEx','_CheckCollisionRayBox','_GetCollisionRayMesh','_GetCollisionRayTriangle','_GetCollisionRayGround','_LoadText','_LoadShader','_UnloadShader','_GetShaderDefault','_GetTextureDefault','_GetShaderLocation','_SetShaderValue','_SetShaderValuei','_SetShaderValueMatrix','_SetMatrixProjection','_SetMatrixModelview','_GenTextureCubemap','_GenTextureIrradiance','_GenTexturePrefilter','_GenTextureBRDF','_BeginShaderMode','_EndShaderMode','_BeginBlendMode','_EndBlendMode','_GetVrDeviceInfo','_InitVrSimulator','_CloseVrSimulator','_IsVrSimulatorReady','_SetVrDistortionShader','_UpdateVrTracking','_ToggleVrMode','_BeginVrDrawing','_EndVrDrawing','_InitAudioDevice','_CloseAudioDevice','_IsAudioDeviceReady','_SetMasterVolume','_LoadWave','_LoadWaveEx','_LoadSound','_LoadSoundFromWave','_UpdateSound','_UnloadWave','_UnloadSound','_PlaySound','_PauseSound','_ResumeSound','_StopSound','_IsSoundPlaying','_SetSoundVolume','_SetSoundPitch','_WaveFormat','_WaveCopy','_WaveCrop','_GetWaveData','_LoadMusicStream','_UnloadMusicStream','_PlayMusicStream','_UpdateMusicStream','_StopMusicStream','_PauseMusicStream','_ResumeMusicStream','_IsMusicPlaying','_SetMusicVolume','_SetMusicPitch','_SetMusicLoopCount','_GetMusicTimeLength','_GetMusicTimePlayed','_InitAudioStream','_UpdateAudioStream','_CloseAudioStream','_IsAudioBufferProcessed','_PlayAudioStream','_PauseAudioStream','_ResumeAudioStream','_IsAudioStreamPlaying','_StopAudioStream','_SetAudioStreamVolume','_SetAudioStreamPitch']" +RAYLIB_SRC=( "audio.c" "core.c" "mini_al.c" "models.c" "rlgl.c" "shapes.c" "text.c" "textures.c" "utils.c" "external/stb_vorbis.c" ) +RAYLIB_OBJ=( "audio.o" "core.o" "mini_al.o" "models.o" "rlgl.o" "shapes.o" "text.o" "textures.o" "utils.o" "external/stb_vorbis.o" ) + +for i in "${RAYLIB_SRC[@]}"; do + emcc "${i}" -o "${i/.c}.o" -O1 -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Wno-unused-function -Wno-unused-variable -Iexternal -Iexternal/glfw/include -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 +done + +emcc `echo "${RAYLIB_OBJ[*]}"` -o raylib.js -g3 -s USE_GLFW=3 -s EXPORTED_FUNCTIONS=$EMCC_EXPORT + +rm "${GOPATH}"/src/github.com/gen2brain/raylib-go/raylib/*.o "${GOPATH}"/src/github.com/gen2brain/raylib-go/raylib/external/*.o diff --git a/raylib/raylib_js.go b/raylib/raylib_js.go new file mode 100644 index 0000000..35b91d9 --- /dev/null +++ b/raylib/raylib_js.go @@ -0,0 +1,5 @@ +// +build js + +//go:generate ./external/scripts/emcc-generate-js.sh + +package raylib