Merge branch 'renderer' into animations

This commit is contained in:
Clément Le Bihan
2021-05-23 18:27:34 +02:00
committed by GitHub
13 changed files with 86 additions and 69 deletions

View File

@@ -105,4 +105,6 @@ if (NOT raylib_FOUND)
endif() endif()
add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS}) 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) target_link_libraries(${LIB_NAME} raylib)

View File

@@ -16,7 +16,7 @@ namespace RAY::Audio
//! @brief Interface for Audio ressources //! @brief Interface for Audio ressources
class IAudio: public IRessource { class IAudio: public IRessource {
public: public:
virtual ~IAudio() = 0; virtual ~IAudio() = default;
//! @brief Load Audio stream from file //! @brief Load Audio stream from file
virtual bool load(const std::string &path) = 0; virtual bool load(const std::string &path) = 0;

View File

@@ -26,7 +26,7 @@ namespace RAY::Camera {
//! @brief A copy constructor //! @brief A copy constructor
Camera2D(const Camera2D &) = default; Camera2D(const Camera2D &) = default;
~Camera2D() = default; ~Camera2D() override = default;
//! @brief A Camera is assignable //! @brief A Camera is assignable
Camera2D &operator=(const Camera2D &) = default; Camera2D &operator=(const Camera2D &) = default;
@@ -52,11 +52,12 @@ namespace RAY::Camera {
//! @brief Returns camera 2d transform matrix //! @brief Returns camera 2d transform matrix
Matrix getMatrix(void) const override; Matrix getMatrix(void) const override;
//! @brief get camera struct
operator ::Camera2D() const;
private: private:
::Camera2D _camera; ::Camera2D _camera;
INTERNAL:
//! @brief get camera struct
operator ::Camera2D() const;
}; };
} }

View File

@@ -29,7 +29,7 @@ namespace RAY::Camera {
//! @brief A copy constructor //! @brief A copy constructor
Camera3D(const Camera3D &) = default; Camera3D(const Camera3D &) = default;
~Camera3D() = default; ~Camera3D() override = default;
//! @brief A Camera is assignable //! @brief A Camera is assignable
Camera3D &operator=(const Camera3D &) = default; Camera3D &operator=(const Camera3D &) = default;
@@ -67,10 +67,13 @@ namespace RAY::Camera {
//! @brief get camera struct //! @brief get camera struct
operator ::Camera3D() const; operator ::Camera3D() const;
private: private:
::Camera3D _camera; ::Camera3D _camera;
Mode _mode; Mode _mode;
INTERNAL:
//! @brief get camera struct
operator ::Camera3D() const;
}; };
} }

View File

@@ -68,8 +68,6 @@ namespace RAY {
//! @return A-component of color //! @return A-component of color
unsigned char getA(void) const; unsigned char getA(void) const;
//! @return color struct
operator ::Color() const;
//! @return hexadecimal value of color //! @return hexadecimal value of color
int toHex(void) const; int toHex(void) const;
@@ -77,6 +75,10 @@ namespace RAY {
private: private:
//! @brief Color, really, that's just it... //! @brief Color, really, that's just it...
::Color _color; ::Color _color;
INTERNAL:
//! @return color struct
operator ::Color() const;
}; };
}; };

View File

@@ -8,13 +8,13 @@
#include "Drawables/2D/Text.hpp" #include "Drawables/2D/Text.hpp"
RAY::Drawables::Drawables2D::Text::Text(const std::string &content, int fontSize, const Vector2 &position, const Color &color): 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; this->_font.recs = nullptr;
} }
RAY::Drawables::Drawables2D::Text::Text(const std::string &content, int fontSize, int x, int y, const Color &color): 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; this->_font.recs = nullptr;
} }

View File

@@ -11,13 +11,12 @@
#include "Drawables/ADrawable2D.hpp" #include "Drawables/ADrawable2D.hpp"
#include <string> #include <string>
#define DEFAULT_LETTER_SPACING 1
namespace RAY::Drawables::Drawables2D { namespace RAY::Drawables::Drawables2D {
//! @brief Text in a two-dimensionnal space //! @brief Text in a two-dimensionnal space
class Text: public ADrawable2D class Text: public ADrawable2D
{ {
public: public:
static constexpr int DefaultLetterSpacing = 1;
//! @brief Text constructor //! @brief Text constructor
//! @param content text //! @param content text
//! @param fontSize size of the text //! @param fontSize size of the text
@@ -79,7 +78,8 @@ namespace RAY::Drawables::Drawables2D {
int _size; int _size;
//! @brief spacing of chars //! @brief spacing of chars
int _spacing; int _spacing;
}; };
}; };

View File

@@ -54,9 +54,6 @@ namespace RAY
//! @brief unload ressources //! @brief unload ressources
bool unload() override; bool unload() override;
//! @brief get image
operator ::Image() const;
operator ::Image *();
//! @brief draw drawable //! @brief draw drawable
void draw(Drawables::ADrawable2D &); void draw(Drawables::ADrawable2D &);
@@ -64,6 +61,11 @@ namespace RAY
private: private:
//! @brief Image, really, that's just it... //! @brief Image, really, that's just it...
::Image _image; ::Image _image;
INTERNAL:
//! @brief get image
operator ::Image() const;
operator ::Image *();
}; };
} }

