diff --git a/demo/addons/godot-openxr/CHANGES.md b/demo/addons/godot-openxr/CHANGES.md index 258c3aeb..80c9dcd7 100644 --- a/demo/addons/godot-openxr/CHANGES.md +++ b/demo/addons/godot-openxr/CHANGES.md @@ -1,6 +1,11 @@ Changes to the Godot OpenXR asset ================================= +1.4.0 +------------------- +- Oculus OpenXR mobile SDK version 42 update. + + 1.3.0 ------------------- - Added default interaction profiles for Samsung Odyssey, HTC Cosmos, HTC Focus and Huawei controllers. diff --git a/thirdparty/README.md b/thirdparty/README.md index 5d0a2029..a12ba780 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -23,7 +23,7 @@ Godots CPP bindings library (submoduled) This is a copy of the Oculus OpenXR mobile SDK downloaded from [here](https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk). - Upstream: https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk -- Version: 40.0.0 +- Version: 42.0.0 - License: https://developer.oculus.com/licenses/oculussdk/ ## OpenXR loader diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/JniUtils.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/JniUtils.h index b318c6f0..278f4fe4 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/JniUtils.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/JniUtils.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : JniUtils.h @@ -5,9 +7,8 @@ Content : JNI utility functions Created : October 21, 2014 Authors : J.M.P. van Waveren, Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #ifndef OVR_JniUtils_h #define OVR_JniUtils_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Asserts.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Asserts.h index 58f6ca6d..ed6b15f8 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Asserts.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Asserts.h @@ -1,28 +1,31 @@ -/************************************************************************************ - -Filename : OVR_Asserts.h -Content : Capture Asserts for Release and Debug builds. Send Telemetry logs in Release builds. -Created : July, 2019 -Notes : - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +/************************************************************************************ + * Filename : OVR_Asserts.h + * Content : Capture Asserts for Release and Debug builds. Send Telemetry logs in + * Release builds. + * Created : July, 2019 + * Notes : + ***********************************************************************************/ -************************************************************************************/ #ifndef OVR_Asserts_h #define OVR_Asserts_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_BitFlags.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_BitFlags.h index 353e05f9..fb7204e9 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_BitFlags.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_BitFlags.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ PublicHeader: OVR_Kernel.h @@ -6,8 +8,6 @@ Content : Template for typesafe number types. Created : June 5, 2014 Authors : Jonathan E. wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #if !defined(OVR_BitFlags_h) diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Compiler.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Compiler.h index ccff226c..4d8b3b10 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Compiler.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Compiler.h @@ -1,29 +1,30 @@ -/************************************************************************************ - -PublicHeader: OVR_Types.h -Filename : OVR_Compiler.h -Content : Compiler-specific feature identification and utilities -Created : June 19, 2014 -Notes : - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. - -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -************************************************************************************/ +/************************************************************************************ + * PublicHeader: OVR_Types.h + * Filename : OVR_Compiler.h + * Content : Compiler-specific feature identification and utilities + * Created : June 19, 2014 + * Notes : + ***********************************************************************************/ #ifndef OVR_Compiler_h #define OVR_Compiler_h @@ -75,6 +76,12 @@ limitations under the License. #endif #endif +#if (__cplusplus > 199711L) +#define OVR_CPP11 +#else +#undef OVR_CPP11 +#endif + #elif defined(__GNUC__) #define OVR_CC_GNU diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_DebugMutex.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_DebugMutex.h index 8bd7e8a6..c0fbd0a4 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_DebugMutex.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_DebugMutex.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_DebugMutex.h @@ -11,8 +13,6 @@ Content : Implements wrappers for std::mutex and that allows tracking of w Created : May 12, 2020 Authors : Jonathan Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "OVR_LogUtils.h" diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Deque.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Deque.h index 00148e9c..e5bf8459 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Deque.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Deque.h @@ -1,32 +1,35 @@ -/************************************************************************************ - -Filename : OVR_Deque.h -Content : Deque container -Created : Nov. 15, 2013 -Authors : Dov Katz - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. - -You may obtain a copy of the License at +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -*************************************************************************************/ +/************************************************************************************ + * Filename : OVR_Deque.h + * Content : Deque container + * Created : Nov. 15, 2013 + * Authors : Dov Katz + ***********************************************************************************/ #ifndef OVR_Deque_h #define OVR_Deque_h +#include + namespace OVR { #define OVR_ALLOC malloc diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_JSON.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_JSON.h index 9ee7b9af..b62b5003 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_JSON.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_JSON.h @@ -1,3 +1,23 @@ +/* + * Portions Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /************************************************************************************ PublicHeader: None @@ -29,23 +49,6 @@ Notes : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. - -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ************************************************************************************/ #ifndef OVR_JSON_h #define OVR_JSON_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Lockless.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Lockless.h index b79f207f..95143cb2 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Lockless.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Lockless.h @@ -1,28 +1,29 @@ -/************************************************************************************ - -Filename : OVR_Lockless.h -Content : Lock-less classes for producer/consumer communication -Created : November 9, 2013 -Authors : John Carmack - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -*************************************************************************************/ +/************************************************************************************ + * Filename : OVR_Lockless.h + * Content : Lock-less classes for producer/consumer communication + * Created : November 9, 2013 + * Authors : John Carmack + ***********************************************************************************/ #ifndef OVR_Lockless_h #define OVR_Lockless_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_LogUtils.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_LogUtils.h index 7e50fb46..69d9ac60 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_LogUtils.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_LogUtils.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_LogUtils.h (Previously Log.h) @@ -5,9 +7,8 @@ Content : Macros and helpers for Android logging. Created : 4/15/2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #if !defined(OVRLib_Log_h) #define OVRLib_Log_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Math.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Math.h index f9b5692c..d5c2d0cf 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Math.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Math.h @@ -1,7 +1,8 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /********************************************************************************/ /** \file OVR_Math.h \brief Implementation of 3D primitives such as vectors, matrices. - \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ #ifndef OVR_Math_h @@ -100,7 +101,7 @@ inline T clamp(T v, T lo, T hi) { // // Independent OVR_MATH_UNUSED implementation for OVR_Math.h. -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #define OVR_MATH_UNUSED(a) \ do { \ __typeof__(&a) __attribute__((unused)) __tmp = &a; \ diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_MemBuffer.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_MemBuffer.h index 2960eae4..fc5d0a72 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_MemBuffer.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_MemBuffer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : MemBuffer.h @@ -5,10 +7,8 @@ Content : Memory buffer. Created : May 13, 2014 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #ifndef MEMBUFFER_H #define MEMBUFFER_H diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Pose.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Pose.h index 5c53acf2..df3c65aa 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Pose.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Pose.h @@ -1,7 +1,8 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /********************************************************************************/ /** \file OVR_Pose.h \brief Implementation of 3D primitives such as vectors, matrices. - \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ #ifndef OVR_Pose_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Std.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Std.h index dd9104ed..258a2233 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Std.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Std.h @@ -1,28 +1,29 @@ -/************************************************************************************ - -Filename : OVR_Std.h -Content : Standard C function interface -Created : September 19, 2012 -Notes : - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -************************************************************************************/ +/************************************************************************************ + * Filename : OVR_Std.h + * Content : Standard C function interface + * Created : September 19, 2012 + * Notes : + ***********************************************************************************/ #ifndef OVR_Std_h #define OVR_Std_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Types.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Types.h index 8aab9850..eb3dea4e 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Types.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_Types.h @@ -1,28 +1,29 @@ -/************************************************************************************ - -Filename : OVR_Types.h -Content : Standard library defines and simple types -Created : September 19, 2012 -Notes : - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -************************************************************************************/ +/************************************************************************************ + * Filename : OVR_Types.h + * Content : Standard library defines and simple types + * Created : September 19, 2012 + * Notes : + ***********************************************************************************/ #ifndef OVR_Types_h #define OVR_Types_h diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_TypesafeNumber.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_TypesafeNumber.h index a9da9f54..c2fd1e72 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_TypesafeNumber.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/OVR_TypesafeNumber.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ PublicHeader: OVR_Kernel.h @@ -6,8 +8,6 @@ Content : Template for typesafe number types. Created : March 2, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #if !defined(OVR_TypesafeNumber_h) diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/StringUtils.h b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/StringUtils.h index 7ad9b4fe..3baa6d48 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/StringUtils.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/Include/StringUtils.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : String_Utils.h @@ -5,8 +7,6 @@ Content : std::string utility functions. Created : May, 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/1stParty/OVR/tests/OVR_LogUtilsTest.cpp b/thirdparty/oculus_mobile_sdk/1stParty/OVR/tests/OVR_LogUtilsTest.cpp index 37d740a2..d0ee3f31 100644 --- a/thirdparty/oculus_mobile_sdk/1stParty/OVR/tests/OVR_LogUtilsTest.cpp +++ b/thirdparty/oculus_mobile_sdk/1stParty/OVR/tests/OVR_LogUtilsTest.cpp @@ -1,4 +1,4 @@ -// Facebook Technologies, LLC Proprietary and Confidential. +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. #include diff --git a/thirdparty/oculus_mobile_sdk/1stParty/utilities/include/GL/gl_format.h b/thirdparty/oculus_mobile_sdk/1stParty/utilities/include/GL/gl_format.h index 05d69df2..007fccb2 100755 --- a/thirdparty/oculus_mobile_sdk/1stParty/utilities/include/GL/gl_format.h +++ b/thirdparty/oculus_mobile_sdk/1stParty/utilities/include/GL/gl_format.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // clang-format off /* ================================================================================================ @@ -7,25 +23,6 @@ Author : J.M.P. van Waveren Date : 07/17/2016 Language : C99 Format : Real tabs with the tab size equal to 4 spaces. -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - -LICENSE -============== - -Copyright (c) Facebook Technologies, LLC and its affiliates. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. DESCRIPTION @@ -92,7 +89,9 @@ static inline void glGetFormatSize( const GLenum internalFormat, GlFormatSize * #include #if defined(_WIN32) +#if !defined(NOMINMAX) #define NOMINMAX +#endif #ifndef __cplusplus #undef inline #define inline __inline diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_composition_layer_depth_test.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_composition_layer_depth_test.h index 597796b9..94eebd8d 100644 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_composition_layer_depth_test.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_composition_layer_depth_test.h @@ -1,10 +1,12 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_composition_layer_depth_test.h Content : Extension to control if a layer will participate in depth testing. If extension is not used no layer will participate in depth testing. Language : C99 Copyright -Copyright(c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene.h index 578a3ac6..b59e8321 100644 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_scene.h @@ -5,8 +7,6 @@ Content : This header defines spatial entity components and functions used information from Scene Model. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once @@ -95,6 +95,7 @@ typedef struct XrBoundary2DFB { // Output, size of the vertex buffer. uint32_t vertexCountOutput; + // Vertices of the polygonal boundary in the coordinate frame of the associated space. // Currently only support outer bounds. XrVector2f* vertices; @@ -164,9 +165,9 @@ xrGetSpaceBoundary2DFB(XrSession session, XrSpace space, XrBoundary2DFB* boundar // Get room layout associated with space that has room layout component enabled. // Note: This functions uses two-call idiom: -// 1) When uuidWallsCapacityInput == 0, only uuidWallsCountOutput will be updated and no UUIDs will +// 1) When wallUuidCapacityInput == 0, only wallUuidCountOutput will be updated and no UUIDs will // be copied; -// 2) When uuidWallsCapacityInput >= uuidWallsCountOutput, UUIDs will be copied to +// 2) When wallUuidCapacityInput >= wallUuidCountOutput, UUIDs will be copied to // entityContainerOutput; // 3) Otherwise returns XR_ERROR_SIZE_INSUFFICIENT. XRAPI_ATTR XrResult XRAPI_CALL diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene_capture.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene_capture.h index 4488a54c..98944dc9 100644 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene_capture.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_scene_capture.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_scene_capture.h Content : Scene Capture functionality. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity.h index 85239339..9e923e7a 100755 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_spatial_entity.h Content : spatial entity interface. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_container.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_container.h index 3cec93e3..ed63bed5 100644 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_container.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_container.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_spatial_entity_container.h Content : Spatial entity container functionality. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once @@ -54,9 +54,9 @@ typedef XrResult(XRAPI_PTR* PFN_xrGetSpaceContainerFB)( // Get space container component. // Note: This functions uses two-call idiom: -// 1) When uuidsCapacityInput == 0, only uuidsCountOutput will be updated and no UUIDs will be +// 1) When uuidCapacityInput == 0, only uuidCountOutput will be updated and no UUIDs will be // copied; -// 2) When uuidsCapacityInput >= uuidsCountOutput, UUIDs will be copied to +// 2) When uuidCapacityInput >= uuidCountOutput, UUIDs will be copied to // spaceContainerOutput; // 3) Otherwise returns XR_ERROR_SIZE_INSUFFICIENT. XRAPI_ATTR XrResult XRAPI_CALL diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_query.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_query.h index b17a945f..d60265ed 100755 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_query.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_query.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_spatial_entity_query.h Content : spatial entity interface. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_storage.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_storage.h index e69b4a14..3aeb7753 100755 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_storage.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/fb_spatial_entity_storage.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : fb_spatial_entity_storage.h Content : spatial entity interface. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_extension_helpers.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_extension_helpers.h index edacb226..1d6e630f 100644 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_extension_helpers.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_extension_helpers.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : openxr_extension_helpers.h Content : Helpers for private and experimental extension definition headers. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus.h index dab4bf71..4092bff6 100755 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : openxr_oculus.h Content : Oculus OpenXR Extensions. Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #ifndef OPENXR_OCULUS_H_ diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus_helpers.h b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus_helpers.h index de3d924f..93f45d72 100755 --- a/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus_helpers.h +++ b/thirdparty/oculus_mobile_sdk/OpenXR/Include/openxr/openxr_oculus_helpers.h @@ -1,11 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : openxr_oculus_helpers.h Content : OpenXR Helper routines Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #ifndef OPENXR_OCULUS_HELPERS_H diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so index 382d1907..4c76ad4c 100755 Binary files a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so and b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so differ diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Release/libopenxr_loader.so b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Release/libopenxr_loader.so index 7b615830..f61dea92 100755 Binary files a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Release/libopenxr_loader.so and b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/arm64-v8a/Release/libopenxr_loader.so differ diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Debug/libopenxr_loader.so b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Debug/libopenxr_loader.so index 498fa4fd..8fb10c70 100755 Binary files a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Debug/libopenxr_loader.so and b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Debug/libopenxr_loader.so differ diff --git a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Release/libopenxr_loader.so b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Release/libopenxr_loader.so index c007ca8b..604ee65b 100755 Binary files a/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Release/libopenxr_loader.so and b/thirdparty/oculus_mobile_sdk/OpenXR/Libs/Android/armeabi-v7a/Release/libopenxr_loader.so differ diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/build.py b/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/build.py index 128b62fe..d4b6e589 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/build.py +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/build.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2004-present Facebook. All Rights Reserved. +# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. # This first bit of code is common bootstrapping code # to determine the SDK root, and to set up the import diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/jni/Android.mk b/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/jni/Android.mk index 1ce63b4c..b5f4bf63 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/jni/Android.mk +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Projects/Android/jni/Android.mk @@ -72,7 +72,6 @@ LOCAL_SRC_FILES := \ ../../../Src/Render/GlBuffer.cpp \ ../../../Src/Render/GlGeometry.cpp \ ../../../Src/Render/GlProgram.cpp \ - ../../../Src/Render/GlSetup.cpp \ ../../../Src/Render/GlTexture.cpp \ ../../../Src/Render/PanelRenderer.cpp \ ../../../Src/Render/ParticleSystem.cpp \ diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/CompilerUtils.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/CompilerUtils.h index b73dd983..377d6bc3 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/CompilerUtils.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/CompilerUtils.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : CompilerUtils.h @@ -6,8 +8,6 @@ Created : March 20, 2018 Authors : Jonathan Wright Language : C++ -Copyright: Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *******************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/FrameParams.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/FrameParams.h index b86673e5..b6c5ce53 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/FrameParams.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/FrameParams.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : FrameParams.h @@ -5,7 +7,6 @@ Content : Common frame parameters Created : July 2020 Authors : Federico Schliemann Language : C++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *******************************************************************************/ diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.cpp index 08ff28fd..5d685229 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ActionComponents.h @@ -5,9 +7,6 @@ Content : Misc. VRMenu Components to handle actions Created : September 12, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "ActionComponents.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.h index 5df773e3..d0ad87ef 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ActionComponents.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ActionComponents.h @@ -5,10 +7,8 @@ Content : Misc. VRMenu Components to handle actions Created : September 12, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include "VRMenuComponent.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.cpp index 1f39f479..7c21adb2 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceAnim_Component.cpp @@ -5,9 +7,6 @@ Content : A reusable component for animating VR menu object surfaces. Created : Sept 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "AnimComponents.h" @@ -118,8 +117,8 @@ eMsgStatus OvrAnimComponent::OnEvent_Impl( case VRMENU_EVENT_FRAME_UPDATE: return Frame(guiSys, vrFrame, self, event); default: - assert(!"Event flags mismatch!"); // the constructor is specifying a flag that's not - // handled + assert(!(bool)"Event flags mismatch!"); // the constructor is specifying a flag that's + // not handled return MSG_STATUS_ALIVE; } } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.h index 090f38b9..4a2f85ec 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/AnimComponents.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceAnim_Component.h @@ -5,10 +7,8 @@ Content : A reusable component for animating VR menu object surfaces. Created : Sept 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include "VRMenuComponent.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.cpp index ed771616..cdae3eba 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : CollisionPrimitive.cpp @@ -5,9 +7,6 @@ Content : Generic collision class supporting ray / triangle intersection. Created : September 10, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "CollisionPrimitive.h" @@ -271,7 +270,7 @@ bool OvrTriCollisionPrimitive::IntersectRay( localDir.z, localDir.Length(), diff); - assert(!"IsNormalized()"); + assert(!(bool)"IsNormalized()"); } if (Intersect_RayTriangle(localStart, localDir, verts[0], verts[1], verts[2], t_, u_, v_)) { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.h index 0278fc45..e883b86b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/CollisionPrimitive.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : CollisionPrimitive.h @@ -5,10 +7,8 @@ Content : Generic collision class supporting ray / triangle intersection. Created : September 10, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.cpp index 22db7ef3..173e02a2 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : DefaultComponent.h @@ -5,9 +7,6 @@ Content : A default menu component that handles basic actions most menu it Created : July 25, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "DefaultComponent.h" @@ -77,7 +76,7 @@ eMsgStatus OvrDefaultComponent::OnEvent_Impl( UpSoundLimiter.PlaySoundEffect(guiSys, "sv_panel_touch_up", 0.1); return MSG_STATUS_ALIVE; default: - assert(!"Event flags mismatch!"); + assert(!(bool)"Event flags mismatch!"); return MSG_STATUS_ALIVE; } } @@ -192,7 +191,7 @@ eMsgStatus OvrSurfaceToggleComponent::OnEvent_Impl( case VRMENU_EVENT_FRAME_UPDATE: return Frame(guiSys, vrFrame, self, event); default: - assert(!"Event flags mismatch!"); + assert(!(bool)"Event flags mismatch!"); return MSG_STATUS_ALIVE; } } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.h index fb13fb17..5dde490d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/DefaultComponent.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : DefaultComponent.h @@ -5,10 +7,8 @@ Content : A default menu component that handles basic actions most menu it Created : July 25, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include "VRMenuComponent.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.cpp index 6deb9711..edc779fc 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Fader.cpp @@ -5,9 +7,6 @@ Content : Utility classes for animation based on alpha values Created : July 25, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "Fader.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.h index dba24368..a7cba53d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Fader.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Fader.h @@ -5,10 +7,8 @@ Content : Utility classes for animation based on alpha values Created : July 25, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once namespace OVRFW { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.cpp index 4fe39755..c6d741e7 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GazeCursor.cpp @@ -5,9 +7,6 @@ Content : Global gaze cursor. Created : June 6, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "GazeCursor.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.h index 06d59494..7f5aac0b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GazeCursor.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GazeCursor.h @@ -5,9 +7,6 @@ Content : Global gaze cursor. Created : June 6, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.cpp index f6aa27ed..067b3844 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OvrGuiSys.cpp @@ -5,9 +7,6 @@ Content : Manager for native GUIs. Created : June 6, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "GuiSys.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.h index 7d8d3f66..384523b3 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/GuiSys.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GuiSys.h @@ -5,9 +7,6 @@ Content : Manager for native GUIs. Created : June 6, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Lerp.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Lerp.h index 62347cab..911afe33 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Lerp.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Lerp.h @@ -1,3 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + /************************************************************************************ Filename : Lerp.h @@ -5,12 +14,6 @@ Content : Simple floating point interpolation. Created : 8/25/2014 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -This source code is licensed under the BSD-style license found in the -LICENSE file in the Cinema/ directory. An additional grant -of patent rights can be found in the PATENTS file in the same directory. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.cpp index 302615f1..deabb5b6 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : MetaDataManager.cpp @@ -5,9 +7,6 @@ Content : A class to manage metadata used by FolderBrowser Created : January 26, 2015 Authors : Jonathan E. Wright, Warsam Osman, Madhu Kalva -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "MetaDataManager.h" @@ -19,8 +18,12 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include #include +#if !defined(OVR_OS_WIN32) #include #include +#else +#include "windows.h" +#endif // !defined(OVR_OS_WIN32) using OVR::JSON; using OVR::JsonReader; @@ -68,6 +71,7 @@ std::unordered_map RelativeDirectoryFileList( const int numSearchPaths = static_cast(searchPaths.size()); for (int index = 0; index < numSearchPaths; ++index) { const std::string fullPath = searchPaths[index] + relativeDirPathString; +#if !defined(OVR_OS_WIN32) DIR* dir = opendir(fullPath.c_str()); if (dir != NULL) { struct dirent* entry; @@ -102,6 +106,38 @@ std::unordered_map RelativeDirectoryFileList( } closedir(dir); } +#else + WIN32_FIND_DATAA findFileData; + HANDLE hFind = FindFirstFileA(fullPath.c_str(), &findFileData); + if (hFind != INVALID_HANDLE_VALUE) { + do { + if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + std::string s = relativeDirPathString; + s += findFileData.cFileName; + s += "\\"; +#if defined(OVR_BUILD_DEBUG) + ALOG("RelativeDirectoryFileList adding - %s", s.c_str()); +#endif + std::string lowerCaseS = s.c_str(); + std::transform( + lowerCaseS.begin(), lowerCaseS.end(), lowerCaseS.begin(), ::tolower); + uniqueStrings[lowerCaseS] = s; + } else { + std::string s = relativeDirPathString; + s += findFileData.cFileName; +#if defined(OVR_BUILD_DEBUG) + ALOG("RelativeDirectoryFileList adding - %s", s.c_str()); +#endif + std::string lowerCaseS = s.c_str(); + std::transform( + lowerCaseS.begin(), lowerCaseS.end(), lowerCaseS.begin(), ::tolower); + uniqueStrings[lowerCaseS] = s; + } + } while (FindNextFileA(hFind, &findFileData) != 0); + } + + FindClose(hFind); +#endif // !defined(OVR_OS_WIN32) } return uniqueStrings; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.h index 4d0e0e29..0ea4c485 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/MetaDataManager.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : MetaDataManager.h @@ -5,9 +7,6 @@ Content : A class to manage metadata used by FolderBrowser Created : January 26, 2015 Authors : Jonathan E. Wright, Warsam Osman, Madhu Kalva -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.cpp index 3e067af9..831bb29d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Reflection.cpp @@ -5,8 +7,6 @@ Content : Functions and declarations for introspection and reflection of C Created : 11/16/2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "Reflection.h" @@ -17,7 +17,12 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include "OVR_TypesafeNumber.h" +#if !defined(WIN32) #include +#else +#include +#endif // !defined(WIN32) + #include // for strtoll namespace OVRFW { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.h index 79e135c3..05eb9326 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/Reflection.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Reflection.h @@ -5,8 +7,6 @@ Content : Functions and declarations for introspection and reflection of C Created : 11/16/2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.cpp index 47667e19..6ad40ea9 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ReflectionData.cpp @@ -5,8 +7,6 @@ Content : Data for introspection and reflection of C++ objects. Created : 11/16/2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ // this is necessary so that offsetof() can work for private class members diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.h index 93442271..60d86218 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ReflectionData.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ReflectionData.h @@ -5,9 +7,8 @@ Content : Data for introspection and reflection of C++ objects. Created : 11/16/2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "Reflection.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.cpp index 1310966a..6891e315 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SoundLimiter.cpp @@ -5,10 +7,8 @@ Content : Utility class for limiting how often sounds play. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #include "SoundLimiter.h" #include "GuiSys.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.h index 85e60d53..4ec48e6a 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/SoundLimiter.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SoundLimiter.cpp @@ -5,9 +7,6 @@ Content : Utility class for limiting how often sounds play. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.cpp index bc08bcca..d1b08ff2 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenu.cpp @@ -7,9 +9,6 @@ Content : Class that implements the basic framework for a VR menu, holds a Created : June 30, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ // includes required for VRMenu.h @@ -367,7 +366,7 @@ void VRMenu::Frame( Close_Impl(guiSys); } break; default: - assert(!"Unhandled menu state!"); + assert(!(bool)"Unhandled menu state!"); break; } CurMenuState = NextMenuState; @@ -393,7 +392,7 @@ void VRMenu::Frame( /// OVR_PERF_TIMER_STOP_MSG( VRMenu_Frame, Name.c_str() ); return; default: - assert(!"Unhandled menu state!"); + assert(!(bool)"Unhandled menu state!"); break; } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.h index bf45b601..05edb92a 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenu.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenu.h @@ -7,8 +9,6 @@ Content : Class that implements the basic framework for a VR menu, holds a Created : June 30, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.cpp index 2b688848..697b4977 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuComponent.h @@ -5,8 +7,6 @@ Content : Menuing system for VR apps. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "VRMenuComponent.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.h index 735c04d8..a9c2ffac 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuComponent.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuComponent.h @@ -5,9 +7,6 @@ Content : Menuing system for VR apps. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.cpp index 2ffdc9d2..7c34a0bf 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuEvent.cpp @@ -5,9 +7,6 @@ Content : Event class for menu events. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "VRMenuEvent.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.h index a62954c4..d41b9a48 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEvent.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuEvent.h @@ -5,9 +7,6 @@ Content : Event class for menu events. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.cpp index f5475c6f..df883034 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuEventHandler.cpp @@ -5,8 +7,6 @@ Content : Menu component for handling hit tests and dispatching events. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "VRMenuEventHandler.h" @@ -293,7 +293,7 @@ void VRMenuEventHandler::HandleEvents( DispatchToPath(guiSys, vrFrame, event, targetPath, false); break; default: - assert(!"unknown dispatch type"); + assert(!(bool)"unknown dispatch type"); break; } } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.h index 55c513a7..b3874d5a 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuEventHandler.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuFrame.h @@ -5,9 +7,6 @@ Content : Menu component for handling hit tests and dispatching events. Created : June 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.cpp index 71b7a612..6b803fb6 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OvrMenuMgr.cpp @@ -5,9 +7,6 @@ Content : Menuing system for VR apps. Created : May 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "VRMenuMgr.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.h index ad135901..242f9179 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuMgr.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuMgr.h @@ -5,10 +7,8 @@ Content : Menuing system for VR apps. Created : May 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include "VRMenuObject.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.cpp index 7707f054..7c48dfcc 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuObject.cpp @@ -5,9 +7,6 @@ Content : Menuing system for VR apps. Created : May 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "VRMenuObject.h" @@ -81,9 +80,6 @@ inline bool Intersect_RayBounds( namespace OVRFW { -float const VRMenuObject::TEXELS_PER_METER = 500.0f; -float const VRMenuObject::DEFAULT_TEXEL_SCALE = 1.0f / TEXELS_PER_METER; - const float VRMenuSurface::Z_BOUNDS = 0.05f; //====================================================================================== @@ -1078,6 +1074,12 @@ void VRMenuObject::AddChild(OvrVRMenuMgr& menuMgr, menuHandle_t const handle) { } // NOTE: bounds will be incorrect until submitted for rendering } +void VRMenuObject::AddChild(VRMenuObject* child) { + Children.push_back(child->GetHandle()); + if (child != nullptr) { + child->SetParentHandle(this->Handle); + } +} //============================== // VRMenuObject::RemoveChild diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.h index 9f013a65..c29bb715 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/VRMenuObject.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : VRMenuObject.h @@ -5,10 +7,8 @@ Content : Menuing system for VR apps. Created : May 23, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include @@ -941,8 +941,8 @@ class VRMenuObject { virtual void AtNode(VRMenuObject* obj) = 0; }; - static float const TEXELS_PER_METER; - static float const DEFAULT_TEXEL_SCALE; + static float constexpr TEXELS_PER_METER{500.0f}; + static float constexpr DEFAULT_TEXEL_SCALE{1.0f / TEXELS_PER_METER}; // Initialize the object after creation void Init(OvrGuiSys& guiSys, VRMenuObjectParms const& parms); @@ -952,6 +952,8 @@ class VRMenuObject { // Adds a child to this menu object void AddChild(OvrVRMenuMgr& menuMgr, menuHandle_t const handle); + // Adds a child to this menu object + void AddChild(VRMenuObject* child); // Removes a child from this menu object, but does not free the child object. void RemoveChild(OvrVRMenuMgr& menuMgr, menuHandle_t const handle); // Removes a child from tis menu object and frees it, along with any children it may have. @@ -1031,6 +1033,7 @@ class VRMenuObject { return ParentHandle; } void SetParentHandle(menuHandle_t const h) { + assert(h != Handle); ParentHandle = h; } @@ -1059,6 +1062,21 @@ class VRMenuObject { return Text; } void SetText(char const* text); + + template + void SetText(const std::string& text, Args... args) { + int size_s = std::snprintf(nullptr, 0, text.c_str(), args...) + 1; // Extra space for '\0' + if (size_s <= 0) { + ALOGE("VRGUI SetText formatting error!"); + return; + } + auto buf = std::vector(size_s); + std::snprintf(buf.data(), buf.size(), text.c_str(), args...); + + Text = std::string(buf.data()); + TextDirty = true; + } + void SetTextWordWrapped(char const* text, class BitmapFont const& font, float const widthInMeters); diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ui_default.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ui_default.h index a7da118d..1bfd6994 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ui_default.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/GUI/ui_default.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ui_default.h @@ -5,9 +7,8 @@ Content : Embedded default texture for UI. Created : Authors : -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + // clang-format off static const size_t uiDefaultTgaSize = 24910; static unsigned char uiDefaultTgaData[] = { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.cpp index 5908532b..35125bda 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ArmModel.cpp @@ -5,8 +7,6 @@ Content : An arm model for the tracked remote Created : 2/20/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "ArmModel.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.h index 7624428d..a704f875 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ArmModel.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ArmModel.h @@ -5,9 +7,8 @@ Content : An arm model for the tracked remote Created : 2/20/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.cpp index b3442612..959dd91c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.cpp @@ -1,10 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : AxisRenderer.cpp Content : A rendering component for axis Created : September 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ @@ -45,10 +46,10 @@ static const char* AxisFragmentShaderSrc = R"glsl( namespace OVRFW { -bool ovrAxisRenderer::Init(size_t count) { +bool ovrAxisRenderer::Init(size_t count, float size) { /// Defaults Count = count; - AxisSize = 0.025f; + AxisSize = size; /// Create Axis program static ovrProgramParm AxisUniformParms[] = { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.h index b1e884cf..a9c8aaa1 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/AxisRenderer.h @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : AxisRenderer.h Content : A rendering component for axis Created : September 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #pragma once #include @@ -23,7 +25,7 @@ class ovrAxisRenderer { ovrAxisRenderer() = default; ~ovrAxisRenderer() = default; - bool Init(size_t count = 64); + bool Init(size_t count = 64, float size = 0.025f); void Shutdown(); void Update(const std::vector& points); void Update(const OVR::Posef* points, size_t count); @@ -32,10 +34,8 @@ class ovrAxisRenderer { const OVRFW::ovrApplFrameIn& in, OVRFW::ovrRendererOutput& out); - public: - float AxisSize; - private: + float AxisSize; GlProgram ProgAxis; ovrSurfaceDef AxisSurfaceDef; ovrDrawSurface AxisSurface; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.cpp index fe490c53..d25af460 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.cpp @@ -1,10 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ControllerRenderer.cpp Content : A one stop for rendering controllers Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ @@ -56,7 +57,7 @@ vec3 transposeMultiply( mat4 m, vec3 v ) void main() { gl_Position = TransformVertex( Position ); - vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); + highp vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); oEye = eye - vec3( ModelMatrix * Position ); oNormal = multiply( ModelMatrix, Normal ); diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.h index 68fa834a..576d40fe 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/ControllerRenderer.h @@ -1,10 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ControllerRenderer.h Content : A one stop for rendering controllers Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.cpp index 85a00c61..cc39fcd4 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Skeleton.cpp @@ -5,8 +7,6 @@ Content : skeleton for arm model implementation Created : 2/20/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "Skeleton.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.h index 0e315144..352f464b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/Skeleton.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Skeleton.h @@ -5,9 +7,8 @@ Content : Skeleton for arm and hand model implementation Created : 2/20/2017 Authors : Jonathan E. Wright, Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.cpp index e5e91962..cada94e1 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SkeletonRenderer.cpp @@ -5,9 +7,8 @@ Content : A rendering component for sample skeletons Created : April 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #include "SkeletonRenderer.h" #include "Misc/Log.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.h index a4ee5807..4d32dc47 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/SkeletonRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SkeletonRenderer.h @@ -5,9 +7,8 @@ Content : A rendering component for sample skeletons Created : April 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.cpp index 07b96804..a4910b43 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.cpp @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : TinyUI.cpp Content : Componentized wrappers for GuiSys Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #include "TinyUI.h" #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.h index 4b6c4043..fcd9c2cd 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Input/TinyUI.h @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : TinyUI.h Content : Componentized wrappers for GuiSys Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #pragma once #include "OVR_Math.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.cpp index f794b73b..275d89b0 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.cpp @@ -1,3 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + /************************************************************************************ Filename : OVR_Locale.cpp @@ -5,12 +14,6 @@ Content : Implementation of string localization for strings loaded at run- Created : April 6, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -This source code is licensed under the BSD-style license found in the -LICENSE file in the Oculus360Photos/ directory. An additional grant -of patent rights can be found in the PATENTS file in the same directory. - ************************************************************************************/ #include "OVR_Locale.h" @@ -68,8 +71,10 @@ class ovrLocaleInternal : public ovrLocale { virtual void ReplaceLocalizedText(char const* inText, char* out, size_t const outSize) const; private: +#if defined(OVR_OS_ANDROID) JNIEnv& jni; jobject activityObject; +#endif std::string Name; // user-specified locale name std::string LanguageCode; // system-specific locale name @@ -85,12 +90,17 @@ OVR::UPInt ovrLocaleInternal::LOCALIZED_KEY_PREFIX_LEN = OVR::OVR_strlen(LOCALIZ //============================== // ovrLocaleInternal::ovrLocaleInternal +#if defined(OVR_OS_ANDROID) ovrLocaleInternal::ovrLocaleInternal( JNIEnv& jni_, jobject activity_, char const* name, char const* languageCode) : jni(jni_), activityObject(activity_), Name(name), LanguageCode(languageCode) {} +#else +ovrLocaleInternal::ovrLocaleInternal(char const* name, char const* languageCode) + : Name(name), LanguageCode(languageCode) {} +#endif //============================== // ovrLocaleInternal::~ovrLocaleInternal @@ -222,6 +232,7 @@ bool ovrLocaleInternal::LoadStringsFromAndroidFormatXMLFile( // Get's a localized UTF-8-encoded string from the Android application's string table. bool ovrLocaleInternal::GetStringJNI(char const* key, char const* defaultOut, std::string& out) const { +#if defined(OVR_OS_ANDROID) // ALOG( "Localizing key '%s'", key ); // if the key doesn't start with KEY_PREFIX then it's not a valid key, just return // the key itself as the output text. @@ -247,8 +258,8 @@ bool ovrLocaleInternal::GetStringJNI(char const* key, char const* defaultOut, st // 0 is not a valid resource id Log.v("VrLocale", name + " is not a valid resource id!!" ); return outString; - } - if ( id != 0 ) + } + if ( id != 0 ) { outString = resources.getText( id ).toString(); //Log.v("VrLocale", "getLocalizedString resolved " + name + " to " + outString); @@ -377,6 +388,10 @@ bool ovrLocaleInternal::GetStringJNI(char const* key, char const* defaultOut, st const char* textObjectString_ch = jni.GetStringUTFChars(textObjectString.GetJString(), 0); out = textObjectString_ch; jni.ReleaseStringUTFChars(textObjectString.GetJString(), textObjectString_ch); +#else + out = defaultOut; +#endif // defined(OVR_OS_ANDROID) + return true; } @@ -504,6 +519,7 @@ ovrLocale::Create(JNIEnv& jni_, jobject activity_, char const* name, ovrFileSys* } #endif +#if defined(OVR_OS_ANDROID) JavaClass localeClass(&jni_, jni_.FindClass("java/util/Locale")); // class pointer of Locale if (localeClass.GetJClass() == NULL) { ALOG("ovrLocale::Create - localeClass == NULL"); @@ -537,6 +553,9 @@ ovrLocale::Create(JNIEnv& jni_, jobject activity_, char const* name, ovrFileSys* } localePtr = new ovrLocaleInternal(jni_, activity_, name, languageCode.c_str()); +#else + localePtr = new ovrLocaleInternal(name, languageCode.c_str()); +#endif // defined(OVR_OS_ANDROID) ALOG("ovrLocale::Create - exited"); return localePtr; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.h index 2221a28a..8111abd3 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Locale/OVR_Locale.h @@ -1,3 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + /************************************************************************************ Filename : OVR_Locale.h @@ -5,13 +14,8 @@ Content : Header file for string localization interface. Created : April 6, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -This source code is licensed under the BSD-style license found in the -LICENSE file in the Oculus360Photos/ directory. An additional grant -of patent rights can be found in the PATENTS file in the same directory. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.c b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.c index 576a1c33..11de894a 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.c +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.c @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : Log.c @@ -6,8 +8,6 @@ Created : February 21, 2018 Authors : J.M.P. van Waveren, Jonathan Wright Language : C++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *******************************************************************************/ #include "Log.h" @@ -15,6 +15,10 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include #include +#if defined(WIN32) +#include "windows.h" +#endif + #if defined(__cplusplus) extern "C" { #endif @@ -53,7 +57,32 @@ void LogWithFilenameTag(const int priority, const char* filename, const char* fm vsnprintf(msg, sizeof(msg), fmt, argPtr); va_end(argPtr); +#if defined(ANDROID) __android_log_write(priority, tag, msg); +#elif defined(WIN32) + OutputDebugStringA("["); + OutputDebugStringA(tag); + switch (priority) { + case SAMPLES_LOG_ERROR: + OutputDebugStringA("] {ERROR} "); + break; + case SAMPLES_LOG_WARN: + OutputDebugStringA("] {WARN} "); + break; + case SAMPLES_LOG_INFO: + OutputDebugStringA("] {INFO} "); + break; + case SAMPLES_LOG_VERBOSE: + default: + OutputDebugStringA("] {VERBOSE} "); + break; + } + OutputDebugStringA(msg); + OutputDebugStringA("\n"); +#else + (void)priority; + printf("[%s] %s\n", tag, msg); +#endif // defined(ANDROID) } #if defined(__cplusplus) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.h index ab2911ff..cf3b0b98 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Misc/Log.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : Log.h @@ -6,40 +8,59 @@ Created : February 21, 2018 Authors : Jonathan Wright Language : C++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *******************************************************************************/ #pragma once +#if defined(ANDROID) #include +#else +#include +#endif // defined(ANDROID) + #include // abort #if defined(__cplusplus) extern "C" { #endif +#if defined(ANDROID) +typedef enum SamplesLogPriority { + SAMPLES_LOG_ERROR = ANDROID_LOG_ERROR, + SAMPLES_LOG_WARN = ANDROID_LOG_WARN, + SAMPLES_LOG_INFO = ANDROID_LOG_INFO, + SAMPLES_LOG_VERBOSE = ANDROID_LOG_VERBOSE, +} SamplesLogPriority; +#else +typedef enum SamplesLogPriority { + SAMPLES_LOG_ERROR = 5, + SAMPLES_LOG_WARN = 4, + SAMPLES_LOG_INFO = 3, + SAMPLES_LOG_VERBOSE = 1, +} SamplesLogPriority; +#endif + void LogWithFilenameTag(const int priority, const char* filename, const char* fmt, ...); #define ALOGE(...) \ - { LogWithFilenameTag(ANDROID_LOG_ERROR, __FILE__, __VA_ARGS__); } + { LogWithFilenameTag(SAMPLES_LOG_ERROR, __FILE__, __VA_ARGS__); } #define ALOGE_FAIL(...) \ { \ - LogWithFilenameTag(ANDROID_LOG_ERROR, __FILE__, __VA_ARGS__); \ + LogWithFilenameTag(SAMPLES_LOG_ERROR, __FILE__, __VA_ARGS__); \ abort(); \ } #if 1 // DEBUG #define ALOG(...) \ - { LogWithFilenameTag(ANDROID_LOG_INFO, __FILE__, __VA_ARGS__); } + { LogWithFilenameTag(SAMPLES_LOG_INFO, __FILE__, __VA_ARGS__); } #define ALOGV(...) \ - { LogWithFilenameTag(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__); } + { LogWithFilenameTag(SAMPLES_LOG_VERBOSE, __FILE__, __VA_ARGS__); } #define ALOGW(...) \ - { LogWithFilenameTag(ANDROID_LOG_WARN, __FILE__, __VA_ARGS__); } + { LogWithFilenameTag(SAMPLES_LOG_WARN, __FILE__, __VA_ARGS__); } #else #define ALOGV(...) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.cpp index 25a39e69..ce889a8d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelCollision.cpp @@ -5,8 +7,6 @@ Content : Basic collision detection for scene walkthroughs. Created : May 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "ModelCollision.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.h index a4b9c350..1eade87e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelCollision.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelCollision.h @@ -5,8 +7,6 @@ Content : Basic collision detection for scene walkthroughs. Created : May 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelDef.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelDef.h index bdfdb25a..5a88bd6d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelDef.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelDef.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelDef.h @@ -5,8 +7,6 @@ Content : Model file definitions. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.cpp index e22735be..418decaa 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelFile.cpp @@ -5,8 +7,6 @@ Content : Model file loading common elements. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "ModelFileLoading.h" @@ -118,7 +118,8 @@ void CalculateTransformFromRTS( const Vector3f translation, const Vector3f scale) { Matrix4f::Multiply(localTransform, Matrix4f(rotation), Matrix4f::Scaling(scale)); - Matrix4f::Multiply(localTransform, Matrix4f::Translation(translation), *localTransform); + Matrix4f::Multiply( + localTransform, Matrix4f::Translation(translation), Matrix4f(*localTransform)); } //----------------------------------------------------------------------------- @@ -157,6 +158,7 @@ void LoadModelFileTexture( model.Textures.push_back(tex); } +#if !defined(OVR_OS_WIN32) static ModelFile* LoadZippedModelFile( unzFile zfp, const char* fileName, @@ -402,6 +404,34 @@ ModelFile* LoadModelFile( return LoadZippedModelFile( zfp, fileName, (char*)zlib_opaque.data, zlib_opaque.len, programs, materialParms); } +#else +ModelFile* LoadModelFileFromMemory( + const char* fileName, + const void* buffer, + int bufferLength, + const ModelGlPrograms& programs, + const MaterialParms& materialParms, + ModelGeo* outModelGeo) { + // Open the .ModelFile file as a zip. + ALOG("LoadModelFileFromMemory %s %i", fileName, bufferLength); + + // Determine wether it's a glb binary file, or if it is a zipped up ovrscene. + if (strstr(fileName, ".glb") != nullptr) { + return LoadModelFile_glB( + fileName, (char*)buffer, bufferLength, programs, materialParms, outModelGeo); + } + + return nullptr; +} + +ModelFile* LoadModelFile( + const char* fileName, + const ModelGlPrograms& programs, + const MaterialParms& materialParms) { + ALOG("LoadModelFile %s", fileName); + return nullptr; +} +#endif // !defined(OVR_OS_WIN32) ModelFile* LoadModelFileFromOtherApplicationPackage( void* zipFile, diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.h index 26fd15c0..3cb4c687 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelFile.h @@ -5,9 +7,8 @@ Content : Model file loading. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "ModelDef.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFileLoading.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFileLoading.h index 27ad96ae..88f2d47f 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFileLoading.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFileLoading.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelFileLoading.h @@ -5,8 +7,6 @@ Content : Model file loading. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_OvrScene.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_OvrScene.cpp index c3b53015..c628e57e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_OvrScene.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_OvrScene.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelFile_OvrScene.cpp @@ -5,8 +7,6 @@ Content : Model file loading ovrscene elements. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "ModelFileLoading.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_glTF.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_glTF.cpp index 7d6a3d47..7e90859b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_glTF.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelFile_glTF.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelFile_OvrScene.cpp @@ -5,8 +7,6 @@ Content : Model file loading glTF elements. Created : December 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "Model/ModelDef.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.cpp index 26a236d7..9ad410c4 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelRender.cpp @@ -5,8 +7,6 @@ Content : Optimized OpenGL rendering path Created : August 9, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "ModelRender.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.h index 162b3f39..37f8bffe 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelRender.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelRender.h @@ -5,9 +7,8 @@ Content : Optimized OpenGL rendering path Created : August 9, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include "OVR_Math.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.cpp index 60dbe010..93e33a02 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelTrace.cpp @@ -5,8 +7,6 @@ Content : Ray tracer using a KD-Tree. Created : May, 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "ModelTrace.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.h index bde3baa9..3657b915 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/ModelTrace.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ModelTrace.h @@ -5,9 +7,8 @@ Content : Ray tracer using a KD-Tree. Created : May, 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "OVR_Math.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.cpp index 087aa0bb..98575367 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SceneView.cpp @@ -5,8 +7,6 @@ Content : Basic viewing and movement in a scene. Created : December 19, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "SceneView.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.h index 31d51728..39b218dd 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Model/SceneView.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SceneView.h @@ -5,8 +7,6 @@ Content : Basic viewing and movement in a scene. Created : December 19, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.cpp index d9b47804..3db8852e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_BinaryFile2.cpp @@ -5,9 +7,6 @@ Content : Simple helper class to read a binary file. Created : Jun, 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "OVR_BinaryFile2.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.h index 5972a0b6..a32c68e1 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_BinaryFile2.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_BinaryFile2.h @@ -5,10 +7,8 @@ Content : Simple helper class to read a binary file. Created : Jun, 2014 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include "OVR_Types.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.cpp index eef13560..5b8c7f53 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_FileSys.cpp @@ -5,8 +7,6 @@ Content : Abraction layer for file systems. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "OVR_FileSys.h" @@ -22,6 +22,13 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include "OVR_Std.h" #include "JniUtils.h" +#if defined(OVR_OS_WIN32) +#include // _access +#include "windows.h" +#include +#pragma comment(lib, "shlwapi.lib") +#endif + namespace OVRFW { bool HasPermission(const char* fileOrDirName, const permissionFlags_t flags) { @@ -40,6 +47,7 @@ bool HasPermission(const char* fileOrDirName, const permissionFlags_t flags) { } int mode = 0; +#if !defined(OVR_OS_WIN32) if (flags & PERMISSION_WRITE) { mode |= W_OK; } @@ -50,6 +58,19 @@ bool HasPermission(const char* fileOrDirName, const permissionFlags_t flags) { mode |= X_OK; } return access(s.c_str(), mode) == 0; +#else + if (flags & PERMISSION_WRITE) { + mode |= 0x2; + } + if (flags & PERMISSION_READ) { + mode |= 0x4; + } + if (flags & PERMISSION_EXECUTE) { + // No execute permission + mode |= 0x4; + } + return _access(s.c_str(), mode) == 0; +#endif // !defined(OVR_OS_WIN32) } static const char* StorageName[EST_COUNT] = { @@ -87,6 +108,31 @@ bool ovrFileSys::GetPathIfValidPermission( return HasPermission(checkPath.c_str(), permission); } +#if defined(OVR_OS_WIN32) +static std::string exeDirAsUri() { + char path[MAX_PATH]; + if (::GetModuleFileNameA(NULL, path, MAX_PATH) == 0) { + return std::string(); + } + if (::PathRemoveFileSpecA(path) == 0) { + // 0 return indicates nothing was removed which should not be possible. + return std::string(); + } + size_t pathLen = strlen(path); + for (int i = 0; i < pathLen; ++i) { + if (path[i] == '\\') { + path[i] = '/'; + } + } + char uri[MAX_PATH]; + DWORD uriSize = MAX_PATH; + if (::UrlCreateFromPathA(path, uri, &uriSize, NULL) != S_OK) { + return std::string(); + } + return std::string(uri); +} +#endif // defined(OVR_OS_WIN32) + void ovrFileSys::PushBackSearchPathIfValid( xrJava const& java, ovrStorageType storageType, @@ -150,6 +196,7 @@ ovrFileSysLocal::ovrFileSysLocal(xrJava const& javaContext) : Jvm(javaContext.Vm // always do unit tests on startup to assure nothing has been broken ovrUri::DoUnitTest(); +#if defined(OVR_OS_ANDROID) ActivityObject = javaContext.Env->NewGlobalRef(javaContext.ActivityObject); // add the apk scheme @@ -241,6 +288,26 @@ ovrFileSysLocal::ovrFileSysLocal(xrJava const& javaContext) : Jvm(javaContext.Vm ALOG("ovrFileSysLocal - apk scheme OpenHost done uri '%s'", curPackageUri); Schemes.push_back(scheme); +#elif defined(OVR_OS_WIN32) + // On windows we will treat "apk" as relative to the exe + std::string exeDirUri = exeDirAsUri(); + std::string fontUri = exeDirAsUri() + "/font"; + + ovrUriScheme_File* scheme = new ovrUriScheme_File("apk"); + if (!scheme->OpenHost("localhost", exeDirUri.c_str())) { + ALOG( + "Failed to OpenHost for file_scheme host '%s', uri '%s'", + "localhost", + exeDirUri.c_str()); + assert(false); + } + if (!scheme->OpenHost("font", fontUri.c_str())) { + ALOG( + "Failed to OpenHost for file_scheme host '%s', uri '%s'", "localhost", fontUri.c_str()); + assert(false); + } + Schemes.push_back(scheme); +#endif ovrUriScheme_File* file_scheme = new ovrUriScheme_File("file"); if (!file_scheme->OpenHost("localhost", "")) { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.h index 860b4915..50cd3aef 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_FileSys.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_FileSys.h @@ -5,20 +7,23 @@ Content : Abraction layer for file systems. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "OVR_Stream.h" #include "OVR_BitFlags.h" #include "OVR_Std.h" +#include "OVR_Types.h" #include #include #include +#if defined(OVR_OS_ANDROID) #include +#endif // defined(OVR_OS_ANDROID) + typedef struct xrJava_ { JavaVM* Vm = nullptr; //< Java Virtual Machine JNIEnv* Env = nullptr; //< Thread specific environment diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.cpp index e7cec7e1..cf1dbcf1 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.cpp @@ -1,3 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + /********************************************************************************** Filename : OVR_Lexer.h @@ -5,12 +14,6 @@ Content : A light-weight lexer Created : May 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -This source code is licensed under the BSD-style license found in the -LICENSE file in the Oculus360Photos/ directory. An additional grant -of patent rights can be found in the PATENTS file in the same directory. - ************************************************************************************/ #include "OVR_Lexer2.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.h index a5d5f76d..9d31c7e3 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Lexer2.h @@ -1,3 +1,12 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + /********************************************************************************** Filename : OVR_Lexer.h @@ -5,13 +14,8 @@ Content : A light-weight lexer Created : May 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -This source code is licensed under the BSD-style license found in the -LICENSE file in the Oculus360Photos/ directory. An additional grant -of patent rights can be found in the PATENTS file in the same directory. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.cpp index 3cb73a63..62ce3255 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_MappedFile.cpp @@ -5,11 +7,12 @@ Content : Cross-platform memory-mapped file wrapper. Created : May 12, 2014 Authors : Chris Taylor -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "OVR_MappedFile.h" +#include "OVR_Types.h" + +#if defined(OVR_OS_ANDROID) #if defined(OVR_OS_ANDROID) // disable warnings on implicit type conversion where value may be changed by conversion for @@ -211,3 +214,5 @@ void MappedView::Close() { } } // namespace OVRFW + +#endif // defined(OVR_OS_ANDROID) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.h index 328acba3..08463516 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_MappedFile.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_MappedFile.h @@ -5,9 +7,6 @@ Content : Cross-platform memory-mapped file wrapper. Created : May 12, 2014 Authors : Chris Taylor -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.cpp index dfaccee5..9a29abfa 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_Stream.cpp @@ -5,9 +7,8 @@ Content : Abstraction for file streams. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #include "OVR_Stream.h" #include "Misc/Log.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.h index 57d6403d..d31a7e60 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_Stream.h @@ -5,8 +7,6 @@ Content : Abstraction for file streams. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream_Impl.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream_Impl.h index c55dc24b..61682340 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream_Impl.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Stream_Impl.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_Stream_Impl.h @@ -5,8 +7,6 @@ Content : Implementations of file streams classes. Created : July 2, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.cpp index 2185077f..b366bcb7 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.cpp @@ -1,3 +1,23 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /************************************************************************** Filename : OVR_UTF8Util.cpp @@ -7,23 +27,6 @@ Notes : Notes : Much useful info at "UTF-8 and Unicode FAQ" http://www.cl.cam.ac.uk/~mgk25/unicode.html -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. - -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - ************************************************************************************/ #include "OVR_UTF8Util.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.h index c7b85d96..ff5e895b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_UTF8Util.h @@ -1,28 +1,30 @@ -/************************************************************************************ - -Filename : OVR_UTF8Util.h -Content : UTF8 Unicode character encoding/decoding support -Created : September 19, 2012 -Notes : - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which -otherwise accompanies this software in either electronic or hard copy form. +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * Licensed under the Oculus SDK License Agreement (the "License"); + * you may not use the Oculus SDK except in compliance with the License, + * which is provided at the time of installation or download, or which + * otherwise accompanies this software in either electronic or hard copy form. + * + * You may obtain a copy of the License at + * + * https://developer.oculus.com/licenses/oculussdk/ + * + * Unless required by applicable law or agreed to in writing, the Oculus SDK + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -You may obtain a copy of the License at - -http://www.oculusvr.com/licenses/LICENSE-3.3 - -Unless required by applicable law or agreed to in writing, the Oculus VR SDK -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +/************************************************************************************ + * Filename : OVR_UTF8Util.h + * Content : UTF8 Unicode character encoding/decoding support + * Created : September 19, 2012 + * Notes : + ***********************************************************************************/ -************************************************************************************/ #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.cpp index 31bac68d..c5ee80b9 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_Uri.cpp @@ -5,8 +7,6 @@ Content : URI parser. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "OVR_Uri.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.h index d4c596d4..96e8711c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/OVR_Uri.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_Uri.h @@ -5,9 +7,8 @@ Content : URI parser. Created : July 1, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include // for size_t diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.cpp index f1ddf031..feed43e6 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PackageFiles.cpp @@ -5,9 +7,6 @@ Content : Read files from the application package zip Created : August 18, 2014 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ #include "PackageFiles.h" @@ -20,7 +19,10 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include #include #include + +#if !defined(OVR_OS_WIN32) #include +#endif #include #include @@ -113,6 +115,7 @@ static bool ovr_ReadFileFromOtherApplicationPackageInternal( return false; } +#if !defined(OVR_OS_WIN32) std::lock_guard mutex(PackageFileMutex); const int locateRet = unzLocateFile(zipFile, nameInZip, 2 /* case insensitive */); @@ -214,6 +217,10 @@ static bool ovr_ReadFileFromOtherApplicationPackageInternal( } return true; +#else + // No equivalent of other application package on windows. + return false; +#endif // !defined(OVR_OS_WIN32) } bool ovr_ReadFileFromOtherApplicationPackage( diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.h index 0d07cd0d..cbac037e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/PackageFiles.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PackageFiles.h @@ -5,10 +7,8 @@ Content : Read files from the application package zip Created : August 18, 2014 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - - *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.cpp index e1344f36..2fd04c78 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BeamRenderer.cpp @@ -5,8 +7,6 @@ Content : Class that manages and renders view-oriented beams. Created : October 23; 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "BeamRenderer.h" @@ -28,9 +28,9 @@ inline Vector3f GetViewMatrixPosition(Matrix4f const& m) { namespace OVRFW { static const char* BeamVertexSrc = R"glsl( -attribute vec4 Position; -attribute vec4 VertexColor; -attribute vec2 TexCoord; +attribute highp vec4 Position; +attribute lowp vec4 VertexColor; +attribute highp vec2 TexCoord; varying lowp vec4 outColor; varying highp vec2 oTexCoord; @@ -56,6 +56,8 @@ void main() )glsl"; static const char* ParametricFragmentSrc = R"glsl( +precision highp float; + varying lowp vec4 outColor; varying highp vec2 oTexCoord; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.h index 968c2020..4bb1a262 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BeamRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BeamRenderer.h @@ -5,9 +7,8 @@ Content : Class that manages and renders view-oriented beams. Created : October 23, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.cpp index 8e919eca..2ef25e10 100644 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BillBoardRenderer.cpp @@ -5,8 +7,6 @@ Content : Class that manages and renders view-oriented billboards. Created : October 23; 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "BillBoardRenderer.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.h index 05b4881f..ad6739dd 100644 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BillBoardRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BillBoardRenderer.h @@ -5,9 +7,8 @@ Content : Class that manages and renders view-oriented billboards. Created : October 23, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.cpp index 7908f171..c7616e95 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BitmapFont.cpp @@ -5,8 +7,6 @@ Content : Monospaced bitmap font rendering intended for debugging only. Created : March 11, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ // TODO: diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.h index 6c394236..c6b97c16 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/BitmapFont.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : BitmapFont.h @@ -5,8 +7,6 @@ Content : Bitmap font rendering. Created : March 11, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.cpp index 081c43ba..a3240053 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : DebugLines.cpp @@ -5,8 +7,6 @@ Content : Class that manages and renders debug lines. Created : April 22, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "DebugLines.h" @@ -30,8 +30,8 @@ using OVR::Vector4f; namespace OVRFW { static const char* DebugLineVertexSrc = R"glsl( - attribute vec4 Position; - attribute vec4 VertexColor; + attribute highp vec4 Position; + attribute lowp vec4 VertexColor; varying lowp vec4 outColor; void main() { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.h index b978aea4..248691f3 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/DebugLines.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : DebugLines.h @@ -5,8 +7,6 @@ Content : Class that manages and renders debug lines. Created : April 22, 2014 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.cpp index 7b01fc8c..1269185c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : EaseFunctions.h @@ -5,8 +7,6 @@ Content : Functions for blending alpha over time. Created : October 12, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "EaseFunctions.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.h index 61540b31..28efface 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/EaseFunctions.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : EaseFunctions.h @@ -5,8 +7,6 @@ Content : Functions for blending alpha over time. Created : October 12, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.c b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.c index 79230f20..1c7d996b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.c +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.c @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Egl.cpp @@ -7,8 +9,6 @@ Created : March, 2015 Authors : J.M.P. van Waveren Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "Egl.h" @@ -20,11 +20,14 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig // Implementation //============================================================================== +#if defined(ANDROID) PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR_; PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR_; PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR_; PFNEGLSIGNALSYNCKHRPROC eglSignalSyncKHR_; PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR_; +#endif // defined(ANDROID) + PFNGLINVALIDATEFRAMEBUFFER_ glInvalidateFramebuffer_; /* @@ -37,8 +40,12 @@ PFNGLINVALIDATEFRAMEBUFFER_ glInvalidateFramebuffer_; OpenGLExtensions_t glExtensions; -void* GetExtensionProc(const char* functionName) { +void* EglGetExtensionProc(const char* functionName) { +#if defined(ANDROID) void* ptr = (void*)eglGetProcAddress(functionName); +#elif defined(WIN32) + void* ptr = (void*)wglGetProcAddress(functionName); +#endif // defined(ANDROID) if (ptr == NULL) { ALOG("NOT FOUND: %s", functionName); } @@ -59,15 +66,20 @@ void EglInitExtensions() { strstr(allExtensions, "GL_EXT_texture_filter_anisotropic"); } - eglCreateSyncKHR_ = (PFNEGLCREATESYNCKHRPROC)GetExtensionProc("eglCreateSyncKHR"); - eglDestroySyncKHR_ = (PFNEGLDESTROYSYNCKHRPROC)GetExtensionProc("eglDestroySyncKHR"); - eglClientWaitSyncKHR_ = (PFNEGLCLIENTWAITSYNCKHRPROC)GetExtensionProc("eglClientWaitSyncKHR"); - eglSignalSyncKHR_ = (PFNEGLSIGNALSYNCKHRPROC)GetExtensionProc("eglSignalSyncKHR"); - eglGetSyncAttribKHR_ = (PFNEGLGETSYNCATTRIBKHRPROC)GetExtensionProc("eglGetSyncAttribKHR"); +#if defined(ANDROID) + eglCreateSyncKHR_ = (PFNEGLCREATESYNCKHRPROC)EglGetExtensionProc("eglCreateSyncKHR"); + eglDestroySyncKHR_ = (PFNEGLDESTROYSYNCKHRPROC)EglGetExtensionProc("eglDestroySyncKHR"); + eglClientWaitSyncKHR_ = + (PFNEGLCLIENTWAITSYNCKHRPROC)EglGetExtensionProc("eglClientWaitSyncKHR"); + eglSignalSyncKHR_ = (PFNEGLSIGNALSYNCKHRPROC)EglGetExtensionProc("eglSignalSyncKHR"); + eglGetSyncAttribKHR_ = (PFNEGLGETSYNCATTRIBKHRPROC)EglGetExtensionProc("eglGetSyncAttribKHR"); +#endif // defined(ANDROID) glInvalidateFramebuffer_ = - (PFNGLINVALIDATEFRAMEBUFFER_)eglGetProcAddress("glInvalidateFramebuffer"); + (PFNGLINVALIDATEFRAMEBUFFER_)EglGetExtensionProc("glInvalidateFramebuffer"); } +#if defined(ANDROID) + const char* EglErrorString(const EGLint error) { switch (error) { case EGL_SUCCESS: @@ -105,6 +117,14 @@ const char* EglErrorString(const EGLint error) { } } +#else + +const char* EglErrorString(const GLint err) { + return ovrGl_ErrorString_Windows(err); +} + +#endif // defined(ANDROID) + const char* GlFrameBufferStatusString(GLenum status) { switch (status) { case GL_FRAMEBUFFER_UNDEFINED: @@ -177,6 +197,8 @@ bool GLCheckErrorsWithTitle(const char* logTitle) { return hadError; } +#if defined(ANDROID) + EGLint GL_FlushSync(int timeout) { // if extension not present, return NO_SYNC if (eglCreateSyncKHR_ == NULL) { @@ -387,3 +409,15 @@ void ovrEgl_DestroyContext(ovrEgl* egl) { egl->Display = 0; } } + +#else + +void ovrEgl_CreateContext(ovrEgl* egl, const ovrEgl* shareEgl) { + ovrGl_CreateContext_Windows(&egl->hDC, &egl->hGLRC); +} + +void ovrEgl_DestroyContext(ovrEgl* egl) { + ovrGl_DestroyContext_Windows(); +} + +#endif // defined(ANDROID) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.h index 3d1f1dbb..0d3fb91d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Egl.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Egl.h @@ -6,7 +8,6 @@ Content : EGL utility functions. Originally part of the VrCubeWorld_NativeActi Created : March, 2015 Authors : J.M.P. van Waveren Language : C99 -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ @@ -15,10 +16,14 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include #include +#if !defined(WIN32) #include #include #include #include +#else +#include "GlWrapperWin32.h" +#endif // !defined(WIN32) #if defined(__cplusplus) extern "C" { @@ -104,6 +109,7 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)( #endif /* GL_OES_EGL_image_external */ typedef struct ovrEgl_s { +#if !defined(WIN32) EGLint MajorVersion; EGLint MinorVersion; EGLDisplay Display; @@ -111,6 +117,10 @@ typedef struct ovrEgl_s { EGLSurface TinySurface; EGLSurface MainSurface; EGLContext Context; +#else + HDC hDC; + HGLRC hGLRC; +#endif // defined(WIN32) } ovrEgl; typedef struct { @@ -125,17 +135,20 @@ extern OpenGLExtensions_t glExtensions; // forward declarations //============================================================================== +void* EglGetExtensionProc(const char* functionName); void EglInitExtensions(); void ovrEgl_Clear(ovrEgl* egl); void ovrEgl_CreateContext(ovrEgl* egl, const ovrEgl* shareEgl); void ovrEgl_DestroyContext(ovrEgl* egl); +#if defined(ANDROID) // EGL_KHR_reusable_sync extern PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR_; extern PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR_; extern PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR_; extern PFNEGLSIGNALSYNCKHRPROC eglSignalSyncKHR_; extern PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR_; +#endif // defined(ANDROID) typedef void(GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFER_)( GLenum target, @@ -157,7 +170,11 @@ void GL_InvalidateFramebuffer( const bool depthBuffer); const char* GlFrameBufferStatusString(GLenum status); +#if defined(ANDROID) const char* EglErrorString(const EGLint error); +#else +const char* EglErrorString(const GLint error); +#endif // defined(ANDROID) #ifdef OVR_BUILD_DEBUG #define CHECK_GL_ERRORS 1 diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.cpp index 3ba98fe2..7956fc7c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.cpp @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GeometryBuilder.cpp Content : OpenGL geometry setup. Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #include "GeometryBuilder.h" namespace OVRFW { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.h index 6fbeaa08..5bad197e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryBuilder.h @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GeometryBuilder.h Content : OpenGL geometry setup. Created : July 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.cpp index 96cc46ed..248dd020 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : GeometryRenderer.cpp @@ -5,9 +7,9 @@ Content : Simple rendering for geometry-based types Created : Mar 2021 Authors : Federico Schliemann Language : C++ -Copyright: Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *******************************************************************************/ + #include "GeometryRenderer.h" #include "Misc/Log.h" @@ -52,13 +54,15 @@ const char* GeometryVertexShaderSrc = R"glsl( #ifdef HAS_VERTEX_COLORS oColor = VertexColor; #endif /// HAS_VERTEX_COLORS - vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); + lowp vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); oEye = eye - vec3( ModelMatrix * Position ); oNormal = multiply( ModelMatrix, Normal ); } )glsl"; static const char* GeometryFragmentShaderSrc = R"glsl( + precision lowp float; + uniform lowp vec4 ChannelControl; uniform lowp vec4 DiffuseColor; uniform lowp vec3 SpecularLightDirection; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.h index 709d2a2a..0d558633 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GeometryRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : GeometryRenderer.h @@ -5,7 +7,6 @@ Content : Simple rendering for geometry-based types Created : Mar 2021 Authors : Federico Schliemann Language : C++ -Copyright: Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *******************************************************************************/ @@ -32,9 +33,15 @@ class GeometryRenderer { void SetPose(const OVR::Posef& pose) { ModelPose_ = pose; } + OVR::Posef GetPose() { + return ModelPose_; + } void SetScale(OVR::Vector3f v) { ModelScale_ = v; } + OVR::Vector3f GetScale() { + return ModelScale_; + } public: OVR::Vector4f ChannelControl = {1, 1, 1, 1}; diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.cpp index 58ce449f..df9cd2a8 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlBuffer.cpp @@ -5,8 +7,6 @@ Content : OpenGL texture loading. Created : September 30, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "GlBuffer.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.h index f8d4d542..b61e8ed9 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlBuffer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlBuffer.h @@ -5,9 +7,8 @@ Content : OpenGL Buffer Management. Created : Authors : -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "Egl.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.cpp index 6f8b27f3..7c23d60e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlGeometry.cpp @@ -5,8 +7,6 @@ Content : OpenGL geometry setup. Created : October 8, 2013 Authors : John Carmack, J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "GlGeometry.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.h index 6f725c47..6bab7e18 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlGeometry.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlGeometry.h @@ -5,9 +7,8 @@ Content : OpenGL geometry setup. Created : October 8, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.cpp index 323f8d23..db043fd4 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlProgram.cpp @@ -5,8 +7,6 @@ Content : Shader program compilation. Created : October 11, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "GlProgram.h" @@ -107,6 +107,7 @@ CompileShader(GLenum shaderType, const char* directives, const char* src, GLint if (directives != NULL) { srcString.append(directives); + srcString.append("\n"); } // TODO: If a c string isn't passed here, the previous contents of srcString (ie version info) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.h index e1a987f8..cb9ede77 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlProgram.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlProgram.h @@ -5,9 +7,8 @@ Content : Shader program compilation. Created : October 11, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "Egl.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.cpp deleted file mode 100755 index 2b0df94e..00000000 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/************************************************************************************ - -Filename : GlSetup.cpp -Content : GL Setup -Created : August 24, 2013 -Authors : John Carmack - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -************************************************************************************/ -#include "GlSetup.h" -#include "Misc/Log.h" - -namespace OVRFW { - -static void LogStringWords(const char* allExtensions) { - const char* start = allExtensions; - while (1) { - const char* end = strstr(start, " "); - if (end == nullptr) { - break; - } - unsigned int nameLen = (unsigned int)(end - start); - if (nameLen > 256) { - nameLen = 256; - } - char* word = new char[nameLen + 1]; - memcpy(word, start, nameLen); - word[nameLen] = '\0'; - ALOG("%s", word); - delete[] word; - - start = end + 1; - } -} - -static EGLConfig EglConfigForConfigID(const EGLDisplay display, const GLint configID) { - static const int MAX_CONFIGS = 1024; - EGLConfig configs[MAX_CONFIGS]; - EGLint numConfigs = 0; - - if (EGL_FALSE == eglGetConfigs(display, configs, MAX_CONFIGS, &numConfigs)) { - ALOGW("eglGetConfigs() failed"); - return nullptr; - } - - for (int i = 0; i < numConfigs; i++) { - EGLint value = 0; - - eglGetConfigAttrib(display, configs[i], EGL_CONFIG_ID, &value); - if (value == configID) { - return configs[i]; - } - } - - return nullptr; -} - -// Returns nullptr if no config is found. -static EGLConfig ChooseColorConfig( - const EGLDisplay display, - const int redBits, - const int greenBits, - const int blueBits, - const int depthBits, - const int samples, - const bool pbuffer) { - // We do NOT want to use eglChooseConfig, because the Android EGL code pushes in - // multisample flags behind our back if the user has selected the "force 4x MSAA" - // option in settings, and that is completely wasted for our warp target. - static const int MAX_CONFIGS = 1024; - EGLConfig configs[MAX_CONFIGS]; - EGLint numConfigs = 0; - - if (EGL_FALSE == eglGetConfigs(display, configs, MAX_CONFIGS, &numConfigs)) { - ALOGW("eglGetConfigs() failed"); - return nullptr; - } - ALOG("eglGetConfigs() = %i configs", numConfigs); - - // We don't want a depth/stencil buffer - const EGLint configAttribs[] = { - EGL_ALPHA_SIZE, - redBits == 8 ? 8 : 0, // need alpha for the multi-pass timewarp compositor - EGL_BLUE_SIZE, - blueBits, - EGL_GREEN_SIZE, - greenBits, - EGL_RED_SIZE, - redBits, - EGL_DEPTH_SIZE, - depthBits, - // EGL_STENCIL_SIZE, 0, - EGL_SAMPLES, - samples, - EGL_NONE}; - - for (int i = 0; i < numConfigs; i++) { - EGLint value = 0; - - // EGL_RENDERABLE_TYPE is a bit field - eglGetConfigAttrib(display, configs[i], EGL_RENDERABLE_TYPE, &value); - - if ((value & EGL_OPENGL_ES3_BIT_KHR) != EGL_OPENGL_ES3_BIT_KHR) { - continue; - } - - // For our purposes, the pbuffer config also needs to be compatible with - // normal window rendering so it can share textures with the window context. - // I am unsure if it would be portable to always request EGL_PBUFFER_BIT, so - // I only do it on request. - eglGetConfigAttrib(display, configs[i], EGL_SURFACE_TYPE, &value); - const int surfs = EGL_WINDOW_BIT | (pbuffer ? EGL_PBUFFER_BIT : 0); - if ((value & surfs) != surfs) { - continue; - } - - int j = 0; - for (; configAttribs[j] != EGL_NONE; j += 2) { - EGLint valueLocal = 0; - eglGetConfigAttrib(display, configs[i], configAttribs[j], &valueLocal); - if (valueLocal != configAttribs[j + 1]) { - break; - } - } - if (configAttribs[j] == EGL_NONE) { - ALOG("Found a renderable config: %p", configs[i]); - return configs[i]; - } - } - return nullptr; -} - -glSetup_t GL_Setup( - const EGLContext shareContext, - const int requestedGlEsVersion, - const int redBits, - const int greenBits, - const int blueBits, - const int depthBits, - const int multisamples, - const GLuint contextPriority) { - ALOG( - "GL_Setup: requestGlEsVersion(%d), redBits(%d), greenBits(%d), blueBits(%d), depthBits(%d), multisamples(%d), contextPriority(%d)", - requestedGlEsVersion, - redBits, - greenBits, - blueBits, - depthBits, - multisamples, - contextPriority); - - glSetup_t egl = {}; - - // Get the built in display - // TODO: check for external HDMI displays - egl.display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - - // Initialize EGL - EGLint majorVersion; - EGLint minorVersion; - eglInitialize(egl.display, &majorVersion, &minorVersion); - ALOG("eglInitialize gives majorVersion %i, minorVersion %i", majorVersion, minorVersion); - - const char* eglVendorString = eglQueryString(egl.display, EGL_VENDOR); - ALOG("EGL_VENDOR: %s", eglVendorString); - const char* eglClientApisString = eglQueryString(egl.display, EGL_CLIENT_APIS); - ALOG("EGL_CLIENT_APIS: %s", eglClientApisString); - const char* eglVersionString = eglQueryString(egl.display, EGL_VERSION); - ALOG("EGL_VERSION: %s", eglVersionString); - const char* eglExtensionString = eglQueryString(egl.display, EGL_EXTENSIONS); - ALOG("EGL_EXTENSIONS:"); - LogStringWords(eglExtensionString); - - // We do NOT want to use eglChooseConfig, because the Android EGL code pushes in - // multisample flags behind our back if the user has selected the "force 4x MSAA" - // option in developer settings, and that is completely wasted for our warp target. - egl.config = ChooseColorConfig( - egl.display, - redBits, - greenBits, - blueBits, - depthBits, - multisamples, - true /* pBuffer compatible */); - if (egl.config == 0) { - ALOGE_FAIL("No acceptable EGL color configs."); - return egl; - } - - // The EGLContext is created with the EGLConfig - // Try to get an OpenGL ES 3.0 context first, which is required to do - // MSAA to framebuffer objects on Adreno. - for (int version = requestedGlEsVersion; version >= 2; version--) { - ALOG( - "Trying for a EGL_CONTEXT_CLIENT_VERSION %i context shared with %p:", - version, - shareContext); - // We want the application context to be lower priority than the TimeWarp context. - EGLint contextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, version, EGL_NONE, EGL_NONE, EGL_NONE}; - - // Don't set EGL_CONTEXT_PRIORITY_LEVEL_IMG at all if set to - // EGL_CONTEXT_PRIORITY_MEDIUM_IMG, It is the caller's responsibility to use that if the - // driver doesn't support it. - if (contextPriority != EGL_CONTEXT_PRIORITY_MEDIUM_IMG) { - contextAttribs[2] = EGL_CONTEXT_PRIORITY_LEVEL_IMG; - contextAttribs[3] = contextPriority; - } - - egl.context = eglCreateContext(egl.display, egl.config, shareContext, contextAttribs); - if (egl.context != EGL_NO_CONTEXT) { - ALOG("Succeeded."); - egl.glEsVersion = version; - - EGLint configIDReadback; - if (!eglQueryContext(egl.display, egl.context, EGL_CONFIG_ID, &configIDReadback)) { - ALOGW("eglQueryContext EGL_CONFIG_ID failed"); - } - EGLConfig configCheck = EglConfigForConfigID(egl.display, configIDReadback); - - ALOG( - "Created context with config %p, query returned ID %i = config %p", - egl.config, - configIDReadback, - configCheck); - break; - } - } - if (egl.context == EGL_NO_CONTEXT) { - ALOGW("eglCreateContext failed: %s", EglErrorString(eglGetError())); - return egl; - } - - if (contextPriority != EGL_CONTEXT_PRIORITY_MEDIUM_IMG) { - // See what context priority we actually got - EGLint actualPriorityLevel; - eglQueryContext( - egl.display, egl.context, EGL_CONTEXT_PRIORITY_LEVEL_IMG, &actualPriorityLevel); - switch (actualPriorityLevel) { - case EGL_CONTEXT_PRIORITY_HIGH_IMG: - ALOG("Context is EGL_CONTEXT_PRIORITY_HIGH_IMG"); - break; - case EGL_CONTEXT_PRIORITY_MEDIUM_IMG: - ALOG("Context is EGL_CONTEXT_PRIORITY_MEDIUM_IMG"); - break; - case EGL_CONTEXT_PRIORITY_LOW_IMG: - ALOG("Context is EGL_CONTEXT_PRIORITY_LOW_IMG"); - break; - default: - ALOG("Context has unknown priority level"); - break; - } - } - - // Because EGL_KHR_surfaceless_context is not widespread (Only on Tegra as of - // September 2013), we need to create a tiny pbuffer surface to make the context - // current. - // - // It is necessary to use a config with the same characteristics that the - // context was created with, plus the pbuffer flag, or we will get an - // EGL_BAD_MATCH error on the eglMakeCurrent() call. - // - // This is necessary to support 565 framebuffers, which may be important - // for higher refresh rate displays. - const EGLint attrib_list[] = {EGL_WIDTH, 16, EGL_HEIGHT, 16, EGL_NONE}; - egl.pbufferSurface = eglCreatePbufferSurface(egl.display, egl.config, attrib_list); - if (egl.pbufferSurface == EGL_NO_SURFACE) { - ALOGW("eglCreatePbufferSurface failed: %s", EglErrorString(eglGetError())); - eglDestroyContext(egl.display, egl.context); - egl.context = EGL_NO_CONTEXT; - return egl; - } - - if (eglMakeCurrent(egl.display, egl.pbufferSurface, egl.pbufferSurface, egl.context) == - EGL_FALSE) { - ALOGW("eglMakeCurrent pbuffer failed: %s", EglErrorString(eglGetError())); - eglDestroySurface(egl.display, egl.pbufferSurface); - eglDestroyContext(egl.display, egl.context); - egl.context = EGL_NO_CONTEXT; - return egl; - } - - const char* glVendorString = (const char*)glGetString(GL_VENDOR); - ALOG("GL_VENDOR: %s", glVendorString); - const char* glRendererString = (const char*)glGetString(GL_RENDERER); - ALOG("GL_RENDERER: %s", glRendererString); - const char* glVersionString = (const char*)glGetString(GL_VERSION); - ALOG("GL_VERSION: %s", glVersionString); - const char* glSlVersionString = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - ALOG("GL_SHADING_LANGUAGE_VERSION: %s", glSlVersionString); - - return egl; -} - -void GL_Shutdown(glSetup_t& glSetup) { - if (eglMakeCurrent(glSetup.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == - EGL_FALSE) { - ALOGE_FAIL("eglMakeCurrent: failed: %s", EglErrorString(eglGetError())); - } - if (eglDestroyContext(glSetup.display, glSetup.context) == EGL_FALSE) { - ALOGE_FAIL("eglDestroyContext: failed: %s", EglErrorString(eglGetError())); - } - if (eglDestroySurface(glSetup.display, glSetup.pbufferSurface) == EGL_FALSE) { - ALOGE_FAIL("eglDestroySurface: failed: %s", EglErrorString(eglGetError())); - } - if (eglTerminate(glSetup.display) == EGL_FALSE) { - ALOGE_FAIL("eglTerminate(): failed: %s", EglErrorString(eglGetError())); - } - - glSetup.glEsVersion = 0; - glSetup.display = 0; - glSetup.pbufferSurface = 0; - glSetup.config = 0; - glSetup.context = 0; -} - -bool GL_ProcessEvents(int32_t& exitCode) { - exitCode = 0; - return false; -} - -} // namespace OVRFW diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.h deleted file mode 100755 index 4ed79d0f..00000000 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlSetup.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************************ - -Filename : GlSetup.h -Content : GL Setup -Created : August 24, 2013 -Authors : John Carmack - -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - -************************************************************************************/ -#pragma once -#include "Egl.h" - -namespace OVRFW { -struct glSetup_t { - int glEsVersion; // 2 or 3 - EGLDisplay display; - EGLSurface pbufferSurface; // use to make context current when we don't have window surfaces - EGLConfig config; - EGLContext context; -}; - -// Create an appropriate config, a tiny pbuffer surface, and a context, -// then make it current. This combination can be used before and after -// the actual window surfaces are available. -// egl.context will be EGL_NO_CONTEXT if there was an error. -// requestedGlEsVersion can be 2 or 3. If 3 is requested, 2 might still -// be returned in glSetup_t.glEsVersion. -// -// If contextPriority == EGL_CONTEXT_PRIORITY_MID_IMG, then no priority -// attribute will be set, otherwise EGL_CONTEXT_PRIORITY_LEVEL_IMG will -// be set with contextPriority. -glSetup_t GL_Setup( - const EGLContext shareContext, - const int requestedGlEsVersion, - const int redBits, - const int greenBits, - const int blueBits, - const int depthBits, - const int multisamples, - const GLuint contextPriority); - -void GL_Shutdown(glSetup_t& glSetup); - -// returns true if the application should exit -bool GL_ProcessEvents(int32_t& exitCode); - -} // namespace OVRFW diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.cpp index 3587551f..185350a6 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlTexture.cpp @@ -5,8 +7,6 @@ Content : OpenGL texture loading. Created : September 30, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ // Make sure we get PRIu64 @@ -205,7 +205,7 @@ static void ScanFilePath(const char* url, const char** pfilename, const char** p static std::string GetExtension(const std::string& s) { const char* ext = nullptr; ScanFilePath(s.c_str(), nullptr, &ext); - return std::string(ext); + return ext != nullptr ? std::string(ext) : ""; } namespace OVRFW { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.h index 0206dad7..8c21a5ef 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlTexture.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GlTexture.h @@ -5,9 +7,8 @@ Content : OpenGL texture loading. Created : September 30, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.c b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.c new file mode 100644 index 00000000..63c38987 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.c @@ -0,0 +1,803 @@ +/* +Copyright (c) 2016 Oculus VR, LLC. +*/ + +// This file is a cut down version of gfxwrapper_opengl.c from the OpenXR SDK. +// It is originally based on the Oculus multiplatform GL wrapper but all of the +// code for platforms other than WIN32 has been removed. + +#include "GlWrapperWin32.h" + +#if defined(WIN32) + +#include +#include +#include +#include +#include +#include +#include +#include // for memset +#include // for EBUSY, ETIMEDOUT etc. +#include // for isspace, isdigit + +#define APPLICATION_NAME "OpenGL SI" +#define WINDOW_TITLE "OpenGL SI" + +#include "GL/Glu.h" +#pragma comment(lib, "glu32.lib") + +static void Error(const char* format, ...) { + char buffer[4096]; + va_list args; + va_start(args, format); + vsnprintf_s(buffer, 4096, _TRUNCATE, format, args); + va_end(args); + + OutputDebugStringA(buffer); + + // MessageBoxA(NULL, buffer, "ERROR", MB_OK | MB_ICONINFORMATION); + // Without exiting, the application will likely crash. + if (format != NULL) { + exit(1); + } +} + +/* +================================================================================================================================ + +OpenGL error checking. + +================================================================================================================================ +*/ + +#if !defined(NDEBUG) +#define GL(func) \ + func; \ + GlCheckErrors(#func); +#else +#define GL(func) func; +#endif + +#if !defined(NDEBUG) +#define EGL(func) \ + if (func == EGL_FALSE) { \ + Error(#func " failed: %s", EglErrorString(eglGetError())); \ + } +#else +#define EGL(func) \ + if (func == EGL_FALSE) { \ + Error(#func " failed: %s", EglErrorString(eglGetError())); \ + } +#endif + +/* +================================ +Get proc address / extensions +================================ +*/ + +PROC GetExtension(const char* functionName) { + return wglGetProcAddress(functionName); +} + +PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +PFNGLISRENDERBUFFERPROC glIsRenderbuffer; +PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glCheckNamedFramebufferStatus; + +PFNGLGENBUFFERSPROC glGenBuffers; +PFNGLDELETEBUFFERSPROC glDeleteBuffers; +PFNGLBINDBUFFERPROC glBindBuffer; +PFNGLBINDBUFFERBASEPROC glBindBufferBase; +PFNGLBUFFERDATAPROC glBufferData; +PFNGLBUFFERSUBDATAPROC glBufferSubData; +PFNGLBUFFERSTORAGEPROC glBufferStorage; +PFNGLMAPBUFFERPROC glMapBuffer; +PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +PFNGLUNMAPBUFFERPROC glUnmapBuffer; + +PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; +PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; +PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; + +PFNGLACTIVETEXTUREPROC glActiveTexture; +PFNGLTEXIMAGE3DPROC glTexImage3D; +PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; +PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D; +PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; +PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; +PFNGLTEXSTORAGE2DPROC glTexStorage2D; +PFNGLTEXSTORAGE3DPROC glTexStorage3D; +PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; +PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; +PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample; +PFNGLTEXSTORAGE3DMULTISAMPLEPROC glTexStorage3DMultisample; +PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +PFNGLBINDIMAGETEXTUREPROC glBindImageTexture; + +PFNGLCREATEPROGRAMPROC glCreateProgram; +PFNGLDELETEPROGRAMPROC glDeleteProgram; +PFNGLCREATESHADERPROC glCreateShader; +PFNGLDELETESHADERPROC glDeleteShader; +PFNGLSHADERSOURCEPROC glShaderSource; +PFNGLCOMPILESHADERPROC glCompileShader; +PFNGLGETSHADERIVPROC glGetShaderiv; +PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +PFNGLUSEPROGRAMPROC glUseProgram; +PFNGLATTACHSHADERPROC glAttachShader; +PFNGLLINKPROGRAMPROC glLinkProgram; +PFNGLGETPROGRAMIVPROC glGetProgramiv; +PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; +PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +PFNGLGETPROGRAMRESOURCEINDEXPROC glGetProgramResourceIndex; +PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; +PFNGLSHADERSTORAGEBLOCKBINDINGPROC glShaderStorageBlockBinding; +PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; +PFNGLUNIFORM1IPROC glUniform1i; +PFNGLUNIFORM1IVPROC glUniform1iv; +PFNGLUNIFORM2IVPROC glUniform2iv; +PFNGLUNIFORM3IVPROC glUniform3iv; +PFNGLUNIFORM4IVPROC glUniform4iv; +PFNGLUNIFORM1FPROC glUniform1f; +PFNGLUNIFORM1FVPROC glUniform1fv; +PFNGLUNIFORM2FVPROC glUniform2fv; +PFNGLUNIFORM3FVPROC glUniform3fv; +PFNGLUNIFORM4FVPROC glUniform4fv; +PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; +PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv; +PFNGLUNIFORMMATRIX2X4FVPROC glUniformMatrix2x4fv; +PFNGLUNIFORMMATRIX3X2FVPROC glUniformMatrix3x2fv; +PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; +PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; +PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv; +PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv; +PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; + +PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; +PFNGLDISPATCHCOMPUTEPROC glDispatchCompute; +PFNGLMEMORYBARRIERPROC glMemoryBarrier; + +PFNGLGENQUERIESPROC glGenQueries; +PFNGLDELETEQUERIESPROC glDeleteQueries; +PFNGLISQUERYPROC glIsQuery; +PFNGLBEGINQUERYPROC glBeginQuery; +PFNGLENDQUERYPROC glEndQuery; +PFNGLQUERYCOUNTERPROC glQueryCounter; +PFNGLGETQUERYIVPROC glGetQueryiv; +PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; +PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; +PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; +PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + +PFNGLFENCESYNCPROC glFenceSync; +PFNGLCLIENTWAITSYNCPROC glClientWaitSync; +PFNGLDELETESYNCPROC glDeleteSync; +PFNGLISSYNCPROC glIsSync; + +PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; +PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate; + +PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; +PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; + +PFNGLBLENDCOLORPROC glBlendColor; +PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; +PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; +PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; +PFNWGLDELAYBEFORESWAPNVPROC wglDelayBeforeSwapNV; + +PFNGLDEPTHRANGEFPROC glDepthRangef; +PFNGLBLENDEQUATIONPROC glBlendEquation; +PFNGLINVALIDATEFRAMEBUFFERPROC glInvalidateFramebuffer; + +void GlBootstrapExtensions() { + wglChoosePixelFormatARB = + (PFNWGLCHOOSEPIXELFORMATARBPROC)GetExtension("wglChoosePixelFormatARB"); + wglCreateContextAttribsARB = + (PFNWGLCREATECONTEXTATTRIBSARBPROC)GetExtension("wglCreateContextAttribsARB"); + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)GetExtension("wglSwapIntervalEXT"); + wglDelayBeforeSwapNV = (PFNWGLDELAYBEFORESWAPNVPROC)GetExtension("wglDelayBeforeSwapNV"); +} + +void GlInitExtensions() { + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)GetExtension("glGenFramebuffers"); + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)GetExtension("glDeleteFramebuffers"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)GetExtension("glBindFramebuffer"); + glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)GetExtension("glBlitFramebuffer"); + glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)GetExtension("glGenRenderbuffers"); + glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)GetExtension("glDeleteRenderbuffers"); + glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)GetExtension("glBindRenderbuffer"); + glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)GetExtension("glIsRenderbuffer"); + glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)GetExtension("glRenderbufferStorage"); + glRenderbufferStorageMultisample = + (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)GetExtension("glRenderbufferStorageMultisample"); + glFramebufferRenderbuffer = + (PFNGLFRAMEBUFFERRENDERBUFFERPROC)GetExtension("glFramebufferRenderbuffer"); + glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)GetExtension("glFramebufferTexture2D"); + glFramebufferTextureLayer = + (PFNGLFRAMEBUFFERTEXTURELAYERPROC)GetExtension("glFramebufferTextureLayer"); + glCheckFramebufferStatus = + (PFNGLCHECKFRAMEBUFFERSTATUSPROC)GetExtension("glCheckFramebufferStatus"); + glCheckNamedFramebufferStatus = + (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)GetExtension("glCheckNamedFramebufferStatus"); + + glGenBuffers = (PFNGLGENBUFFERSPROC)GetExtension("glGenBuffers"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)GetExtension("glDeleteBuffers"); + glBindBuffer = (PFNGLBINDBUFFERPROC)GetExtension("glBindBuffer"); + glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)GetExtension("glBindBufferBase"); + glBufferData = (PFNGLBUFFERDATAPROC)GetExtension("glBufferData"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)GetExtension("glBufferSubData"); + glBufferStorage = (PFNGLBUFFERSTORAGEPROC)GetExtension("glBufferStorage"); + glMapBuffer = (PFNGLMAPBUFFERPROC)GetExtension("glMapBuffer"); + glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)GetExtension("glMapBufferRange"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)GetExtension("glUnmapBuffer"); + + glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)GetExtension("glGenVertexArrays"); + glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)GetExtension("glDeleteVertexArrays"); + glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)GetExtension("glBindVertexArray"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)GetExtension("glVertexAttribPointer"); + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)GetExtension("glVertexAttribDivisor"); + glDisableVertexAttribArray = + (PFNGLDISABLEVERTEXATTRIBARRAYPROC)GetExtension("glDisableVertexAttribArray"); + glEnableVertexAttribArray = + (PFNGLENABLEVERTEXATTRIBARRAYPROC)GetExtension("glEnableVertexAttribArray"); + + glActiveTexture = (PFNGLACTIVETEXTUREPROC)GetExtension("glActiveTexture"); + glTexImage3D = (PFNGLTEXIMAGE3DPROC)GetExtension("glTexImage3D"); + glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)GetExtension("glCompressedTexImage2D"); + glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)GetExtension("glCompressedTexImage3D"); + glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)GetExtension("glTexSubImage3D"); + glCompressedTexSubImage2D = + (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)GetExtension("glCompressedTexSubImage2D"); + glCompressedTexSubImage3D = + (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)GetExtension("glCompressedTexSubImage3D"); + glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)GetExtension("glTexStorage2D"); + glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)GetExtension("glTexStorage3D"); + glTexImage2DMultisample = + (PFNGLTEXIMAGE2DMULTISAMPLEPROC)GetExtension("glTexImage2DMultisample"); + glTexImage3DMultisample = + (PFNGLTEXIMAGE3DMULTISAMPLEPROC)GetExtension("glTexImage3DMultisample"); + glTexStorage2DMultisample = + (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)GetExtension("glTexStorage2DMultisample"); + glTexStorage3DMultisample = + (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)GetExtension("glTexStorage3DMultisample"); + glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)GetExtension("glGenerateMipmap"); + glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)GetExtension("glBindImageTexture"); + + glCreateProgram = (PFNGLCREATEPROGRAMPROC)GetExtension("glCreateProgram"); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC)GetExtension("glDeleteProgram"); + glCreateShader = (PFNGLCREATESHADERPROC)GetExtension("glCreateShader"); + glDeleteShader = (PFNGLDELETESHADERPROC)GetExtension("glDeleteShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)GetExtension("glShaderSource"); + glCompileShader = (PFNGLCOMPILESHADERPROC)GetExtension("glCompileShader"); + glGetShaderiv = (PFNGLGETSHADERIVPROC)GetExtension("glGetShaderiv"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)GetExtension("glGetShaderInfoLog"); + glUseProgram = (PFNGLUSEPROGRAMPROC)GetExtension("glUseProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)GetExtension("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)GetExtension("glLinkProgram"); + glGetProgramiv = (PFNGLGETPROGRAMIVPROC)GetExtension("glGetProgramiv"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)GetExtension("glGetProgramInfoLog"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)GetExtension("glGetAttribLocation"); + glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)GetExtension("glBindAttribLocation"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)GetExtension("glGetUniformLocation"); + glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GetExtension("glGetUniformBlockIndex"); + glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)GetExtension("glProgramUniform1i"); + glUniform1i = (PFNGLUNIFORM1IPROC)GetExtension("glUniform1i"); + glUniform1iv = (PFNGLUNIFORM1IVPROC)GetExtension("glUniform1iv"); + glUniform2iv = (PFNGLUNIFORM2IVPROC)GetExtension("glUniform2iv"); + glUniform3iv = (PFNGLUNIFORM3IVPROC)GetExtension("glUniform3iv"); + glUniform4iv = (PFNGLUNIFORM4IVPROC)GetExtension("glUniform4iv"); + glUniform1f = (PFNGLUNIFORM1FPROC)GetExtension("glUniform1f"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)GetExtension("glUniform1fv"); + glUniform2fv = (PFNGLUNIFORM2FVPROC)GetExtension("glUniform2fv"); + glUniform3fv = (PFNGLUNIFORM3FVPROC)GetExtension("glUniform3fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)GetExtension("glUniform4fv"); + glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)GetExtension("glUniformMatrix3fv"); + glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)GetExtension("glUniformMatrix2x3fv"); + glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)GetExtension("glUniformMatrix2x4fv"); + glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)GetExtension("glUniformMatrix3x2fv"); + glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)GetExtension("glUniformMatrix3fv"); + glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)GetExtension("glUniformMatrix3x4fv"); + glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)GetExtension("glUniformMatrix4x2fv"); + glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)GetExtension("glUniformMatrix4x3fv"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)GetExtension("glUniformMatrix4fv"); + glGetProgramResourceIndex = + (PFNGLGETPROGRAMRESOURCEINDEXPROC)GetExtension("glGetProgramResourceIndex"); + glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GetExtension("glUniformBlockBinding"); + glShaderStorageBlockBinding = + (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)GetExtension("glShaderStorageBlockBinding"); + + glDrawElementsInstanced = + (PFNGLDRAWELEMENTSINSTANCEDPROC)GetExtension("glDrawElementsInstanced"); + glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)GetExtension("glDispatchCompute"); + glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)GetExtension("glMemoryBarrier"); + + glGenQueries = (PFNGLGENQUERIESPROC)GetExtension("glGenQueries"); + glDeleteQueries = (PFNGLDELETEQUERIESPROC)GetExtension("glDeleteQueries"); + glIsQuery = (PFNGLISQUERYPROC)GetExtension("glIsQuery"); + glBeginQuery = (PFNGLBEGINQUERYPROC)GetExtension("glBeginQuery"); + glEndQuery = (PFNGLENDQUERYPROC)GetExtension("glEndQuery"); + glQueryCounter = (PFNGLQUERYCOUNTERPROC)GetExtension("glQueryCounter"); + glGetQueryiv = (PFNGLGETQUERYIVPROC)GetExtension("glGetQueryiv"); + glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)GetExtension("glGetQueryObjectiv"); + glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)GetExtension("glGetQueryObjectuiv"); + glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)GetExtension("glGetQueryObjecti64v"); + glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)GetExtension("glGetQueryObjectui64v"); + + glFenceSync = (PFNGLFENCESYNCPROC)GetExtension("glFenceSync"); + glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)GetExtension("glClientWaitSync"); + glDeleteSync = (PFNGLDELETESYNCPROC)GetExtension("glDeleteSync"); + glIsSync = (PFNGLISSYNCPROC)GetExtension("glIsSync"); + + glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)GetExtension("glBlendFuncSeparate"); + glBlendEquationSeparate = + (PFNGLBLENDEQUATIONSEPARATEPROC)GetExtension("glBlendEquationSeparate"); + + glBlendColor = (PFNGLBLENDCOLORPROC)GetExtension("glBlendColor"); + + glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)GetExtension("glDebugMessageControl"); + glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)GetExtension("glDebugMessageCallback"); + + glDepthRangef = (PFNGLDEPTHRANGEFPROC)GetExtension("glDepthRangef"); + glBlendEquation = (PFNGLBLENDEQUATIONPROC)GetExtension("glBlendEquation"); + glInvalidateFramebuffer = + (PFNGLINVALIDATEFRAMEBUFFERPROC)GetExtension("glInvalidateFramebuffer"); +} + +typedef enum { + KS_GPU_SURFACE_COLOR_FORMAT_R5G6B5, + KS_GPU_SURFACE_COLOR_FORMAT_B5G6R5, + KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8, + KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8, + KS_GPU_SURFACE_COLOR_FORMAT_MAX +} ksGpuSurfaceColorFormat; + +typedef enum { + KS_GPU_SURFACE_DEPTH_FORMAT_NONE, + KS_GPU_SURFACE_DEPTH_FORMAT_D16, + KS_GPU_SURFACE_DEPTH_FORMAT_D24, + KS_GPU_SURFACE_DEPTH_FORMAT_MAX +} ksGpuSurfaceDepthFormat; + +typedef enum { + KS_GPU_SAMPLE_COUNT_1 = 1, + KS_GPU_SAMPLE_COUNT_2 = 2, + KS_GPU_SAMPLE_COUNT_4 = 4, + KS_GPU_SAMPLE_COUNT_8 = 8, + KS_GPU_SAMPLE_COUNT_16 = 16, + KS_GPU_SAMPLE_COUNT_32 = 32, + KS_GPU_SAMPLE_COUNT_64 = 64, +} ksGpuSampleCount; + +typedef struct { + HDC hDC; + HGLRC hGLRC; +} ksGpuContext; + +typedef struct { + unsigned char redBits; + unsigned char greenBits; + unsigned char blueBits; + unsigned char alphaBits; + unsigned char colorBits; + unsigned char depthBits; +} ksGpuSurfaceBits; + +typedef struct { + ksGpuContext context; + ksGpuSurfaceColorFormat colorFormat; + ksGpuSurfaceDepthFormat depthFormat; + ksGpuSampleCount sampleCount; + int windowWidth; + int windowHeight; + + HINSTANCE hInstance; + HDC hDC; + HWND hWnd; +} ksGpuWindow; + +/* +================================================================================================================================ + +GPU Context. + +================================================================================================================================ +*/ + +ksGpuSurfaceBits ksGpuContext_BitsForSurfaceFormat( + const ksGpuSurfaceColorFormat colorFormat, + const ksGpuSurfaceDepthFormat depthFormat) { + ksGpuSurfaceBits bits; + bits.redBits = + ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R5G6B5) + ? 5 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B5G6R5) ? 5 : 8)))); + bits.greenBits = + ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R5G6B5) + ? 6 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B5G6R5) ? 6 : 8)))); + bits.blueBits = + ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R5G6B5) + ? 5 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B5G6R5) ? 5 : 8)))); + bits.alphaBits = + ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R8G8B8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8) + ? 8 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_R5G6B5) + ? 0 + : ((colorFormat == KS_GPU_SURFACE_COLOR_FORMAT_B5G6R5) ? 0 : 8)))); + bits.colorBits = bits.redBits + bits.greenBits + bits.blueBits + bits.alphaBits; + bits.depthBits = + ((depthFormat == KS_GPU_SURFACE_DEPTH_FORMAT_D16) + ? 16 + : ((depthFormat == KS_GPU_SURFACE_DEPTH_FORMAT_D24) ? 24 : 0)); + return bits; +} + +static bool ksGpuContext_CreateForSurface( + ksGpuContext* context, + const ksGpuSurfaceColorFormat colorFormat, + const ksGpuSurfaceDepthFormat depthFormat, + const ksGpuSampleCount sampleCount, + HINSTANCE hInstance, + HDC hDC) { + const ksGpuSurfaceBits bits = ksGpuContext_BitsForSurfaceFormat(colorFormat, depthFormat); + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, // version + PFD_DRAW_TO_WINDOW | // must support windowed + PFD_SUPPORT_OPENGL | // must support OpenGL + PFD_DOUBLEBUFFER, // must support double buffering + PFD_TYPE_RGBA, // iPixelType + bits.colorBits, // cColorBits + 0, + 0, // cRedBits, cRedShift + 0, + 0, // cGreenBits, cGreenShift + 0, + 0, // cBlueBits, cBlueShift + 0, + 0, // cAlphaBits, cAlphaShift + 0, // cAccumBits + 0, // cAccumRedBits + 0, // cAccumGreenBits + 0, // cAccumBlueBits + 0, // cAccumAlphaBits + bits.depthBits, // cDepthBits + 0, // cStencilBits + 0, // cAuxBuffers + PFD_MAIN_PLANE, // iLayerType + 0, // bReserved + 0, // dwLayerMask + 0, // dwVisibleMask + 0 // dwDamageMask + }; + + HWND localWnd = NULL; + HDC localDC = hDC; + + if (sampleCount > KS_GPU_SAMPLE_COUNT_1) { + // A valid OpenGL context is needed to get OpenGL extensions including + // wglChoosePixelFormatARB and wglCreateContextAttribsARB. A device context with a valid + // pixel format is needed to create an OpenGL context. However, once a pixel format is set + // on a device context it is final. Therefore a pixel format is set on the device context of + // a temporary window to create a context to get the extensions for multi-sampling. + localWnd = + CreateWindowA(APPLICATION_NAME, "temp", 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); + localDC = GetDC(localWnd); + } + + int pixelFormat = ChoosePixelFormat(localDC, &pfd); + if (pixelFormat == 0) { + Error("Failed to find a suitable pixel format."); + return false; + } + + if (!SetPixelFormat(localDC, pixelFormat, &pfd)) { + Error("Failed to set the pixel format."); + return false; + } + + // Now that the pixel format is set, create a temporary context to get the extensions. + { + HGLRC hGLRC = wglCreateContext(localDC); + wglMakeCurrent(localDC, hGLRC); + + GlBootstrapExtensions(); + + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hGLRC); + } + + if (sampleCount > KS_GPU_SAMPLE_COUNT_1) { + // Release the device context and destroy the window that were created to get extensions. + ReleaseDC(localWnd, localDC); + DestroyWindow(localWnd); + + int pixelFormatAttribs[] = { + WGL_DRAW_TO_WINDOW_ARB, + GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, + GL_TRUE, + WGL_DOUBLE_BUFFER_ARB, + GL_TRUE, + WGL_PIXEL_TYPE_ARB, + WGL_TYPE_RGBA_ARB, + WGL_COLOR_BITS_ARB, + bits.colorBits, + WGL_DEPTH_BITS_ARB, + bits.depthBits, + WGL_SAMPLE_BUFFERS_ARB, + 1, + WGL_SAMPLES_ARB, + sampleCount, + 0}; + + unsigned int numPixelFormats = 0; + + if (!wglChoosePixelFormatARB( + hDC, pixelFormatAttribs, NULL, 1, &pixelFormat, &numPixelFormats) || + numPixelFormats == 0) { + Error("Failed to find MSAA pixel format."); + return false; + } + + memset(&pfd, 0, sizeof(pfd)); + + if (!DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) { + Error("Failed to describe the pixel format."); + return false; + } + + if (!SetPixelFormat(hDC, pixelFormat, &pfd)) { + Error("Failed to set the pixel format."); + return false; + } + } + + int contextAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, + OPENGL_VERSION_MAJOR, + WGL_CONTEXT_MINOR_VERSION_ARB, + OPENGL_VERSION_MINOR, + WGL_CONTEXT_PROFILE_MASK_ARB, + WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, + WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB, + 0}; + + context->hDC = hDC; + context->hGLRC = wglCreateContextAttribsARB(hDC, NULL, contextAttribs); + if (!context->hGLRC) { + Error("Failed to create GL context."); + return false; + } + + wglMakeCurrent(hDC, context->hGLRC); + + GlInitExtensions(); + + return true; +} + +void ksGpuContext_Destroy(ksGpuContext* context) { + if (context->hGLRC) { + if (!wglMakeCurrent(NULL, NULL)) { + DWORD error = GetLastError(); + Error("Failed to release context error code (%d).", error); + } + + if (!wglDeleteContext(context->hGLRC)) { + DWORD error = GetLastError(); + Error("Failed to delete context error code (%d).", error); + } + context->hGLRC = NULL; + } + context->hDC = NULL; +} + +/* +================================================================================================================================ + +GPU Window. + +================================================================================================================================ +*/ + +void ksGpuWindow_Destroy(ksGpuWindow* window) { + ksGpuContext_Destroy(&window->context); + + if (window->hDC) { + if (!ReleaseDC(window->hWnd, window->hDC)) { + Error("Failed to release device context."); + } + window->hDC = NULL; + } + + if (window->hWnd) { + if (!DestroyWindow(window->hWnd)) { + Error("Failed to destroy the window."); + } + window->hWnd = NULL; + } + + if (window->hInstance) { + if (!UnregisterClassA(APPLICATION_NAME, window->hInstance)) { + Error("Failed to unregister window class."); + } + window->hInstance = NULL; + } +} + +static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + switch (message) { + case WM_CLOSE: { + PostQuitMessage(0); + return 0; + } + } + return DefWindowProcA(hWnd, message, wParam, lParam); +} + +bool ksGpuWindow_Create( + ksGpuWindow* window, + ksGpuSurfaceColorFormat colorFormat, + ksGpuSurfaceDepthFormat depthFormat, + ksGpuSampleCount sampleCount, + int width, + int height) { + memset(window, 0, sizeof(ksGpuWindow)); + + window->colorFormat = colorFormat; + window->depthFormat = depthFormat; + window->sampleCount = sampleCount; + window->windowWidth = width; + window->windowHeight = height; + + DEVMODEA lpDevMode; + memset(&lpDevMode, 0, sizeof(DEVMODEA)); + lpDevMode.dmSize = sizeof(DEVMODEA); + lpDevMode.dmDriverExtra = 0; + + window->hInstance = GetModuleHandleA(NULL); + + WNDCLASSA wc; + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = window->hInstance; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = APPLICATION_NAME; + + if (!RegisterClassA(&wc)) { + Error("Failed to register window class."); + return false; + } + + // Fixed size window. + DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; + + RECT windowRect; + windowRect.left = (long)0; + windowRect.right = (long)width; + windowRect.top = (long)0; + windowRect.bottom = (long)height; + + AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle); + + RECT desktopRect; + GetWindowRect(GetDesktopWindow(), &desktopRect); + + const int offsetX = (desktopRect.right - (windowRect.right - windowRect.left)) / 2; + const int offsetY = (desktopRect.bottom - (windowRect.bottom - windowRect.top)) / 2; + + windowRect.left += offsetX; + windowRect.right += offsetX; + windowRect.top += offsetY; + windowRect.bottom += offsetY; + + window->hWnd = CreateWindowExA( + dwExStyle, // Extended style for the window + APPLICATION_NAME, // Class name + WINDOW_TITLE, // Window title + dwStyle | // Defined window style + WS_CLIPSIBLINGS | // Required window style + WS_CLIPCHILDREN, // Required window style + windowRect.left, // Window X position + windowRect.top, // Window Y position + windowRect.right - windowRect.left, // Window width + windowRect.bottom - windowRect.top, // Window height + NULL, // No parent window + NULL, // No menu + window->hInstance, // Instance + NULL); // No WM_CREATE parameter + if (!window->hWnd) { + ksGpuWindow_Destroy(window); + Error("Failed to create window."); + return false; + } + + SetWindowLongPtrA(window->hWnd, GWLP_USERDATA, (LONG_PTR)window); + + window->hDC = GetDC(window->hWnd); + if (!window->hDC) { + ksGpuWindow_Destroy(window); + Error("Failed to acquire device context."); + return false; + } + + ksGpuContext_CreateForSurface( + &window->context, colorFormat, depthFormat, sampleCount, window->hInstance, window->hDC); + + wglMakeCurrent(window->context.hDC, window->context.hGLRC); + + ShowWindow(window->hWnd, SW_SHOW); + SetForegroundWindow(window->hWnd); + SetFocus(window->hWnd); + + return true; +} + +ksGpuWindow window; + +void ovrGl_CreateContext_Windows(HDC* hDC, HGLRC* hGLRC) { + ksGpuSurfaceColorFormat colorFormat = KS_GPU_SURFACE_COLOR_FORMAT_B8G8R8A8; + ksGpuSurfaceDepthFormat depthFormat = KS_GPU_SURFACE_DEPTH_FORMAT_D24; + ksGpuSampleCount sampleCount = KS_GPU_SAMPLE_COUNT_1; + if (!ksGpuWindow_Create(&window, colorFormat, depthFormat, sampleCount, 640, 480)) { + Error("Unable to create GL context"); + } + + *hDC = window.context.hDC; + *hGLRC = window.context.hGLRC; +} + +void ovrGl_DestroyContext_Windows(HDC* hDC, HGLRC* hGLRC) { + ksGpuWindow_Destroy(&window); +} + +const char* ovrGl_ErrorString_Windows(const GLint err) { + return (const char*)gluErrorString(err); +} + +#endif // defined(OS_WINDOWS) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.h new file mode 100644 index 00000000..9123f868 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GlWrapperWin32.h @@ -0,0 +1,174 @@ +/* +Copyright (c) 2016 Oculus VR, LLC. +*/ + +// This file is a cut down version of gfxwrapper_opengl.h from the OpenXR SDK. +// It is originally based on the Oculus multiplatform GL wrapper but all of the +// code for platforms other than WIN32 has been removed. + +#pragma once + +#if defined(WIN32) + +#ifdef __cplusplus +extern "C" { +#endif + +#define OPENGL_VERSION_MAJOR 4 +#define OPENGL_VERSION_MINOR 3 +#define GLSL_VERSION "430" +#define SPIRV_VERSION "99" + +#define GL_APIENTRY APIENTRY +#define GL_APIENTRYP APIENTRYP + +#include +#include +#define GL_EXT_color_subtable +#include +#include +#include + +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 + +extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer; +extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +extern PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glCheckNamedFramebufferStatus; + +extern PFNGLGENBUFFERSPROC glGenBuffers; +extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; +extern PFNGLBINDBUFFERPROC glBindBuffer; +extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; +extern PFNGLBUFFERDATAPROC glBufferData; +extern PFNGLBUFFERSUBDATAPROC glBufferSubData; +extern PFNGLBUFFERSTORAGEPROC glBufferStorage; +extern PFNGLMAPBUFFERPROC glMapBuffer; +extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; + +extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; +extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; +extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; + +extern PFNGLACTIVETEXTUREPROC glActiveTexture; +extern PFNGLTEXIMAGE3DPROC glTexImage3D; +extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; +extern PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D; +extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; +extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; +extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; + +extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; +extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; +extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample; +extern PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample; +extern PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample; +extern PFNGLTEXSTORAGE3DMULTISAMPLEPROC glTexStorage3DMultisample; +extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture; + +extern PFNGLCREATEPROGRAMPROC glCreateProgram; +extern PFNGLDELETEPROGRAMPROC glDeleteProgram; +extern PFNGLCREATESHADERPROC glCreateShader; +extern PFNGLDELETESHADERPROC glDeleteShader; +extern PFNGLSHADERSOURCEPROC glShaderSource; +extern PFNGLCOMPILESHADERPROC glCompileShader; +extern PFNGLGETSHADERIVPROC glGetShaderiv; +extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +extern PFNGLUSEPROGRAMPROC glUseProgram; +extern PFNGLATTACHSHADERPROC glAttachShader; +extern PFNGLLINKPROGRAMPROC glLinkProgram; +extern PFNGLGETPROGRAMIVPROC glGetProgramiv; +extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; +extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +extern PFNGLGETPROGRAMRESOURCEINDEXPROC glGetProgramResourceIndex; +extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; +extern PFNGLSHADERSTORAGEBLOCKBINDINGPROC glShaderStorageBlockBinding; +extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; +extern PFNGLUNIFORM1IPROC glUniform1i; +extern PFNGLUNIFORM1IVPROC glUniform1iv; +extern PFNGLUNIFORM2IVPROC glUniform2iv; +extern PFNGLUNIFORM3IVPROC glUniform3iv; +extern PFNGLUNIFORM4IVPROC glUniform4iv; +extern PFNGLUNIFORM1FPROC glUniform1f; +extern PFNGLUNIFORM1FVPROC glUniform1fv; +extern PFNGLUNIFORM2FVPROC glUniform2fv; +extern PFNGLUNIFORM3FVPROC glUniform3fv; +extern PFNGLUNIFORM4FVPROC glUniform4fv; +extern PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; +extern PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv; +extern PFNGLUNIFORMMATRIX2X4FVPROC glUniformMatrix2x4fv; +extern PFNGLUNIFORMMATRIX3X2FVPROC glUniformMatrix3x2fv; +extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; +extern PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; +extern PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv; +extern PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv; +extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; + +extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; +extern PFNGLDISPATCHCOMPUTEPROC glDispatchCompute; +extern PFNGLMEMORYBARRIERPROC glMemoryBarrier; + +extern PFNGLGENQUERIESPROC glGenQueries; +extern PFNGLDELETEQUERIESPROC glDeleteQueries; +extern PFNGLISQUERYPROC glIsQuery; +extern PFNGLBEGINQUERYPROC glBeginQuery; +extern PFNGLENDQUERYPROC glEndQuery; +extern PFNGLQUERYCOUNTERPROC glQueryCounter; +extern PFNGLGETQUERYIVPROC glGetQueryiv; +extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; +extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; +extern PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v; +extern PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; + +extern PFNGLFENCESYNCPROC glFenceSync; +extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync; +extern PFNGLDELETESYNCPROC glDeleteSync; +extern PFNGLISSYNCPROC glIsSync; + +extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; +extern PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate; + +extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; +extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; + +extern PFNGLBLENDCOLORPROC glBlendColor; +extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; +extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; +extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; +extern PFNWGLDELAYBEFORESWAPNVPROC wglDelayBeforeSwapNV; + +extern PFNGLDEPTHRANGEFPROC glDepthRangef; +extern PFNGLBLENDEQUATIONPROC glBlendEquation; +extern PFNGLINVALIDATEFRAMEBUFFERPROC glInvalidateFramebuffer; + +void ovrGl_CreateContext_Windows(HDC* hDC, HGLRC* hGLRC); +void ovrGl_DestroyContext_Windows(); +const char* ovrGl_ErrorString_Windows(const GLint error); + +#ifdef __cplusplus +} +#endif + +#endif // defined(WIN32) diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GpuState.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GpuState.h index f96bab80..fc6be730 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GpuState.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/GpuState.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : GpuState.h @@ -5,9 +7,8 @@ Content : Gpu state management. Created : August 9. 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "Egl.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.cpp index 0d21f3b8..c0017247 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.cpp @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PanelRenderer.cpp Content : Class that manages and renders quad-based panels with custom shaders. Created : September 19, 2019 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ + #include "PanelRenderer.h" #include "Misc/Log.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.h index 6dac8aed..7ad1a155 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PanelRenderer.h @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PanelRenderer.h Content : Class that manages and renders quad-based panels with custom shaders. Created : September 19, 2019 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.cpp index 23193e9c..52b742f0 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ParticleSystem.h @@ -5,8 +7,6 @@ Content : A simple particle system for System Activities. Created : October 12, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "ParticleSystem.h" @@ -53,6 +53,8 @@ void main() )glsl"; static const char* particleGeoFragmentSrc = R"glsl( +precision highp float; + varying highp vec2 oTexCoord; varying lowp vec4 oColor; void main() diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.h index fcf48b3c..b93848e6 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/ParticleSystem.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : ParticleSystem.h @@ -5,8 +7,6 @@ Content : A simple particle system for System Activities. Created : October 12, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.cpp index ebc890a2..61777e9d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PointList.cpp @@ -5,8 +7,6 @@ Content : Abstract base class for a list of points. Created : 6/16/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "PointList.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.h index 776a8de0..de935c8c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/PointList.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : PointList.h @@ -5,8 +7,6 @@ Content : Abstract base class for a list of points. Created : 6/16/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.cpp index fc64dd13..eb91ab36 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Ribbon.h @@ -5,8 +7,6 @@ Content : Class that renders connected polygon strips from a list of point Created : 6/16/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "Ribbon.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.h index 7b1ae3d7..5fc4132b 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/Ribbon.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Ribbon.h @@ -5,8 +7,6 @@ Content : Class that renders connected polygon strips from a list of point Created : 6/16/2017 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SimpleBeamRenderer.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SimpleBeamRenderer.h index 308d8ebd..a045757a 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SimpleBeamRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SimpleBeamRenderer.h @@ -1,12 +1,14 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SimpleBeamRenderer.h Content : Helper for beam and particle rendering Created : July 2020 Authors : Matthew Langille -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ + #pragma once #include "OVR_Math.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.cpp index ffbaacf2..2776956c 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceRender.cpp @@ -5,8 +7,6 @@ Content : Optimized OpenGL rendering path Created : August 9, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "SurfaceRender.h" @@ -112,7 +112,7 @@ ChangeGpuState(const ovrGpuState oldState, const ovrGpuState newState, bool forc (newState.depthRange[1] != oldState.depthRange[1])) { GL(glDepthRangef(newState.depthRange[0], newState.depthRange[1])); } -#if GL_ES_VERSION_2_0 == 0 +#if !defined(GL_ES_VERSION_2_0) || GL_ES_VERSION_2_0 == 0 if (force || newState.polygonMode != oldState.polygonMode) { GL(glPolygonMode(GL_FRONT_AND_BACK, newState.polygonMode)); } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.h index 68c4b6f9..0d076cc9 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceRender.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceRender.h @@ -5,9 +7,8 @@ Content : Optimized OpenGL rendering path Created : August 9, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.cpp index e44bc07a..83ce80d8 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceTexture.cpp @@ -5,8 +7,6 @@ Content : Interface to Android SurfaceTexture objects Created : September 17, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #include "SurfaceTexture.h" @@ -23,10 +23,14 @@ SurfaceTexture::SurfaceTexture(JNIEnv* jni_) : textureId(0), javaObject(NULL), jni(NULL), - nanoTimeStamp(0), + nanoTimeStamp(0) +#if defined(OVR_OS_ANDROID) + , updateTexImageMethodId(NULL), getTimestampMethodId(NULL), - setDefaultBufferSizeMethodId(NULL) { + setDefaultBufferSizeMethodId(NULL) +#endif // defined(OVR_OS_ANDROID) +{ jni = jni_; glGenTextures(1, &textureId); @@ -37,6 +41,7 @@ SurfaceTexture::SurfaceTexture(JNIEnv* jni_) glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); +#if defined(OVR_OS_ANDROID) static const char* className = "android/graphics/SurfaceTexture"; JavaClass surfaceTextureClass(jni, jni->FindClass(className)); if (0 == surfaceTextureClass.GetJClass()) { @@ -75,6 +80,7 @@ SurfaceTexture::SurfaceTexture(JNIEnv* jni_) if (javaObject == 0) { ALOGE_FAIL("NewGlobalRef() failed"); } +#endif // defined(OVR_OS_ANDROID) } SurfaceTexture::~SurfaceTexture() { @@ -82,17 +88,22 @@ SurfaceTexture::~SurfaceTexture() { glDeleteTextures(1, &textureId); textureId = 0; } +#if defined(OVR_OS_ANDROID) if (javaObject) { jni->DeleteGlobalRef(javaObject); javaObject = 0; } +#endif // defined(OVR_OS_ANDROID) } void SurfaceTexture::SetDefaultBufferSize(const int width, const int height) { +#if defined(OVR_OS_ANDROID) jni->CallVoidMethod(javaObject, setDefaultBufferSizeMethodId, width, height); +#endif // defined(OVR_OS_ANDROID) } void SurfaceTexture::Update() { +#if defined(OVR_OS_ANDROID) // latch the latest movie frame to the texture if (!javaObject) { return; @@ -100,6 +111,7 @@ void SurfaceTexture::Update() { jni->CallVoidMethod(javaObject, updateTexImageMethodId); nanoTimeStamp = jni->CallLongMethod(javaObject, getTimestampMethodId); +#endif // defined(OVR_OS_ANDROID) } unsigned int SurfaceTexture::GetTextureId() { diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.h index c6a3c768..e2207186 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/SurfaceTexture.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : SurfaceTexture.h @@ -5,9 +7,8 @@ Content : Interface to Android SurfaceTexture objects Created : September 17, 2013 Authors : John Carmack -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "JniUtils.h" @@ -56,9 +57,11 @@ class SurfaceTexture { // to be processed / mipmapped by other code. long long nanoTimeStamp; +#if defined(OVR_OS_ANDROID) jmethodID updateTexImageMethodId; jmethodID getTimestampMethodId; jmethodID setDefaultBufferSizeMethodId; +#endif // defined(OVR_OS_ANDROID) }; } // namespace OVRFW diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.cpp index 1e93042e..f9c67611 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : TextureAtlas.h @@ -5,8 +7,6 @@ Content : A simple particle system for System Activities. Created : October 23, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "TextureAtlas.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.h index 330bc85e..54889bb7 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureAtlas.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : TextureAtlas.h @@ -5,8 +7,6 @@ Content : A simple particle system for System Activities. Created : October 23, 2015 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.cpp index 597a9c18..64634560 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_TextureManager.cpp @@ -5,8 +7,6 @@ Content : Keeps track of textures so they don't need to be loaded more tha Created : 1/22/2016 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ // Make sure we get PRIu64 diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.h index 806909a6..e0dcc051 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/Render/TextureManager.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : OVR_TextureManager.cpp @@ -5,9 +7,8 @@ Content : Keeps track of textures so they don't need to be loaded more tha Created : 1/22/2016 Authors : Jonathan E. Wright -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ + #pragma once #include "OVR_TypesafeNumber.h" diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.cpp b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.cpp index 70053b02..969a47f8 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : System.cpp @@ -6,8 +8,6 @@ Created : February 21, 2018 Authors : J.M.P. van Waveren, Jonathan Wright Language : C++ -Copyright: Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *******************************************************************************/ #include "System.h" @@ -20,7 +20,11 @@ namespace OVRFW { double GetTimeInSeconds() { struct timespec now; +#if !defined(WIN32) clock_gettime(CLOCK_MONOTONIC, &now); +#else + timespec_get(&now, TIME_UTC); +#endif return (now.tv_sec * 1e9 + now.tv_nsec) * 0.000000001; } diff --git a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.h b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.h index 553677a5..40f7bb8e 100755 --- a/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.h +++ b/thirdparty/oculus_mobile_sdk/SampleCommon/Src/System.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : System.h @@ -6,8 +8,6 @@ Created : February 21, 2018 Authors : J.M.P. van Waveren, Jonathan Wright Language : C++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *******************************************************************************/ #pragma once diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Projects/Android/build.py b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Projects/Android/build.py index 128b62fe..d4b6e589 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Projects/Android/build.py +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Projects/Android/build.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2004-present Facebook. All Rights Reserved. +# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. # This first bit of code is common bootstrapping code # to determine the SDK root, and to set up the import diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.cpp index 7d5b2c3c..e117f2b9 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.cpp @@ -1,10 +1,11 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : HandMaskRenderer.cpp Content : A one stop for rendering hand masks Created : May 2021 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. ************************************************************************************/ @@ -46,6 +47,8 @@ const char* VertexShaderSrc = R"glsl( )glsl"; static const char* FragmentShaderSrc = R"glsl( + precision highp float; + varying highp vec2 oTexCoord; varying highp vec3 oInstanceColor; diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.h b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.h index ef121e33..bae5dc6f 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandMaskRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : HandMaskRenderer.h @@ -5,9 +7,8 @@ Content : A one stop for rendering hand masks Created : 03/24/2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ + #pragma once #include @@ -28,7 +29,7 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #elif defined(WIN32) #include #define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_PLATFORM_WINDOWS 1 +#define XR_USE_PLATFORM_WIN32 1 #endif // defined(ANDROID) #include diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.cpp b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.cpp index e1b834ca..08d95525 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : HandRenderer.cpp @@ -5,8 +7,6 @@ Content : A one stop for rendering hands Created : April 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #include "HandRenderer.h" @@ -67,7 +67,7 @@ const char* VertexShaderSrc = R"glsl( + localPos4 * JointWeights.w; gl_Position = TransformVertex( localPos ); - vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); + highp vec3 eye = transposeMultiply( sm.ViewMatrix[VIEW_ID], -vec3( sm.ViewMatrix[VIEW_ID][3] ) ); oEye = eye - vec3( ModelMatrix * Position ); highp vec3 localNormal1 = multiply(jb.Joints[int(JointIndices.x)], Normal); @@ -85,6 +85,8 @@ const char* VertexShaderSrc = R"glsl( )glsl"; static const char* FragmentShaderSrc = R"glsl( + precision lowp float; + uniform sampler2D Texture0; uniform lowp vec3 SpecularLightDirection; uniform lowp vec3 SpecularLightColor; @@ -147,7 +149,7 @@ static const char* FragmentShaderSrc = R"glsl( + fresnelValue ; gl_FragColor.xyz = controllerColor; - gl_FragColor.w = clamp( fresnel, 0.0, 1.0 ) * Confidence; + gl_FragColor.w = ( clamp( fresnel, 0.0, 0.7 ) + 0.3 ) * Confidence; } )glsl"; /// clang-format on diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.h b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.h index c2546078..92554f74 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.h +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Input/HandRenderer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : HandRenderer.h @@ -5,8 +7,6 @@ Content : A one stop for rendering hands Created : April 2020 Authors : Federico Schliemann -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - ************************************************************************************/ #pragma once @@ -29,7 +29,7 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #elif defined(WIN32) #include #define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_PLATFORM_WINDOWS 1 +#define XR_USE_PLATFORM_WIN32 1 #endif // defined(ANDROID) #include diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.cpp b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.cpp index b44adfb2..b5781c95 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.cpp @@ -42,10 +42,10 @@ bool ovrFramebuffer_Create( const int height, const int multisamples) { PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT = - (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)eglGetProcAddress( + (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)EglGetExtensionProc( "glRenderbufferStorageMultisampleEXT"); PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glFramebufferTexture2DMultisampleEXT = - (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)eglGetProcAddress( + (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)EglGetExtensionProc( "glFramebufferTexture2DMultisampleEXT"); frameBuffer->Width = width; @@ -111,8 +111,13 @@ bool ovrFramebuffer_Create( // Populate the swapchain image array. for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { - frameBuffer->ColorSwapChainImage[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR; - frameBuffer->ColorSwapChainImage[i].next = NULL; +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) + frameBuffer->ColorSwapChainImage[i] = + XrSwapchainImageOpenGLESKHR{XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR}; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + frameBuffer->ColorSwapChainImage[i] = + XrSwapchainImageOpenGLKHR{XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR}; +#endif // } OXR(xrEnumerateSwapchainImages( frameBuffer->ColorSwapChain.Handle, diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.h b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.h index 7c4d1db4..2c284b71 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.h +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/Render/Framebuffer.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /************************************************************************************ Filename : Framebuffer.h @@ -6,16 +8,10 @@ Content : Frame buffer utilities. Originally part of the VrCubeWorld_NativeAct Created : March, 2015 Authors : J.M.P. van Waveren -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. - *************************************************************************************/ #pragma once -#include -#include -#include -#include #include "Render/Egl.h" #if !defined(EGL_OPENGL_ES3_BIT_KHR) @@ -52,15 +48,14 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)( #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 #endif -#include - #if defined(ANDROID) +#include #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 #elif defined(WIN32) #include #define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_PLATFORM_WINDOWS 1 +#define XR_USE_PLATFORM_WIN32 1 #endif // defined(ANDROID) #include diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.cpp b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.cpp index 0fc862d2..2e014d9d 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.cpp +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.cpp @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : XrApp.cpp @@ -5,18 +7,19 @@ Content : OpenXR application base class. Created : July 2020 Authors : Federico Schliemann Language : c++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *******************************************************************************/ #include "XrApp.h" +#if defined(ANDROID) #include #include #include #include #include #include // for prctl( PR_SET_NAME ) +#endif // defined(ANDROID) using OVR::Bounds3f; using OVR::Matrix4f; @@ -28,7 +31,7 @@ using OVR::Vector4f; void OXR_CheckErrors(XrInstance instance, XrResult result, const char* function, bool failOnError) { if (XR_FAILED(result)) { - char errorBuffer[XR_MAX_RESULT_STRING_SIZE]; + char errorBuffer[XR_MAX_RESULT_STRING_SIZE]{}; xrResultToString(instance, result, errorBuffer); if (failOnError) { ALOGE("OpenXR error: %s: %s\n", function, errorBuffer); @@ -69,21 +72,9 @@ inline OVR::Vector2f XrVector2f_To_OVRVector2f(const XrVector2f& src) { return OVR::Vector2f{src.x, src.y}; } -__attribute__((unused)) static void LOG_POSE(const char* msg, const XrPosef* p) { - ALOGV( - "%s: orientation = { %f %f %f %f }, position = { %f %f %f }", - msg, - p->orientation.x, - p->orientation.y, - p->orientation.z, - p->orientation.w, - p->position.x, - p->position.y, - p->position.z); -} - namespace OVRFW { +#if defined(ANDROID) /** * Process the next main command. */ @@ -139,11 +130,14 @@ void XrApp::HandleAndroidCmd(struct android_app* app, int32_t cmd) { } } } +#endif // defined(ANDROID) void XrApp::HandleSessionStateChanges(XrSessionState state) { if (state == XR_SESSION_STATE_READY) { +#if defined(ANDROID) assert(Resumed); assert(NativeWindow != NULL); +#endif // defined(ANDROID) assert(SessionActive == false); XrSessionBeginInfo sessionBeginInfo; @@ -158,6 +152,7 @@ void XrApp::HandleSessionStateChanges(XrSessionState state) { // Set session state once we have entered VR mode and have a valid session object. if (SessionActive) { +#if defined(ANDROID) XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT; switch (CpuLevel) { case 0: @@ -217,9 +212,12 @@ void XrApp::HandleSessionStateChanges(XrSessionState state) { Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, MainThreadTid)); OXR(pfnSetAndroidApplicationThreadKHR( Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, RenderThreadTid)); +#endif // defined(ANDROID) } } else if (state == XR_SESSION_STATE_STOPPING) { +#if defined(ANDROID) assert(Resumed == false); +#endif // defined(ANDROID) assert(SessionActive); OXR(xrEndSession(Session)); @@ -285,6 +283,9 @@ void XrApp::HandleXrEvents() { case XR_SESSION_STATE_STOPPING: HandleSessionStateChanges(session_state_changed_event->state); break; + case XR_SESSION_STATE_EXITING: + ShouldExit = true; + break; default: break; } @@ -425,6 +426,38 @@ std::vector XrApp::GetExtensions() { return extensions; } +std::vector XrApp::GetXrExtensionProperties() const { + XrResult result; + PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; + OXR(result = xrGetInstanceProcAddr( + XR_NULL_HANDLE, + "xrEnumerateInstanceExtensionProperties", + (PFN_xrVoidFunction*)&xrEnumerateInstanceExtensionProperties)); + if (result != XR_SUCCESS) { + ALOGE("Failed to get xrEnumerateInstanceExtensionProperties function pointer."); + exit(1); + } + + uint32_t numInputExtensions = 0; + uint32_t numOutputExtensions = 0; + OXR(xrEnumerateInstanceExtensionProperties( + NULL, numInputExtensions, &numOutputExtensions, NULL)); + ALOGV("xrEnumerateInstanceExtensionProperties found %u extension(s).", numOutputExtensions); + + numInputExtensions = numOutputExtensions; + + std::vector extensionProperties( + numOutputExtensions, {XR_TYPE_EXTENSION_PROPERTIES}); + + OXR(xrEnumerateInstanceExtensionProperties( + NULL, numInputExtensions, &numOutputExtensions, extensionProperties.data())); + for (uint32_t i = 0; i < numOutputExtensions; i++) { + ALOGV("Extension #%d = '%s'.", i, extensionProperties[i].extensionName); + } + + return extensionProperties; +}; + // Returns a map from interaction profile paths to vectors of suggested bindings. // xrSuggestInteractionProfileBindings() is called once for each interaction profile path in the // returned map. @@ -519,6 +552,7 @@ std::unordered_map> XrApp::GetSugg // Called one time when the application process starts. // Returns true if the application initialized successfully. bool XrApp::Init(const xrJava* context) { +#if defined(ANDROID) // Loader PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; xrGetInstanceProcAddr( @@ -532,6 +566,7 @@ bool XrApp::Init(const xrJava* context) { loaderInitializeInfoAndroid.applicationContext = context->ActivityObject; xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); } +#endif // defined(ANDROID) // Log available layers. { @@ -570,51 +605,48 @@ bool XrApp::Init(const xrJava* context) { // Check that the extensions required are present. std::vector extensions = GetExtensions(); - - const char* const* requiredExtensionNames = extensions.data(); - const uint32_t numRequiredExtensions = extensions.size(); + ALOGV("Required extension from app (num=%i): ", extensions.size()); + for (auto extension : extensions) { + ALOGV("\t%s", extension); + } // Check the list of required extensions against what is supported by the runtime. + // And remove from required list if it is not supported. { - XrResult result; - PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; - OXR(result = xrGetInstanceProcAddr( - XR_NULL_HANDLE, - "xrEnumerateInstanceExtensionProperties", - (PFN_xrVoidFunction*)&xrEnumerateInstanceExtensionProperties)); - if (result != XR_SUCCESS) { - ALOGE("Failed to get xrEnumerateInstanceExtensionProperties function pointer."); - exit(1); - } - - uint32_t numInputExtensions = 0; - uint32_t numOutputExtensions = 0; - OXR(xrEnumerateInstanceExtensionProperties( - NULL, numInputExtensions, &numOutputExtensions, NULL)); - ALOGV("xrEnumerateInstanceExtensionProperties found %u extension(s).", numOutputExtensions); - - numInputExtensions = numOutputExtensions; - - std::vector extensionProperties( - numOutputExtensions, {XR_TYPE_EXTENSION_PROPERTIES}); - - OXR(xrEnumerateInstanceExtensionProperties( - NULL, numInputExtensions, &numOutputExtensions, extensionProperties.data())); - for (uint32_t i = 0; i < numOutputExtensions; i++) { - ALOGV("Extension #%d = '%s'.", i, extensionProperties[i].extensionName); - } + const auto extensionProperties = GetXrExtensionProperties(); + std::vector removedExtensions; + + extensions.erase( + std::remove_if( + extensions.begin(), + extensions.end(), + [&extensionProperties, &removedExtensions](const char* requiredExtensionName) { + bool found = false; + for (auto extensionProperty : extensionProperties) { + if (!strcmp(requiredExtensionName, extensionProperty.extensionName)) { + ALOGV("Found required extension %s", requiredExtensionName); + found = true; + break; + } + } - for (uint32_t i = 0; i < numRequiredExtensions; i++) { - bool found = false; - for (uint32_t j = 0; j < numOutputExtensions; j++) { - if (!strcmp(requiredExtensionNames[i], extensionProperties[j].extensionName)) { - ALOGV("Found required extension %s", requiredExtensionNames[i]); - found = true; - break; - } - } - if (!found) { - ALOGW("WARNING - Failed to find required extension %s", requiredExtensionNames[i]); + if (!found) { + ALOGW( + "WARNING - Failed to find required extension %s", + requiredExtensionName); + removedExtensions.push_back(requiredExtensionName); + return true; + } + return false; + }), + extensions.end()); + + if (!removedExtensions.empty()) { + ALOGW( + "Following required extensions from app were excluded based on their existence (num=%i): ", + removedExtensions.size()); + for (auto extension : removedExtensions) { + ALOGW("\t%s", extension.c_str()); } } } @@ -636,8 +668,8 @@ bool XrApp::Init(const xrJava* context) { instanceCreateInfo.applicationInfo = appInfo; instanceCreateInfo.enabledApiLayerCount = 0; instanceCreateInfo.enabledApiLayerNames = NULL; - instanceCreateInfo.enabledExtensionCount = numRequiredExtensions; - instanceCreateInfo.enabledExtensionNames = requiredExtensionNames; + instanceCreateInfo.enabledExtensionCount = extensions.size(); + instanceCreateInfo.enabledExtensionNames = extensions.data(); XrResult initResult; OXR(initResult = xrCreateInstance(&instanceCreateInfo, &Instance)); @@ -732,7 +764,11 @@ bool XrApp::Init(const xrJava* context) { CpuLevel = CPU_LEVEL; GpuLevel = GPU_LEVEL; +#if defined(ANDROID) MainThreadTid = gettid(); +#else + MainThreadTid = 0; +#endif // defined(ANDROID) SystemId = systemId; // Actions @@ -743,25 +779,18 @@ bool XrApp::Init(const xrJava* context) { XrPath handSubactionPaths[2] = {LeftHandPath, RightHandPath}; AimPoseAction = CreateAction( - BaseActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, &handSubactionPaths[0]); + BaseActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, handSubactionPaths); GripPoseAction = CreateAction( - BaseActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, &handSubactionPaths[0]); + BaseActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, handSubactionPaths); + JoystickAction = CreateAction( - BaseActionSet, - XR_ACTION_TYPE_VECTOR2F_INPUT, - "move_on_joy", - NULL, - 2, - &handSubactionPaths[0]); + BaseActionSet, XR_ACTION_TYPE_VECTOR2F_INPUT, "move_on_joy", NULL, 2, handSubactionPaths); + IndexTriggerAction = CreateAction( - BaseActionSet, - XR_ACTION_TYPE_FLOAT_INPUT, - "index_trigger", - NULL, - 2, - &handSubactionPaths[0]); + BaseActionSet, XR_ACTION_TYPE_FLOAT_INPUT, "index_trigger", NULL, 2, handSubactionPaths); + GripTriggerAction = CreateAction( - BaseActionSet, XR_ACTION_TYPE_FLOAT_INPUT, "grip_trigger", NULL, 2, &handSubactionPaths[0]); + BaseActionSet, XR_ACTION_TYPE_FLOAT_INPUT, "grip_trigger", NULL, 2, handSubactionPaths); ButtonAAction = CreateAction(BaseActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "button_a", NULL); ButtonBAction = CreateAction(BaseActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "button_b", NULL); ButtonXAction = CreateAction(BaseActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "button_x", NULL); @@ -936,6 +965,10 @@ bool XrApp::InitSession() { OXR(xrGetViewConfigurationProperties( Instance, SystemId, supportedViewConfigType, &ViewportConfig)); + for (int eye = 0; eye < MAX_NUM_EYES; eye++) { + Projections[eye] = XrView{XR_TYPE_VIEW}; + } + bool stageSupported = false; uint32_t numOutputSpaces = 0; OXR(xrEnumerateReferenceSpaces(Session, 0, &numOutputSpaces, NULL)); @@ -960,6 +993,12 @@ bool XrApp::InitSession() { spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL; OXR(xrCreateReferenceSpace(Session, &spaceCreateInfo, &LocalSpace)); + // xrCreateActionSpace requires Session, create them here. + LeftControllerAimSpace = CreateActionSpace(AimPoseAction, LeftHandPath); + RightControllerAimSpace = CreateActionSpace(AimPoseAction, RightHandPath); + LeftControllerGripSpace = CreateActionSpace(GripPoseAction, LeftHandPath); + RightControllerGripSpace = CreateActionSpace(GripPoseAction, RightHandPath); + // to use as fake stage if (stageSupported) { spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE; @@ -969,8 +1008,6 @@ bool XrApp::InitSession() { CurrentSpace = StageSpace; } - EglInitExtensions(); - // Create the frame buffers. for (int eye = 0; eye < MAX_NUM_EYES; eye++) { ovrFramebuffer_Create( @@ -982,13 +1019,12 @@ bool XrApp::InitSession() { NUM_MULTI_SAMPLES); } - // Attach to session - AttachActionSets(); - - LeftControllerAimSpace = XR_NULL_HANDLE; - LeftControllerGripSpace = XR_NULL_HANDLE; - RightControllerAimSpace = XR_NULL_HANDLE; - RightControllerGripSpace = XR_NULL_HANDLE; + // xrAttachSessionActionSets can only be called once, so skip it if the application + // is doing it manually + if (!SkipSyncActions) { + // Attach to session + AttachActionSets(); + } return SessionInit(); } @@ -997,7 +1033,6 @@ void XrApp::EndSession() { for (int eye = 0; eye < MAX_NUM_EYES; eye++) { ovrFramebuffer_Destroy(&FrameBuffer[eye]); } - ovrEgl_DestroyContext(&Egl); OXR(xrDestroySpace(HeadSpace)); OXR(xrDestroySpace(LocalSpace)); @@ -1006,8 +1041,10 @@ void XrApp::EndSession() { OXR(xrDestroySpace(StageSpace)); } CurrentSpace = XR_NULL_HANDLE; - OXR(xrDestroySession(Session)); SessionEnd(); + OXR(xrDestroySession(Session)); + + ovrEgl_DestroyContext(&Egl); } // Called one time when the applicatoin process exits @@ -1025,23 +1062,16 @@ void XrApp::AttachActionSets() { OXR(xrAttachSessionActionSets(Session, &attachInfo)); } -void XrApp::SyncActionSets(ovrApplFrameIn& in, XrFrameState& frameState) { +void XrApp::SyncActionSets(ovrApplFrameIn& in) { // sync action data - XrActiveActionSet activeActionSet = {}; - activeActionSet.actionSet = BaseActionSet; - activeActionSet.subactionPath = XR_NULL_PATH; - - XrActionsSyncInfo syncInfo = {}; - syncInfo.type = XR_TYPE_ACTIONS_SYNC_INFO; - syncInfo.next = NULL; + XrActiveActionSet activeActionSet{BaseActionSet}; + XrActionsSyncInfo syncInfo{XR_TYPE_ACTIONS_SYNC_INFO}; syncInfo.countActiveActionSets = 1; syncInfo.activeActionSets = &activeActionSet; OXR(xrSyncActions(Session, &syncInfo)); // query input action states - XrActionStateGetInfo getInfo = {}; - getInfo.type = XR_TYPE_ACTION_STATE_GET_INFO; - getInfo.next = NULL; + XrActionStateGetInfo getInfo = {XR_TYPE_ACTION_STATE_GET_INFO}; getInfo.subactionPath = XR_NULL_PATH; XrAction controller[] = {AimPoseAction, GripPoseAction, AimPoseAction, GripPoseAction}; @@ -1057,7 +1087,7 @@ void XrApp::SyncActionSets(ovrApplFrameIn& in, XrFrameState& frameState) { XrPosef_Identity(), XrPosef_Identity(), XrPosef_Identity(), XrPosef_Identity()}; for (int i = 0; i < 4; i++) { if (ActionPoseIsActive(controller[i], subactionPath[i])) { - LocVel lv = GetSpaceLocVel(controllerSpace[i], frameState.predictedDisplayTime); + LocVel lv = GetSpaceLocVel(controllerSpace[i], ToXrTime(in.PredictedDisplayTime)); ControllerPoseActive[i] = (lv.loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0; ControllerPose[i] = lv.loc.pose; @@ -1078,12 +1108,10 @@ void XrApp::SyncActionSets(ovrApplFrameIn& in, XrFrameState& frameState) { ALOG( "Current interaction profile is: '%s'", ipPath); #endif - /// accounting - in.PredictedDisplayTime = FromXrTime(frameState.predictedDisplayTime); /// Update pose XrSpaceLocation loc = {}; loc.type = XR_TYPE_SPACE_LOCATION; - OXR(xrLocateSpace(HeadSpace, CurrentSpace, frameState.predictedDisplayTime, &loc)); + OXR(xrLocateSpace(HeadSpace, CurrentSpace, ToXrTime(in.PredictedDisplayTime), &loc)); in.HeadPose = XrPosef_To_OVRPosef(loc.pose); /// grip & point space in.LeftRemotePointPose = XrPosef_To_OVRPosef(ControllerPose[0]); @@ -1172,10 +1200,13 @@ void XrApp::SyncActionSets(ovrApplFrameIn& in, XrFrameState& frameState) { */ } -void XrApp::HandleInput(ovrApplFrameIn& in, XrFrameState& frameState) { - // Sync default actions - SyncActionSets(in, frameState); - // Call extension +void XrApp::HandleInput(ovrApplFrameIn& in) { + if (!SkipSyncActions) { + // Sync default actions + SyncActionSets(in); + } + + // Call application Update function Update(in); } @@ -1265,6 +1296,7 @@ void XrApp::Update(const ovrApplFrameIn& in) {} void XrApp::Render(const ovrApplFrameIn& in, ovrRendererOutput& out) {} // App entry point +#if defined(ANDROID) void XrApp::Run(struct android_app* app) { ALOGV("----------------------------------------------------------------"); ALOGV("android_app_entry()"); @@ -1282,19 +1314,32 @@ void XrApp::Run(struct android_app* app) { Context.Vm = app->activity->vm; Context.Env = Env; Context.ActivityObject = app->activity->clazz; +#else +void XrApp::Run() { + Context.Vm = nullptr; + Context.Env = nullptr; + Context.ActivityObject = nullptr; +#endif // defined(ANDROID) Init(&Context); InitSession(); +#if defined(ANDROID) app->userData = this; app->onAppCmd = app_handle_cmd; +#endif // defined(ANDROID) bool stageBoundsDirty = true; int frameCount = -1; +#if defined(ANDROID) while (app->destroyRequested == 0) { +#else + while (true) { +#endif // defined(ANDROID) frameCount++; +#if defined(ANDROID) // Read all pending events. for (;;) { int events; @@ -1312,24 +1357,26 @@ void XrApp::Run(struct android_app* app) { source->process(app, source); } } +#elif defined(WIN32) + MSG msg; + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) { + if (msg.message == WM_QUIT) { + ShouldExit = true; + } else { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } +#endif // defined(ANDROID) HandleXrEvents(); - if (SessionActive == false) { - continue; + if (ShouldExit) { + break; } - if (LeftControllerAimSpace == XR_NULL_HANDLE) { - LeftControllerAimSpace = CreateActionSpace(AimPoseAction, LeftHandPath); - } - if (RightControllerAimSpace == XR_NULL_HANDLE) { - RightControllerAimSpace = CreateActionSpace(AimPoseAction, RightHandPath); - } - if (LeftControllerGripSpace == XR_NULL_HANDLE) { - LeftControllerGripSpace = CreateActionSpace(GripPoseAction, LeftHandPath); - } - if (RightControllerGripSpace == XR_NULL_HANDLE) { - RightControllerGripSpace = CreateActionSpace(GripPoseAction, RightHandPath); + if (SessionActive == false) { + continue; } if (stageBoundsDirty) { @@ -1390,6 +1437,13 @@ void XrApp::Run(struct android_app* app) { OVRFW::ovrRendererOutput out = {}; in.FrameIndex = frameCount; + /// time accounting + in.PredictedDisplayTime = FromXrTime(frameState.predictedDisplayTime); + if (PrevDisplayTime > 0) { + in.DeltaSeconds = FromXrTime(frameState.predictedDisplayTime - PrevDisplayTime); + } + PrevDisplayTime = frameState.predictedDisplayTime; + XrPosef viewTransform[2]; for (int eye = 0; eye < MAX_NUM_EYES; eye++) { XrPosef xfHeadFromEye = Projections[eye].pose; @@ -1410,7 +1464,7 @@ void XrApp::Run(struct android_app* app) { out.FrameMatrices.CenterView = XrMatrix4x4f_To_OVRMatrix4f(viewMat); // Input - HandleInput(in, frameState); + HandleInput(in); // Set-up the compositor layers for this frame. // NOTE: Multiple independent layers are allowed, but they need to be added @@ -1477,7 +1531,9 @@ void XrApp::Run(struct android_app* app) { EndSession(); Shutdown(&Context); +#if defined(ANDROID) (*app->activity->vm).DetachCurrentThread(); +#endif // defined(ANDROID) } } // namespace OVRFW diff --git a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.h b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.h index a9a34145..08749f47 100755 --- a/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.h +++ b/thirdparty/oculus_mobile_sdk/SampleXrFramework/Src/XrApp.h @@ -1,3 +1,5 @@ +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + /******************************************************************************* Filename : XrApp.h @@ -5,7 +7,6 @@ Content : OpenXR application base class. Created : July 2020 Authors : Federico Schliemann Language : c++ -Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. *******************************************************************************/ @@ -23,6 +24,7 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include "FrameParams.h" #include "OVR_FileSys.h" +#if defined(ANDROID) #include #include #include @@ -36,6 +38,9 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #if !defined(EGL_OPENGL_ES3_BIT_KHR) #define EGL_OPENGL_ES3_BIT_KHR 0x0040 #endif +#elif defined(WIN32) +#include "windows.h" +#endif // defined(ANDROID) // EXT_texture_border_clamp #ifndef GL_CLAMP_TO_BORDER @@ -73,7 +78,7 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)( #elif defined(WIN32) #include #define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_PLATFORM_WINDOWS 1 +#define XR_USE_PLATFORM_WIN32 1 #endif // defined(ANDROID) #include @@ -88,7 +93,7 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)( void OXR_CheckErrors(XrInstance instance, XrResult result, const char* function, bool failOnError); -#if defined(DEBUG) +#if defined(DEBUG) || defined(_DEBUG) #define OXR(func) OXR_CheckErrors(Instance, func, #func, true); #else #define OXR(func) OXR_CheckErrors(Instance, func, #func, false); @@ -208,7 +213,11 @@ class XrApp { virtual ~XrApp() = default; // App entry point +#if defined(ANDROID) void Run(struct android_app* app); +#else + void Run(); +#endif // defined(ANDROID) //============================ // public context interface @@ -233,15 +242,11 @@ class XrApp { RunWhilePaused = b; } +#if defined(ANDROID) void HandleAndroidCmd(struct android_app* app, int32_t cmd); +#endif // defined(ANDROID) protected: - uint64_t GetFrameIndex() const { - return FrameIndex; - } - double GetDisplayTime() const { - return DisplayTime; - } int GetNumFramebuffers() const { return NumFramebuffers; } @@ -249,6 +254,8 @@ class XrApp { return &FrameBuffer[eye]; } + std::vector GetXrExtensionProperties() const; + //============================ // App functions // All App* function can be overridden by the derived application class to @@ -357,7 +364,7 @@ class XrApp { /// XR Input state overrides virtual void AttachActionSets(); - virtual void SyncActionSets(ovrApplFrameIn& in, XrFrameState& frameState); + virtual void SyncActionSets(ovrApplFrameIn& in); // Called to deal with lifetime void HandleSessionStateChanges(XrSessionState state); @@ -384,7 +391,7 @@ class XrApp { virtual void HandleXrEvents(); // Internal Input - void HandleInput(ovrApplFrameIn& in, XrFrameState& frameState); + void HandleInput(ovrApplFrameIn& in); // Internal Render void RenderFrame(const ovrApplFrameIn& in, ovrRendererOutput& out); @@ -397,29 +404,41 @@ class XrApp { xrJava Context; ovrLifecycle Lifecycle = LIFECYCLE_UNKNOWN; ovrEgl Egl = { +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) 0, 0, EGL_NO_DISPLAY, EGL_CAST(EGLConfig, 0), EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT}; + EGL_NO_CONTEXT +#endif // defined(XR_USE_GRAPHICS_API_OPENGL_ES) + }; +#if defined(ANDROID) ANativeWindow* NativeWindow; - bool Resumed; - bool Focused; + bool Resumed = false; +#endif // defined(ANDROID) + bool ShouldExit = false; + bool Focused = false; - XrInstance Instance; - XrSession Session; + // When set the framework will skip calling + // SyncActionSets(), this is useful if an app + // wants control over xrSyncAction + // Note: This means input in ovrApplFrameIn won't be set + bool SkipSyncActions = false; + + XrInstance Instance = XR_NULL_HANDLE; + XrSession Session = XR_NULL_HANDLE; XrViewConfigurationProperties ViewportConfig; XrViewConfigurationView ViewConfigurationView[MAX_NUM_EYES]; XrView Projections[MAX_NUM_EYES]; - XrSystemId SystemId; - XrSpace HeadSpace; - XrSpace LocalSpace; - XrSpace StageSpace; - XrSpace CurrentSpace; - bool SessionActive; + XrSystemId SystemId = XR_NULL_SYSTEM_ID; + XrSpace HeadSpace = XR_NULL_HANDLE; + XrSpace LocalSpace = XR_NULL_HANDLE; + XrSpace StageSpace = XR_NULL_HANDLE; + XrSpace CurrentSpace = XR_NULL_HANDLE; + bool SessionActive = false; XrActionSet BaseActionSet = XR_NULL_HANDLE; XrPath LeftHandPath = XR_NULL_PATH; @@ -453,8 +472,7 @@ class XrApp { std::unique_ptr SceneModel; private: - uint64_t FrameIndex = 0; - double DisplayTime = 0.0; + XrTime PrevDisplayTime = 0.0; int SwapInterval; int CpuLevel = CPU_LEVEL; int GpuLevel = GPU_LEVEL; @@ -481,12 +499,23 @@ class XrApp { appl->Run(app); \ } +#elif defined(WIN32) + +#define ENTRY_POINT(appClass) \ + __pragma(comment(linker, "/SUBSYSTEM:WINDOWS")); \ + int APIENTRY WinMain(HINSTANCE, HINSTANCE, PSTR, int) { \ + auto appl = std::make_unique(); \ + appl->Run(); \ + return 0; \ + } + #else #define ENTRY_POINT(appClass) \ - int main(int argv, const char** argc) { \ + int main(int, const char**) { \ auto appl = std::make_unique(); \ - appl->Run(argv, argc); \ + appl->Run(); \ + return 0; \ } #endif // defined(ANDROID) diff --git a/thirdparty/oculus_mobile_sdk/VrApp.gradle b/thirdparty/oculus_mobile_sdk/VrApp.gradle index 7a239c85..8a49a454 100755 --- a/thirdparty/oculus_mobile_sdk/VrApp.gradle +++ b/thirdparty/oculus_mobile_sdk/VrApp.gradle @@ -280,6 +280,13 @@ project.task('genDebugKeystore', type: GenDebugKeystore ) { description 'generate debug keystore' } +// Workaround to fix issue in Android Studio Chipmunk 2021.2.1 and later +// where opening a project would result in a 'prepareKotlinBuildScriptModel' +// not found error +if (!tasks.findByName("prepareKotlinBuildScriptModel")) { + tasks.register("prepareKotlinBuildScriptModel") {} +} + // ************************************************************** // Task interceptor to add dependant tasks diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/AndroidManifest.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/AndroidManifest.xml new file mode 100644 index 00000000..f0fb84e3 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.bat b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.bat new file mode 100644 index 00000000..facf79f2 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.bat @@ -0,0 +1,29 @@ +@rem Only edit the master copy of this file in SDK_ROOT/bin/scripts/build/perproject + +@setlocal enableextensions enabledelayedexpansion + +@if not exist "build.gradle" @echo Build script must be executed from project directory. & goto :Abort + +@set P=.. + +:TryAgain + +@rem @echo P = %P% + +@if exist "%P%\bin\scripts\build\build.py.bat" goto :Found + +@if exist "%P%\bin\scripts\build" @echo "Could not find build.py.bat" & goto :Abort + +@set P=%P%\.. + +@goto :TryAgain + +:Found + +@set P=%P%\bin\scripts\build +@call %P%\build.py.bat %1 %2 %3 %4 %5 +@goto :End + +:Abort + +:End diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.gradle b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.gradle new file mode 100644 index 00000000..ce874c18 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.gradle @@ -0,0 +1,52 @@ + +apply plugin: 'com.android.application' +apply from: "${rootProject.projectDir}/VrApp.gradle" + + + +android { + // This is the name of the generated apk file, which will have + // -debug.apk or -release.apk appended to it. + // The filename doesn't effect the Android installation process. + // Use only letters to remain compatible with the package name. + project.archivesBaseName = "xrcolorspacefb" + + dependencies { + implementation 'com.android.support:appcompat-v7:26.0.0' + } + + + defaultConfig { + // Gradle replaces the manifest package with this value, which must + // be unique on a system. If you don't change it, a new app + // will replace an older one. + applicationId "com.oculus.sdk." + project.archivesBaseName + minSdkVersion 24 + targetSdkVersion 25 + compileSdkVersion 26 + + // override app plugin abiFilters for 64-bit support + externalNativeBuild { + ndk { + abiFilters 'arm64-v8a' + } + ndkBuild { + abiFilters 'arm64-v8a' + } + } + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['../../java'] + jniLibs.srcDir 'libs' + assets.srcDirs = ['../../assets'] + res.srcDirs = ['../../res'] + } + } + + lintOptions { + disable 'ExpiredTargetSdkVersion' + } +} diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.py b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.py new file mode 100644 index 00000000..128b62fe --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/build.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# Copyright 2004-present Facebook. All Rights Reserved. + +# This first bit of code is common bootstrapping code +# to determine the SDK root, and to set up the import +# path for additional python code. + +# begin bootstrap +import os +import sys + + +def init(): + root = os.path.realpath(os.path.dirname(os.path.realpath(__file__))) + os.chdir(root) # make sure we are always executing from the project directory + while os.path.isdir(os.path.join(root, "bin/scripts/build")) == False: + root = os.path.realpath(os.path.join(root, "..")) + if ( + len(root) <= 5 + ): # Should catch both Posix and Windows root directories (e.g. '/' and 'C:\') + print("Unable to find SDK root. Exiting.") + sys.exit(1) + root = os.path.abspath(root) + os.environ["OCULUS_SDK_PATH"] = root + sys.path.append(root + "/bin/scripts/build") + + +init() +import ovrbuild + +ovrbuild.init() +# end bootstrap + + +ovrbuild.build() diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Android.mk b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Android.mk new file mode 100644 index 00000000..4621fee6 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Android.mk @@ -0,0 +1,26 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := xrsamples_xrcolorspacefb + +include ../../../../cflags.mk + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../../../../../SampleCommon/Src \ + $(LOCAL_PATH)/../../../../../SampleXrFramework/Src \ + $(LOCAL_PATH)/../../../../../1stParty/OVR/Include \ + $(LOCAL_PATH)/../../../../../1stParty/utilities/include \ + $(LOCAL_PATH)/../../../../../3rdParty/stb/src \ + $(LOCAL_PATH)/../../../../../3rdParty/khronos/openxr/OpenXR-SDK/include \ + +LOCAL_SRC_FILES := ../../../Src/main.cpp \ + +# include default libraries +LOCAL_LDLIBS := -llog -landroid -lGLESv3 -lEGL +LOCAL_STATIC_LIBRARIES := samplexrframework +LOCAL_SHARED_LIBRARIES := openxr_loader + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,SampleXrFramework/Projects/Android/jni) +$(call import-module,OpenXR/Projects/AndroidPrebuilt/jni) diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Application.mk b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Application.mk new file mode 100644 index 00000000..130b9663 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/jni/Application.mk @@ -0,0 +1,10 @@ +# MAKEFILE_LIST specifies the current used Makefiles, of which this is the last +# one. I use that to obtain the Application.mk dir then import the root +# Application.mk. +ROOT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))../../../../.. + +NDK_MODULE_PATH := $(ROOT_DIR) + +# ndk-r14 introduced failure for missing dependencies. If 'false', the clean +# step will error as we currently remove prebuilt artifacts on clean. +APP_ALLOW_MISSING_DEPS=true diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/settings.gradle b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/settings.gradle new file mode 100644 index 00000000..b2dcfdff --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Projects/Android/settings.gradle @@ -0,0 +1,5 @@ +rootProject.projectDir = new File(settingsDir, '../../../..') +rootProject.name = "XrColorSpaceFB" + +include ':', \ + ':XrSamples:XrColorSpaceFB:Projects:Android' diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/main.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/main.cpp new file mode 100644 index 00000000..c06b92cb --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/main.cpp @@ -0,0 +1,351 @@ +/******************************************************************************* + +Filename : Main.cpp +Content : Simple test app for XrColorSpaceFB +Created : +Authors : Andreas Selvik +Language : C++ +Copyright: Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + +*******************************************************************************/ + +#include +#include +#include + +#include + +#include "GUI/VRMenuObject.h" +#include "Render/BitmapFont.h" +#include "Render/GeometryBuilder.h" +#include "openxr_reflection_macro.h" +#include "XrApp.h" + +#include "OVR_Math.h" +#include "Input/ControllerRenderer.h" +#include "Input/TinyUI.h" +#include "Render/GeometryRenderer.h" +#include "Render/SimpleBeamRenderer.h" + +class XrAppBaseApp : public OVRFW::XrApp { + public: + static constexpr std::string_view sampleExplanation = + "XR devices may display RGB color triplets differently from many \n" + "monitors used in development, that is, they may use a different \n" + "color space than what is common for computer monitors. \n" + "\n" + "XrColorSpaceFB is an extension that allow a developer to specify \n" + "the color space in which they have authored their application so \n" + "the correct colors are shown when the application is running on \n" + "the XR device. \n" + "\n" + "For the majority of developers, the recommendation for Meta Quest \n" + "devices is to author your content in sRGB (XR_COLOR_SPACE_REC_709)\n" + "and leave the color space conversion to the default value (which \n" + "is \"XR_COLOR_SPACE_RIFT_CV1_FB\" on Meta Quest 2). \n" + "For more details and recommendations for color management, see: \n" + "https://developer.oculus.com/resources/color-management-guide/ \n"; + + XrAppBaseApp() : OVRFW::XrApp() { + BackgroundColor = OVR::Vector4f(0.55f, 0.35f, 0.1f, 1.0f); + } + + // Returns a list of OpenXR extensions needed for this app + virtual std::vector GetExtensions() override { + std::vector extensions = XrApp::GetExtensions(); + + // Add "XR_FB_color_space" to the list of extensions + // The sample framework will add this to enabledExtensionNames + // when calling xrCreateInstance() + extensions.push_back(XR_FB_COLOR_SPACE_EXTENSION_NAME); + return extensions; + } + + // Before this function, OVRFW::XrApp::Init() calls, among other things; + // - xrInitializeLoaderKHR(...) + // - xrCreateInstance with the extensions from GetExtensions(...), + // - xrSuggestInteractionProfileBindings(...) to set up action bindings + // Before calling this function: + virtual bool AppInit(const xrJava* context) override { + // Init UI system + if (false == ui_.Init(context, GetFileSys())) { + ALOG("TinyUI::Init FAILED."); + return false; + } + + // Bind extension functions so we can call them + OXR(xrGetInstanceProcAddr( + GetInstance(), + "xrEnumerateColorSpacesFB", + reinterpret_cast(&xrEnumerateColorSpacesFB))); + OXR(xrGetInstanceProcAddr( + GetInstance(), + "xrSetColorSpaceFB", + reinterpret_cast(&xrSetColorSpaceFB))); + + return true; + } + + // Before this function, and after AppInit, XrApp::InitSession() calls: + // - xrCreateSession(...) to create our Session + // - xrCreateReferenceSpace(...) for local and stage space + // - Create swapchain with xrCreateSwapchain(...) + // - xrAttachSessionActionSets(...) + // Before calling this function: + virtual bool SessionInit() override { + { + // Get native HMD color space by chaining XrSystemColorSpacePropertiesFB + // to the next pointer of XrSystemProperties + XrSystemColorSpacePropertiesFB colorSpaceProps{ + XR_TYPE_SYSTEM_COLOR_SPACE_PROPERTIES_FB}; + XrSystemProperties sysprops{XR_TYPE_SYSTEM_PROPERTIES}; + sysprops.next = &colorSpaceProps; + OXR(xrGetSystemProperties(GetInstance(), GetSystemId(), &sysprops)); + + // The sample just displays the native HMD color space, + // but an app could use this to load different assets + // and to inform which colorspace it wants to select. + std::string str = + "Native HMD color space: " + std::string(XrEnumStr(colorSpaceProps.colorSpace)); + ui_.AddLabel(str, {-1.0f, 2.4f, -2.0f}, {700.0f, 45.0f}); + } + + // The default source color space is not something that's + // provided by XrColorSpaceFB OpenXR extension, so just initialize + // the label to say [default] + declaredLabel_ = ui_.AddLabel( + "App declared color space: [default]", {-1.0f, 2.3f, -2.0f}, {700.0f, 45.0f}); + + { // Enumerate supported source color spaces with xrEnumerateColorSpaceFB + + // xrEnumerateColorSpacesFB uses the two-call idiom + // First call with nullptr to get the required size: + uint32_t colorSpaceCount{0}; + OXR(xrEnumerateColorSpacesFB(GetSession(), 0, &colorSpaceCount, nullptr)); + + // Allocate array with enough space for the data + auto colorSpaces = std::vector(colorSpaceCount); + + // Second call gets the actual data + OXR(xrEnumerateColorSpacesFB( + GetSession(), (uint32_t)colorSpaces.size(), &colorSpaceCount, colorSpaces.data())); + + // Header + ui_.AddLabel("Compatible color spaces:", {-1.0f, 2.15f, -2.0f}, {700.0f, 45.0f}); + + // Create one button for each supported color space conversion + float posY = 2.0f; + for (auto colorSpace : colorSpaces) { + ui_.AddButton(XrEnumStr(colorSpace), {-1.0f, posY, -2.0f}, {600.0f, 60.0f}, [=]() { + // Set source color space with xrSetColorSpaceFB when button is pressed + // Remember that this is the source colorspace and no the target colorspace + OXR(xrSetColorSpaceFB(GetSession(), colorSpace)); + + declaredColorSpace_ = colorSpace; // For display in the UI + }); + posY -= 0.15f; + } + } + + // Create the rest of the UI + CreateColorCheckerCubes(); + CreateSampleDescriptionPanel(); + + /// Disable scene navitgation + GetScene().SetFootPos({0.0f, 0.0f, 0.0f}); + this->FreeMove = false; + + // Init objects that need OpenXR Session + if (false == controllerRenderL_.Init(true)) { + ALOG("SessionInit::Init L controller renderer FAILED."); + return false; + } + if (false == controllerRenderR_.Init(false)) { + ALOG("SessionInit::Init R controller renderer FAILED."); + return false; + } + cursorBeamRenderer_.Init(GetFileSys(), nullptr, OVR::Vector4f(1.0f), 1.0f); + + return true; + } + + // Called every frame + virtual void Update(const OVRFW::ovrApplFrameIn& in) override { + // Update the UI with the latest declared color space + if (declaredColorSpace_ != XR_COLOR_SPACE_MAX_ENUM_FB) { + std::string label = "App declared color space: "; + label += XrEnumStr(declaredColorSpace_); + declaredLabel_->SetText(label.c_str()); + } + + colorCheckerRenderer_.Update(); + + // Clear the intersection rays from last frame: + ui_.HitTestDevices().clear(); + + if (in.LeftRemoteTracked) { + controllerRenderL_.Update(in.LeftRemotePose); + const bool didTrigger = in.LeftRemoteIndexTrigger > 0.5f; + ui_.AddHitTestRay(in.LeftRemotePointPose, didTrigger); + } + + if (in.RightRemoteTracked) { + controllerRenderR_.Update(in.RightRemotePose); + const bool didTrigger = in.RightRemoteIndexTrigger > 0.5f; + ui_.AddHitTestRay(in.RightRemotePointPose, didTrigger); + } + + ui_.Update(in); + cursorBeamRenderer_.Update(in, ui_.HitTestDevices()); + } + + virtual void Render(const OVRFW::ovrApplFrameIn& in, OVRFW::ovrRendererOutput& out) override { + colorCheckerRenderer_.Render(out.Surfaces); + + ui_.Render(in, out); + + if (in.LeftRemoteTracked) { + controllerRenderL_.Render(out.Surfaces); + } + if (in.RightRemoteTracked) { + controllerRenderR_.Render(out.Surfaces); + } + + /// Render beams last, since they render with transparency + cursorBeamRenderer_.Render(in, out); + } + + virtual void SessionEnd() override { + controllerRenderL_.Shutdown(); + controllerRenderR_.Shutdown(); + cursorBeamRenderer_.Shutdown(); + colorCheckerRenderer_.Shutdown(); + } + + virtual void AppShutdown(const xrJava* context) override { + OVRFW::XrApp::AppShutdown(context); + ui_.Shutdown(); + } + + void CreateColorCheckerCubes() { + // From https://en.wikipedia.org/wiki/ColorChecker + // These values are authored for the sRGB (Rec. 709) color space + std::vector Rec709ColorChecker = { + // clang-format off + "#735244", "#c29682", "#627a9d", "#576c43", "#8580b1", "#67bdaa", + "#d67e2c", "#505ba6", "#c15a63", "#5e3c6c", "#9dbc40", "#e0a32e", + "#383d96", "#469449", "#af363c", "#e7c71f", "#bb5695", "#0885a1", + "#f3f3f2", "#c8c8c8", "#a0a0a0", "#7a7a7a", "#555555", "#343434" + // clang-format on + }; + + auto linearRgbaFromGammaHex = [](std::string_view hex) { + float r = std::stoul(std::string(hex.substr(1, 2)), nullptr, 16) / 256.0f; + float g = std::stoul(std::string(hex.substr(3, 2)), nullptr, 16) / 256.0f; + float b = std::stoul(std::string(hex.substr(5, 2)), nullptr, 16) / 256.0f; + + // Convert colors from gamma 2.2 into linear space for direct shader usage + // Note: If you were to use a texture with these RGB values, and you configure + // the texture as an sRGB texture, this conversion would happen in the GPU + // as your shader reads the texels. But since we are providing the values + // directly into the fragment shader, we need to do this manually. + // Try removing this part and see what happens to the colors :) + r = powf(r, 2.2); + g = powf(g, 2.2); + b = powf(b, 2.2); + + return OVR::Vector4f{r, g, b, 1.0f}; + }; + + OVR::Vector3f chartPose = {0.5, 1.5f, -2.0f}; + ui_.AddLabel( + "Color checker authored for sRGB (XR_COLOR_SPACE_REC_709_FB):", + {chartPose.x, chartPose.y + 0.65f, chartPose.z}, + {750.0f, 45.0f}); + + OVRFW::GeometryBuilder colorCheckerCubes; + + constexpr float tileSize = 0.2f; + constexpr float tileGap = 0.04f; + constexpr float chartSizeX = 6 * tileSize + 5 * tileGap; + constexpr float chartSizeY = 4 * tileSize + 3 * tileGap; + constexpr float chartBorder = 0.1f; + + auto transform = OVR::Matrix4f::Translation(chartPose) * + OVR::Matrix4f::Scaling( + chartSizeX + 2 * chartBorder, chartSizeY + 2 * chartBorder, 0.01); + colorCheckerCubes.Add( + OVRFW::BuildUnitCubeDescriptor(), + OVRFW::GeometryBuilder::kInvalidIndex, + {0.0f, 0.0f, 0.0f, 1.0f}, + transform); + + int i = 0; + for (auto tileColor : Rec709ColorChecker) { + int row = i / 6; + int col = i % 6; + i++; + + float tileX = chartPose.x - (chartSizeX - tileSize) / 2.0f + (tileSize + tileGap) * col; + float tileY = chartPose.y + (chartSizeY - tileSize) / 2.0f - (tileSize + tileGap) * row; + float tileZ = chartPose.z + 0.005f; + + transform = OVR::Matrix4f::Translation({tileX, tileY, tileZ}) * + OVR::Matrix4f::Scaling(tileSize, tileSize, 0.1); + + colorCheckerCubes.Add( + OVRFW::BuildUnitCubeDescriptor(), + OVRFW::GeometryBuilder::kInvalidIndex, + linearRgbaFromGammaHex(tileColor), + transform); + + ui_.AddLabel(tileColor, {tileX, tileY, tileZ + 0.07f}, {100.0f, 45.0f}) + ->SetColor({0, 0, 0, 0}); // Set label background to transparent + } + colorCheckerRenderer_.Init(colorCheckerCubes.ToGeometryDescriptor()); + + // Tricks to disable shading and lighting of the color checker + // to ensure the final image contains the exact RGB values we want: + colorCheckerRenderer_.ChannelControl = {0, 1, 0}; // Only enable ambient color + // Pass through vertex color to the final image by using the ambient light + colorCheckerRenderer_.AmbientLightColor = {1, 1, 1}; + } + + void CreateSampleDescriptionPanel() { + // Panel to provide sample description to the user for context + auto descriptionLabel = ui_.AddLabel( + static_cast(sampleExplanation), {2.0f, 1.5f, -1.5f}, {950.0f, 600.0f}); + + // Align and size the description text for readability + OVRFW::VRMenuFontParms fontParams{}; + fontParams.Scale = 0.5f; + fontParams.AlignHoriz = OVRFW::HORIZONTAL_LEFT; + descriptionLabel->SetFontParms(fontParams); + descriptionLabel->SetTextLocalPosition({-0.65f, 0, 0}); + + // Tilt the description billboard 45 degrees towards the user + descriptionLabel->SetLocalRotation( + OVR::Quat::FromRotationVector({0, OVR::DegreeToRad(-45.0f), 0})); + } + + private: + // Function pointers to extension functions + // Remember that you need to call xrGetInstanceProcAddr after + // instance initiation to get these + PFN_xrEnumerateColorSpacesFB xrEnumerateColorSpacesFB{nullptr}; + PFN_xrSetColorSpaceFB xrSetColorSpaceFB{nullptr}; + + XrColorSpaceFB declaredColorSpace_{XR_COLOR_SPACE_MAX_ENUM_FB}; + + OVRFW::VRMenuObject* declaredLabel_; + OVRFW::GeometryRenderer colorCheckerRenderer_; + OVRFW::ControllerRenderer controllerRenderL_; + OVRFW::ControllerRenderer controllerRenderR_; + OVRFW::TinyUI ui_; + + // Renderer that draws the beam from the controller + OVRFW::SimpleBeamRenderer cursorBeamRenderer_; + std::vector beams_; +}; + +ENTRY_POINT(XrAppBaseApp) diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/openxr_reflection_macro.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/openxr_reflection_macro.h new file mode 100644 index 00000000..7944486b --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/Src/openxr_reflection_macro.h @@ -0,0 +1,19 @@ +#pragma once +#include + +// Macro copied from example in openxr_reflection.h +#define XR_ENUM_CASE_STR(name, val) \ + case name: \ + return #name; + +#define XR_ENUM_STR(enumType) \ + constexpr const char* XrEnumStr(enumType e) { \ + switch (e) { XR_LIST_ENUM_##enumType(XR_ENUM_CASE_STR) default : return "Unknown"; } \ + } + +// Creates overloads of XrEnumStr() function for these enum types +XR_ENUM_STR(XrColorSpaceFB); +XR_ENUM_STR(XrResult); + +#undef XR_ENUM_CASE_STR +#undef XR_ENUM_STR diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/assets.txt b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/assets.txt new file mode 100644 index 00000000..2cc30f71 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/assets.txt @@ -0,0 +1 @@ +This file is a placeholder. diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/panel.ktx b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/panel.ktx new file mode 100644 index 00000000..deb13e8a Binary files /dev/null and b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/assets/panel.ktx differ diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/java/MainActivity.java b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/java/MainActivity.java new file mode 100644 index 00000000..cce85480 --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/java/MainActivity.java @@ -0,0 +1,28 @@ +// Copyright (c) Facebook Technologies, LLC and its affiliates. All Rights reserved. +package com.oculus.sdk.xrcolorspacefb; + +/** + * When using NativeActivity, we currently need to handle loading of dependent shared libraries + * manually before a shared library that depends on them is loaded, since there is not currently a + * way to specify a shared library dependency for NativeActivity via the manifest meta-data. + * + *

