From 5e0f5d56903e7c483afb679a912f3afaf30c92e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Fri, 21 May 2021 12:15:11 +0200 Subject: [PATCH 1/5] fuirst commit develop --- sources/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/main.cpp b/sources/main.cpp index 70491566..a1cad89d 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -4,7 +4,7 @@ int main() { WAL::Wal wal; - + // this is the first develop push try { wal.run(); return 0; @@ -12,4 +12,4 @@ int main() std::cerr << ex.what() << std::endl; return 84; } -} +} \ No newline at end of file From 3d5ce0ff8142cbde4da41ea9aa8d8862279efc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sun, 23 May 2021 11:17:41 +0200 Subject: [PATCH 2/5] fix IAudio dtor --- lib/Ray/sources/Audio/IAudio.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Ray/sources/Audio/IAudio.hpp b/lib/Ray/sources/Audio/IAudio.hpp index 82dc1606..65753870 100644 --- a/lib/Ray/sources/Audio/IAudio.hpp +++ b/lib/Ray/sources/Audio/IAudio.hpp @@ -16,7 +16,7 @@ namespace RAY::Audio //! @brief Interface for Audio ressources class IAudio: public IRessource { public: - virtual ~IAudio() = 0; + virtual ~IAudio() = default; //! @brief Load Audio stream from file virtual bool load(const std::string &path) = 0; From bce3d68874da15316e2a01095100f25ac651e091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sun, 23 May 2021 11:27:18 +0200 Subject: [PATCH 3/5] adding some missing overrides (not putting explicits here) --- lib/Ray/sources/Camera/Camera2D.hpp | 2 +- lib/Ray/sources/Camera/Camera3D.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Ray/sources/Camera/Camera2D.hpp b/lib/Ray/sources/Camera/Camera2D.hpp index ed82e785..dc934e43 100644 --- a/lib/Ray/sources/Camera/Camera2D.hpp +++ b/lib/Ray/sources/Camera/Camera2D.hpp @@ -26,7 +26,7 @@ namespace RAY::Camera { //! @brief A copy constructor Camera2D(const Camera2D &) = default; - ~Camera2D() = default; + ~Camera2D() override = default; //! @brief A Camera is assignable Camera2D &operator=(const Camera2D &) = default; diff --git a/lib/Ray/sources/Camera/Camera3D.hpp b/lib/Ray/sources/Camera/Camera3D.hpp index 4edc6bfb..e0e82b8d 100644 --- a/lib/Ray/sources/Camera/Camera3D.hpp +++ b/lib/Ray/sources/Camera/Camera3D.hpp @@ -29,7 +29,7 @@ namespace RAY::Camera { //! @brief A copy constructor Camera3D(const Camera3D &) = default; - ~Camera3D() = default; + ~Camera3D() override = default; //! @brief A Camera is assignable Camera3D &operator=(const Camera3D &) = default; From b2c38a6adff3a1f02c4d251b17e5488cc08c3aec Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Sun, 23 May 2021 16:39:31 +0200 Subject: [PATCH 4/5] raw data structure methods calls are now forbidden for functions outside RAY --- lib/Ray/CMakeLists.txt | 2 + lib/Ray/sources/Camera/Camera2D.hpp | 7 ++-- lib/Ray/sources/Camera/Camera3D.hpp | 7 ++-- lib/Ray/sources/Color.hpp | 6 ++- lib/Ray/sources/Drawables/Image.hpp | 8 ++-- lib/Ray/sources/Drawables/Texture.hpp | 7 ++-- lib/Ray/sources/Vector/Vector2.hpp | 48 ++++++++++++------------ lib/Ray/sources/Vector/Vector3.hpp | 53 ++++++++++++++------------- 8 files changed, 76 insertions(+), 62 deletions(-) diff --git a/lib/Ray/CMakeLists.txt b/lib/Ray/CMakeLists.txt index 32e0a5a9..4fe68278 100644 --- a/lib/Ray/CMakeLists.txt +++ b/lib/Ray/CMakeLists.txt @@ -99,4 +99,6 @@ if (NOT raylib_FOUND) endif() add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS}) +target_compile_definitions(${LIB_NAME} INTERFACE INTERNAL=private) +target_compile_definitions(${LIB_NAME} PRIVATE INTERNAL=public) target_link_libraries(${LIB_NAME} raylib) diff --git a/lib/Ray/sources/Camera/Camera2D.hpp b/lib/Ray/sources/Camera/Camera2D.hpp index dc934e43..66289ab2 100644 --- a/lib/Ray/sources/Camera/Camera2D.hpp +++ b/lib/Ray/sources/Camera/Camera2D.hpp @@ -52,11 +52,12 @@ namespace RAY::Camera { //! @brief Returns camera 2d transform matrix Matrix getMatrix(void) const override; - //! @brief get camera struct - operator ::Camera2D() const; - private: ::Camera2D _camera; + + INTERNAL: + //! @brief get camera struct + operator ::Camera2D() const; }; } diff --git a/lib/Ray/sources/Camera/Camera3D.hpp b/lib/Ray/sources/Camera/Camera3D.hpp index e0e82b8d..97e91dd9 100644 --- a/lib/Ray/sources/Camera/Camera3D.hpp +++ b/lib/Ray/sources/Camera/Camera3D.hpp @@ -62,12 +62,13 @@ namespace RAY::Camera { // Set camera mode (multiple camera modes available) void setMode(Mode mode); - //! @brief get camera struct - operator ::Camera3D() const; - private: ::Camera3D _camera; Mode _mode; + + INTERNAL: + //! @brief get camera struct + operator ::Camera3D() const; }; } diff --git a/lib/Ray/sources/Color.hpp b/lib/Ray/sources/Color.hpp index 0ad89a87..9a67d317 100644 --- a/lib/Ray/sources/Color.hpp +++ b/lib/Ray/sources/Color.hpp @@ -68,8 +68,6 @@ namespace RAY { //! @return A-component of color unsigned char getA(void) const; - //! @return color struct - operator ::Color() const; //! @return hexadecimal value of color int toHex(void) const; @@ -77,6 +75,10 @@ namespace RAY { private: //! @brief Color, really, that's just it... ::Color _color; + + INTERNAL: + //! @return color struct + operator ::Color() const; }; }; diff --git a/lib/Ray/sources/Drawables/Image.hpp b/lib/Ray/sources/Drawables/Image.hpp index c9f8577d..beeda629 100644 --- a/lib/Ray/sources/Drawables/Image.hpp +++ b/lib/Ray/sources/Drawables/Image.hpp @@ -54,9 +54,6 @@ namespace RAY //! @brief unload ressources bool unload() override; - //! @brief get image - operator ::Image() const; - operator ::Image *(); //! @brief draw drawable void draw(Drawables::ADrawable2D &); @@ -64,6 +61,11 @@ namespace RAY private: //! @brief Image, really, that's just it... ::Image _image; + + INTERNAL: + //! @brief get image + operator ::Image() const; + operator ::Image *(); }; } diff --git a/lib/Ray/sources/Drawables/Texture.hpp b/lib/Ray/sources/Drawables/Texture.hpp index bab0c36f..fb4bf0ec 100644 --- a/lib/Ray/sources/Drawables/Texture.hpp +++ b/lib/Ray/sources/Drawables/Texture.hpp @@ -45,13 +45,14 @@ namespace RAY //! @brief unload ressources bool unload() override; - //! @return libray Texture struct - operator ::Texture() const; - protected: private: //! @brief Texture, really, that's just it... ::Texture _texture; + + INTERNAL: + //! @return libray Texture struct + operator ::Texture() const; }; } diff --git a/lib/Ray/sources/Vector/Vector2.hpp b/lib/Ray/sources/Vector/Vector2.hpp index e384b020..9a5e1608 100644 --- a/lib/Ray/sources/Vector/Vector2.hpp +++ b/lib/Ray/sources/Vector/Vector2.hpp @@ -12,37 +12,39 @@ namespace RAY { //! @brief A Two-dimensionnal Vector data type. - struct Vector2 + class Vector2 { - //! @brief Vector 2 constructor - //! @param x x-value of vector, such as a width - //! @param y y-value of vector, such as a height - Vector2(float x, float y); + public: + //! @brief Vector 2 constructor + //! @param x x-value of vector, such as a width + //! @param y y-value of vector, such as a height + Vector2(float x, float y); - //! @brief Vector 2 constructor - //! @brief All values are set to zero - Vector2(); + //! @brief Vector 2 constructor + //! @brief All values are set to zero + Vector2(); - //! @brief A default Vector 2 copy-constructor - Vector2(const Vector2 &) = default; + //! @brief A default Vector 2 copy-constructor + Vector2(const Vector2 &) = default; - //! @brief A Vector 2 constructor from libray's vector2 - Vector2(const ::Vector2 &); + //! @brief A Vector 2 constructor from libray's vector2 + Vector2(const ::Vector2 &); - //! @brief A default Vector 2 destructor - ~Vector2() = default; + //! @brief A default Vector 2 destructor + ~Vector2() = default; - //! @brief A Vector 2 is assignable - Vector2 &operator=(const Vector2 &) = default; - - //! @brief A RAY Vector2 is cast-able in libray's Vector2 - operator ::Vector2() const; + //! @brief A Vector 2 is assignable + Vector2 &operator=(const Vector2 &) = default; - //! @brief X value of vector - float x; - //! @brief Y value of vector - float y; + //! @brief X value of vector + float x; + //! @brief Y value of vector + float y; + + INTERNAL: + //! @brief A RAY Vector2 is cast-able in libray's Vector2 + operator ::Vector2() const; }; } diff --git a/lib/Ray/sources/Vector/Vector3.hpp b/lib/Ray/sources/Vector/Vector3.hpp index 6b847ebe..b154b8c0 100644 --- a/lib/Ray/sources/Vector/Vector3.hpp +++ b/lib/Ray/sources/Vector/Vector3.hpp @@ -12,39 +12,42 @@ namespace RAY { //! @brief A Three-dimensionnal Vector data type. - struct Vector3 + class Vector3 { - //! @brief Vector 3 constructor - //! @param x x-value of vector, such as a width - //! @param y y-value of vector, such as a height - //! @param z z-value of vector, such as a depth - Vector3(float x, float y, float z); + public: + //! @brief Vector 3 constructor + //! @param x x-value of vector, such as a width + //! @param y y-value of vector, such as a height + //! @param z z-value of vector, such as a depth + Vector3(float x, float y, float z); - //! @brief Vector 3 constructor - //! @brief All values are set to zero - Vector3(); + //! @brief Vector 3 constructor + //! @brief All values are set to zero + Vector3(); - //! @brief A default Vector 3 copy-constructor - Vector3(const Vector3 &) = default; + //! @brief A default Vector 3 copy-constructor + Vector3(const Vector3 &) = default; - //! @brief A Vector 3 constructor from libray's vector3 - Vector3(const ::Vector3 &); + //! @brief A Vector 3 constructor from libray's vector3 + Vector3(const ::Vector3 &); - //! @brief A default Vector 3 destructor - ~Vector3() = default; + //! @brief A default Vector 3 destructor + ~Vector3() = default; - //! @brief A Vector 3 is assignable - Vector3 &operator=(const Vector3 &) = default; + //! @brief A Vector 3 is assignable + Vector3 &operator=(const Vector3 &) = default; - //! @brief A RAY Vector3 is cast-able in libray's Vector3 - operator ::Vector3() const; - //! @brief X value of vector - float x; - //! @brief Y value of vector - float y; - //! @brief Z value of vector - float z; + //! @brief X value of vector + float x; + //! @brief Y value of vector + float y; + //! @brief Z value of vector + float z; + + INTERNAL: + //! @brief A RAY Vector3 is cast-able in libray's Vector3 + operator ::Vector3() const; }; } From 23a87c18325c901aa1f93e6b128a73687f625ae5 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Sun, 23 May 2021 17:08:04 +0200 Subject: [PATCH 5/5] using constexpr for constant default letter spacing --- lib/Ray/sources/Drawables/2D/Text.cpp | 4 ++-- lib/Ray/sources/Drawables/2D/Text.hpp | 6 +++--- lib/Ray/sources/Window.cpp | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Ray/sources/Drawables/2D/Text.cpp b/lib/Ray/sources/Drawables/2D/Text.cpp index 72a5086f..29da6b8f 100644 --- a/lib/Ray/sources/Drawables/2D/Text.cpp +++ b/lib/Ray/sources/Drawables/2D/Text.cpp @@ -8,13 +8,13 @@ #include "Drawables/2D/Text.hpp" RAY::Drawables::Drawables2D::Text::Text(const std::string &content, int fontSize, const Vector2 &position, const Color &color): - ADrawable2D(position, color), _text(content), _size(fontSize), _spacing(DEFAULT_LETTER_SPACING) + ADrawable2D(position, color), _text(content), _size(fontSize), _spacing(this->DefaultLetterSpacing) { this->_font.recs = nullptr; } RAY::Drawables::Drawables2D::Text::Text(const std::string &content, int fontSize, int x, int y, const Color &color): - ADrawable2D(x, y, color), _text(content), _size(fontSize), _spacing(DEFAULT_LETTER_SPACING) + ADrawable2D(x, y, color), _text(content), _size(fontSize), _spacing(this->DefaultLetterSpacing) { this->_font.recs = nullptr; } diff --git a/lib/Ray/sources/Drawables/2D/Text.hpp b/lib/Ray/sources/Drawables/2D/Text.hpp index e1fb8ca0..46e0bd37 100644 --- a/lib/Ray/sources/Drawables/2D/Text.hpp +++ b/lib/Ray/sources/Drawables/2D/Text.hpp @@ -11,13 +11,12 @@ #include "Drawables/ADrawable2D.hpp" #include -#define DEFAULT_LETTER_SPACING 1 - namespace RAY::Drawables::Drawables2D { //! @brief Text in a two-dimensionnal space class Text: public ADrawable2D { public: + static constexpr int DefaultLetterSpacing = 1; //! @brief Text constructor //! @param content text //! @param fontSize size of the text @@ -79,7 +78,8 @@ namespace RAY::Drawables::Drawables2D { int _size; //! @brief spacing of chars - int _spacing; + int _spacing; + }; }; diff --git a/lib/Ray/sources/Window.cpp b/lib/Ray/sources/Window.cpp index de8f08da..0bfe0147 100644 --- a/lib/Ray/sources/Window.cpp +++ b/lib/Ray/sources/Window.cpp @@ -112,12 +112,14 @@ void RAY::Window::setDrawingState(enum RAY::Window::drawingState state) void RAY::Window::useCamera(RAY::Camera::Camera2D &camera) { + this->unuseCamera(); this->_displayState = RAY::Window::TWO_DIMENSIONNAL; BeginMode2D(camera); } void RAY::Window::useCamera(RAY::Camera::Camera3D &camera) { + this->unuseCamera(); this->_displayState = RAY::Window::THREE_DIMENSIONNAL; BeginMode3D(camera); }