View File

@@ -45,13 +45,14 @@ namespace RAY
//! @brief unload ressources //! @brief unload ressources
bool unload() override; bool unload() override;
//! @return libray Texture struct
operator ::Texture() const;
protected: protected:
private: private:
//! @brief Texture, really, that's just it... //! @brief Texture, really, that's just it...
::Texture _texture; ::Texture _texture;
INTERNAL:
//! @return libray Texture struct
operator ::Texture() const;
}; };
} }

View File

@@ -12,37 +12,39 @@
namespace RAY { namespace RAY {
//! @brief A Two-dimensionnal Vector data type. //! @brief A Two-dimensionnal Vector data type.
struct Vector2 class Vector2
{ {
//! @brief Vector 2 constructor public:
//! @param x x-value of vector, such as a width //! @brief Vector 2 constructor
//! @param y y-value of vector, such as a height //! @param x x-value of vector, such as a width
Vector2(float x, float y); //! @param y y-value of vector, such as a height
Vector2(float x, float y);
//! @brief Vector 2 constructor //! @brief Vector 2 constructor
//! @brief All values are set to zero //! @brief All values are set to zero
Vector2(); Vector2();
//! @brief A default Vector 2 copy-constructor //! @brief A default Vector 2 copy-constructor
Vector2(const Vector2 &) = default; Vector2(const Vector2 &) = default;
//! @brief A Vector 2 constructor from libray's vector2 //! @brief A Vector 2 constructor from libray's vector2
Vector2(const ::Vector2 &); Vector2(const ::Vector2 &);
//! @brief A default Vector 2 destructor //! @brief A default Vector 2 destructor
~Vector2() = default; ~Vector2() = default;
//! @brief A Vector 2 is assignable //! @brief A Vector 2 is assignable
Vector2 &operator=(const Vector2 &) = default; Vector2 &operator=(const Vector2 &) = default;
//! @brief A RAY Vector2 is cast-able in libray's Vector2
operator ::Vector2() const;
//! @brief X value of vector //! @brief X value of vector
float x; float x;
//! @brief Y value of vector //! @brief Y value of vector
float y; float y;
INTERNAL:
//! @brief A RAY Vector2 is cast-able in libray's Vector2
operator ::Vector2() const;
}; };
} }

View File

@@ -12,39 +12,42 @@
namespace RAY { namespace RAY {
//! @brief A Three-dimensionnal Vector data type. //! @brief A Three-dimensionnal Vector data type.
struct Vector3 class Vector3
{ {
//! @brief Vector 3 constructor public:
//! @param x x-value of vector, such as a width //! @brief Vector 3 constructor
//! @param y y-value of vector, such as a height //! @param x x-value of vector, such as a width
//! @param z z-value of vector, such as a depth //! @param y y-value of vector, such as a height
Vector3(float x, float y, float z); //! @param z z-value of vector, such as a depth
Vector3(float x, float y, float z);
//! @brief Vector 3 constructor //! @brief Vector 3 constructor
//! @brief All values are set to zero //! @brief All values are set to zero
Vector3(); Vector3();
//! @brief A default Vector 3 copy-constructor //! @brief A default Vector 3 copy-constructor
Vector3(const Vector3 &) = default; Vector3(const Vector3 &) = default;
//! @brief A Vector 3 constructor from libray's vector3 //! @brief A Vector 3 constructor from libray's vector3
Vector3(const ::Vector3 &); Vector3(const ::Vector3 &);
//! @brief A default Vector 3 destructor //! @brief A default Vector 3 destructor
~Vector3() = default; ~Vector3() = default;
//! @brief A Vector 3 is assignable //! @brief A Vector 3 is assignable
Vector3 &operator=(const Vector3 &) = default; Vector3 &operator=(const Vector3 &) = default;
//! @brief A RAY Vector3 is cast-able in libray's Vector3
operator ::Vector3() const;
//! @brief X value of vector //! @brief X value of vector
float x; float x;
//! @brief Y value of vector //! @brief Y value of vector
float y; float y;
//! @brief Z value of vector //! @brief Z value of vector
float z; float z;
INTERNAL:
//! @brief A RAY Vector3 is cast-able in libray's Vector3
operator ::Vector3() const;
}; };
} }

View File

@@ -112,12 +112,14 @@ void RAY::Window::setDrawingState(enum RAY::Window::drawingState state)
void RAY::Window::useCamera(RAY::Camera::Camera2D &camera) void RAY::Window::useCamera(RAY::Camera::Camera2D &camera)
{ {
this->unuseCamera();
this->_displayState = RAY::Window::TWO_DIMENSIONNAL; this->_displayState = RAY::Window::TWO_DIMENSIONNAL;
BeginMode2D(camera); BeginMode2D(camera);
} }
void RAY::Window::useCamera(RAY::Camera::Camera3D &camera) void RAY::Window::useCamera(RAY::Camera::Camera3D &camera)
{ {
this->unuseCamera();
this->_displayState = RAY::Window::THREE_DIMENSIONNAL; this->_displayState = RAY::Window::THREE_DIMENSIONNAL;
BeginMode3D(camera); BeginMode3D(camera);
} }

View File

@@ -19,7 +19,6 @@
int main() int main()
{ {
WAL::Wal wal;
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------