From da8f828e2d8be389a06047715aaa44f02c41083b Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Fri, 8 Dec 2017 15:26:54 +0100 Subject: [PATCH] Add web template and mainloop js --- raylib/external/scripts/emcc-generate-js.sh | 5 +- raylib/external/web/index.html | 240 ++++++++++++++++++++ raylib/external/web/mainloop.js | 7 + 3 files changed, 250 insertions(+), 2 deletions(-) create mode 100644 raylib/external/web/index.html create mode 100644 raylib/external/web/mainloop.js diff --git a/raylib/external/scripts/emcc-generate-js.sh b/raylib/external/scripts/emcc-generate-js.sh index be71a38..bea2a78 100755 --- a/raylib/external/scripts/emcc-generate-js.sh +++ b/raylib/external/scripts/emcc-generate-js.sh @@ -1,5 +1,6 @@ #!/bin/sh +BASE_DIR="${GOPATH}/src/github.com/gen2brain/raylib-go/raylib" 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" ) @@ -8,6 +9,6 @@ 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 +emcc `echo "${RAYLIB_OBJ[*]}"` -o raylib.js --post-js "${BASE_DIR}/external/web/mainloop.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 +rm "${BASE_DIR}"/*.o "${BASE_DIR}"/external/*.o diff --git a/raylib/external/web/index.html b/raylib/external/web/index.html new file mode 100644 index 0000000..f61ee38 --- /dev/null +++ b/raylib/external/web/index.html @@ -0,0 +1,240 @@ + + + + + + + raylib-go HTML5 + + + + + + + + + + + + + +
+ + +
+
Downloading...
+ + + + + +
+ +
+
+ +
+ +
+ + + + + + + + + diff --git a/raylib/external/web/mainloop.js b/raylib/external/web/mainloop.js new file mode 100644 index 0000000..9c3a3d0 --- /dev/null +++ b/raylib/external/web/mainloop.js @@ -0,0 +1,7 @@ +function _emscripten_set_main_loop_go(fps, simulateInfiniteLoop) { + if (_go_update_function !== undefined && typeof _go_update_function == 'function') { + _emscripten_set_main_loop(_go_update_function, fps, simulateInfiniteLoop); + } +} + +Module["_emscripten_set_main_loop_go"] = _emscripten_set_main_loop_go;