mirror of
https://github.com/haya3218/SDfmL.git
synced 2024-08-14 23:57:09 +00:00
whoohohoh
This commit is contained in:
parent
b42a5e324d
commit
8749aac2fd
7 changed files with 45 additions and 53 deletions
|
@ -5,42 +5,48 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
project(Skateboard)
|
project(Skateboard)
|
||||||
|
|
||||||
# include directories
|
# include directories
|
||||||
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/")
|
set(INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/"
|
||||||
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/"
|
||||||
set(OUT2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/MIDI/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/MIDI/"
|
||||||
set(OUT3_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/toml/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/toml/"
|
||||||
set(OUT4_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/sdfml/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/sdfml/"
|
||||||
set(OUT5_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL_gpu/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/SDL_gpu/"
|
||||||
set(OUT6_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/"
|
||||||
set(OUT7_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/lua/")
|
"${CMAKE_CURRENT_LIST_DIR}/src/lua/"
|
||||||
|
)
|
||||||
|
|
||||||
option(PREFER_MODPLUG "Use libmodplug api instead of libopenmpt for module playback" ON)
|
option(PREFER_MODPLUG "Use libmodplug api instead of libopenmpt for module playback" ON)
|
||||||
|
|
||||||
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
# Lib paths
|
||||||
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x64")
|
set(suffix "${CMAKE_CURRENT_LIST_DIR}/lib")
|
||||||
else ()
|
|
||||||
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x86")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Support both 32 and 64 bit builds
|
# Support both 32 and 64 bit builds
|
||||||
# Someone make a pull request to support MingW
|
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||||
# Way to lazy to do that right now
|
set(LIB_PATH "${suffix}/x64")
|
||||||
set(MAIN_LIBRARIES "${MAIN_LIBRARIES_E}/luajit.lib;${MAIN_LIBRARIES_E}/lua51.lib;${MAIN_LIBRARIES_E}/SDL2_gpu.lib;${MAIN_LIBRARIES_E}/libmodplug.lib;${MAIN_LIBRARIES_E}/soloud_static.lib;${MAIN_LIBRARIES_E}/SDL2.lib;${MAIN_LIBRARIES_E}/SDL2_ttf.lib")
|
else ()
|
||||||
|
set(LIB_PATH "${suffix}/x86")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Lib files
|
||||||
|
# MingW supports .lib files now I believe??
|
||||||
|
set(MAIN_LIBRARIES "luajit.lib"
|
||||||
|
"lua51.lib"
|
||||||
|
"SDL2_gpu.lib"
|
||||||
|
"libmodplug.lib"
|
||||||
|
"soloud_static.lib"
|
||||||
|
"SDL2.lib"
|
||||||
|
"SDL2_ttf.lib")
|
||||||
|
|
||||||
# strip it all
|
# strip it all
|
||||||
string(STRIP "${MAIN_LIBRARIES}" MAIN_LIBRARIES)
|
string(STRIP "${MAIN_LIBRARIES}" MAIN_LIBRARIES)
|
||||||
|
|
||||||
# Include the damn directories
|
# Include the damn directories
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${INCLUDE_DIRS})
|
||||||
include_directories(${OUT_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT2_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT3_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT4_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT5_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT6_INCLUDE_DIRS})
|
|
||||||
include_directories(${OUT7_INCLUDE_DIRS})
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||||
|
|
||||||
|
# library dirs
|
||||||
|
link_directories(${LIB_PATH})
|
||||||
|
|
||||||
# add EVERY FUCKING source file to SOURCES
|
# add EVERY FUCKING source file to SOURCES
|
||||||
FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
|
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
|
||||||
|
@ -61,6 +67,8 @@ FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/*.h"
|
"${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/*.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FILE(GLOB DLLS "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp")
|
||||||
|
|
||||||
# set c++ std to 17
|
# set c++ std to 17
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
@ -74,8 +82,12 @@ if ( MSVC )
|
||||||
target_compile_options(Skateboard PRIVATE /W1)
|
target_compile_options(Skateboard PRIVATE /W1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# LINK EVERYTHING
|
# MingW : for a lib file to not require lib before the name
|
||||||
target_link_libraries(Skateboard ${MAIN_LIBRARIES})
|
if (MINGW)
|
||||||
|
target_link_libraries(Skateboard ":${MAIN_LIBRARIES}")
|
||||||
|
else()
|
||||||
|
target_link_libraries(Skateboard ${MAIN_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
# set build dir
|
# set build dir
|
||||||
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
|
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
|
||||||
|
@ -90,7 +102,7 @@ set_target_properties(Skateboard PROPERTIES
|
||||||
)
|
)
|
||||||
|
|
||||||
# copy dll files
|
# copy dll files
|
||||||
file(COPY "${MAIN_LIBRARIES_E}/" DESTINATION ${BUILD_DIRECTORY})
|
file(COPY "${LIB_PATH}/" DESTINATION ${BUILD_DIRECTORY})
|
||||||
|
|
||||||
# remove lib files
|
# remove lib files
|
||||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/*.lib")
|
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/*.lib")
|
||||||
|
|
|
@ -67,6 +67,7 @@ ExampleState m;
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (sdfml::init() > 0) {
|
if (sdfml::init() > 0) {
|
||||||
|
sdfml::llog("game died", "", NORMAL, __FILENAME__, __LINE__);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -405,8 +405,6 @@ namespace sdfml {
|
||||||
|
|
||||||
static GPU_Camera camera;
|
static GPU_Camera camera;
|
||||||
|
|
||||||
static LuaHandler lua;
|
|
||||||
|
|
||||||
inline int init(float width = DEFAULT_WINDOW_WIDTH, float height = DEFAULT_WINDOW_HEIGHT, string window_name = "Unknown",
|
inline int init(float width = DEFAULT_WINDOW_WIDTH, float height = DEFAULT_WINDOW_HEIGHT, string window_name = "Unknown",
|
||||||
int win_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_ALLOW_HIGHDPI|SDL_WINDOW_SHOWN) {
|
int win_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_ALLOW_HIGHDPI|SDL_WINDOW_SHOWN) {
|
||||||
std::ofstream logFile;
|
std::ofstream logFile;
|
||||||
|
@ -439,7 +437,7 @@ namespace sdfml {
|
||||||
mContext.direct_win = wmInfo.info.win.window;
|
mContext.direct_win = wmInfo.info.win.window;
|
||||||
|
|
||||||
sound.init();
|
sound.init();
|
||||||
sound.initSF(soundfont);
|
|
||||||
llog("SoLoud", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
|
llog("SoLoud", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
|
||||||
|
|
||||||
camera = GPU_GetDefaultCamera();
|
camera = GPU_GetDefaultCamera();
|
||||||
|
|
|
@ -27239,7 +27239,7 @@ namespace sol {
|
||||||
using iterator = typename global_table::iterator;
|
using iterator = typename global_table::iterator;
|
||||||
using const_iterator = typename global_table::const_iterator;
|
using const_iterator = typename global_table::const_iterator;
|
||||||
|
|
||||||
state_view(lua_State* Ls = NULL) : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, global_tag) {
|
state_view(lua_State* Ls) : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, global_tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state_view(this_state Ls) : state_view(Ls.L) {
|
state_view(this_state Ls) : state_view(Ls.L) {
|
||||||
|
|
|
@ -6,7 +6,5 @@ std::pair<SoLoud::WavStream, SoLoud::Modplug> sdfml::musicBank;
|
||||||
#else
|
#else
|
||||||
std::pair<SoLoud::WavStream, SoLoud::Openmpt> sdfml::musicBank;
|
std::pair<SoLoud::WavStream, SoLoud::Openmpt> sdfml::musicBank;
|
||||||
#endif
|
#endif
|
||||||
SoLoud::Midi sdfml::midiBank;
|
|
||||||
SoLoud::SoundFont sdfml::midiSF;
|
|
||||||
SoLoud::Soloud sdfml::audio;
|
SoLoud::Soloud sdfml::audio;
|
||||||
sdfml::AudioHandler sdfml::sound;
|
sdfml::AudioHandler sdfml::sound;
|
|
@ -20,18 +20,11 @@ namespace sdfml {
|
||||||
#else
|
#else
|
||||||
extern std::pair<SoLoud::WavStream, SoLoud::Openmpt> musicBank;
|
extern std::pair<SoLoud::WavStream, SoLoud::Openmpt> musicBank;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern SoLoud::Midi midiBank;
|
|
||||||
extern SoLoud::SoundFont midiSF;
|
|
||||||
|
|
||||||
extern SoLoud::Soloud audio;
|
extern SoLoud::Soloud audio;
|
||||||
|
|
||||||
class MusicHandler {
|
class MusicHandler {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void playMidi(std::string path) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void playMusic(std::string path) {
|
void playMusic(std::string path) {
|
||||||
musicBank.first.stop();
|
musicBank.first.stop();
|
||||||
|
@ -58,10 +51,6 @@ namespace sdfml {
|
||||||
audio.init(audio.CLIP_ROUNDOFF, audio.MINIAUDIO);
|
audio.init(audio.CLIP_ROUNDOFF, audio.MINIAUDIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSF(std::string path) {
|
|
||||||
midiSF.load(path.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void deinit() {
|
void deinit() {
|
||||||
audio.stopAll();
|
audio.stopAll();
|
||||||
audio.deinit();
|
audio.deinit();
|
||||||
|
|
|
@ -12,22 +12,14 @@ namespace sdfml {
|
||||||
class LuaHandler {
|
class LuaHandler {
|
||||||
protected:
|
protected:
|
||||||
sol::state _lua_state;
|
sol::state _lua_state;
|
||||||
sol::state_view _lua_view;
|
sol::state_view _lua_view = NULL;
|
||||||
sol::load_result _cur_result;
|
sol::load_result _cur_result;
|
||||||
bool _prefer_view = false;
|
bool _prefer_view = false;
|
||||||
public:
|
public:
|
||||||
LuaHandler() {
|
|
||||||
sol::state_view temp(NULL);
|
|
||||||
_lua_view = temp;
|
|
||||||
}
|
|
||||||
int open_state(std::string path, bool immediate = false);
|
int open_state(std::string path, bool immediate = false);
|
||||||
|
|
||||||
int create_from_lua_state(lua_State* L, std::string path, bool immediate = false);
|
int create_from_lua_state(lua_State* L, std::string path, bool immediate = false);
|
||||||
|
|
||||||
int open_from_lua_state(lua_State* L, std::string path, bool immediate = false) {
|
|
||||||
return create_from_lua_state(L, path, immediate);
|
|
||||||
}
|
|
||||||
|
|
||||||
int run_state();
|
int run_state();
|
||||||
|
|
||||||
template <typename TName = int>
|
template <typename TName = int>
|
||||||
|
@ -39,6 +31,8 @@ namespace sdfml {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void add_libraries(Args&&... libraries);
|
void add_libraries(Args&&... libraries);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//static LuaHandler lua;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue