mirror of
https://github.com/haya3218/SDfmL.git
synced 2024-08-14 23:57:09 +00:00
Update shit
STILL NOT FOR USE!
This commit is contained in:
parent
25b1051e92
commit
18bf427dc3
3 changed files with 77 additions and 42 deletions
|
@ -6,15 +6,14 @@ project(Skateboard)
|
|||
|
||||
# SDL2 include directories
|
||||
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/")
|
||||
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/BASS/")
|
||||
set(BASS_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/BASS/BASS/")
|
||||
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/")
|
||||
|
||||
# Support both 32 and 64 bit builds
|
||||
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
set(MAIN_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2main.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2_image.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2_ttf.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/bass.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/bass_fx.lib")
|
||||
set(MAIN_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2main.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2_image.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2_ttf.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/soloud_static_x64.lib")
|
||||
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x64/")
|
||||
else ()
|
||||
set(MAIN_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2main.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2_image.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2_ttf.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/bass.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/bass_fx.lib")
|
||||
set(MAIN_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2main.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2_image.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2_ttf.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/soloud_static_x86.lib")
|
||||
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x86/")
|
||||
endif ()
|
||||
|
||||
|
@ -24,7 +23,6 @@ string(STRIP "${MAIN_LIBRARIES}" MAIN_LIBRARIES)
|
|||
# Include the damn directories
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
include_directories(${OUT_INCLUDE_DIRS})
|
||||
include_directories(${BASS_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
|
||||
# add EVERY FUCKING source file to SOURCES
|
||||
|
@ -34,10 +32,42 @@ FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
|||
"${CMAKE_CURRENT_LIST_DIR}/src/*.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.c"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_out.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_fx.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_out.cc"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_fx.cc")
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_audiosource.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_bassboostfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_biquadresonantfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_bus.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_c.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_dcremovalfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_echofilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_error.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_fader.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_fft.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_fftfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_file_hack_off.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_file_hack_on.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_file.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_filter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_flangerfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_freeverbfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_internal.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_lofifilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_misc.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_monotone.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_noise.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_openmpt.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_queue.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_robotizefilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_sfxr.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_speech.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_tedsid.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_thread.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_vic.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_vizsn.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_wav.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_waveshaperfilter.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_wavstream.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud.h"
|
||||
)
|
||||
|
||||
# set c++ std to 17
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
@ -70,7 +100,7 @@ file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2_image.lib")
|
|||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2_ttf.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2main.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2test.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/bass.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/bass_fx.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/soloud_x64.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/soloud_x86.lib")
|
||||
|
||||
# :)
|
|
@ -10,6 +10,9 @@
|
|||
#include "SDL2/SDL_ttf.h"
|
||||
#include "Render.hpp"
|
||||
#include "SDL2/SDL_syswm.h"
|
||||
#include "SoLoud/soloud.h"
|
||||
#include "SoLoud/soloud_wav.h"
|
||||
#include "SoLoud/soloud_openmpt.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Render;
|
||||
|
@ -18,11 +21,14 @@ SDL_Window* Render::window;
|
|||
SDL_Renderer* Render::renderer;
|
||||
SDL_Event Render::event;
|
||||
State* Render::current_state = nullptr;
|
||||
array<anshub::AudioOut, MAX_SE> Render::audioArray;
|
||||
anshub::AudioOut Render::music;
|
||||
SoLoud::Soloud Render::music;
|
||||
SoLoud::Soloud Render::se;
|
||||
SoLoud::Wav Render::waveLoader;
|
||||
SoLoud::Openmpt Render::modLoader;
|
||||
string Render::currentMusic = "";
|
||||
HWND Render::hwnd;
|
||||
HWND Render::consoleD;
|
||||
int Render::seIndex;
|
||||
|
||||
Render::Object::Object() {
|
||||
|
||||
|
@ -184,11 +190,15 @@ void Render::Object::centerSelf(AXIS axis) {
|
|||
bool Render::Init(string window_name) {
|
||||
consoleD = GetConsoleWindow();
|
||||
SetWindowTextA(consoleD, "Logging window");
|
||||
if (!BASS_Init(1, 44100, BASS_DEVICE_8BITS|BASS_DEVICE_REINIT, 0, NULL)) {
|
||||
cout << "BASS has failed to initialize. Is your dll broken? <NO ERROR>" << endl;
|
||||
if (se.init() > 0) {
|
||||
cout << "SoLoud has failed to load. Is your dll broken?" << endl;
|
||||
return false;
|
||||
}
|
||||
cout << "Successfully initialized the BASS audio system. Command next." << endl;
|
||||
if (music.init() > 0) {
|
||||
cout << "SoLoud has failed to load. Is your dll broken?" << endl;
|
||||
return false;
|
||||
}
|
||||
cout << "Successfully initialized the SoLoud audio system. Command next." << endl;
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
|
||||
cout << "SDL has failed to initialize. Is your dll broken? " << SDL_GetError() << endl;
|
||||
return false;
|
||||
|
@ -323,34 +333,24 @@ void Render::SwitchState(State* state) {
|
|||
current_state->Create();
|
||||
}
|
||||
|
||||
bool Render::playSound(string path, int id) {
|
||||
if (id == NULL) {
|
||||
for (int i = 0; i < MAX_SE; i++) {
|
||||
if (audioArray[i].NowPlaying(false).size() == 0) {
|
||||
audioArray[i].Play(path);
|
||||
cout << "Played " << path << ". audio id no: " << i << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
audioArray[id].Play(path);
|
||||
bool Render::playSound(string path, bool override) {
|
||||
waveLoader.setLooping(false);
|
||||
if (override) {
|
||||
se.stop(seIndex);
|
||||
}
|
||||
waveLoader.load(path.c_str());
|
||||
seIndex = se.play(waveLoader);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Render::playMusic(string path) {
|
||||
if (path == "") {
|
||||
music.Stop(currentMusic);
|
||||
cout << "Stopped music from " << path << "." << endl;
|
||||
return true;
|
||||
if (currentMusic == path) {
|
||||
music.stopAll();
|
||||
}
|
||||
if (currentMusic != "") {
|
||||
music.Stop(currentMusic);
|
||||
cout << "Stopped music from " << path << "." << endl;
|
||||
}
|
||||
cout << "Played " << path << " as music." << endl;
|
||||
music.Play(path, true);
|
||||
waveLoader.load(path.c_str());
|
||||
waveLoader.setLooping(true);
|
||||
music.play(waveLoader);
|
||||
currentMusic = path;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include "SDL2/SDL_ttf.h"
|
||||
#include "BASS/audio_out.h"
|
||||
#include "SDL2/SDL_FontCache.h"
|
||||
#include "SoLoud/soloud.h"
|
||||
#include "SoLoud/soloud_wav.h"
|
||||
#include "SoLoud/soloud_openmpt.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -222,14 +225,16 @@ namespace Render {
|
|||
|
||||
extern State* current_state;
|
||||
|
||||
extern array<anshub::AudioOut, MAX_SE> audioArray;
|
||||
extern anshub::AudioOut music;
|
||||
extern SoLoud::Soloud se;
|
||||
extern SoLoud::Soloud music;
|
||||
extern SoLoud::Wav waveLoader;
|
||||
extern SoLoud::Openmpt modLoader;
|
||||
extern string currentMusic;
|
||||
extern int seIndex;
|
||||
/*
|
||||
* Play a sound. If a sound is currently playing then it will proceed to a different sound id.
|
||||
* You can also specify the specific id, if you intentionally want the sound to override another.
|
||||
* Play a sound. Will not override unless said so.
|
||||
*/
|
||||
bool playSound(string path, int id = NULL);
|
||||
bool playSound(string path, bool override = false);
|
||||
/*
|
||||
* Play music. Always loops.
|
||||
* Passing a blank string (e.g. "") will stop the current playing music.
|
||||
|
|
Loading…
Reference in a new issue