Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Apps/Playground/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ target_link_libraries(Playground
add_custom_command(TARGET Playground POST_BUILD
COMMAND ${CMAKE_COMMAND} -E $<IF:$<BOOL:$<TARGET_RUNTIME_DLLS:Playground>>,copy,true> $<TARGET_RUNTIME_DLLS:Playground> $<TARGET_FILE_DIR:Playground> COMMAND_EXPAND_LISTS)

if(ANGLE_LIBEGL)
add_custom_command(TARGET Playground POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANGLE_LIBEGL}" "$<TARGET_FILE_DIR:Playground>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANGLE_LIBGLESV2}" "$<TARGET_FILE_DIR:Playground>"
COMMENT "Copying ANGLE libraries to Playground output directory"
)
endif()

if (UNIX AND NOT APPLE AND NOT ANDROID)
# Ubuntu mixes old experimental header and new runtime libraries
# Resulting in crash at runtime for std::filesystem
Expand Down
8 changes: 8 additions & 0 deletions Apps/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ add_test(NAME UnitTests COMMAND UnitTests)
add_custom_command(TARGET UnitTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E $<IF:$<BOOL:$<TARGET_RUNTIME_DLLS:UnitTests>>,copy,true> $<TARGET_RUNTIME_DLLS:UnitTests> $<TARGET_FILE_DIR:UnitTests> COMMAND_EXPAND_LISTS)

if(ANGLE_LIBEGL)
add_custom_command(TARGET UnitTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANGLE_LIBEGL}" "$<TARGET_FILE_DIR:UnitTests>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANGLE_LIBGLESV2}" "$<TARGET_FILE_DIR:UnitTests>"
COMMENT "Copying ANGLE libraries to UnitTests output directory"
)
endif()

foreach(ASSET ${BABYLONJS_ASSETS} ${BABYLONJS_MATERIALS_ASSETS} ${TEST_ASSETS})
get_filename_component(ASSET_NAME "${ASSET}" NAME)
add_custom_command(
Expand Down
52 changes: 50 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ FetchContent_Declare(base-n
EXCLUDE_FROM_ALL)
FetchContent_Declare(bgfx.cmake
GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git
GIT_TAG ccbe08cbef9e370d0b7a2a4023d424247a727624
GIT_TAG 7499c2fe6b7f403381f397c04325450312f74c2e
EXCLUDE_FROM_ALL)
FetchContent_Declare(CMakeExtensions
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git
GIT_TAG 631780e42886e5f12bfd1a5568c7395f1d657f43
GIT_TAG 631780e42886e5f12bfd1a5568c7395f1d657f43
EXCLUDE_FROM_ALL)
FetchContent_Declare(glslang
GIT_REPOSITORY https://github.com/BabylonJS/glslang.git
Expand Down Expand Up @@ -202,13 +202,61 @@ elseif(UNIX)
elseif(WIN32)
if(NOT GRAPHICS_API)
set(GRAPHICS_API D3D11)
elseif(GRAPHICS_API STREQUAL "OpenGLWindowsDevOnly")
# OpenGLES via ANGLE from a Chromium-based browser (dev-only).
set(GRAPHICS_API OpenGL)
set(BABYLON_NATIVE_OPENGLES_FROM_BROWSER ON)
else()
if(NOT GRAPHICS_API STREQUAL Vulkan AND NOT GRAPHICS_API STREQUAL D3D11 AND NOT GRAPHICS_API STREQUAL D3D12)
message(FATAL_ERROR "Unrecognized/Unsupported render API: ${GRAPHICS_API}")
endif()
endif()
endif()

# Find ANGLE libraries from Edge or Chrome when using OpenGLWindowsDevOnly.
if(BABYLON_NATIVE_OPENGLES_FROM_BROWSER)
Comment thread
bkaradzic-microsoft marked this conversation as resolved.
foreach(_browser_exe "msedge.exe" "chrome.exe")
if(ANGLE_LIBEGL)
break()
endif()
foreach(_reg_root "HKLM" "HKCU")
if(ANGLE_LIBEGL)
break()
endif()
execute_process(
COMMAND reg query "${_reg_root}\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\${_browser_exe}" /ve
OUTPUT_VARIABLE _reg_output
ERROR_QUIET
RESULT_VARIABLE _reg_result
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT _reg_result EQUAL 0)
continue()
endif()
string(REGEX MATCH "REG_SZ[ \t]+([^\r\n]+)" _ "${_reg_output}")
string(STRIP "${CMAKE_MATCH_1}" _browser_path)
if(NOT _browser_path)
continue()
endif()
cmake_path(GET _browser_path PARENT_PATH _browser_dir)
file(GLOB _version_dirs LIST_DIRECTORIES true "${_browser_dir}/[0-9]*")
list(SORT _version_dirs ORDER DESCENDING)
foreach(_version_dir ${_version_dirs})
if(IS_DIRECTORY "${_version_dir}" AND EXISTS "${_version_dir}/libEGL.dll")
set(ANGLE_LIBEGL "${_version_dir}/libEGL.dll")
set(ANGLE_LIBGLESV2 "${_version_dir}/libGLESv2.dll")
message(STATUS "Found ANGLE libraries in: ${_version_dir}")
break()
endif()
endforeach()
endforeach()
endforeach()

if(NOT ANGLE_LIBEGL)
message(FATAL_ERROR "OpenGLWindowsDevOnly requires ANGLE libraries (libEGL.dll, libGLESv2.dll) from Edge or Chrome, but none were found.")
endif()
endif()

if(APPLE)
set(BABYLON_NATIVE_PLATFORM_IMPL_EXT "mm")
else()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#pragma once

#include <EGL/egl.h>

namespace Babylon::Graphics
{
using DeviceT = EGLContext;
using DeviceT = void*;
using TextureT = unsigned int;
using TextureFormatT = unsigned int;

Expand Down
Loading