mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-28 16:58:57 +08:00
Merge pull request #36 from benjitrosch/remove-platform-abstraction
remove platform abstraction layer
This commit is contained in:
commit
176b11e08e
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -34,7 +34,7 @@ jobs:
|
||||||
|
|
||||||
- name: Create binary directory
|
- name: Create binary directory
|
||||||
run: |
|
run: |
|
||||||
cmake -B build -DBLAH_PLATFORM_WIN32=OFF -DBLAH_PLATFORM_SDL2=ON
|
cmake -B build
|
||||||
- name: Build project binary
|
- name: Build project binary
|
||||||
run: |
|
run: |
|
||||||
cmake --build build --config Release
|
cmake --build build --config Release
|
||||||
|
|
|
@ -25,8 +25,7 @@ add_library(blah
|
||||||
src/blah_audio.cpp
|
src/blah_audio.cpp
|
||||||
src/internal/blah_renderer_opengl.cpp
|
src/internal/blah_renderer_opengl.cpp
|
||||||
src/internal/blah_renderer_d3d11.cpp
|
src/internal/blah_renderer_d3d11.cpp
|
||||||
src/internal/blah_platform_sdl2.cpp
|
src/internal/blah_platform.cpp
|
||||||
src/internal/blah_platform_win32.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(blah
|
target_include_directories(blah
|
||||||
|
@ -37,8 +36,6 @@ target_include_directories(blah
|
||||||
)
|
)
|
||||||
|
|
||||||
# Platform Variables
|
# Platform Variables
|
||||||
option(BLAH_PLATFORM_SDL2 "Use SDL2 Platform Backend" ON)
|
|
||||||
option(BLAH_PLATFORM_WIN32 "Use Win32 Platform Backend" OFF)
|
|
||||||
option(BLAH_RENDERER_OPENGL "Make OpenGL Renderer available" ON)
|
option(BLAH_RENDERER_OPENGL "Make OpenGL Renderer available" ON)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(BLAH_RENDERER_D3D11 "Make D3D11 Renderer available" ON)
|
option(BLAH_RENDERER_D3D11 "Make D3D11 Renderer available" ON)
|
||||||
|
@ -61,44 +58,32 @@ if (BLAH_RENDERER_D3D11)
|
||||||
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# use the SDL2 Platform Backend
|
# Emscripten can import SDL2 directly
|
||||||
# Link and create SDL2 Definition
|
if (EMSCRIPTEN)
|
||||||
if (BLAH_PLATFORM_SDL2)
|
|
||||||
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
|
||||||
|
|
||||||
# Emscripten can import SDL2 directly
|
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
||||||
if (EMSCRIPTEN)
|
target_link_libraries(blah "-s USE_SDL=2 -s USE_WEBGL2=1")
|
||||||
|
|
||||||
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
# Pull SDL2 from its Github repo
|
||||||
target_link_libraries(blah "-s USE_SDL=2 -s USE_WEBGL2=1")
|
else()
|
||||||
|
if (NOT DEFINED BLAH_SDL2_LIBS)
|
||||||
|
include(FetchContent)
|
||||||
|
set(FETCHCONTENT_QUIET FALSE)
|
||||||
|
|
||||||
# Pull SDL2 from its Github repo
|
FetchContent_Declare(
|
||||||
else()
|
SDL2
|
||||||
if (NOT DEFINED BLAH_SDL2_LIBS)
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
||||||
include(FetchContent)
|
GIT_TAG release-2.26.0 # grab latest stable release
|
||||||
set(FETCHCONTENT_QUIET FALSE)
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
FetchContent_Declare(
|
FetchContent_MakeAvailable(SDL2)
|
||||||
SDL2
|
set(BLAH_SDL2_LIBS SDL2main SDL2-static)
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
set(BLAH_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
|
||||||
GIT_TAG release-2.26.0 # grab latest stable release
|
|
||||||
GIT_PROGRESS TRUE
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(SDL2)
|
|
||||||
set(BLAH_SDL2_LIBS SDL2main SDL2-static)
|
|
||||||
set(BLAH_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# statically link SDL2 since we're building it ourselves
|
|
||||||
set(LIBS ${LIBS} ${BLAH_SDL2_LIBS})
|
|
||||||
target_include_directories(blah PRIVATE ${BLAH_SDL2_INCLUDE})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# use the Win32 Platform Backend
|
# statically link SDL2 since we're building it ourselves
|
||||||
elseif (BLAH_PLATFORM_WIN32)
|
set(LIBS ${LIBS} ${BLAH_SDL2_LIBS})
|
||||||
|
target_include_directories(blah PRIVATE ${BLAH_SDL2_INCLUDE})
|
||||||
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(blah PRIVATE ${LIBS})
|
target_link_libraries(blah PRIVATE ${LIBS})
|
||||||
|
|
|
@ -39,10 +39,6 @@ int main()
|
||||||
|
|
||||||
#### building
|
#### building
|
||||||
- Requires C++17 and CMake 3.14+
|
- Requires C++17 and CMake 3.14+
|
||||||
- A single **Platform** implementation must be enabled in CMake:
|
|
||||||
- [SDL2](https://github.com/NoelFB/blah/blob/master/src/internal/platform_sdl2.cpp) (Default) `BLAH_PLATFORM_SDL2`
|
|
||||||
- [WIN32](https://github.com/NoelFB/blah/blob/master/src/internal/platform_win32.cpp) (Unfinished) `BLAH_PLATFORM_WIN32`
|
|
||||||
- Additional platforms can be added by implementing the [Platform Backend](https://github.com/NoelFB/blah/blob/master/src/internal/platform.h)
|
|
||||||
- At least one **Renderer** implementation must be enabled in CMake:
|
- At least one **Renderer** implementation must be enabled in CMake:
|
||||||
- [OpenGL](https://github.com/NoelFB/blah/blob/master/src/internal/renderer_gl.cpp) (Default on Linux/macOS) `BLAH_RENDERER_OPENGL`
|
- [OpenGL](https://github.com/NoelFB/blah/blob/master/src/internal/renderer_gl.cpp) (Default on Linux/macOS) `BLAH_RENDERER_OPENGL`
|
||||||
- [D3D11](https://github.com/NoelFB/blah/blob/master/src/internal/renderer_d3d11.cpp) (Default on Windows) `BLAH_RENDERER_D3D11`
|
- [D3D11](https://github.com/NoelFB/blah/blob/master/src/internal/renderer_d3d11.cpp) (Default on Windows) `BLAH_RENDERER_D3D11`
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
#define STB_VORBIS_HEADER_ONLY
|
#define STB_VORBIS_HEADER_ONLY
|
||||||
#include "third_party/stb_vorbis.c"
|
#include "third_party/stb_vorbis.c"
|
||||||
|
|
||||||
#ifdef BLAH_PLATFORM_SDL2
|
|
||||||
#define CUTE_SOUND_FORCE_SDL
|
#define CUTE_SOUND_FORCE_SDL
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CUTE_SOUND_IMPLEMENTATION
|
#define CUTE_SOUND_IMPLEMENTATION
|
||||||
#define CUTE_SOUND_SCALAR_MODE
|
#define CUTE_SOUND_SCALAR_MODE
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#ifdef BLAH_PLATFORM_SDL2
|
|
||||||
|
|
||||||
#include "blah_platform.h"
|
#include "blah_platform.h"
|
||||||
#include "blah_renderer.h"
|
#include "blah_renderer.h"
|
||||||
#include "blah_internal.h"
|
#include "blah_internal.h"
|
||||||
|
@ -618,5 +616,3 @@ void Platform::open_url(const char* url)
|
||||||
{
|
{
|
||||||
SDL_OpenURL(url);
|
SDL_OpenURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BLAH_PLATFORM_SDL2
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user