The simplest method for doing so is to subclass NativeActivity with an empty activity that + * calls System.loadLibrary on the dependent libraries, which is unfortunate when the goal is to + * write a pure native C/C++ only Android activity. + * + *

A native-code only solution is to load the dependent libraries dynamically using dlopen(). + * However, there are a few considerations, see: + * https://groups.google.com/forum/#!msg/android-ndk/l2E2qh17Q6I/wj6s_6HSjaYJ + * + *

1. Only call dlopen() if you're sure it will succeed as the bionic dynamic linker will + * remember if dlopen failed and will not re-try a dlopen on the same lib a second time. + * + *

2. Must remember what libraries have already been loaded to avoid infinitely looping when + * libraries have circular dependencies. + */ +public class MainActivity extends android.app.NativeActivity { + static { + System.loadLibrary("openxr_loader"); + System.loadLibrary("xrsamples_xrcolorspacefb"); + } +} diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/res/values/strings.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/res/values/strings.xml new file mode 100644 index 00000000..ad5df76c --- /dev/null +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrColorSpaceFB/res/values/strings.xml @@ -0,0 +1,4 @@ + + + XrColorSpaceFB Sample + diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Projects/Android/AndroidManifest.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Projects/Android/AndroidManifest.xml index 0a716f8e..2fca96fd 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Projects/Android/AndroidManifest.xml +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Projects/Android/AndroidManifest.xml @@ -6,7 +6,7 @@ - + diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Src/XrCompositor_NativeActivity.c b/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Src/XrCompositor_NativeActivity.c index 9cb85de2..094bba2c 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Src/XrCompositor_NativeActivity.c +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrCompositor_NativeActivity/Src/XrCompositor_NativeActivity.c @@ -3183,6 +3183,10 @@ void android_main(struct android_app* app) { } XrView* projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView))); + for (int eye = 0; eye < ovrMaxNumEyes; eye++) { + memset(&projections[eye], 0, sizeof(XrView)); + projections[eye].type = XR_TYPE_VIEW; + } // Actions XrActionSet runningActionSet = @@ -3239,9 +3243,9 @@ void android_main(struct android_app* app) { XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath}; XrAction aimPoseAction = CreateAction( - runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, handSubactionPaths); XrAction gripPoseAction = CreateAction( - runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, handSubactionPaths); XrPath interactionProfilePath = XR_NULL_PATH; XrPath interactionProfilePathTouch = XR_NULL_PATH; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/AndroidManifest.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/AndroidManifest.xml index 29daceca..a4dd6a70 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/AndroidManifest.xml +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/AndroidManifest.xml @@ -15,7 +15,8 @@ - + + diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/build.gradle b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/build.gradle index 72114a8c..804a1a61 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/build.gradle +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Projects/Android/build.gradle @@ -43,6 +43,7 @@ android { jniLibs.srcDir 'libs' assets.srcDirs = ['../../assets'] + res.srcDirs = ['../../res'] } } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Src/main.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Src/main.cpp index f93602da..baf57941 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Src/main.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/Src/main.cpp @@ -203,7 +203,7 @@ class XrHandsApp : public OVRFW::XrApp { auto& handTracker = isLeft ? handTrackerL_ : handTrackerR_; auto& handRenderer = isLeft ? handRendererL_ : handRendererR_; auto& handJointRenderers = isLeft ? handJointRenderersL_ : handJointRenderersR_; - auto& jointLocations = isLeft ? jointLocationsL_ : jointLocationsR_; + auto* jointLocations = isLeft ? jointLocationsL_ : jointLocationsR_; auto& handCapsuleRenderers = isLeft ? handCapsuleRenderersL_ : handCapsuleRenderersR_; @@ -370,7 +370,7 @@ class XrHandsApp : public OVRFW::XrApp { } /// Hands - { + if (xrLocateHandJointsEXT_) { /// L XrHandTrackingScaleFB scaleL{XR_TYPE_HAND_TRACKING_SCALE_FB}; scaleL.next = nullptr; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/res/values/strings.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/res/values/strings.xml index 6e2f9bc0..db904ba8 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/res/values/strings.xml +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrHandsFB/res/values/strings.xml @@ -1,4 +1,4 @@ - Xr Hands FB + XrHandsFB Sample diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/AndroidManifest.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/AndroidManifest.xml index c3725845..854083b1 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/AndroidManifest.xml +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/AndroidManifest.xml @@ -27,9 +27,8 @@ - + - @@ -48,6 +47,7 @@ + diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/build.gradle b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/build.gradle index 50d2bae0..da62af09 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/build.gradle +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Projects/Android/build.gradle @@ -38,6 +38,7 @@ android { jniLibs.srcDir 'libs' assets.srcDirs = ['../../assets'] + res.srcDirs = ['../../res'] } } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.cpp index 5ed7f54c..1d7ee4aa 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.cpp @@ -57,6 +57,8 @@ void main() )glsl"; static const char* FragmentShaderSrc = R"glsl( +precision lowp float; + uniform sampler2D Texture0; uniform lowp vec3 SpecularLightDirection; uniform lowp vec3 SpecularLightColor; @@ -174,8 +176,10 @@ bool KeyboardRenderer::Init(std::vector& keyboardBuffer) { void KeyboardRenderer::Shutdown() { OVRFW::GlProgram::Free(ProgKeyboard); - delete KeyboardModel; - KeyboardModel = nullptr; + if (KeyboardModel != nullptr) { + delete KeyboardModel; + KeyboardModel = nullptr; + } } void KeyboardRenderer::Update(const OVR::Posef& pose, const OVR::Vector3f& scale) { @@ -186,11 +190,13 @@ void KeyboardRenderer::Update(const OVR::Posef& pose, const OVR::Vector3f& scale void KeyboardRenderer::Render(std::vector& surfaceList) { /// toggle alpha override AlphaBlendFactor = UseSolidTexture ? 1.0f : 0.0f; - for (auto& model : KeyboardModel->Models) { - ovrDrawSurface controllerSurface; - controllerSurface.surface = &(model.surfaces[0].surfaceDef); - controllerSurface.modelMatrix = Transform; - surfaceList.push_back(controllerSurface); + if (KeyboardModel != nullptr) { + for (auto& model : KeyboardModel->Models) { + ovrDrawSurface controllerSurface; + controllerSurface.surface = &(model.surfaces[0].surfaceDef); + controllerSurface.modelMatrix = Transform; + surfaceList.push_back(controllerSurface); + } } } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.h index 645b2e40..ea784a40 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/Input/KeyboardRenderer.h @@ -19,8 +19,15 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All #include "OVR_FileSys.h" #include "OVR_Math.h" +#if defined(ANDROID) #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#else +#include "unknwn.h" +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif + #include #include #include @@ -48,7 +55,7 @@ class KeyboardRenderer { private: float AlphaBlendFactor = 1.0f; GlProgram ProgKeyboard; - ModelFile* KeyboardModel; + ModelFile* KeyboardModel = nullptr; GlTexture KeyboardTextureSolid; OVR::Matrix4f Transform; }; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/main.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/main.cpp index 95eba290..1196bb7a 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/main.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/main.cpp @@ -10,17 +10,11 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All *******************************************************************************/ #include -#include // for exit() -#include // for sleep() #include #include #include #include -#include -#include -#include - #include "XrApp.h" #include "Input/AxisRenderer.h" @@ -128,6 +122,16 @@ class XrKeyboardApp : public OVRFW::XrApp { SetSwitchUseRemoteKeyboard( bigText_, connectionRequiredButton_, useRemoteKeyboardButton_, false); + trackingRequiredButton_ = ui_.AddButton( + "Show Untracked Keyboard", {0.1f, 0.75f, -1.9f}, {500.0f, 100.0f}, [=]() { + bool currentState = keyboard_->TrackingRequired(); + bool newState = !currentState; + SetTrackingRequired( + bigText_, connectionRequiredButton_, trackingRequiredButton_, newState); + }); + + SetTrackingRequired(bigText_, connectionRequiredButton_, trackingRequiredButton_, true); + return true; } @@ -248,7 +252,7 @@ class XrKeyboardApp : public OVRFW::XrApp { if (keyboard_->GetAndClearSystemKeyboardStateChanged()) { // update the render model if (keyboard_->SystemKeyboardExists()) { - std::vector keyboardBuffer = renderModel_->LoadRenderModel(); + std::vector keyboardBuffer = renderModel_->LoadRenderModel(keyboard_->UseRemoteKeyboard()); if (keyboardBuffer.size() > 0) { ALOG("### Keyboard Render Model Size: %u", (uint32_t)keyboardBuffer.size()); keyboardRenderer_.Init(keyboardBuffer); @@ -592,6 +596,25 @@ class XrKeyboardApp : public OVRFW::XrApp { : passthrough_->GetProjectedLayer(); } + void SetTrackingRequired( + OVRFW::VRMenuObject* bigText, + OVRFW::VRMenuObject* connectionRequiredButton, + OVRFW::VRMenuObject* toggleButton, + bool state) { + if (state) { + keyboard_->SetTrackingRequired(true); + toggleButton->SetSurfaceColor(0, OVR::Vector4f(0.25f, 0.25f, 1.0f, 1.0f)); + toggleButton->SetText("Show Untracked Keyboard"); + } else { + // set connection required to false since if we aren't tracking we are likely in debug + // mode and connection isn't necessary + SetSwitchConnectionRequired(bigText, connectionRequiredButton, false); + keyboard_->SetTrackingRequired(false); + toggleButton->SetSurfaceColor(0, OVR::Vector4f(1.0f, 0.25f, 0.25f, 1.0f)); + toggleButton->SetText("Do Not Show Untracked Keyboard"); + } + } + void SetSwitchConnectionRequired( OVRFW::VRMenuObject* bigText, OVRFW::VRMenuObject* toggleButton, @@ -675,6 +698,7 @@ class XrKeyboardApp : public OVRFW::XrApp { OVRFW::VRMenuObject* systemText_ = nullptr; OVRFW::VRMenuObject* connectionRequiredButton_ = nullptr; OVRFW::VRMenuObject* useRemoteKeyboardButton_ = nullptr; + OVRFW::VRMenuObject* trackingRequiredButton_ = nullptr; /// fade heuristic to match VrShell float keyboardOpacity_ = 0.0f; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_helper.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_helper.h index 4cefc14e..1fffe033 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_helper.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_helper.h @@ -8,8 +8,15 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All ************************************************************************************************/ #pragma once +#if defined(ANDROID) #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#else +#include "unknwn.h" +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif + #include #include #include @@ -41,7 +48,7 @@ class XrHelper { if (XR_FAILED(xr)) { char errorBuffer[XR_MAX_RESULT_STRING_SIZE]; xrResultToString(instance_, xr, errorBuffer); - XRLOG("XR FAIL: `%s` -> `%s` 0x%08X", func, errorBuffer, (uint)xr); + XRLOG("XR FAIL: `%s` -> `%s` 0x%08X", func, errorBuffer, (uint64_t)xr); lastError_ = xr; return false; } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_keyboard_helper.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_keyboard_helper.h index e12c4ca5..2275e612 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_keyboard_helper.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_keyboard_helper.h @@ -21,6 +21,12 @@ class XrKeyboardHelper : public XrHelper { (PFN_xrVoidFunction*)(&xrQuerySystemTrackedKeyboardFB_))); oxr(xrGetInstanceProcAddr( instance, "xrCreateKeyboardSpaceFB", (PFN_xrVoidFunction*)(&xrCreateKeyboardSpaceFB_))); + + fakeLocation_.locationFlags = + XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT | + XR_SPACE_LOCATION_POSITION_TRACKED_BIT | + XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | + XR_SPACE_LOCATION_POSITION_VALID_BIT; } ~XrKeyboardHelper() override { @@ -127,7 +133,10 @@ class XrKeyboardHelper : public XrHelper { public: /// Own interface const XrSpaceLocation& Location() const { - return location_; + if (IsLocationActive() || trackingRequired_) { + return location_; + } + return fakeLocation_; } bool IsTracking() const { return (keyboardSpace_ != XR_NULL_HANDLE); @@ -138,7 +147,7 @@ class XrKeyboardHelper : public XrHelper { const XrSpaceLocationFlags isValid = XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT; XrSpaceLocationFlags flags = isTracked | isValid; - return IsTracking() && (location_.locationFlags & flags); + return (IsTracking() && (location_.locationFlags & flags)) || !trackingRequired_; } void ResetSystemKeyboardTracking() { @@ -234,6 +243,19 @@ class XrKeyboardHelper : public XrHelper { return false; } + bool TrackingRequired() { + return trackingRequired_; + } + + bool SetTrackingRequired(bool state) { + if (state != trackingRequired_) { + trackingRequired_ = state; + ResetSystemKeyboardTracking(); + return true; + } + return false; + } + bool TrackingSystemKeyboard() { return trackingSystemKeyboard_; } @@ -270,6 +292,7 @@ class XrKeyboardHelper : public XrHelper { XrSpace keyboardSpace_ = XR_NULL_HANDLE; /// Keyboard - data XrSpaceLocation location_{XR_TYPE_SPACE_LOCATION}; + XrSpaceLocation fakeLocation_{XR_TYPE_SPACE_LOCATION}; XrVector3f size_; // mapping the system level active tracked keyboard @@ -280,5 +303,6 @@ class XrKeyboardHelper : public XrHelper { bool systemKeyboardStateChanged_ = false; bool requireKeyboardConnectedToTrack_ = true; bool useRemoteKeyboard_ = false; + bool trackingRequired_ = false; XrKeyboardTrackingDescriptionFB systemKeyboardDesc_; }; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_passthrough_helper.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_passthrough_helper.h index 8642f76e..20fd0b4d 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_passthrough_helper.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_passthrough_helper.h @@ -158,7 +158,9 @@ class XrPassthroughHelper : public XrHelper { /// also create a hand layer layerInfo.purpose = XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_HANDS_FB; if (!oxr(xrCreatePassthroughLayerFB_(session_, &layerInfo, &layerHands_))) { - return false; + // If the runtime does not support passthrough keyboard hands, that's ok + // we will keep going with the layer we have. + // return false; } /// style diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_render_model_helper.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_render_model_helper.h index ed1a8971..3d566de9 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_render_model_helper.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/Src/xr_render_model_helper.h @@ -60,9 +60,16 @@ class XrRenderModelHelper : public XrHelper { return properties_; } - std::vector LoadRenderModel() { + std::vector LoadRenderModel(bool remote) { std::vector buffer; XrInstance instance = GetInstance(); + std::string strToCheck; + if (remote) { + strToCheck = "/model_fb/keyboard/remote"; + } else { + strToCheck = "/model_fb/keyboard/local"; + } + for (const auto& p : paths_) { char buf[256]; uint32_t bufCount = 0; @@ -71,7 +78,7 @@ class XrRenderModelHelper : public XrHelper { oxr(xrPathToString(instance, p.path, bufCount, &bufCount, nullptr)); oxr(xrPathToString(instance, p.path, bufCount, &bufCount, &buf[0])); std::string pathString = buf; - if (pathString.rfind("/model_fb/keyboard", 0) == 0) { + if (pathString.rfind(strToCheck, 0) == 0) { XrRenderModelPropertiesFB prop{XR_TYPE_RENDER_MODEL_PROPERTIES_FB}; XrResult result = xrGetRenderModelPropertiesFB_(session_, p.path, &prop); if (result == XR_SUCCESS) { @@ -101,6 +108,7 @@ class XrRenderModelHelper : public XrHelper { "XrRenderModelHelper: loaded modelKey %u buffer size is %u", prop.modelKey, buffer.size()); + return buffer; } } else { XRLOG( @@ -131,7 +139,7 @@ class XrRenderModelHelper : public XrHelper { oxr(xrEnumerateRenderModelPathsFB_(session_, pathCount, &pathCount, nullptr)); if (pathCount > 0) { XRLOG("XrRenderModelHelper: found %u models ", pathCount); - paths_.resize(pathCount); + paths_.resize(pathCount, { XR_TYPE_RENDER_MODEL_PATH_INFO_FB }); /// Fill in the path data oxr(xrEnumerateRenderModelPathsFB_(session_, pathCount, &pathCount, &paths_[0])); /// Print paths for debug purpose diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/res/values/strings.xml b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/res/values/strings.xml index f6e7a0a3..65cc995f 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/res/values/strings.xml +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrKeyboard/res/values/strings.xml @@ -1,4 +1,4 @@ - Xr Keyboard + Xr Keyboard Sample diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.cpp index d30f4696..b40bbf57 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.cpp @@ -15,12 +15,18 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include // for memset #include #include + +#if defined(ANDROID) #include #include #include // for prctl( PR_SET_NAME ) #include #include // for native window JNI #include +#else +#include +#endif // defined(ANDROID) + #include #include "XrPassthrough.h" @@ -35,26 +41,30 @@ using namespace OVR; #define OVR_LOG_TAG "XrPassthrough" +#if !defined(XR_USE_GRAPHICS_API_OPENGL_ES) && !defined(XR_USE_GRAPHICS_API_OPENGL) +#error A graphics backend must be defined! +#elif defined(XR_USE_GRAPHICS_API_OPENGL_ES) && defined(XR_USE_GRAPHICS_API_OPENGL) +#error Only one graphics backend shall be defined! +#endif + +#if defined(ANDROID) #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, OVR_LOG_TAG, __VA_ARGS__) #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, OVR_LOG_TAG, __VA_ARGS__) +#else +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif static const int CPU_LEVEL = 2; static const int GPU_LEVEL = 3; static const int NUM_MULTI_SAMPLES = 4; -__attribute__((unused)) static void LOG_POSE(const char* msg, const XrPosef* p) { - ALOGV( - "%s: orientation = { %f %f %f %f }, position = { %f %f %f }", - msg, - p->orientation.x, - p->orientation.y, - p->orientation.z, - p->orientation.w, - p->position.x, - p->position.y, - p->position.z); -} - /* ================================================================================ @@ -108,6 +118,7 @@ Egl Utility Functions ================================================================================ */ +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) static const char* EglErrorString(const EGLint error) { switch (error) { case EGL_SUCCESS: @@ -281,9 +292,29 @@ void Egl::DestroyContext() { } } +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + +void Egl::Clear() { + hDC = 0; + hGLRC = 0; +} + +void Egl::CreateContext(const Egl*) { + ovrGl_CreateContext_Windows(&hDC, &hGLRC); +} + +void Egl::DestroyContext() { + ovrGl_DestroyContext_Windows(); +} + +#endif + void App::Clear() { +#if defined(XR_USE_PLATFORM_ANDROID) NativeWindow = NULL; Resumed = false; +#endif // defined(XR_USE_PLATFORM_ANDROID) + ShouldExit = false; Focused = false; Instance = XR_NULL_HANDLE; Session = XR_NULL_HANDLE; @@ -313,8 +344,10 @@ void App::Clear() { void App::HandleSessionStateChanges(XrSessionState state) { if (state == XR_SESSION_STATE_READY) { +#if defined(XR_USE_PLATFORM_ANDROID) assert(Resumed); assert(NativeWindow != NULL); +#endif // defined(XR_USE_PLATFORM_ANDROID) assert(SessionActive == false); XrSessionBeginInfo sessionBeginInfo = {}; @@ -327,6 +360,7 @@ void App::HandleSessionStateChanges(XrSessionState state) { SessionActive = (result == XR_SUCCESS); +#if defined(XR_USE_PLATFORM_ANDROID) // Set session state once we have entered VR mode and have a valid session object. if (SessionActive) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT; @@ -389,10 +423,12 @@ void App::HandleSessionStateChanges(XrSessionState state) { OXR(pfnSetAndroidApplicationThreadKHR( Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, RenderThreadTid)); } +#endif // defined(XR_USE_PLATFORM_ANDROID) } else if (state == XR_SESSION_STATE_STOPPING) { +#if defined(XR_USE_PLATFORM_ANDROID) assert(Resumed == false); +#endif // defined(XR_USE_PLATFORM_ANDROID) assert(SessionActive); - OXR(xrEndSession(Session)); SessionActive = false; } @@ -423,6 +459,7 @@ void App::HandleXrEvents() { ALOGV("xrPollEvent: received XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED event"); break; case XR_TYPE_EVENT_DATA_PERF_SETTINGS_EXT: { +#if defined(XR_USE_PLATFORM_ANDROID) const XrEventDataPerfSettingsEXT* perf_settings_event = (XrEventDataPerfSettingsEXT*)(baseEventHeader); ALOGV( @@ -431,6 +468,7 @@ void App::HandleXrEvents() { perf_settings_event->subDomain, perf_settings_event->fromLevel, perf_settings_event->toLevel); +#endif // defined(XR_USE_PLATFORM_ANDROID) } break; case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: ALOGV( @@ -456,6 +494,9 @@ void App::HandleXrEvents() { case XR_SESSION_STATE_STOPPING: HandleSessionStateChanges(session_state_changed_event->state); break; + case XR_SESSION_STATE_EXITING: + ShouldExit = true; + break; default: break; } @@ -467,6 +508,7 @@ void App::HandleXrEvents() { } } +#if defined(XR_USE_PLATFORM_ANDROID) /* ================================================================================ @@ -527,6 +569,7 @@ static void app_handle_cmd(struct android_app* androidApp, int32_t cmd) { } } } +#endif // defined(XR_USE_PLATFORM_ANDROID) void UpdateStageBounds(App& app) { XrExtent2Df stageBounds = {}; @@ -548,7 +591,12 @@ void UpdateStageBounds(App& app) { * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */ +#if defined(XR_USE_PLATFORM_ANDROID) void android_main(struct android_app* androidApp) { +#else +int main() { +#endif +#if defined(XR_USE_PLATFORM_ANDROID) ALOGV("----------------------------------------------------------------"); ALOGV("android_app_entry()"); ALOGV(" android_main()"); @@ -558,10 +606,12 @@ void android_main(struct android_app* androidApp) { // Note that AttachCurrentThread will reset the thread name. prctl(PR_SET_NAME, (long)"OVR::Main", 0, 0, 0); +#endif // defined(XR_USE_PLATFORM_ANDROID) App app; app.Clear(); +#if defined(XR_USE_PLATFORM_ANDROID) PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; xrGetInstanceProcAddr( XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR); @@ -574,6 +624,7 @@ void android_main(struct android_app* androidApp) { loaderInitializeInfoAndroid.applicationContext = androidApp->activity->clazz; xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); } +#endif // defined(XR_USE_PLATFORM_ANDROID) // Log available layers. { @@ -613,11 +664,18 @@ void android_main(struct android_app* androidApp) { // Check that the extensions required are present. const char* const requiredExtensionNames[] = { +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME, +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + XR_KHR_OPENGL_ENABLE_EXTENSION_NAME, +#endif +#if defined(XR_USE_PLATFORM_ANDROID) XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME, XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME, +#endif // defined(XR_USE_PLATFORM_ANDROID) XR_FB_PASSTHROUGH_EXTENSION_NAME, - XR_FB_TRIANGLE_MESH_EXTENSION_NAME}; + XR_FB_TRIANGLE_MESH_EXTENSION_NAME + }; const uint32_t numRequiredExtensions = sizeof(requiredExtensionNames) / sizeof(requiredExtensionNames[0]); @@ -744,6 +802,7 @@ void android_main(struct android_app* androidApp) { assert(MaxLayerCount <= systemProperties.graphicsProperties.maxLayerCount); // Get the graphics requirements. +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL; OXR(xrGetInstanceProcAddr( app.Instance, @@ -753,6 +812,17 @@ void android_main(struct android_app* androidApp) { XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {}; graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR; OXR(pfnGetOpenGLESGraphicsRequirementsKHR(app.Instance, systemId, &graphicsRequirements)); +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + PFN_xrGetOpenGLGraphicsRequirementsKHR pfnGetOpenGLGraphicsRequirementsKHR = NULL; + OXR(xrGetInstanceProcAddr( + app.Instance, + "xrGetOpenGLGraphicsRequirementsKHR", + (PFN_xrVoidFunction*)(&pfnGetOpenGLGraphicsRequirementsKHR))); + + XrGraphicsRequirementsOpenGLKHR graphicsRequirements = {}; + graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR; + OXR(pfnGetOpenGLGraphicsRequirementsKHR(app.Instance, systemId, &graphicsRequirements)); +#endif // Create the EGL Context app.egl.CreateContext(nullptr); @@ -771,7 +841,11 @@ void android_main(struct android_app* androidApp) { app.CpuLevel = CPU_LEVEL; app.GpuLevel = GPU_LEVEL; +#if defined(ANDROID) app.MainThreadTid = gettid(); +#else + app.MainThreadTid = (int)std::hash{}(std::this_thread::get_id()); +#endif app.SystemId = systemId; @@ -797,16 +871,24 @@ void android_main(struct android_app* androidApp) { // FB_passthrough sample end // Create the OpenXR Session. - XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {}; - graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; - graphicsBindingAndroidGLES.next = NULL; - graphicsBindingAndroidGLES.display = app.egl.Display; - graphicsBindingAndroidGLES.config = app.egl.Config; - graphicsBindingAndroidGLES.context = app.egl.Context; +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) + XrGraphicsBindingOpenGLESAndroidKHR graphicsBinding = {}; + graphicsBinding.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; + graphicsBinding.next = NULL; + graphicsBinding.display = app.egl.Display; + graphicsBinding.config = app.egl.Config; + graphicsBinding.context = app.egl.Context; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + XrGraphicsBindingOpenGLWin32KHR graphicsBinding = {}; + graphicsBinding.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR; + graphicsBinding.next = NULL; + graphicsBinding.hDC = app.egl.hDC; + graphicsBinding.hGLRC = app.egl.hGLRC; +#endif XrSessionCreateInfo sessionCreateInfo = {}; sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO; - sessionCreateInfo.next = &graphicsBindingAndroidGLES; + sessionCreateInfo.next = &graphicsBinding; sessionCreateInfo.createFlags = 0; sessionCreateInfo.systemId = app.SystemId; @@ -871,6 +953,7 @@ void android_main(struct android_app* androidApp) { // Log the view config info for each view type for debugging purposes. for (uint32_t e = 0; e < viewCount; e++) { const XrViewConfigurationView* element = &elements[e]; + (void)element; ALOGV( "Viewport [%d]: Recommended Width=%d Height=%d SampleCount=%d", @@ -946,6 +1029,9 @@ void android_main(struct android_app* androidApp) { } auto projections = new XrView[NUM_EYES]; + for (int eye = 0; eye < NUM_EYES; eye++) { + projections[eye] = XrView{XR_TYPE_VIEW}; + } GLenum format = GL_SRGB8_ALPHA8; int width = app.ViewConfigurationView[0].recommendedImageRectWidth; @@ -966,11 +1052,19 @@ void android_main(struct android_app* androidApp) { // Create the swapchain. OXR(xrCreateSwapchain(app.Session, &swapChainCreateInfo, &app.ColorSwapChain)); OXR(xrEnumerateSwapchainImages(app.ColorSwapChain, 0, &app.SwapChainLength, nullptr)); +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) auto images = new XrSwapchainImageOpenGLESKHR[app.SwapChainLength]; // Populate the swapchain image array. for (uint32_t i = 0; i < app.SwapChainLength; i++) { images[i] = {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR}; } +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + auto images = new XrSwapchainImageOpenGLKHR[app.SwapChainLength]; + // Populate the swapchain image array. + for (uint32_t i = 0; i < app.SwapChainLength; i++) { + images[i] = {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR}; + } +#endif OXR(xrEnumerateSwapchainImages( app.ColorSwapChain, @@ -1038,8 +1132,10 @@ void android_main(struct android_app* androidApp) { } // FB_passthrough sample end +#if defined(XR_USE_PLATFORM_ANDROID) androidApp->userData = &app; androidApp->onAppCmd = app_handle_cmd; +#endif // defined(XR_USE_PLATFORM_ANDROID) bool stageBoundsDirty = true; @@ -1063,9 +1159,15 @@ void android_main(struct android_app* androidApp) { float clearColor[4] = {0.0f, 0.0f, 0.0f, 0.2f}; - while (androidApp->destroyRequested == 0) { +#if defined(XR_USE_PLATFORM_ANDROID) + while (androidApp->destroyRequested == 0) +#else + while (true) +#endif + { frameCount++; +#if defined(XR_USE_PLATFORM_ANDROID) // Read all pending events. for (;;) { int events; @@ -1085,9 +1187,24 @@ void android_main(struct android_app* androidApp) { source->process(androidApp, source); } } +#elif defined(XR_USE_PLATFORM_WIN32) + MSG msg; + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) { + if (msg.message == WM_QUIT) { + app.ShouldExit = true; + } else { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } +#endif // defined(XR_USE_PLATFORM_ANDROID) app.HandleXrEvents(); + if (app.ShouldExit) { + break; + } + if (app.SessionActive == false) { frameCount = -1; framesCyclePaused = 0; @@ -1325,7 +1442,6 @@ void android_main(struct android_app* androidApp) { XrPosef xfLocalFromEye[NUM_EYES]; for (int eye = 0; eye < NUM_EYES; eye++) { - // LOG_POSE( "viewTransform", &projectionInfo.projections[eye].viewTransform ); XrPosef xfHeadFromEye = projections[eye].pose; xfLocalFromEye[eye] = XrPosef_Multiply(xfLocalFromHead, xfHeadFromEye); @@ -1454,5 +1570,7 @@ void android_main(struct android_app* androidApp) { OXR(xrDestroySession(app.Session)); OXR(xrDestroyInstance(app.Instance)); +#if defined(XR_USE_PLATFORM_ANDROID) (*androidApp->activity->vm).DetachCurrentThread(); +#endif // defined(XR_USE_PLATFORM_ANDROID) } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.h index 351088db..89dd3810 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthrough.h @@ -1,12 +1,19 @@ #pragma once +#if defined(ANDROID) #include #include #include #include - #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#else +#include "unknwn.h" +#include "Render/GlWrapperWin32.h" +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif // defined(ANDROID) + #include #include #include @@ -61,6 +68,7 @@ struct Egl { void Clear(); void CreateContext(const Egl* shareEgl); void DestroyContext(); +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) EGLint MajorVersion; EGLint MinorVersion; EGLDisplay Display; @@ -68,6 +76,10 @@ struct Egl { EGLSurface TinySurface; EGLSurface MainSurface; EGLContext Context; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + HDC hDC; + HGLRC hGLRC; +#endif }; /* @@ -97,8 +109,12 @@ struct App { void HandleXrEvents(); Egl egl; + +#if defined(XR_USE_PLATFORM_ANDROID) ANativeWindow* NativeWindow; bool Resumed; +#endif // defined(XR_USE_PLATFORM_ANDROID) + bool ShouldExit; bool Focused; XrInstance Instance; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.cpp index 8b9d3b24..c180aae0 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.cpp @@ -15,21 +15,26 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include #include #include + +#if defined(ANDROID) #include #include #include // for prctl( PR_SET_NAME ) #include #include // for native window JNI #include +#endif // defined(ANDROID) #include #include +#if defined(ANDROID) #include #include #include #include +#endif // defined(ANDROID) #include "XrPassthroughGl.h" @@ -88,12 +93,23 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)( #define DEBUG 1 #define OVR_LOG_TAG "XrPassthroughGl" +#if defined(ANDROID) #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, OVR_LOG_TAG, __VA_ARGS__) #if DEBUG #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, OVR_LOG_TAG, __VA_ARGS__) #else #define ALOGV(...) #endif +#else +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif /* ================================================================================ @@ -670,6 +686,16 @@ void Framebuffer::Clear() { Elements = nullptr; } +static void* GlGetExtensionProc(const char* functionName) { +#if defined(ANDROID) + return (void*)eglGetProcAddress(functionName); +#elif defined(WIN32) + return (void*)wglGetProcAddress(functionName); +#else + static_assert(false); +#endif +} + bool Framebuffer::Create( const GLenum colorFormat, const int width, @@ -678,10 +704,10 @@ bool Framebuffer::Create( const int swapChainLength, GLuint* colorTextures) { PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC glFramebufferTextureMultiviewOVR = - (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)eglGetProcAddress( + (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)GlGetExtensionProc( "glFramebufferTextureMultiviewOVR"); PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC glFramebufferTextureMultisampleMultiviewOVR = - (PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)eglGetProcAddress( + (PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)GlGetExtensionProc( "glFramebufferTextureMultisampleMultiviewOVR"); Width = width; @@ -731,7 +757,7 @@ bool Framebuffer::Create( multisamples /* samples */, 0 /* baseViewIndex */, 2 /* numViews */)); - } else { + } else if (glFramebufferTextureMultiviewOVR != nullptr) { GL(glFramebufferTextureMultiviewOVR( GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.h index fff066b9..dd56783a 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughGl.h @@ -1,6 +1,11 @@ #pragma once +#if defined(ANDROID) #include +#else +#include "Render/GlWrapperWin32.h" +#endif // defined(ANDROID) + #include "OVR_Math.h" #ifndef NUM_EYES diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.cpp index b9a05049..c9b65f83 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.cpp @@ -15,10 +15,14 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include // for memset #include #include + +#if defined(ANDROID) #include #include #include // for native window JNI #include +#endif // defined(ANDROID) + #include #include @@ -35,8 +39,20 @@ using namespace OVR; #define DEBUG 1 #define LOG_TAG "XrPassthrough" +#if defined(ANDROID) #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__) +#else +#include +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif namespace { @@ -153,19 +169,10 @@ void AppInput_init(App& app) { XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath}; aimPoseAction = CreateAction( - runningActionSet, - XR_ACTION_TYPE_POSE_INPUT, - "aim_pose", - nullptr, - 2, - &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", nullptr, 2, handSubactionPaths); + gripPoseAction = CreateAction( - runningActionSet, - XR_ACTION_TYPE_POSE_INPUT, - "grip_pose", - nullptr, - 2, - &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", nullptr, 2, handSubactionPaths); XrPath interactionProfilePath = XR_NULL_PATH; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.h index 7d30e904..90e6b2cb 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrPassthrough/Src/XrPassthroughInput.h @@ -1,5 +1,6 @@ #pragma once +#if defined(ANDROID) #include #include #include @@ -7,6 +8,13 @@ #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#else +#include "unknwn.h" +#include "Render/GlWrapperWin32.h" +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif // defined(ANDROID) + #include #include #include diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.cpp index 9b7ece0e..ee2a30fd 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.cpp @@ -113,6 +113,13 @@ struct OpenGLExtensions_t { }; OpenGLExtensions_t glExtensions; + +Matrix4f ZOffsetTransform(const float zOffset) { + Matrix4f transform = Matrix4f::Identity(); + transform(2, 3) = zOffset; + return transform; +} + } // namespace static void EglInitExtensions() { @@ -743,29 +750,30 @@ ovrPlane ovrPlane::ovrPlane(const XrSpace space) : Space(space) {} -void ovrPlane::Update(const XrRect2Df& boundingBox2D, const XrColor4f& color, const float zOffset) { +void ovrPlane::Update(const XrRect2Df& boundingBox2D, const XrColor4f& color) { const auto& offset = boundingBox2D.offset; const auto& extent = boundingBox2D.extent; const std::vector vertices = { - XrVector3f{offset.x, offset.y, zOffset}, - XrVector3f{offset.x + extent.width, offset.y, zOffset}, - XrVector3f{offset.x + extent.width, offset.y + extent.height, zOffset}, - XrVector3f{offset.x, offset.y + extent.height, zOffset}}; + XrVector3f{offset.x, offset.y, 0.0f}, + XrVector3f{offset.x + extent.width, offset.y, 0.0f}, + XrVector3f{offset.x + extent.width, offset.y + extent.height, 0.0f}, + XrVector3f{offset.x, offset.y + extent.height, 0.0f}}; Geometry.CreatePlane(vertices, color); } -void ovrPlane::Update( - const XrBoundary2DFB& boundary2D, - const XrColor4f& color, - const float zOffset) { +void ovrPlane::Update(const XrBoundary2DFB& boundary2D, const XrColor4f& color) { std::vector vertices; vertices.reserve(boundary2D.vertexCountOutput); for (uint32_t i = 0; i < boundary2D.vertexCountOutput; ++i) { - vertices.push_back(XrVector3f{boundary2D.vertices[i].x, boundary2D.vertices[i].y, zOffset}); + vertices.push_back(XrVector3f{boundary2D.vertices[i].x, boundary2D.vertices[i].y, 0.0f}); } Geometry.CreatePlane(vertices, color); } +void ovrPlane::SetZOffset(const float zOffset) { + ZOffset = zOffset; +} + void ovrPlane::SetPose(const XrPosef& T_World_Plane_Xr) { T_World_Plane = FromXrPosef(T_World_Plane_Xr); IsPoseSet_ = true; @@ -1132,7 +1140,10 @@ void ovrAppRenderer::RenderFrame(const FrameIn& frameIn) { continue; } if (Scene.PlaneProgram.UniformLocation[ovrUniform::Index::MODEL_MATRIX] >= 0) { - const Matrix4f transform = Matrix4f(plane.T_World_Plane); + Matrix4f transform = Matrix4f(plane.T_World_Plane); + if (plane.ZOffset != 0.0f) { + transform *= ZOffsetTransform(plane.ZOffset); + } GL(glUniformMatrix4fv( Scene.PlaneProgram.UniformLocation[ovrUniform::Index::MODEL_MATRIX], 1, @@ -1163,8 +1174,11 @@ void ovrAppRenderer::RenderFrame(const FrameIn& frameIn) { continue; } if (Scene.AxesProgram.UniformLocation[ovrUniform::Index::MODEL_MATRIX] >= 0) { - const Matrix4f transform = - Matrix4f(plane.T_World_Plane) * Matrix4f::Scaling(0.1, 0.1, 0.1); + Matrix4f transform = Matrix4f(plane.T_World_Plane); + if (plane.ZOffset != 0.0f) { + transform *= ZOffsetTransform(plane.ZOffset); + } + transform *= Matrix4f::Scaling(0.1, 0.1, 0.1); GL(glUniformMatrix4fv( Scene.AxesProgram.UniformLocation[ovrUniform::Index::MODEL_MATRIX], 1, diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.h index 115482e5..1cdfcba6 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelGl.h @@ -9,6 +9,7 @@ #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 + #include #include #include @@ -108,13 +109,14 @@ struct ovrFramebuffer { struct ovrPlane { explicit ovrPlane(const XrSpace space); - void Update(const XrRect2Df& boundingBox2D, const XrColor4f& color, const float zOffset = 0.0f); + void Update(const XrRect2Df& boundingBox2D, const XrColor4f& color); - void - Update(const XrBoundary2DFB& boundary2D, const XrColor4f& color, const float zOffset = 0.0f); + void Update(const XrBoundary2DFB& boundary2D, const XrColor4f& color); void SetPose(const XrPosef& T_World_Plane); + void SetZOffset(const float zOffset); + bool IsRenderable() const { return IsPoseSet_ && Geometry.IsRenderable(); } @@ -122,6 +124,7 @@ struct ovrPlane { XrSpace Space; OVR::Posef T_World_Plane; ovrGeometry Geometry; + float ZOffset = 0.0f; // Z offset in the plane frame private: bool IsPoseSet_ = false; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelXr.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelXr.cpp index ed8e0127..71e04ac4 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelXr.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SceneModelXr.cpp @@ -139,17 +139,17 @@ bool isValid(const XrUuidEXT& uuid) { } static const std::map SemanticLabelToColorMap = { - {"DESK", {1.f, 0.f, 0.f, 0.2f}}, - {"COUCH", {0.f, 1.f, 0.f, 0.2f}}, + {"DESK", {1.0f, 0.0f, 0.0f, 0.2f}}, + {"COUCH", {0.0f, 1.0f, 0.0f, 0.2f}}, {"FLOOR", {0.2f, 0.2f, 0.8f, 1.0f}}, {"CEILING", {0.3f, 0.3f, 0.3f, 1.0f}}, - {"WALL_FACE", {0.5f, 0.5f, 0.f, 1.0f}}, - {"WINDOW_FRAME", {0.f, 0.5f, 0.6f, 0.8f}}, - {"DOOR_FRAME", {0.f, 0.2f, 0.2f, 1.0f}}, - {"OTHER", {1.f, 0.f, 1.f, 0.2f}}}; + {"WALL_FACE", {0.5f, 0.5f, 0.0f, 1.0f}}, + {"WINDOW_FRAME", {0.0f, 0.5f, 0.6f, 0.8f}}, + {"DOOR_FRAME", {0.0f, 0.2f, 0.2f, 1.0f}}, + {"OTHER", {1.0f, 0.0f, 1.0f, 0.2f}}}; XrColor4f GetColorForSemanticLabels(const std::string& labels) { - const XrColor4f defaultColor = {0.2f, 0.2f, 0.f, 0.2f}; + const XrColor4f defaultColor = {0.2f, 0.2f, 0.0f, 0.2f}; if (labels.empty()) { return defaultColor; } @@ -698,11 +698,11 @@ std::string GetSemanticLabels(ovrApp& app, const XrSpace space) { bool UpdateOvrPlane(ovrApp& app, ovrPlane& plane) { const auto labels = GetSemanticLabels(app, plane.Space); const auto color = GetColorForSemanticLabels(labels); - float zOffset = 0.0f; + // Move windows and doors so they appear in front of the walls if (labels.find("WINDOW_FRAME") != std::string::npos || labels.find("DOOR_FRAME") != std::string::npos) { - zOffset = 0.01f; // move 1cm on Z+ + plane.SetZOffset(0.01f); // move 1cm on Z+ } if (app.CurrentPlaneVisualizationMode == ovrApp::PlaneVisualizationMode::BoundingBox) { @@ -715,7 +715,7 @@ bool UpdateOvrPlane(ovrApp& app, ovrPlane& plane) { ALOGE("Failed getting bounding box 2D!"); return false; } - plane.Update(boundingBox2D, color, zOffset); + plane.Update(boundingBox2D, color); return true; } else if (app.CurrentPlaneVisualizationMode == ovrApp::PlaneVisualizationMode::Boundary) { XrResult res; @@ -737,7 +737,7 @@ bool UpdateOvrPlane(ovrApp& app, ovrPlane& plane) { ALOGE("Failed getting boundary 2D!"); return false; } - plane.Update(boundary2D, color, zOffset); + plane.Update(boundary2D, color); return true; } return false; @@ -1531,6 +1531,9 @@ void android_main(struct android_app* androidApp) { } auto projections = new XrView[NUM_EYES]; + for (int eye = 0; eye < NUM_EYES; eye++) { + projections[eye] = XrView{XR_TYPE_VIEW}; + } GLenum format = GL_SRGB8_ALPHA8; int width = app.ViewConfigurationView[0].recommendedImageRectWidth; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SimpleXrInput.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SimpleXrInput.cpp index 08a4bb18..0a20fbf8 100644 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SimpleXrInput.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSceneModel/Src/SimpleXrInput.cpp @@ -48,7 +48,6 @@ struct SimpleXrInputImpl : public SimpleXrInput { XrPath leftHandPath; XrPath rightHandPath; - std::vector handSubactionPaths; XrActionSet actionSet = XR_NULL_HANDLE; XrAction a = XR_NULL_HANDLE; @@ -102,7 +101,7 @@ struct SimpleXrInputImpl : public SimpleXrInput { OXR(xrStringToPath(instance, "/user/hand/left", &leftHandPath)); OXR(xrStringToPath(instance, "/user/hand/right", &rightHandPath)); - handSubactionPaths = {leftHandPath, rightHandPath}; + XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath}; actionSet = CreateActionSet(1, "main_action_set", "main ActionSet"); a = CreateAction(actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "a", "A button"); @@ -110,25 +109,21 @@ struct SimpleXrInputImpl : public SimpleXrInput { x = CreateAction(actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "x", "X button"); y = CreateAction(actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "y", "Y button"); trigger = CreateAction( - actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "trigger", nullptr, 2, &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "trigger", nullptr, 2, handSubactionPaths); thumbClick = CreateAction( - actionSet, - XR_ACTION_TYPE_BOOLEAN_INPUT, - "thumb_click", - nullptr, - 2, - &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "thumb_click", nullptr, 2, handSubactionPaths); + thumbStick = CreateAction( actionSet, XR_ACTION_TYPE_VECTOR2F_INPUT, "thumb_stick", nullptr, 2, - &handSubactionPaths[0]); + handSubactionPaths); aim = CreateAction( - actionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", nullptr, 2, &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", nullptr, 2, handSubactionPaths); grip = CreateAction( - actionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", nullptr, 2, &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", nullptr, 2, handSubactionPaths); std::vector bindings; bindings.push_back(Suggest(a, "/user/hand/right/input/a/click")); diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpaceWarp/Src/XrSpaceWarp.c b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpaceWarp/Src/XrSpaceWarp.c index 5edac017..31519220 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpaceWarp/Src/XrSpaceWarp.c +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpaceWarp/Src/XrSpaceWarp.c @@ -3026,6 +3026,10 @@ void android_main(struct android_app* app) { } XrView* projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView))); + for (int eye = 0; eye < ovrMaxNumEyes; eye++) { + memset(&projections[eye], 0, sizeof(XrView)); + projections[eye].type = XR_TYPE_VIEW; + } // Actions XrActionSet runningActionSet = @@ -3053,9 +3057,9 @@ void android_main(struct android_app* app) { XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath}; XrAction aimPoseAction = CreateAction( - runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", NULL, 2, handSubactionPaths); XrAction gripPoseAction = CreateAction( - runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, &handSubactionPaths[0]); + runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", NULL, 2, handSubactionPaths); XrPath interactionProfilePath = XR_NULL_PATH; XrPath interactionProfilePathTouch = XR_NULL_PATH; diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.cpp index d1275db5..ec4db8c7 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.cpp @@ -1,16 +1,31 @@ // Simple Xr Input +#if defined(ANDROID) #include +#endif + #include #include #include "SimpleXrInput.h" +#if defined(ANDROID) #define DEBUG 1 #define OVR_LOG_TAG "SimpleXrInput" #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, OVR_LOG_TAG, __VA_ARGS__) #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, OVR_LOG_TAG, __VA_ARGS__) +#else +#define DEBUG 1 +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif /* ================================================================================ @@ -46,7 +61,6 @@ struct SimpleXrInputImpl : public SimpleXrInput { XrPath leftHandPath; XrPath rightHandPath; - std::vector handSubactionPaths; XrActionSet actionSet = XR_NULL_HANDLE; XrAction a = XR_NULL_HANDLE; @@ -88,7 +102,7 @@ struct SimpleXrInputImpl : public SimpleXrInput { OXR(xrStringToPath(instance, "/user/hand/left", &leftHandPath)); OXR(xrStringToPath(instance, "/user/hand/right", &rightHandPath)); - handSubactionPaths = {leftHandPath, rightHandPath}; + XrPath handSubactionPaths[2] = {leftHandPath, rightHandPath}; actionSet = CreateActionSet(1, "main_action_set", "main ActionSet"); a = CreateAction(actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "a", "A button"); @@ -97,9 +111,9 @@ struct SimpleXrInputImpl : public SimpleXrInput { y = CreateAction(actionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "y", "Y button"); aim = CreateAction( - actionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", nullptr, 2, &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_POSE_INPUT, "aim_pose", nullptr, 2, handSubactionPaths); grip = CreateAction( - actionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", nullptr, 2, &handSubactionPaths[0]); + actionSet, XR_ACTION_TYPE_POSE_INPUT, "grip_pose", nullptr, 2, handSubactionPaths); std::vector bindings; bindings.push_back(Suggest(a, "/user/hand/right/input/a/click")); diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.h index ade69735..8ab1d7e3 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SimpleXrInput.h @@ -1,5 +1,6 @@ // Simple Xr Input +#if defined(ANDROID) #include #include @@ -9,6 +10,14 @@ #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#elif defined(WIN32) +#include "Render/GlWrapperWin32.h" + +#include +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif + #include #include #include diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.cpp index cbb38dcf..42232f70 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.cpp @@ -15,21 +15,26 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include #include #include + +#if defined(ANDROID) #include #include #include // for prctl( PR_SET_NAME ) #include #include // for native window JNI #include +#endif #include #include +#if defined(ANDROID) #include #include #include #include +#endif #include "SpatialAnchorGl.h" @@ -86,6 +91,8 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)( #endif #define DEBUG 1 + +#if defined(ANDROID) #define OVR_LOG_TAG "SpatialAnchorGl" #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, OVR_LOG_TAG, __VA_ARGS__) @@ -95,6 +102,17 @@ typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)( #define ALOGV(...) #endif +#else +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif // defined(ANDROID) + /* ================================================================================ @@ -645,6 +663,16 @@ void ovrFramebuffer::Clear() { Elements = nullptr; } +static void* GlGetExtensionProc(const char* functionName) { +#if defined(ANDROID) + return (void*)eglGetProcAddress(functionName); +#elif defined(WIN32) + return (void*)wglGetProcAddress(functionName); +#else + static_assert(false); +#endif +} + bool ovrFramebuffer::Create( const GLenum colorFormat, const int width, @@ -653,10 +681,10 @@ bool ovrFramebuffer::Create( const int swapChainLength, GLuint* colorTextures) { PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC glFramebufferTextureMultiviewOVR = - (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)eglGetProcAddress( + (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)GlGetExtensionProc( "glFramebufferTextureMultiviewOVR"); PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC glFramebufferTextureMultisampleMultiviewOVR = - (PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)eglGetProcAddress( + (PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC)GlGetExtensionProc( "glFramebufferTextureMultisampleMultiviewOVR"); Width = width; @@ -706,7 +734,7 @@ bool ovrFramebuffer::Create( multisamples /* samples */, 0 /* baseViewIndex */, 2 /* numViews */)); - } else { + } else if (glFramebufferTextureMultiviewOVR) { GL(glFramebufferTextureMultiviewOVR( GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, @@ -755,9 +783,11 @@ void ovrFramebuffer::Unbind() { } void ovrFramebuffer::Resolve() { +#if defined(ANDROID) // Discard the depth buffer, so the tiler won't need to write it back out to memory. const GLenum depthAttachment[1] = {GL_DEPTH_ATTACHMENT}; glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, 1, depthAttachment); +#endif // defined(ANDROID) // We now let the resolve happen implicitly. } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.h index 128f8d97..0941636d 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorGl.h @@ -2,10 +2,19 @@ #include +#if defined(ANDROID) #include #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#elif defined(WIN32) +#include "Render/GlWrapperWin32.h" + +#include +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif + #include #include #include diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.cpp b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.cpp index c40b4c92..55c1d89d 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.cpp +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.cpp @@ -18,12 +18,18 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include #include #include + +#if defined(ANDROID) #include #include #include // for prctl( PR_SET_NAME ) #include #include // for native window JNI #include +#else +#include +#endif + #include #include "SpatialAnchorXr.h" @@ -35,17 +41,39 @@ Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rig #include +#if defined(_WIN32) +// Favor the high performance NVIDIA or AMD GPUs +extern "C" { +// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf +__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +// https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/ +__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; +} +#endif // defined(_WIN32) + using namespace OVR; #if !defined(EGL_OPENGL_ES3_BIT_KHR) #define EGL_OPENGL_ES3_BIT_KHR 0x0040 #endif +#if defined(ANDROID) #define DEBUG 1 #define OVR_LOG_TAG "SpatialAnchorXr" #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, OVR_LOG_TAG, __VA_ARGS__) #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, OVR_LOG_TAG, __VA_ARGS__) +#else +#include +#define ALOGE(...) \ + printf("ERROR: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#define ALOGV(...) \ + printf("VERBOSE: "); \ + printf(__VA_ARGS__); \ + printf("\n") +#endif static const int CPU_LEVEL = 2; static const int GPU_LEVEL = 3; @@ -53,19 +81,6 @@ static const int NUM_MULTI_SAMPLES = 4; static const uint32_t MAX_PERSISTENT_SPACES = 20; -__attribute__((unused)) static void LOG_POSE(const char* msg, const XrPosef* p) { - ALOGV( - "%s: orientation = { %f %f %f %f }, position = { %f %f %f }", - msg, - p->orientation.x, - p->orientation.y, - p->orientation.z, - p->orientation.w, - p->position.x, - p->position.y, - p->position.z); -} - union ovrCompositorLayer_Union { XrCompositionLayerProjection Projection; XrCompositionLayerQuad Quad; @@ -112,7 +127,6 @@ OpenXR Utility Functions ================================================================================ */ -#if defined(DEBUG) static void OXR_CheckErrors(XrResult result, const char* function, bool failOnError) { if (XR_FAILED(result)) { char errorBuffer[XR_MAX_RESULT_STRING_SIZE]; @@ -124,7 +138,6 @@ static void OXR_CheckErrors(XrResult result, const char* function, bool failOnEr } } } -#endif #if defined(DEBUG) #define OXR(func) OXR_CheckErrors(func, #func, true); @@ -196,6 +209,7 @@ Egl Utility Functions ================================================================================ */ +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) static const char* EglErrorString(const EGLint error) { switch (error) { case EGL_SUCCESS: @@ -232,6 +246,7 @@ static const char* EglErrorString(const EGLint error) { return "unknown"; } } +#endif // defined(XR_USE_GRAPHICS_API_OPENGL_ES) /* ================================================================================ @@ -245,6 +260,7 @@ struct ovrEgl { void Clear(); void CreateContext(const ovrEgl* shareEgl); void DestroyContext(); +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) EGLint MajorVersion; EGLint MinorVersion; EGLDisplay Display; @@ -252,9 +268,14 @@ struct ovrEgl { EGLSurface TinySurface; EGLSurface MainSurface; EGLContext Context; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + HDC hDC; + HGLRC hGLRC; +#endif // }; void ovrEgl::Clear() { +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) MajorVersion = 0; MinorVersion = 0; Display = 0; @@ -262,8 +283,13 @@ void ovrEgl::Clear() { TinySurface = EGL_NO_SURFACE; MainSurface = EGL_NO_SURFACE; Context = EGL_NO_CONTEXT; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + hDC = 0; + hGLRC = 0; +#endif } +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) void ovrEgl::CreateContext(const ovrEgl* shareEgl) { if (Display != 0) { return; @@ -390,6 +416,18 @@ void ovrEgl::DestroyContext() { } } +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + +void ovrEgl::CreateContext(const ovrEgl*) { + ovrGl_CreateContext_Windows(&hDC, &hGLRC); +} + +void ovrEgl::DestroyContext() { + ovrGl_DestroyContext_Windows(); +} + +#endif + /* ================================================================================ @@ -430,8 +468,11 @@ struct ovrApp { bool IsComponentSupported(XrSpace space, XrSpaceComponentTypeFB type); ovrEgl Egl; +#if defined(XR_USE_PLATFORM_ANDROID) ANativeWindow* NativeWindow; bool Resumed; +#endif // defined(XR_USE_PLATFORM_ANDROID) + bool ShouldExit; bool Focused; XrSession Session; @@ -470,8 +511,11 @@ struct ovrApp { }; void ovrApp::Clear() { +#if defined(XR_USE_PLATFORM_ANDROID) NativeWindow = NULL; Resumed = false; +#endif // defined(XR_USE_PLATFORM_ANDROID) + ShouldExit = false; Focused = false; instance = XR_NULL_HANDLE; Session = XR_NULL_HANDLE; @@ -502,8 +546,10 @@ void ovrApp::Clear() { void ovrApp::HandleSessionStateChanges(XrSessionState state) { if (state == XR_SESSION_STATE_READY) { +#if defined(XR_USE_PLATFORM_ANDROID) assert(Resumed); assert(NativeWindow != NULL); +#endif // defined(XR_USE_PLATFORM_ANDROID) assert(SessionActive == false); XrSessionBeginInfo sessionBeginInfo = {}; @@ -516,6 +562,7 @@ void ovrApp::HandleSessionStateChanges(XrSessionState state) { SessionActive = (result == XR_SUCCESS); +#if defined(XR_USE_PLATFORM_ANDROID) // Set session state once we have entered VR mode and have a valid session object. if (SessionActive) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT; @@ -578,8 +625,11 @@ void ovrApp::HandleSessionStateChanges(XrSessionState state) { OXR(pfnSetAndroidApplicationThreadKHR( Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, RenderThreadTid)); } +#endif // defined(XR_USE_PLATFORM_ANDROID) } else if (state == XR_SESSION_STATE_STOPPING) { +#if defined(XR_USE_PLATFORM_ANDROID) assert(Resumed == false); +#endif // defined(XR_USE_PLATFORM_ANDROID) assert(SessionActive); OXR(xrEndSession(Session)); @@ -662,6 +712,9 @@ void ovrApp::HandleXrEvents() { case XR_SESSION_STATE_STOPPING: HandleSessionStateChanges(session_state_changed_event->state); break; + case XR_SESSION_STATE_EXITING: + ShouldExit = true; + break; default: break; } @@ -852,6 +905,7 @@ Native Activity ================================================================================ */ +#if defined(ANDROID) /** * Process the next main command. */ @@ -904,6 +958,7 @@ static void app_handle_cmd(struct android_app* androidApp, int32_t cmd) { } } } +#endif // defined(ANDROID) static Matrix4f OvrFromXr(const XrMatrix4x4f& x) { return Matrix4f( @@ -1022,12 +1077,18 @@ void PlaceAnchor(ovrApp& app, SimpleXrInput* input, const XrFrameState& frameSta ALOGV("Place Spatial Anchor initiated."); } +#if defined(XR_USE_PLATFORM_ANDROID) /** * This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */ void android_main(struct android_app* androidApp) { +#else +int main() { +#endif // defined(XR_USE_PLATFORM_ANDROID) + +#if defined(XR_USE_PLATFORM_ANDROID) ALOGV("----------------------------------------------------------------"); ALOGV("android_app_entry()"); ALOGV(" android_main()"); @@ -1037,10 +1098,12 @@ void android_main(struct android_app* androidApp) { // Note that AttachCurrentThread will reset the thread name. prctl(PR_SET_NAME, (long)"OVR::Main", 0, 0, 0); +#endif // defined(XR_USE_PLATFORM_ANDROID) ovrApp app; app.Clear(); +#if defined(XR_USE_PLATFORM_ANDROID) PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; xrGetInstanceProcAddr( XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR); @@ -1053,6 +1116,7 @@ void android_main(struct android_app* androidApp) { loaderInitializeInfoAndroid.applicationContext = androidApp->activity->clazz; xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); } +#endif // defined(XR_USE_PLATFORM_ANDROID) // Log available layers. { @@ -1092,13 +1156,20 @@ void android_main(struct android_app* androidApp) { // Check that the extensions required are present. const char* const requiredExtensionNames[] = { +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME, +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + XR_KHR_OPENGL_ENABLE_EXTENSION_NAME, +#endif +#if defined(XR_USE_PLATFORM_ANDROID) XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME, XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME, +#endif // defined(XR_USE_PLATFORM_ANDROID) XR_FB_PASSTHROUGH_EXTENSION_NAME, XR_FB_SPATIAL_ENTITY_EXTENSION_NAME, XR_FB_SPATIAL_ENTITY_QUERY_EXTENSION_NAME, - XR_FB_SPATIAL_ENTITY_STORAGE_EXTENSION_NAME}; + XR_FB_SPATIAL_ENTITY_STORAGE_EXTENSION_NAME + }; const uint32_t numRequiredExtensions = sizeof(requiredExtensionNames) / sizeof(requiredExtensionNames[0]); @@ -1222,6 +1293,7 @@ void android_main(struct android_app* androidApp) { assert(ovrMaxLayerCount <= systemProperties.graphicsProperties.maxLayerCount); +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) // Get the graphics requirements. PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL; OXR(xrGetInstanceProcAddr( @@ -1232,6 +1304,18 @@ void android_main(struct android_app* androidApp) { XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {}; graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR; OXR(pfnGetOpenGLESGraphicsRequirementsKHR(instance, systemId, &graphicsRequirements)); +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + // Get the graphics requirements. + PFN_xrGetOpenGLGraphicsRequirementsKHR pfnGetOpenGLGraphicsRequirementsKHR = NULL; + OXR(xrGetInstanceProcAddr( + instance, + "xrGetOpenGLGraphicsRequirementsKHR", + (PFN_xrVoidFunction*)(&pfnGetOpenGLGraphicsRequirementsKHR))); + + XrGraphicsRequirementsOpenGLKHR graphicsRequirements = {}; + graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR; + OXR(pfnGetOpenGLGraphicsRequirementsKHR(instance, systemId, &graphicsRequirements)); +#endif // Create the EGL Context app.Egl.CreateContext(nullptr); @@ -1250,21 +1334,33 @@ void android_main(struct android_app* androidApp) { app.CpuLevel = CPU_LEVEL; app.GpuLevel = GPU_LEVEL; +#if defined(ANDROID) app.MainThreadTid = gettid(); +#else + app.MainThreadTid = (int)std::hash{}(std::this_thread::get_id()); +#endif // defined(ANDROID) app.SystemId = systemId; // Create the OpenXR Session. - XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {}; - graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; - graphicsBindingAndroidGLES.next = NULL; - graphicsBindingAndroidGLES.display = app.Egl.Display; - graphicsBindingAndroidGLES.config = app.Egl.Config; - graphicsBindingAndroidGLES.context = app.Egl.Context; +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) + XrGraphicsBindingOpenGLESAndroidKHR graphicsBinding = {}; + graphicsBinding.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; + graphicsBinding.next = NULL; + graphicsBinding.display = app.Egl.Display; + graphicsBinding.config = app.Egl.Config; + graphicsBinding.context = app.Egl.Context; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + XrGraphicsBindingOpenGLWin32KHR graphicsBinding = {}; + graphicsBinding.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR; + graphicsBinding.next = NULL; + graphicsBinding.hDC = app.Egl.hDC; + graphicsBinding.hGLRC = app.Egl.hGLRC; +#endif // XrSessionCreateInfo sessionCreateInfo = {}; sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO; - sessionCreateInfo.next = &graphicsBindingAndroidGLES; + sessionCreateInfo.next = &graphicsBinding; sessionCreateInfo.createFlags = 0; sessionCreateInfo.systemId = app.SystemId; @@ -1403,6 +1499,9 @@ void android_main(struct android_app* androidApp) { } auto projections = new XrView[NUM_EYES]; + for (int eye = 0; eye < NUM_EYES; eye++) { + projections[eye] = XrView{XR_TYPE_VIEW}; + } GLenum format = GL_SRGB8_ALPHA8; int width = app.ViewConfigurationView[0].recommendedImageRectWidth; @@ -1423,10 +1522,18 @@ void android_main(struct android_app* androidApp) { // Create the swapchain. OXR(xrCreateSwapchain(app.Session, &swapChainCreateInfo, &app.ColorSwapChain)); OXR(xrEnumerateSwapchainImages(app.ColorSwapChain, 0, &app.SwapChainLength, nullptr)); +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) auto images = new XrSwapchainImageOpenGLESKHR[app.SwapChainLength]; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + auto images = new XrSwapchainImageOpenGLKHR[app.SwapChainLength]; +#endif // Populate the swapchain image array. for (uint32_t i = 0; i < app.SwapChainLength; i++) { +#if defined(XR_USE_GRAPHICS_API_OPENGL_ES) images[i] = {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR}; +#elif defined(XR_USE_GRAPHICS_API_OPENGL) + images[i] = {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR}; +#endif } OXR(xrEnumerateSwapchainImages( @@ -1446,8 +1553,10 @@ void android_main(struct android_app* androidApp) { delete[] images; delete[] colorTextures; +#if defined(ANDROID) androidApp->userData = &app; androidApp->onAppCmd = app_handle_cmd; +#endif // defined(ANDROID) bool stageBoundsDirty = true; @@ -1549,7 +1658,9 @@ void android_main(struct android_app* androidApp) { OXR(app.FunPtrs.xrPassthroughLayerSetStyleFB(reconPassthroughLayer, &style)); } - OXR(result = app.FunPtrs.xrPassthroughStartFB(passthrough)); + if (result != XR_ERROR_FEATURE_UNSUPPORTED) { + OXR(result = app.FunPtrs.xrPassthroughStartFB(passthrough)); + } } // Controller button states @@ -1560,9 +1671,15 @@ void android_main(struct android_app* androidApp) { bool xButtonVal = false; bool xPrevButtonVal = false; - while (androidApp->destroyRequested == 0) { +#if defined(XR_USE_PLATFORM_ANDROID) + while (androidApp->destroyRequested == 0) +#else + while (true) +#endif + { frameCount++; +#if defined(XR_USE_PLATFORM_ANDROID) // Read all pending events. for (;;) { int events; @@ -1582,9 +1699,24 @@ void android_main(struct android_app* androidApp) { source->process(androidApp, source); } } +#elif defined(XR_USE_PLATFORM_WIN32) + MSG msg; + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) { + if (msg.message == WM_QUIT) { + app.ShouldExit = true; + } else { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } +#endif app.HandleXrEvents(); + if (app.ShouldExit) { + break; + } + if (app.SessionActive == false) { continue; } @@ -1853,5 +1985,7 @@ void android_main(struct android_app* androidApp) { OXR(xrDestroySession(app.Session)); OXR(xrDestroyInstance(instance)); +#if defined(XR_USE_PLATFORM_ANDROID) (*androidApp->activity->vm).DetachCurrentThread(); +#endif // defined(XR_USE_PLATFORM_ANDROID) } diff --git a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.h b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.h index 0b97a87a..efaa5ac6 100755 --- a/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.h +++ b/thirdparty/oculus_mobile_sdk/XrSamples/XrSpatialAnchor/Src/SpatialAnchorXr.h @@ -1,5 +1,6 @@ #pragma once +#if defined(ANDROID) #include #include #include @@ -7,6 +8,14 @@ #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_PLATFORM_ANDROID 1 +#elif defined(WIN32) +#include "Render/GlWrapperWin32.h" + +#include +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif + #include #include #include diff --git a/thirdparty/oculus_mobile_sdk/bin/scripts/python.bat b/thirdparty/oculus_mobile_sdk/bin/scripts/python.bat index 0f379dcc..c140a225 100755 --- a/thirdparty/oculus_mobile_sdk/bin/scripts/python.bat +++ b/thirdparty/oculus_mobile_sdk/bin/scripts/python.bat @@ -22,23 +22,23 @@ @IF NOT exist "%ANDROID_NDK_HOME%" ( - @echo Cannot find the Android NDK + @echo Cannot find the Android NDK - goto :End + goto :End ) @if exist "%ANDROID_NDK_HOME%\prebuilt\windows\bin\python.exe" ( - @"%ANDROID_NDK_HOME%\prebuilt\windows\bin\python.exe" %1 %2 %3 %4 %5 %6 + @"%ANDROID_NDK_HOME%\prebuilt\windows\bin\python.exe" %1 %2 %3 %4 %5 %6 ) else ( - @if exist "%ANDROID_NDK_HOME%\prebuilt\windows-x86_64\bin\python.exe" ( - @"%ANDROID_NDK_HOME%\prebuilt\windows-x86_64\bin\python.exe" %1 %2 %3 %4 %5 %6 - ) else ( - @echo Cannot find python.exe in the NDK. - goto :End - ) + @if exist "%ANDROID_NDK_HOME%\prebuilt\windows-x86_64\bin\python.exe" ( + @"%ANDROID_NDK_HOME%\prebuilt\windows-x86_64\bin\python.exe" %1 %2 %3 %4 %5 %6 + ) else ( + @echo Cannot find python.exe in the NDK. + goto :End + ) ) :End