Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ namespace winrt::BabylonReactNative::implementation {
_width = static_cast<size_t>(size.Width);
_height = static_cast<size_t>(size.Height);

// Use windowTypePtr == 2 for xaml swap chain panels
auto windowTypePtr = reinterpret_cast<void*>(2);
auto windowPtr = get_abi(static_cast<winrt::Windows::UI::Xaml::Controls::SwapChainPanel>(*this));
Babylon::UpdateView(windowPtr, _width, _height, windowTypePtr);
Babylon::UpdateView(windowPtr, _width, _height);
}

void EngineView::OnPointerPressed(IInspectable const& /*sender*/, PointerEventArgs const& args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(BABYLON_REACT_NATIVE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../react-native")
set(BABYLON_NATIVE_WINDOWS_STORE_USE_SWAPCHAINPANEL 1)

include(${BABYLON_REACT_NATIVE_DIR}/shared/CMakeLists.txt)

set(BABYLON_NATIVE_DIR "${BABYLON_REACT_NATIVE_DIR}/submodules/BabylonNative")
Expand Down
1 change: 1 addition & 0 deletions Modules/@babylonjs/react-native/ios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../shared/CMakeLists.txt)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++")

# configure Babylon Native to use JSI
set(NAPI_JAVASCRIPT_ENGINE "JSI" CACHE STRING "The JavaScript engine to power N-API")
Expand Down
15 changes: 10 additions & 5 deletions Modules/@babylonjs/react-native/shared/BabylonNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,20 @@ namespace Babylon
Napi::Detach(m_env);
}

void UpdateView(void* windowPtr, void* windowTypePtr, size_t width, size_t height)
void UpdateView(void* windowPtr, size_t width, size_t height)
{
GraphicsConfiguration graphicsConfig{};
graphicsConfig.WindowPtr = reinterpret_cast<WindowType>(windowPtr);
graphicsConfig.Width = width;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit can we have this as a reinterpret_cast()?

graphicsConfig.Height = height;

if (!g_graphics)
{
g_graphics = Graphics::CreateGraphics(windowPtr, windowTypePtr, width, height);
g_graphics = Graphics::CreateGraphics(graphicsConfig);
}
else
{
g_graphics->UpdateWindow(windowPtr, windowTypePtr);
g_graphics->UpdateWindow(graphicsConfig);
g_graphics->UpdateSize(width, height);
}

Expand Down Expand Up @@ -222,11 +227,11 @@ namespace Babylon
g_nativeModule.reset();
}

