diff --git a/sdlpp/Makefile b/sdlpp/Makefile index 7e72384..ffe1f70 100644 --- a/sdlpp/Makefile +++ b/sdlpp/Makefile @@ -1,14 +1,17 @@ -CXX ?= g++ -CPPFLAGS = -std=c++14 -Wall -Wextra -pedantic - MAJOR ?= 1 MINOR ?= 0 RELEASE ?= 0 ifeq ($(OS),Windows_NT) UNAME_S := Windows +CXX = cl +CXXFLAGS = -MD -EHsc /DDLLEXPORT +OBJEXT = obj else UNAME_S := $(shell uname -s) +CXX ?= g++ +CXXFLAGS = -std=c++14 -Wall -Wextra -pedantic +OBJEXT = o endif ifeq ($(UNAME_S),Linux) @@ -19,28 +22,41 @@ ifeq ($(UNAME_S),Darwin) SDLPPLIBRARY = libsdlpp.dylib LIBRARYFLAGS = endif +ifeq ($(UNAME_S),Windows) +SDLPPLIBRARY = libsdlpp.dll +LIBRARYFLAGS = +endif -OBJECTFILES = sdlpp_circlecolider.o sdlpp_circlerenderer.o sdlpp_collision.o sdlpp_common.o sdlpp_font.o sdlpp_linerenderer.o sdlpp_rectcolider.o sdlpp_rectrenderer.o sdlpp_renderer.o sdlpp_renderobject.o sdlpp_scene.o sdlpp_textrenderer.o sdlpp_texture.o sdlpp_window.o +OBJECTFILES = sdlpp_circlecolider.${OBJEXT} sdlpp_circlerenderer.${OBJEXT} sdlpp_collision.${OBJEXT} sdlpp_common.${OBJEXT} sdlpp_font.${OBJEXT} sdlpp_linerenderer.${OBJEXT} sdlpp_rectcolider.${OBJEXT} sdlpp_rectrenderer.${OBJEXT} sdlpp_renderer.${OBJEXT} sdlpp_renderobject.${OBJEXT} sdlpp_scene.${OBJEXT} sdlpp_textrenderer.${OBJEXT} sdlpp_texture.${OBJEXT} sdlpp_window.${OBJEXT} all: ${SDLPPLIBRARY} -%.o: %.cpp - ${CXX} ${CPPFLAGS} ${LIBRARYFLAGS} -c $< -o $@ +ifeq ($(UNAME_S),Windows) +%.${OBJEXT}: %.cpp + ${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} /c $< /Fo"$@" +else +%.${OBJEXT}: %.cpp + ${CXX} ${CXXFLAGS} ${LIBRARYFLAGS} -c $< -o $@ +endif ifeq ($(UNAME_S),Linux) ${SDLPPLIBRARY}: ${OBJECTFILES} - ${CXX} ${CPPFLAGS} -shared -Wl,-soname,libsdlpp.so.${MAJOR}\ + ${CXX} ${CXXFLAGS} -shared -Wl,-soname,libsdlpp.so.${MAJOR}\ -o ${SDLPPLIBRARY} $^ ln -sf ${SDLPPLIBRARY} libsdlpp.so ln -sf ${SDLPPLIBRARY} libsdlpp.so.${MAJOR} endif ifeq ($(UNAME_S),Darwin) ${SDLPPLIBRARY}: ${OBJECTFILES} - ${CXX} ${CPPFLAGS} -dynamiclib -install_name ${SDLPPLIBRARY}\ + ${CXX} ${CXXFLAGS} -dynamiclib -install_name ${SDLPPLIBRARY}\ -current_version ${MAJOR}.${MINOR} $^ -lSDL2 -lSDL2_image -lSDL2_gfx -lSDL2_ttf -o $@ endif +ifeq ($(UNAME_S),Windows) +${SDLPPLIBRARY}: ${OBJECTFILES} + ${CXX} /LD $^ /link SDL2.lib SDL2_ttf.lib SDL2_image.lib /OUT:$@ /IMPLIB:libsdlpp.lib +endif clean: - ${RM} *.so* *.o *.dylib + ${RM} *.so* *.${OBJEXT} *.dylib libsdlpp* .PHONY: all clean test diff --git a/sdlpp/sdlpp_circlecolider.hpp b/sdlpp/sdlpp_circlecolider.hpp index 64019d7..e598de5 100644 --- a/sdlpp/sdlpp_circlecolider.hpp +++ b/sdlpp/sdlpp_circlecolider.hpp @@ -7,7 +7,7 @@ #include "sdlpp_collision.hpp" namespace SDLPP { -class CircleColider : public CollisionPolygon { +class SDLPPSCOPE CircleColider : public CollisionPolygon { public: CircleColider( double x, double y, double rad ); virtual ~CircleColider() {} diff --git a/sdlpp/sdlpp_circlerenderer.hpp b/sdlpp/sdlpp_circlerenderer.hpp index de1d51b..d6b12d4 100644 --- a/sdlpp/sdlpp_circlerenderer.hpp +++ b/sdlpp/sdlpp_circlerenderer.hpp @@ -7,7 +7,7 @@ #include namespace SDLPP { -class CircleRender : public RenderObject { +class SDLPPSCOPE CircleRender : public RenderObject { public: CircleRender() = delete; virtual ~CircleRender(){}; diff --git a/sdlpp/sdlpp_collision.hpp b/sdlpp/sdlpp_collision.hpp index 1b1fe48..4edca47 100644 --- a/sdlpp/sdlpp_collision.hpp +++ b/sdlpp/sdlpp_collision.hpp @@ -5,7 +5,7 @@ #include "sdlpp_renderer.hpp" namespace SDLPP { -class CollisionPolygon { +class SDLPPSCOPE CollisionPolygon { public: CollisionPolygon( double x, double y ); virtual ~CollisionPolygon() {} @@ -36,9 +36,9 @@ protected: SDL_Color sdl_outline = { 0, 0, 0, 0 }; }; -bool infinityIntersection( const SDLPP::CollisionPolygon &infinite, +SDLPPSCOPE bool infinityIntersection( const SDLPP::CollisionPolygon &infinite, const SDLPP::CollisionPolygon &other ); -bool intersects( const SDLPP::CollisionPolygon &p1, +SDLPPSCOPE bool intersects( const SDLPP::CollisionPolygon &p1, const SDLPP::CollisionPolygon &p2 ); } // namespace SDLPP #endif diff --git a/sdlpp/sdlpp_common.hpp b/sdlpp/sdlpp_common.hpp index 0deb4c1..451141f 100644 --- a/sdlpp/sdlpp_common.hpp +++ b/sdlpp/sdlpp_common.hpp @@ -1,3 +1,16 @@ +#ifndef SDLPPSCOPE +#ifdef _WIN32 +#ifdef DLLEXPORT +#define SDLPPSCOPE __declspec( dllexport ) +#else +#define SDLPPSCOPE __declspec( dllimport ) +#endif +#else +#define SDLPPSCOPE +#endif +#endif + + #ifndef SDLPP_HPP_COMMON #define SDLPP_HPP_COMMON @@ -22,17 +35,17 @@ namespace SDLPP { -int hex2num( char c ); +SDLPPSCOPE int hex2num( char c ); -bool init(); -bool init( uint32_t SDL_OPTIONS ); -bool init( uint32_t SDL_OPTIONS, int IMAGE_OPTIONS ); +SDLPPSCOPE bool init(); +SDLPPSCOPE bool init( uint32_t SDL_OPTIONS ); +SDLPPSCOPE bool init( uint32_t SDL_OPTIONS, int IMAGE_OPTIONS ); -std::tuple< int, int, int, int > getColorsHEX( const std::string &color ); -SDL_Color getSDLColorHEX( const std::string &color ); -std::tuple< int, int, int, int > getColorsSDLColor( const SDL_Color &color ); -SDL_Color getSDLColorTuple( const std::tuple< int, int, int, int > &tuple ); +SDLPPSCOPE std::tuple< int, int, int, int > getColorsHEX( const std::string &color ); +SDLPPSCOPE SDL_Color getSDLColorHEX( const std::string &color ); +SDLPPSCOPE std::tuple< int, int, int, int > getColorsSDLColor( const SDL_Color &color ); +SDLPPSCOPE SDL_Color getSDLColorTuple( const std::tuple< int, int, int, int > &tuple ); -bool getSDLEvent( SDL_Event &e ); +SDLPPSCOPE bool getSDLEvent( SDL_Event &e ); } // end of namespace SDLPP #endif diff --git a/sdlpp/sdlpp_font.hpp b/sdlpp/sdlpp_font.hpp index aef386a..7983cde 100644 --- a/sdlpp/sdlpp_font.hpp +++ b/sdlpp/sdlpp_font.hpp @@ -6,7 +6,7 @@ #include namespace SDLPP { -class Font { +class SDLPPSCOPE Font { public: Font() = delete; Font( const std::string &font, int size ); diff --git a/sdlpp/sdlpp_linerenderer.hpp b/sdlpp/sdlpp_linerenderer.hpp index 64f74e3..043d22d 100644 --- a/sdlpp/sdlpp_linerenderer.hpp +++ b/sdlpp/sdlpp_linerenderer.hpp @@ -5,7 +5,7 @@ #include "sdlpp_renderobject.hpp" namespace SDLPP { -class LineRenderer : public RenderObject { +class SDLPPSCOPE LineRenderer : public RenderObject { public: LineRenderer() = delete; virtual ~LineRenderer(){}; diff --git a/sdlpp/sdlpp_rectcolider.hpp b/sdlpp/sdlpp_rectcolider.hpp index c965897..ece0db0 100644 --- a/sdlpp/sdlpp_rectcolider.hpp +++ b/sdlpp/sdlpp_rectcolider.hpp @@ -7,7 +7,7 @@ #include namespace SDLPP { -class RectColider : public CollisionPolygon { +class SDLPPSCOPE RectColider : public CollisionPolygon { public: RectColider( double x, double y, double w, double h ); virtual ~RectColider() {} diff --git a/sdlpp/sdlpp_rectrenderer.hpp b/sdlpp/sdlpp_rectrenderer.hpp index 6002249..ea86393 100644 --- a/sdlpp/sdlpp_rectrenderer.hpp +++ b/sdlpp/sdlpp_rectrenderer.hpp @@ -6,7 +6,7 @@ #include "sdlpp_rectcolider.hpp" namespace SDLPP { -class RectangleRender : public RenderObject { +class SDLPPSCOPE RectangleRender : public RenderObject { public: RectangleRender() = delete; virtual ~RectangleRender(){}; diff --git a/sdlpp/sdlpp_renderer.hpp b/sdlpp/sdlpp_renderer.hpp index 5aaf62e..2c4df1c 100644 --- a/sdlpp/sdlpp_renderer.hpp +++ b/sdlpp/sdlpp_renderer.hpp @@ -7,7 +7,7 @@ #include namespace SDLPP { -class Renderer { +class SDLPPSCOPE Renderer { public: Renderer() = delete; Renderer( Window &window ); diff --git a/sdlpp/sdlpp_renderobject.hpp b/sdlpp/sdlpp_renderobject.hpp index f6deda8..48de5d7 100644 --- a/sdlpp/sdlpp_renderobject.hpp +++ b/sdlpp/sdlpp_renderobject.hpp @@ -10,9 +10,9 @@ #include namespace SDLPP { -class Scene; +class SDLPPSCOPE Scene; -class RenderObject { +class SDLPPSCOPE RenderObject { public: RenderObject( const std::shared_ptr< Renderer > &r ) : renderer( r ) {} virtual ~RenderObject() {} diff --git a/sdlpp/sdlpp_scene.hpp b/sdlpp/sdlpp_scene.hpp index 85e5037..2182a37 100644 --- a/sdlpp/sdlpp_scene.hpp +++ b/sdlpp/sdlpp_scene.hpp @@ -11,7 +11,7 @@ #include "sdlpp_renderobject.hpp" namespace SDLPP { -class Scene { +class SDLPPSCOPE Scene { public: Scene( std::shared_ptr< Renderer > &r ); void addObject( const std::shared_ptr< RenderObject > &obj ); diff --git a/sdlpp/sdlpp_textrenderer.hpp b/sdlpp/sdlpp_textrenderer.hpp index a83fc41..f54ce7f 100644 --- a/sdlpp/sdlpp_textrenderer.hpp +++ b/sdlpp/sdlpp_textrenderer.hpp @@ -8,7 +8,7 @@ #include namespace SDLPP { -class TextRenderer : public RectangleRender { +class SDLPPSCOPE TextRenderer : public RectangleRender { public: TextRenderer() = delete; TextRenderer( double x, double y, double w, double h, diff --git a/sdlpp/sdlpp_texture.hpp b/sdlpp/sdlpp_texture.hpp index fb1eab6..7428ee5 100644 --- a/sdlpp/sdlpp_texture.hpp +++ b/sdlpp/sdlpp_texture.hpp @@ -8,7 +8,7 @@ #include "sdlpp_renderer.hpp" namespace SDLPP { -class Texture { +class SDLPPSCOPE Texture { public: Texture() = delete; Texture( std::shared_ptr< Renderer > &renderer, diff --git a/sdlpp/sdlpp_window.hpp b/sdlpp/sdlpp_window.hpp index fdb81ad..b871414 100644 --- a/sdlpp/sdlpp_window.hpp +++ b/sdlpp/sdlpp_window.hpp @@ -6,7 +6,7 @@ #include namespace SDLPP { -class Window { +class SDLPPSCOPE Window { public: Window(); Window( const std::string &window_name );