Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce multiple renderer support #73

Draft
wants to merge 14 commits into
base: unstable
Choose a base branch
from
24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Directories
## VS Editors
.vs/
.vscode/
ide/.kdev4/*
ide/build/*
ide/.cache/*
rte/bin/xyg
rte/bin/release/*
rte/obj/*

## Clangd Cache
*/.cache

## KDevelop
*/.kdev4/

# Files
*.o
*.dll
*.exe
## KDevelop
*.kdev4

## Brux Runtime Output
*/log.txt
log.txt

## IDE Meson User Files
ide/meson.build.user
rte/*.layout
rte/bin/brux
Expand Down
15 changes: 0 additions & 15 deletions .vscode/c_cpp_properties.json

This file was deleted.

76 changes: 0 additions & 76 deletions .vscode/settings.json

This file was deleted.

18 changes: 14 additions & 4 deletions docs/en/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,24 @@

* <a name="getAudioDriver"></a>**`getAudioDriver()`**

Deprecated alternate name for getAudioDriverName.

* <a name="getAudioDriverName"></a>**`getAudioDriverName()`**

Returns the name of the currently active audio driver.

If no audio driver is present, this will return the string `None`.

Note that `None` actually is an audio driver (see `src/audio/audio_none.cpp`), but it does not actually handle audio and is only used as a fallback.
If no audio driver is present, this will return the string `Null`.

Note that `Null` actually is an audio driver (see `src/audio/backend/audio_null.cpp`), but it does not actually handle audio and is only used as a fallback.

* <a name="setAudioDriver"></a>**`setAudioDriver( kind )`**

> NOTE: This should only be run BEFORE loading files. Otherwise you lose audio completely!

Sets the audio driver to whatever value is specified. 0 is Null, 1 is SDL2.

* <a name="isAudioAvailable"></a>**`isAudioAvailable()`**

Checks if audio playback is currently available.

Note that this function's implementation currently does not check that the audio stack is working, it only checks that a real audio driver (not the fallback `None` driver, which doesn't actually handle audio) is present.
Note that this function's implementation currently does not check that the audio stack is working, it only checks that a real audio driver (not the fallback `Null` driver, which doesn't actually handle audio) is present.
38 changes: 26 additions & 12 deletions rte/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ project(brux)
set(CMAKE_CXX_STANDARD 17)

# Set initial variables

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(INSTALL_SUBDIR_BIN "/")

# Define options

option(BUILD_STATIC_LIBS "Link libraries statically whenever possible" OFF)

find_package(SDL2_mixer QUIET)

# Enable USE_SDL2_MIXER by default if SDL2_mixer is found
# Please don't disable this unless you have a specific reason to.
# fastfill is significantly faster than the original algorithm, as it's O(1) instead of O(n).

if (SDL2_mixer_FOUND)
option(USE_SDL2_MIXER "Use SDL2 to provide audio support" ON)
Expand Down Expand Up @@ -104,34 +103,49 @@ include_directories(${SDL2_INCLUDE_DIRS})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")

# Search for source files and copy the test suite to the output directory
file(GLOB SRCFILES src/audio/*.cpp
file(GLOB SRCFILES src/audio/audio.cpp src/audio/backend/audio_null.cpp src/video/video.cpp
src/brux/*.cpp
src/external/*.c)
add_executable(brux ${SRCFILES})
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/test/" DESTINATION "${RUNTIME_OUTPUT_DIR}")

if (USE_SDL2_MIXER)
add_library(brux_audio_sdl2 SHARED src/audio/backend/audio_sdl2.cpp)

if(WIN32)
target_link_libraries(brux_audio_sdl2 PUBLIC ${SDL2_MIXER_LIBRARIES})
else()
target_link_libraries(brux_audio_sdl2 PUBLIC SDL2::Mixer)
endif()
endif()

add_library(brux_video_sdl2 SHARED src/video/backend/video_sdl2.cpp)
if(WIN32)
target_link_libraries(brux_video_sdl2 PUBLIC ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_GFX_LIBRARIES})
else()
target_link_libraries(brux_video_sdl2 PUBLIC SDL2 SDL2::Image SDL2::GFX)
endif()

# Link libraries

if(WIN32) # FIXME: Proper way of having the SDL2 libraries copied over to binary on Windows?
target_link_libraries(brux PUBLIC ${SDL2_LIBRARIES})
target_link_libraries(brux PUBLIC ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(brux PUBLIC ${SDL2_GFX_LIBRARIES})

if (USE_SDL2_MIXER)
target_link_libraries(brux PUBLIC ${SDL2_MIXER_LIBRARIES})
endif()

target_link_libraries(brux PUBLIC simplesquirrel_static)
else()
target_link_libraries(brux PUBLIC SDL2)
target_link_libraries(brux PUBLIC SDL2::Image)
target_link_libraries(brux PUBLIC SDL2::GFX)

if (USE_SDL2_MIXER)
target_link_libraries(brux PUBLIC SDL2::Mixer)
endif()

target_link_libraries(brux PUBLIC simplesquirrel)
endif()

target_link_libraries(brux PUBLIC LibPhysfs)

if (USE_SDL2_MIXER)
target_link_libraries(brux PUBLIC brux_audio_sdl2)
endif()

target_link_libraries(brux PUBLIC brux_video_sdl2)
14 changes: 10 additions & 4 deletions rte/_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
git submodule update --init --recursive
mkdir build
cd build
cmake .. -DGENERATE_WRAPPER=ON
make

if [[ ! -d build ]]; then
mkdir build
cd build
cmake .. -DGENERATE_WRAPPER=ON
else
cd build
fi

cmake --build .
15 changes: 10 additions & 5 deletions rte/_buildrun.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
git submodule update --init --recursive
mkdir build
cd build
cmake .. -DGENERATE_WRAPPER=ON
make
./brux

if [[ ! -d build ]]; then
mkdir build
cd build
cmake .. -DGENERATE_WRAPPER=ON
else
cd build
fi

cmake --build . && ./brux
Loading