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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ else()
GLAD::GLAD
harfbuzz::harfbuzz
PNG::PNG
WebP::webp
WebP::webpdemux
WebP::libwebpmux
WebP::webpdecoder
WebP::webp
yoga::yogacore
RIVE::rive
RIVE::renderer
Expand Down
152 changes: 119 additions & 33 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,139 @@
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "debug",
"inherits": "base",
"displayName": "Debug Build",
"description": "Configure for Debug with vcpkg",
"generator": "Ninja",
"description": "Configure for Debug (platform auto)",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"inherits": "base",
"displayName": "Release Build",
"description": "Configure for Release with vcpkg",
"generator": "Ninja",
"description": "Configure for Release (platform auto)",
"binaryDir": "${sourceDir}/build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"CMAKE_BUILD_TYPE": "Release"
}
},

{
"name": "debug-macos",
"displayName": "Debug Build (arm64 macOS)",
"inherits": "debug",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-osx"
}
},
{
"name": "release-macos",
"displayName": "Release Build (arm64 macOS)",
"inherits": "release",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-osx"
}
},
{
"name": "debug-x64-macos",
"displayName": "Debug Build (x64 macOS)",
"inherits": "debug",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-osx"
}
},
{
"name": "release-x64-macos",
"displayName": "Release Build (x64 macOS)",
"inherits": "release",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-osx"
}
},

{
"name": "debug-windows",
"inherits": "debug",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "release-windows",
"inherits": "release",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "debug-linux",
"inherits": "debug",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
},
{
"name": "release-linux",
"inherits": "release",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
},
{
"name": "web-debug",
"inherits": "base",
"displayName": "Web Debug Build",
"description": "Configure for WebAssembly Debug with Emscripten",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/web_debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "wasm32-emscripten",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"CMAKE_CROSSCOMPILING_EMULATOR": "$env{EMSDK}/node/22.16.0_64bit/bin/node",
"EMSCRIPTEN": "ON"
},
"environment": {
Expand All @@ -48,16 +143,13 @@
},
{
"name": "web-release",
"inherits": "base",
"displayName": "Web Release Build",
"description": "Configure for WebAssembly Release with Emscripten",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/web_release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "wasm32-emscripten",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"CMAKE_CROSSCOMPILING_EMULATOR": "$env{EMSDK}/node/22.16.0_64bit/bin/node",
"EMSCRIPTEN": "ON"
},
"environment": {
Expand All @@ -66,21 +158,15 @@
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
},
{
"name": "web-debug",
"configurePreset": "web-debug"
},
{
"name": "web-release",
"configurePreset": "web-release"
}
{ "name": "debug-macos", "configurePreset": "debug-macos" },
{ "name": "release-macos", "configurePreset": "release-macos" },
{ "name": "debug-x64-macos", "configurePreset": "debug-x64-macos" },
{ "name": "release-x64-macos", "configurePreset": "release-x64-macos" },
{ "name": "debug-windows", "configurePreset": "debug-windows" },
{ "name": "release-windows", "configurePreset": "release-windows" },
{ "name": "debug-linux", "configurePreset": "debug-linux" },
{ "name": "release-linux", "configurePreset": "release-linux" },
{ "name": "web-debug", "configurePreset": "web-debug" },
{ "name": "web-release", "configurePreset": "web-release" }
]
}
36 changes: 28 additions & 8 deletions cmake/FindRIVE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ elseif(UNIX)
set(RIVE_PLATFORM_NAME "linux")
endif()

