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
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ jobs:
case:
- { name: 'Windows (DirectX 9)', os: 'windows-latest', platform: 'D3D9' }
- { name: 'Windows (GL3, glfw)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'GLFW' }
- { name: 'Windows (GL3, SDL2)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'SDL2' }
- { name: 'Windows (GL3, SDL2)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'SDL2', sdl-version: '2-latest' }
- { name: 'Windows (GL3, SDL3)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'SDL3', sdl-version: '3-latest' }
- { name: 'Windows (null)', os: 'windows-latest', platform: 'NULL' }
- { name: 'macOS (GL3, glfw)', os: 'macos-latest', platform: 'GL3', gl3_gfxlib: 'GLFW' }
- { name: 'macOS (GL3, SDL2)', os: 'macos-latest', platform: 'GL3', gl3_gfxlib: 'SDL2' }
- { name: 'macOS (GL3, SDL2)', os: 'macos-latest', platform: 'GL3', gl3_gfxlib: 'SDL2', sdl-version: '2-latest' }
- { name: 'macOS (GL3, SDL3)', os: 'macos-latest', platform: 'GL3', gl3_gfxlib: 'SDL3', sdl-version: '3-latest' }
- { name: 'macOS (null)', os: 'macos-latest', platform: 'NULL' }
- { name: 'Ubuntu (GL3, glfw)', os: 'ubuntu-latest', platform: 'GL3', gl3_gfxlib: 'GLFW' }
- { name: 'Ubuntu (GL3, SDL2)', os: 'ubuntu-latest', platform: 'GL3', gl3_gfxlib: 'SDL2' }
- { name: 'Ubuntu (GL3, SDL2)', os: 'ubuntu-latest', platform: 'GL3', gl3_gfxlib: 'SDL2', sdl-version: '2-latest' }
- { name: 'Ubuntu (null)', os: 'ubuntu-latest', platform: 'NULL' }
- { name: 'PlayStation 2', os: 'ubuntu-latest', platform: 'PS2', ps2: true, container: 'ps2dev/ps2dev:latest', cmake-toolchain-file: 'cmake/ps2/cmaketoolchain/toolchain_ps2_ee.cmake' }
- { name: 'Nintendo Switch', os: 'ubuntu-latest', platform: 'GL3', gl3_gfxlib: 'GLFW', glfw-nobuild: true, container: 'devkitpro/devkita64:latest', cmake-toolchain-file: '/opt/devkitpro/cmake/Switch.cmake' }
Expand All @@ -36,11 +38,11 @@ jobs:
if: ${{ matrix.case.ps2 }}
run: |
apk add cmake gmp mpc1 mpfr4 make pkgconf git
- name: 'Setup SDL2'
if: ${{ matrix.case.gl3_gfxlib == 'SDL2' }}
- name: 'Setup SDL'
if: ${{ !!matrix.case.sdl-version }}
uses: libsdl-org/setup-sdl@main
with:
version: 2-latest
version: ${{ matrix.case.sdl-version }}
install-linux-dependencies: true
cmake-toolchain-file: ${{ matrix.case.cmake-toolchain-file }}
- name: 'Setup GLFW'
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if(NOT LIBRW_PLATFORM IN_LIST LIBRW_PLATFORMS)
endif()

if(LIBRW_PLATFORM_GL3)
set(LIBRW_GL3_GFXLIBS "GLFW" "SDL2")
set(LIBRW_GL3_GFXLIBS "GLFW" "SDL2" "SDL3")
set(LIBRW_GL3_GFXLIB "GLFW" CACHE STRING "gfxlib for gl3 (choices=${LIBRW_GL3_GFXLIBS})")
set_property(CACHE LIBRW_GL3_GFXLIB PROPERTY STRINGS ${LIBRW_GL3_GFXLIBS})
if(LIBRW_PLATFORM_GL3)
Expand Down Expand Up @@ -91,6 +91,7 @@ if(LIBRW_INSTALL)
EXPORT librw-targets NAMESPACE librw::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
export(TARGETS librw NAMESPACE librw:: FILE librw-targets.cmake)

if(LIBRW_GL3_GFXLIB STREQUAL "SDL2")
install(
Expand Down Expand Up @@ -126,8 +127,10 @@ if(LIBRW_INSTALL)
elseif(LIBRW_PLATFORM_GL3)
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
set(platform "-gl3-glfw")
else()
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")
set(platform "-gl3-sdl2")
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL3")
set(platform "-gl3-sdl3")
endif()
elseif(LIBRW_PLATFORM_D3D9)
set(platform "-d3d9")
Expand Down
11 changes: 8 additions & 3 deletions cmake/librw-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ if(LIBRW_PLATFORM_GL3)
message(FATAL_ERROR "find_package(OpenGL) failed: no target was created")
endif()

include(CMakeFindDependencyMacro)
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
if (NOT TARGET glfw)
find_package(glfw3 REQUIRED)
find_dependency(glfw3 REQUIRED)
endif()
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")
if (NOT TARGET SDL2::SDL2)
find_package(SDL2 CONFIG)
find_dependency(SDL2 CONFIG)
if (NOT TARGET SDL2::SDL2)
find_package(SDL2 MODULE REQUIRED)
find_dependency(SDL2 MODULE REQUIRED)
endif()
endif()
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL3")
if (NOT TARGET SDL3::SDL3)
find_dependency(SDL3 CONFIG REQUIRED)
endif()
endif()
endif()
24 changes: 21 additions & 3 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ newoption {
allowed = {
{ "glfw", "GLFW" },
{ "sdl2", "SDL2" },
{ "sdl3", "SDL3" },
},
}

Expand All @@ -27,7 +28,14 @@ newoption {
trigger = "sdl2dir",
value = "PATH",
description = "Directory of sdl2",
default = "../SDL2-2.0.14",
default = "../SDL2-2.32.10",
}

newoption {
trigger = "sdl3dir",
value = "PATH",
description = "Directory of sdl3",
default = "../SDL3-3.2.22",
}

workspace "librw"
Expand Down Expand Up @@ -64,6 +72,10 @@ workspace "librw"
defines { "RW_GL3" }
if _OPTIONS["gfxlib"] == "sdl2" then
defines { "LIBRW_SDL2" }
elseif _OPTIONS["gfxlib"] == "sdl3" then
defines { "LIBRW_SDL3" }
elseif _OPTIONS["gfxlib"] == "glfw" then
defines { "LIBRW_GLFW" }
end
filter { "platforms:*d3d9" }
defines { "RW_D3D9" }
Expand Down Expand Up @@ -131,21 +143,27 @@ function findlibs()
links { "GL" }
if _OPTIONS["gfxlib"] == "glfw" then
links { "glfw" }
else
elseif _OPTIONS["gfxlib"] == "sdl2" then
links { "SDL2" }
elseif _OPTIONS["gfxlib"] == "sdl3" then
links { "SDL3" }
end
filter { "platforms:win-amd64-gl3" }
libdirs { path.join(_OPTIONS["glfwdir64"], "lib-vc2015") }
libdirs { path.join(_OPTIONS["sdl2dir"], "lib/x64") }
libdirs { path.join(_OPTIONS["sdl3dir"], "lib/x64") }
filter { "platforms:win-x86-gl3" }
libdirs { path.join(_OPTIONS["glfwdir32"], "lib-vc2015") }
libdirs { path.join(_OPTIONS["sdl2dir"], "lib/x86") }
libdirs { path.join(_OPTIONS["sdl3dir"], "lib/x86") }
filter { "platforms:win*gl3" }
links { "opengl32" }
if _OPTIONS["gfxlib"] == "glfw" then
links { "glfw3" }
else
elseif _OPTIONS["gfxlib"] == "sdl2" then
links { "SDL2" }
elseif _OPTIONS["gfxlib"] == "sdl3" then
links { "SDL3" }
end
filter { "platforms:*d3d9" }
links { "gdi32", "d3d9" }
Expand Down
3 changes: 2 additions & 1 deletion skeleton/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_library(librw_skeleton
glfw.cpp
sdl2.cpp
sdl3.cpp
skeleton.cpp
skeleton.h
win.cpp
Expand Down Expand Up @@ -38,7 +39,7 @@ target_link_libraries(librw_skeleton
librw
)

if (LIBRW_GL3_GFXLIB STREQUAL "SDL2")
if (LIBRW_GL3_GFXLIB MATCHES "SDL[23]")
target_compile_definitions(librw_skeleton PRIVATE SDL_MAIN_HANDLED)
endif()

Expand Down
2 changes: 1 addition & 1 deletion skeleton/glfw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef LIBRW_SDL2
#ifdef LIBRW_GLFW

#include <rw.h>
#include "skeleton.h"
Expand Down
Loading
Loading