Skip to content
Open
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
11 changes: 9 additions & 2 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
- name: Install macOS packages
if: ${{ startsWith(matrix.platform.name, 'macOS') }}
run: |
brew install ccache cmake sdl2 lzo libogg libvorbis theora openal-soft jpeg-turbo
brew install ccache cmake dylibbundler sdl2 lzo libogg libvorbis theora openal-soft jpeg-turbo

- name: Install Fedora packages
if: ${{ matrix.platform.name == 'Fedora' }}
Expand Down Expand Up @@ -187,6 +187,13 @@ jobs:
if: ${{ startsWith(matrix.platform.name, 'macOS') }}
run: ccache -s || true

- name: Make macOS app bundle
if: ${{ startsWith(matrix.platform.name, 'macOS') && matrix.configuration == 'Release' && steps.cmake-build.outcome == 'success' }}
id: make-macos-app-bundle
run: |
bash misc/macos/make_app_bundle.sh "${{ matrix.platform.arch }}" "${{ matrix.configuration }}"
file build/artifacts/openxray*.*

# TODO: Merge this step with 'Make AppImage' once we switch to CMake 4.2 which directly supports AppImage generation with CPack
# https://cmake.org/cmake/help/latest/cpack_gen/appimage.html
- name: Make package
Expand All @@ -209,7 +216,7 @@ jobs:
file build/artifacts/openxray*.*

- name: Upload OpenXRay artifact
if: ${{ steps.make-package.outcome == 'success' || steps.make-appimage.outcome == 'success' }}
if: ${{ steps.make-package.outcome == 'success' || steps.make-appimage.outcome == 'success' || steps.make-macos-app-bundle.outcome == 'success' }}
uses: actions/upload-artifact@main
with:
name: ${{ matrix.platform.name }} ${{ matrix.configuration }} ${{ matrix.platform.arch }} (${{ matrix.platform.cc }} github-${{ github.run_number }})
Expand Down
24 changes: 22 additions & 2 deletions cmake/XRay.Compiler.GNULike.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,28 @@ if (APPLE)
if ($ENV{MACOSX_DEPLOYMENT_TARGET})
set(CMAKE_OSX_DEPLOYMENT_TARGET $ENV{MACOSX_DEPLOYMENT_TARGET})
else()
message(NOTICE "CMAKE_OSX_DEPLOYMENT_TARGET is not set, defaulting it to your system's version: ${CMAKE_SYSTEM_VERSION}")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_SYSTEM_VERSION})
execute_process(
COMMAND sw_vers -productVersion
OUTPUT_VARIABLE XRAY_MACOS_PRODUCT_VERSION
RESULT_VARIABLE XRAY_SW_VERS_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

if (XRAY_SW_VERS_RESULT STREQUAL "0" AND XRAY_MACOS_PRODUCT_VERSION MATCHES "^([0-9]+)")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}.0")
message(NOTICE "CMAKE_OSX_DEPLOYMENT_TARGET is not set, defaulting it to macOS ${CMAKE_OSX_DEPLOYMENT_TARGET}")
elseif (CMAKE_SYSTEM_VERSION MATCHES "^([0-9]+)")
set(XRAY_DARWIN_VERSION_MAJOR "${CMAKE_MATCH_1}")
if (XRAY_DARWIN_VERSION_MAJOR GREATER_EQUAL 20)
math(EXPR XRAY_MACOS_VERSION_MAJOR "${XRAY_DARWIN_VERSION_MAJOR} - 9")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${XRAY_MACOS_VERSION_MAJOR}.0")
message(NOTICE "CMAKE_OSX_DEPLOYMENT_TARGET is not set, defaulting it to macOS ${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
message(NOTICE "CMAKE_OSX_DEPLOYMENT_TARGET is not set, defaulting it to 10.15")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
endif()
endif()
endif()
endif()
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
Expand Down
134 changes: 134 additions & 0 deletions misc/macos/make_app_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -lt 2 ]]; then
echo "Usage: $0 <arch> <configuration>"
exit 1
fi

ARCH="$1"
CONFIGURATION="$2"
SKIP_DMG="${OPENXRAY_SKIP_DMG:-0}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
BIN_DIR="${ROOT_DIR}/bin/${ARCH}/${CONFIGURATION}"
ARTIFACTS_DIR="${ROOT_DIR}/build/artifacts"

APP_DIR="${ARTIFACTS_DIR}/OpenXRay.app"
CONTENTS_DIR="${APP_DIR}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
LIBS_DIR="${CONTENTS_DIR}/libs"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
OXR_RES_DIR="${RESOURCES_DIR}/openxray"

if [[ ! -x "${BIN_DIR}/xr_3da" ]]; then
echo "Cannot find executable: ${BIN_DIR}/xr_3da"
exit 1
fi

required_tools=(install_name_tool dylibbundler ditto)
if [[ "${SKIP_DMG}" != "1" ]]; then
required_tools+=(hdiutil)
fi

for tool in "${required_tools[@]}"; do
if ! command -v "${tool}" >/dev/null 2>&1; then
echo "Required tool is missing: ${tool}"
exit 1
fi
done

