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
|
# SDL2 include directories
|
||||||
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/")
|
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/")
|
||||||
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/BASS/")
|
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/")
|
||||||
set(BASS_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/BASS/BASS/")
|
|
||||||
|
|
||||||
# Support both 32 and 64 bit builds
|
# Support both 32 and 64 bit builds
|
||||||
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
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/")
|
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x64/")
|
||||||
else ()
|
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/")
|
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x86/")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ string(STRIP "${MAIN_LIBRARIES}" MAIN_LIBRARIES)
|
||||||
# Include the damn directories
|
# Include the damn directories
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
include_directories(${OUT_INCLUDE_DIRS})
|
include_directories(${OUT_INCLUDE_DIRS})
|
||||||
include_directories(${BASS_INCLUDE_DIRS})
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||||
|
|
||||||
# add EVERY FUCKING source file to SOURCES
|
# 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/*.h"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.c"
|
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.c"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.h"
|
"${CMAKE_CURRENT_LIST_DIR}/src/SDL2/*.h"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_out.h"
|
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_audiosource.h"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_fx.h"
|
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_bassboostfilter.h"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_out.cc"
|
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/soloud_biquadresonantfilter.h"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/BASS/audio_fx.cc")
|
"${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 c++ std to 17
|
||||||
set(CMAKE_CXX_STANDARD 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}/SDL2_ttf.lib")
|
||||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2main.lib")
|
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2main.lib")
|
||||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2test.lib")
|
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2test.lib")
|
||||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/bass.lib")
|
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/soloud_x64.lib")
|
||||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/bass_fx.lib")
|
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/soloud_x86.lib")
|
||||||
|
|
||||||
# :)
|
# :)
|
|
@ -10,6 +10,9 @@
|
||||||
#include "SDL2/SDL_ttf.h"
|
#include "SDL2/SDL_ttf.h"
|
||||||
#include "Render.hpp"
|
#include "Render.hpp"
|
||||||
#include "SDL2/SDL_syswm.h"
|
#include "SDL2/SDL_syswm.h"
|
||||||
|
#include "SoLoud/soloud.h"
|
||||||
|
#include "SoLoud/soloud_wav.h"
|
||||||
|
#include "SoLoud/soloud_openmpt.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Render;
|
using namespace Render;
|
||||||
|
@ -18,11 +21,14 @@ SDL_Window* Render::window;
|
||||||
SDL_Renderer* Render::renderer;
|
SDL_Renderer* Render::renderer;
|
||||||
SDL_Event Render::event;
|
SDL_Event Render::event;
|
||||||
State* Render::current_state = nullptr;
|
State* Render::current_state = nullptr;
|
||||||
array<anshub::AudioOut, MAX_SE> Render::audioArray;
|
SoLoud::Soloud Render::music;
|
||||||
anshub::AudioOut Render::music;
|
SoLoud::Soloud Render::se;
|
||||||
|
SoLoud::Wav Render::waveLoader;
|
||||||
|
SoLoud::Openmpt Render::modLoader;
|
||||||
string Render::currentMusic = "";
|
string Render::currentMusic = "";
|
||||||
HWND Render::hwnd;
|
HWND Render::hwnd;
|
||||||
HWND Render::consoleD;
|
HWND Render::consoleD;
|
||||||
|
int Render::seIndex;
|
||||||
|
|
||||||
Render::Object::Object() {
|
Render::Object::Object() {
|
||||||
|
|
||||||
|
@ -184,11 +190,15 @@ void Render::Object::centerSelf(AXIS axis) {
|
||||||
bool Render::Init(string window_name) {
|
bool Render::Init(string window_name) {
|
||||||
consoleD = GetConsoleWindow();
|
consoleD = GetConsoleWindow();
|
||||||
SetWindowTextA(consoleD, "Logging window");
|
SetWindowTextA(consoleD, "Logging window");
|
||||||
if (!BASS_Init(1, 44100, BASS_DEVICE_8BITS|BASS_DEVICE_REINIT, 0, NULL)) {
|
if (se.init() > 0) {
|
||||||
cout << "BASS has failed to initialize. Is your dll broken? <NO ERROR>" << endl;
|
cout << "SoLoud has failed to load. Is your dll broken?" << endl;
|
||||||
return false;
|
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) {
|
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
|
||||||
cout << "SDL has failed to initialize. Is your dll broken? " << SDL_GetError() << endl;
|
cout << "SDL has failed to initialize. Is your dll broken? " << SDL_GetError() << endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,34 +333,24 @@ void Render::SwitchState(State* state) {
|
||||||
current_state->Create();
|
current_state->Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Render::playSound(string path, int id) {
|
bool Render::playSound(string path, bool override) {
|
||||||
if (id == NULL) {
|
waveLoader.setLooping(false);
|
||||||
for (int i = 0; i < MAX_SE; i++) {
|
if (override) {
|
||||||
if (audioArray[i].NowPlaying(false).size() == 0) {
|
se.stop(seIndex);
|
||||||
audioArray[i].Play(path);
|
|
||||||
cout << "Played " << path << ". audio id no: " << i << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
audioArray[id].Play(path);
|
|
||||||
}
|
}
|
||||||
|
waveLoader.load(path.c_str());
|
||||||
|
seIndex = se.play(waveLoader);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Render::playMusic(string path) {
|
bool Render::playMusic(string path) {
|
||||||
if (path == "") {
|
if (currentMusic == path) {
|
||||||
music.Stop(currentMusic);
|
music.stopAll();
|
||||||
cout << "Stopped music from " << path << "." << endl;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (currentMusic != "") {
|
waveLoader.load(path.c_str());
|
||||||
music.Stop(currentMusic);
|
waveLoader.setLooping(true);
|
||||||
cout << "Stopped music from " << path << "." << endl;
|
music.play(waveLoader);
|
||||||
}
|
|
||||||
cout << "Played " << path << " as music." << endl;
|
|
||||||
music.Play(path, true);
|
|
||||||
currentMusic = path;
|
currentMusic = path;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include "SDL2/SDL_ttf.h"
|
#include "SDL2/SDL_ttf.h"
|
||||||
#include "BASS/audio_out.h"
|
#include "BASS/audio_out.h"
|
||||||
#include "SDL2/SDL_FontCache.h"
|
#include "SDL2/SDL_FontCache.h"
|
||||||
|
#include "SoLoud/soloud.h"
|
||||||
|
#include "SoLoud/soloud_wav.h"
|
||||||
|
#include "SoLoud/soloud_openmpt.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -222,14 +225,16 @@ namespace Render {
|
||||||
|
|
||||||
extern State* current_state;
|
extern State* current_state;
|
||||||
|
|
||||||
extern array<anshub::AudioOut, MAX_SE> audioArray;
|
extern SoLoud::Soloud se;
|
||||||
extern anshub::AudioOut music;
|
extern SoLoud::Soloud music;
|
||||||
|
extern SoLoud::Wav waveLoader;
|
||||||
|
extern SoLoud::Openmpt modLoader;
|
||||||
extern string currentMusic;
|
extern string currentMusic;
|
||||||
|
extern int seIndex;
|
||||||
/*
|
/*
|
||||||
* Play a sound. If a sound is currently playing then it will proceed to a different sound id.
|
* Play a sound. Will not override unless said so.
|
||||||
* You can also specify the specific id, if you intentionally want the sound to override another.
|
|
||||||
*/
|
*/
|
||||||
bool playSound(string path, int id = NULL);
|
bool playSound(string path, bool override = false);
|
||||||
/*
|
/*
|
||||||
* Play music. Always loops.
|
* Play music. Always loops.
|
||||||
* Passing a blank string (e.g. "") will stop the current playing music.
|
* Passing a blank string (e.g. "") will stop the current playing music.
|
||||||
|
|
Loading…
Reference in a new issue