feat: dynamic library support

This commit is contained in:
2025-10-16 20:20:12 +02:00
parent faf9b67222
commit 472cc6b147
13 changed files with 42 additions and 14 deletions

View File

@ -1,4 +1,4 @@
add_library(${ENGINE_TARGET} STATIC add_library(${ENGINE_TARGET} SHARED
src/IO/parser.cpp src/IO/parser.cpp
src/IO/file_manager.cpp src/IO/file_manager.cpp
@ -24,6 +24,8 @@ set_target_properties(${ENGINE_TARGET} PROPERTIES
VISIBILITY_INLINES_HIDDEN YES VISIBILITY_INLINES_HIDDEN YES
) )
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_BUILD_SHARED)
target_include_directories(${ENGINE_TARGET} PUBLIC target_include_directories(${ENGINE_TARGET} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/contrib ${CMAKE_CURRENT_SOURCE_DIR}/contrib

View File

@ -2,8 +2,9 @@
#define APPLICATION_H_ #define APPLICATION_H_
#include "engine/window/events/window.h" #include "engine/window/events/window.h"
#include "engine/export.h"
class IApplication { class ENGINE_API IApplication {
public: public:
virtual ~IApplication() = default; virtual ~IApplication() = default;

View File

@ -2,9 +2,10 @@
#define COMPONENT_BATCH_H_ #define COMPONENT_BATCH_H_
#include "engine/renderer/renderer.h" #include "engine/renderer/renderer.h"
#include "engine/export.h"
// requires mesh component // requires mesh component
struct batch { struct ENGINE_API batch {
friend class Renderer; friend class Renderer;
public: public:
// requires transform component // requires transform component

View File

@ -1,6 +1,8 @@
#ifndef COMPONENTS_PLAYER_H_ #ifndef COMPONENTS_PLAYER_H_
#define COMPONENTS_PLAYER_H_ #define COMPONENTS_PLAYER_H_
struct camera {}; #include "engine/export.h"
struct ENGINE_API camera {};
#endif // COMPONENTS_PLAYER_H_ #endif // COMPONENTS_PLAYER_H_

View File

@ -2,9 +2,11 @@
#define COMPONENTS_LIGHT_H_ #define COMPONENTS_LIGHT_H_
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "engine/renderer/renderer.h"
struct light { #include "engine/renderer/renderer.h"
#include "engine/export.h"
struct ENGINE_API light {
friend class Renderer; friend class Renderer;
public: public:
enum LightType { enum LightType {

View File

@ -2,9 +2,11 @@
#define COMPONENTS_MESH_H_ #define COMPONENTS_MESH_H_
#include <memory> #include <memory>
#include "engine/renderer/wavefront.h"
struct mesh { #include "engine/renderer/wavefront.h"
#include "engine/export.h"
struct ENGINE_API mesh {
std::shared_ptr<Object> object; std::shared_ptr<Object> object;
}; };

View File

@ -1,6 +1,8 @@
#ifndef COMPONENT_ROTATE_H_ #ifndef COMPONENT_ROTATE_H_
#define COMPONENT_ROTATE_H_ #define COMPONENT_ROTATE_H_
struct rotate {}; #include "engine/export.h"
struct ENGINE_API rotate {};
#endif // COMPONENT_ROTATE_H_ #endif // COMPONENT_ROTATE_H_

View File

@ -2,8 +2,9 @@
#define COMPONENTS_TRANSFORM_H_ #define COMPONENTS_TRANSFORM_H_
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "engine/export.h"
struct transform { struct ENGINE_API transform {
glm::vec3 position; glm::vec3 position;
glm::vec3 rotation; glm::vec3 rotation;
glm::vec3 scale; glm::vec3 scale;

View File

@ -0,0 +1,9 @@
#pragma once
#if defined(_WIN32) && defined(ENGINE_BUILD_SHARED)
#define ENGINE_API __declspec(dllexport)
#elif defined(_WIN32)
#define ENGINE_API __declspec(dllimport)
#else
#define ENGINE_API __attribute__((visibility("default")))
#endif

View File

@ -8,8 +8,9 @@
#include "engine/window/events/window.h" #include "engine/window/events/window.h"
#include "engine/app/app.h" #include "engine/app/app.h"
#include "engine/export.h"
class Engine { class ENGINE_API Engine {
public: public:
static void Run(std::unique_ptr<IApplication> app); static void Run(std::unique_ptr<IApplication> app);
private: private:

View File

@ -5,9 +5,10 @@
#include <entt/entity/registry.hpp> #include <entt/entity/registry.hpp>
#include "engine/renderer/shader.h" #include "engine/renderer/shader.h"
#include "engine/export.h"
// TODO: make static or singleton // TODO: make static or singleton
class Renderer { class ENGINE_API Renderer {
public: public:
Renderer(entt::registry& registry); Renderer(entt::registry& registry);

View File

@ -5,7 +5,9 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Shader #include "engine/export.h"
class ENGINE_API Shader
{ {
public: public:
Shader(); Shader();

View File

@ -12,10 +12,12 @@
#include "engine/renderer/material.h" #include "engine/renderer/material.h"
#include "engine/renderer/mesh.h" #include "engine/renderer/mesh.h"
#include "engine/export.h"
enum ObjElement { OHASH, MTLLIB, USEMTL, O, V, VN, VT, F, OUNKNOWN }; enum ObjElement { OHASH, MTLLIB, USEMTL, O, V, VN, VT, F, OUNKNOWN };
enum MtlElement { MHASH, NEWMTL, NS, KA, KS, KD, NI, D, ILLUM, MAP_KD, MAP_KA, MUNKNOWN }; enum MtlElement { MHASH, NEWMTL, NS, KA, KS, KD, NI, D, ILLUM, MAP_KD, MAP_KA, MUNKNOWN };
class Object { class ENGINE_API Object {
friend class Renderer; friend class Renderer;
private: private:
static inline int NormalizeIndex(int idx, int baseCount); static inline int NormalizeIndex(int idx, int baseCount);