void UpdateView(void* windowPtr, size_t width, size_t height, void* windowTypePtr)
void UpdateView(void* windowPtr, size_t width, size_t height)
{
if (auto nativeModule{ g_nativeModule.lock() })
{
nativeModule->UpdateView(windowPtr, windowTypePtr, width, height);
nativeModule->UpdateView(windowPtr, width, height);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/@babylonjs/react-native/shared/BabylonNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Babylon

void Initialize(facebook::jsi::Runtime& jsiRuntime, Dispatcher jsDispatcher);
void Deinitialize();
void UpdateView(void* windowPtr, size_t width, size_t height, void* windowTypePtr = nullptr);
void UpdateView(void* windowPtr, size_t width, size_t height);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we should be removing void * from this header as well, in favor of WindowType.

Currently I cannot include the headers here without build failure, I'll keep tooling with CMake to so that this works, but it may require making this a library instead of a collection of source files included in another library. I'm no CMake expert, however.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id suggest redefining the type here or using a void pointer for the time being. We can update include directories for the native modules to track down the headers required to access the window type definition. But right now the native modules aren't precompiled binaries when distributed through npm. So if BabylonNative.h references babylon native headers and our react-native native module references BabylonNative.h, i'm pretty sure wed have to package and distribute all headers required to resolve the windowtype, which is going to be a lot more work/seems beyond the scope of fixing breaking changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After chatting offline, I'll go forward with retaining void*.

void RenderView();
void ResetView();
void SetMouseButtonState(uint32_t buttonId, bool isDown, uint32_t x, uint32_t y);
Expand Down
2 changes: 1 addition & 1 deletion Modules/@babylonjs/react-native/submodules/BabylonNative
Submodule BabylonNative updated 61 files
+198,061 −197,877 Apps/BabylonScripts/babylon.max.js
+10 −2 Apps/Playground/Android/app/src/main/cpp/BabylonNativeJNI.cpp
+1 −1 Apps/Playground/Scripts/playground_runner.js
+8 −3 Apps/Playground/UWP/App.cpp
+6 −1 Apps/Playground/Win32/App.cpp
+9 −4 Apps/Playground/X11/App.cpp
+2 −1 Apps/Playground/iOS/LibNativeBridge.h
+7 −4 Apps/Playground/iOS/LibNativeBridge.mm
+1 −3 Apps/Playground/iOS/ViewController.swift
+8 −5 Apps/Playground/macOS/ViewController.mm
+14 −6 Apps/ValidationTests/Android/app/src/main/cpp/BabylonNativeJNI.cpp
+11 −10 Apps/ValidationTests/Shared/TestUtils.h
+6 −1 Apps/ValidationTests/Win32/App.cpp
+10 −4 Apps/ValidationTests/X11/App.cpp
+2 −1 Apps/ValidationTests/iOS/LibNativeBridge.h
+9 −6 Apps/ValidationTests/iOS/LibNativeBridge.mm
+1 −2 Apps/ValidationTests/iOS/ViewController.swift
+8 −6 Apps/ValidationTests/macOS/ViewController.mm
+67 −4 Core/Graphics/CMakeLists.txt
+15 −0 Core/Graphics/Include/Android/Babylon/GraphicsPlatform.h
+15 −0 Core/Graphics/Include/Apple/Babylon/GraphicsPlatform.h
+8 −6 Core/Graphics/Include/Shared/Babylon/Graphics.h
+17 −0 Core/Graphics/Include/UWP/CoreWindow/Babylon/GraphicsPlatform.h
+15 −0 Core/Graphics/Include/UWP/SwapChainPanel/Babylon/GraphicsPlatform.h
+15 −0 Core/Graphics/Include/Unix/Babylon/GraphicsPlatform.h
+15 −0 Core/Graphics/Include/Win32/Babylon/GraphicsPlatform.h
+0 −0 Core/Graphics/Source/Android/Babylon/GraphicsPlatformImpl.h
+27 −0 Core/Graphics/Source/Android/GraphicsPlatform.cpp
+0 −0 Core/Graphics/Source/Apple/Babylon/GraphicsPlatformImpl.h
+24 −0 Core/Graphics/Source/Apple/iOS/GraphicsPlatform.mm
+26 −0 Core/Graphics/Source/Apple/macOS/GraphicsPlatform.mm
+12 −22 Core/Graphics/Source/Graphics.cpp
+51 −48 Core/Graphics/Source/GraphicsImpl.cpp
+20 −12 Core/Graphics/Source/GraphicsImpl.h
+0 −0 Core/Graphics/Source/UWP/Babylon/GraphicsPlatformImpl.h
+31 −0 Core/Graphics/Source/UWP/CoreWindow/GraphicsPlatform.cpp
+32 −0 Core/Graphics/Source/UWP/SwapChainPanel/GraphicsPlatform.cpp
+0 −0 Core/Graphics/Source/Unix/Babylon/GraphicsPlatformImpl.h
+41 −0 Core/Graphics/Source/Unix/GraphicsPlatform.cpp
+0 −0 Core/Graphics/Source/Win32/Babylon/GraphicsPlatformImpl.h
+27 −0 Core/Graphics/Source/Win32/GraphicsPlatform.cpp
+20 −0 Dependencies/AndroidExtensions/Include/AndroidExtensions/JavaWrappers.h
+24 −0 Dependencies/AndroidExtensions/Source/JavaWrappers.cpp
+3 −3 Dependencies/xr/Include/XR.h
+12 −12 Dependencies/xr/Source/ARCore/XR.cpp
+12 −12 Dependencies/xr/Source/ARKit/XR.mm
+1 −0 Dependencies/xr/Source/OpenXR/Include/IXrContextOpenXR.h
+16 −21 Dependencies/xr/Source/OpenXR/XR.cpp
+1 −0 Dependencies/xr/Source/OpenXR/XrRegistry.h
+1 −1 Plugins/NativeCapture/CMakeLists.txt
+13 −13 Plugins/NativeCapture/Source/NativeCapture.cpp
+0 −2 Plugins/NativeEngine/Include/Babylon/Plugins/NativeEngine.h
+2 −2 Plugins/NativeEngine/Source/NativeEngine.cpp
+3 −3 Plugins/NativeEngine/Source/NativeEngine.h
+4 −0 Plugins/NativeXr/CMakeLists.txt
+33 −33 Plugins/NativeXr/Source/NativeXr.cpp
+4 −3 Polyfills/Window/CMakeLists.txt
+1 −0 Polyfills/Window/Include/Babylon/Polyfills/Window.h
+21 −0 Polyfills/Window/Source/Window.cpp
+1 −1 Polyfills/Window/Source/Window.h
+45 −26 azure-pipelines.yml