mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Convert back to a static library
This commit is contained in:
parent
50ca206428
commit
d7a79abb1c
@ -6,7 +6,7 @@ project(engine LANGUAGES CXX
|
||||
VERSION "0.1.0"
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
add_library(${PROJECT_NAME} STATIC
|
||||
|
||||
"src/engine.cpp"
|
||||
"src/window.cpp"
|
||||
@ -74,6 +74,8 @@ add_library(${PROJECT_NAME} SHARED
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE DEFINITIONS "ENGINE_EXPORTS")
|
||||
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
@ -143,8 +145,8 @@ add_subdirectory(dependencies/glm)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/glm)
|
||||
|
||||
# spdlog
|
||||
set(SPDLOG_BUILD_SHARED ON CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
set(SPDLOG_BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(dependencies/spdlog)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/spdlog/include)
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
#include "engine_api.h"
|
||||
|
||||
class Object;
|
||||
namespace engine {
|
||||
class Window;
|
||||
class Input;
|
||||
}
|
||||
|
||||
class Object;
|
||||
class ResourceManager;
|
||||
|
||||
class ENGINE_API Component {
|
||||
@ -30,8 +33,8 @@ public:
|
||||
Object& parent;
|
||||
|
||||
protected:
|
||||
Window& win;
|
||||
Input& inp;
|
||||
engine::Window& win;
|
||||
engine::Input& inp;
|
||||
ResourceManager& res;
|
||||
|
||||
private:
|
||||
|
@ -11,3 +11,5 @@
|
||||
# define ENGINE_API
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define ENGINE_API
|
@ -8,7 +8,7 @@
|
||||
|
||||
struct SDL_Window;
|
||||
|
||||
namespace engine::gfx {
|
||||
namespace engine {
|
||||
|
||||
class ENGINE_API GFXDevice {
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace engine {
|
||||
|
||||
class Window;
|
||||
|
||||
enum class InputDevice : int {
|
||||
@ -87,3 +89,5 @@ private:
|
||||
void addInputButtonAsAxis(const std::string& name, InputDevice device, int high, int low);
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -12,8 +12,10 @@
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace engine {
|
||||
class Window;
|
||||
class Input;
|
||||
}
|
||||
class ResourceManager;
|
||||
|
||||
class SceneRoot;
|
||||
@ -28,8 +30,8 @@ namespace components {
|
||||
}
|
||||
|
||||
struct GameIO {
|
||||
Window * const win;
|
||||
Input * const input;
|
||||
engine::Window * const win;
|
||||
engine::Input * const input;
|
||||
ResourceManager * const resMan;
|
||||
};
|
||||
|
||||
@ -43,8 +45,8 @@ public:
|
||||
Object& operator=(const Object&) = delete;
|
||||
~Object();
|
||||
|
||||
Window& win;
|
||||
Input& inp;
|
||||
engine::Window& win;
|
||||
engine::Input& inp;
|
||||
ResourceManager& res;
|
||||
|
||||
SceneRoot& root;
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
ENGINE_API extern const uint64_t BILLION;
|
||||
|
||||
namespace engine {
|
||||
|
||||
class ENGINE_API Window {
|
||||
|
||||
public:
|
||||
@ -197,3 +199,5 @@ private:
|
||||
void onMouseMotionEvent(SDL_MouseMotionEvent& e);
|
||||
void onMouseWheelEvent(SDL_MouseWheelEvent& e);
|
||||
};
|
||||
|
||||
}
|
@ -14,11 +14,12 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace engine::gfx {
|
||||
namespace engine {
|
||||
|
||||
static std::vector<const char*> getRequiredVulkanExtensions(SDL_Window* window)
|
||||
{
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace engine {
|
||||
|
||||
Input::Input(const Window& win) : m_win(win)
|
||||
{
|
||||
m_enabledDevices.fill(true);
|
||||
@ -170,7 +172,8 @@ float Input::getAxis(const std::string& axisName) const
|
||||
if (m_enabledDevices[static_cast<int>(e.device)]) {
|
||||
if (e.isButtonAxis) {
|
||||
return getButtonAxis(e.device, e.high, e.low);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return getDeviceAxis(e.device, e.axis);
|
||||
}
|
||||
}
|
||||
@ -230,3 +233,5 @@ bool Input::getButtonRelease(const std::string& buttonName) const
|
||||
}
|
||||
return isReleased;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
|
||||
const uint64_t BILLION = 1000000000;
|
||||
|
||||
namespace engine {
|
||||
|
||||
Window::Window(const std::string& title) : m_title(title)
|
||||
{
|
||||
|
||||
@ -168,7 +170,8 @@ void Window::onMouseWheelEvent(SDL_MouseWheelEvent &e)
|
||||
if (e.direction == SDL_MOUSEWHEEL_NORMAL) {
|
||||
m_mouse.xscroll = e.preciseX;
|
||||
m_mouse.yscroll = e.preciseY;
|
||||
} else { // flipped
|
||||
}
|
||||
else { // flipped
|
||||
m_mouse.xscroll = -e.preciseX;
|
||||
m_mouse.yscroll = -e.preciseY;
|
||||
}
|
||||
@ -297,7 +300,8 @@ bool Window::setRelativeMouseMode(bool enabled)
|
||||
int code = SDL_SetRelativeMouseMode(static_cast<SDL_bool>(enabled));
|
||||
if (code != 0) {
|
||||
throw std::runtime_error("Unable to set relative mouse mode");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -391,7 +395,8 @@ uint64_t Window::getNanos() const
|
||||
count = SDL_GetPerformanceCounter();
|
||||
if (m_counterFreq == BILLION) {
|
||||
return count;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return count * (BILLION / m_counterFreq);
|
||||
}
|
||||
}
|
||||
@ -440,7 +445,8 @@ bool Window::infoBox(const std::string& title, const std::string& msg)
|
||||
if (isFullscreen() == false) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, title.c_str(), msg.c_str(), m_handle);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -452,3 +458,5 @@ void Window::errorBox(const std::string& message)
|
||||
{
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Game Error", message.c_str(), NULL);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user