# Function to collect source files (RESTORE the original filtering logic)
# Function to collect source files
function(_rive_collect_sources base_path output_var)
file(GLOB_RECURSE all_sources
"${base_path}/*.cpp"
Expand Down Expand Up @@ -125,6 +125,17 @@ function(_rive_collect_sources base_path output_var)
set(include_file FALSE)
endif()

# Filter out D3D files for Windows when using OpenGL
if(RIVE_PLATFORM_WINDOWS AND source MATCHES "/d3d/")
set(include_file FALSE)
endif()
if(RIVE_PLATFORM_WINDOWS AND source MATCHES "/d3d11/")
set(include_file FALSE)
endif()
if(RIVE_PLATFORM_WINDOWS AND source MATCHES "/d3d12/")
set(include_file FALSE)
endif()

if(include_file)
list(APPEND filtered_sources ${source})
endif()
Expand Down Expand Up @@ -241,7 +252,12 @@ if(NOT TARGET RIVE::decoders)

if(WebP_FOUND)
target_compile_definitions(RIVE_decoders PUBLIC RIVE_WEBP=1)
target_link_libraries(RIVE_decoders PUBLIC WebP::webp)
target_link_libraries(RIVE_decoders PUBLIC
WebP::webpdemux
WebP::libwebpmux
WebP::webpdecoder
WebP::webp
)
endif()

# Platform-specific settings
Expand All @@ -259,7 +275,7 @@ if(NOT TARGET RIVE::renderer)
# Rive Renderer - using YUP pattern with platform-specific files
set(rive_renderer_dir "${RIVE_THIRDPARTY_DIR}/rive_renderer")

# Use platform-specific source files (following YUP pattern exactly)
# Use platform-specific source files (following YUP module pattern)
set(rive_renderer_sources "")

# Common sources (always included)
Expand All @@ -270,6 +286,8 @@ if(NOT TARGET RIVE::renderer)
list(APPEND rive_renderer_sources "${rive_renderer_dir}/rive_renderer_emscripten.cpp")
elseif(RIVE_PLATFORM_WINDOWS)
list(APPEND rive_renderer_sources "${rive_renderer_dir}/rive_renderer_windows.cpp")
# Add missing WebGL implementation for Windows when using OpenGL
list(APPEND rive_renderer_sources "${rive_renderer_dir}/source/gl/pls_impl_webgl.cpp")
elseif(RIVE_PLATFORM_APPLE)
list(APPEND rive_renderer_sources "${rive_renderer_dir}/rive_renderer_apple.mm")
elseif(RIVE_PLATFORM_ANDROID)
Expand Down Expand Up @@ -303,11 +321,11 @@ if(NOT TARGET RIVE::renderer)
# Platform-specific defines (following YUP module pattern)
if(RIVE_PLATFORM_WEB)
target_compile_definitions(RIVE_renderer PUBLIC RIVE_WEBGL=1)
elseif(RIVE_PLATFORM_DESKTOP AND NOT RIVE_PLATFORM_APPLE)
# Enable OpenGL for non-Apple desktop platforms (Windows, Linux)
elseif(RIVE_PLATFORM_DESKTOP AND NOT RIVE_PLATFORM_APPLE)
target_compile_definitions(RIVE_renderer PUBLIC
RIVE_DESKTOP_GL=1
YUP_RIVE_USE_OPENGL=1
YUP_RIVE_USE_D3D=0
)

# GLAD dependency for desktop platforms
Expand All @@ -316,11 +334,12 @@ if(NOT TARGET RIVE::renderer)
target_link_libraries(RIVE_renderer PUBLIC GLAD::GLAD)
message(STATUS "Using GLAD::GLAD from FindGlad.cmake")
endif()
elseif(RIVE_PLATFORM_APPLE)
target_compile_definitions(RIVE_renderer PUBLIC YUP_RIVE_USE_METAL=1)
endif()

# Platform-specific frameworks and libraries (following YUP pattern)
if(RIVE_PLATFORM_APPLE)
target_compile_definitions(RIVE_renderer PUBLIC YUP_RIVE_USE_METAL=1)
target_link_libraries(RIVE_renderer PUBLIC
"-framework Metal"
"-framework QuartzCore"
Expand All @@ -332,8 +351,9 @@ if(NOT TARGET RIVE::renderer)
target_compile_definitions(RIVE_renderer PUBLIC RIVE_ANDROID=1)
target_link_libraries(RIVE_renderer PUBLIC EGL GLESv3)
elseif(RIVE_PLATFORM_WINDOWS)
target_compile_definitions(RIVE_renderer PUBLIC YUP_RIVE_USE_D3D=1)
target_link_libraries(RIVE_renderer PUBLIC d3d11 d3dcompiler dxgi)
# Remove D3D for now and use OpenGL
# target_compile_definitions(RIVE_renderer PUBLIC YUP_RIVE_USE_D3D=1)
# target_link_libraries(RIVE_renderer PUBLIC d3d11 d3dcompiler dxgi)
endif()

# Link dependencies
Expand Down
2 changes: 1 addition & 1 deletion src/opengl_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool OpenGLBackend::initialize(void* windowPtr, int width, int height)
#ifdef PLATFORM_WEB
SDL_Log("WebGL context created successfully");
#else
if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress))
if (!gladLoadCustomLoader((GLADloadproc)SDL_GL_GetProcAddress))
{
SDL_Log("Failed to initialize GLAD (OpenGL)");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef _RIVE_BITMAP_DECODER_HPP_
#define _RIVE_BITMAP_DECODER_HPP_

#include <cstdint>
#include <memory>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion third_party/rive_renderer/rive_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
#if YUP_RIVE_USE_OPENGL
#if __APPLE__ && !YUP_RIVE_USE_METAL && !YUP_RIVE_USE_DAWN
#error Must select at least one between YUP_RIVE_USE_METAL, YUP_RIVE_USE_OPENGL or YUP_RIVE_USE_DAWN
#elif _WIN32 && !YUP_RIVE_USE_D3D && !YUP_RIVE_USE_DAWN
#elif _WIN32 && !YUP_RIVE_USE_D3D && !YUP_RIVE_USE_DAWN && !YUP_RIVE_USE_OPENGL
#error Must select at least one between YUP_RIVE_USE_D3D, YUP_RIVE_USE_OPENGL or YUP_RIVE_USE_DAWN
#endif

Expand Down