mkdir -p "${ARTIFACTS_DIR}"
rm -rf "${APP_DIR}"
mkdir -p "${MACOS_DIR}" "${LIBS_DIR}" "${OXR_RES_DIR}"

cat > "${CONTENTS_DIR}/Info.plist" <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>OpenXRay</string>
<key>CFBundleDisplayName</key>
<string>OpenXRay</string>
<key>CFBundleIdentifier</key>
<string>org.openxray.xray-16</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>xr_3da</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST

printf 'APPL????' > "${CONTENTS_DIR}/PkgInfo"

cp "${BIN_DIR}/xr_3da" "${MACOS_DIR}/xr_3da"
chmod +x "${MACOS_DIR}/xr_3da"

find "${BIN_DIR}" -maxdepth 1 -type f -name '*.dylib' -exec cp {} "${LIBS_DIR}/" \;

# Bundle only open-source engine resources from this repository.
cp "${ROOT_DIR}/res/fsgame.ltx" "${OXR_RES_DIR}/fsgame.ltx"
cp -R "${ROOT_DIR}/res/gamedata" "${OXR_RES_DIR}/gamedata"

# Bundle non-system dynamic libraries (Homebrew deps etc.).
dylibbundler \
-of -cd -b \
-x "${MACOS_DIR}/xr_3da" \
-d "${LIBS_DIR}" \
-s "${BIN_DIR}" \
-s "${LIBS_DIR}"

reset_rpaths() {
local binary="$1"

while install_name_tool -delete_rpath "@executable_path/../libs" "${binary}" >/dev/null 2>&1; do
:
done
while install_name_tool -delete_rpath "@executable_path/../libs/" "${binary}" >/dev/null 2>&1; do
:
done

install_name_tool -add_rpath "@executable_path/../libs" "${binary}"
codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - "${binary}" >/dev/null
}

# dylibbundler may leave duplicate LC_RPATH commands, which dyld rejects on newer macOS.
reset_rpaths "${MACOS_DIR}/xr_3da"
for lib in "${LIBS_DIR}"/*.dylib; do
[[ -e "${lib}" ]] || continue
reset_rpaths "${lib}"
done

codesign --force --deep --sign - "${APP_DIR}" >/dev/null

APP_ZIP="${ARTIFACTS_DIR}/openxray-${CONFIGURATION}-${ARCH}.app.zip"
DMG_PATH="${ARTIFACTS_DIR}/openxray-${CONFIGURATION}-${ARCH}.dmg"
DMG_ROOT="${ARTIFACTS_DIR}/dmg-root"

rm -f "${APP_ZIP}" "${DMG_PATH}"
ditto -c -k --sequesterRsrc --keepParent "${APP_DIR}" "${APP_ZIP}"

echo "Created:"
echo " ${APP_ZIP}"
if [[ "${SKIP_DMG}" == "1" ]]; then
echo "Skipped DMG creation (OPENXRAY_SKIP_DMG=1)"
else
rm -rf "${DMG_ROOT}"
mkdir -p "${DMG_ROOT}"
ditto "${APP_DIR}" "${DMG_ROOT}/OpenXRay.app"
ln -s /Applications "${DMG_ROOT}/Applications"
hdiutil create -volname "OpenXRay ${CONFIGURATION} ${ARCH}" -srcfolder "${DMG_ROOT}" -format UDZO -ov "${DMG_PATH}"
rm -rf "${DMG_ROOT}"
echo " ${DMG_PATH}"
fi
16 changes: 15 additions & 1 deletion src/Layers/xrRenderGL/glSH_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

namespace xray::render::RENDER_NAMESPACE
{
namespace
{
void ClearGLErrors()
{
while (glGetError() != GL_NO_ERROR)
{
}
}
} // namespace

void resptrcode_texture::create(LPCSTR _name)
{
_set(RImplementation.Resources->_CreateTexture(_name));
Expand Down Expand Up @@ -196,14 +206,18 @@ void CTexture::Load()
u32 _w = pTheora->Width(false);
u32 _h = pTheora->Height(false);

ClearGLErrors();

glGenBuffers(1, &pBuffer);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pBuffer);
CHK_GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, flags.MemoryUsage, nullptr, GL_STREAM_DRAW));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

glGenTextures(1, &pTexture);
glBindTexture(GL_TEXTURE_2D, pTexture);
CHK_GL(glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, _w, _h));
CHK_GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0));
CHK_GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0));
CHK_GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, _w, _h, 0, GL_BGRA, GL_UNSIGNED_BYTE, nullptr));

pSurface = pTexture;
desc = GL_TEXTURE_2D;
Expand Down
10 changes: 10 additions & 0 deletions src/xrEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ target_sources(xrEngine
TODO.txt
)

if (APPLE)
target_sources_grouped(
TARGET xrEngine
NAME "Platform\\macOS"
FILES
macos/GameDataResolver.cpp
macos/GameDataResolver.h
)
endif()

target_include_directories(xrEngine
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down
Loading
Loading