image + texture

This commit is contained in:
arthur.jamet
2021-05-19 12:47:42 +02:00
parent a6bd69872c
commit e66f5d10a5
25 changed files with 126 additions and 25 deletions
+1
View File
@@ -0,0 +1 @@
build/
+2
View File
@@ -68,6 +68,8 @@ set(SRC
src/Controllers/Mouse.cpp
src/Drawables/ADrawable2D.cpp
src/Drawables/ADrawable3D.cpp
src/Drawables/Image.cpp
src/Drawables/Texture.cpp
)
add_library(${LIB_NAME} STATIC ${SRC} ${HEADERS})
+1 -1
View File
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables2D {
Circle &setRadius(int radius) const;
//! @brief Draw Circle on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Radius of the circle
+1 -1
View File
@@ -51,7 +51,7 @@ namespace RAY::Drawables::Drawables2D {
Line &setRotation(int);
//! @brief Draw line on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Length of the line
int _length;
+1 -1
View File
@@ -36,7 +36,7 @@ namespace RAY::Drawables::Drawables2D {
~Point() = default;
//! @brief Draw point on window
void drawOn(Window &);
void drawOn(Canvas &);
};
};
+1 -1
View File
@@ -48,7 +48,7 @@ namespace RAY::Drawables::Drawables2D {
Rectangle &setDimensions(int x, int y);
//! @brief Draw rectangle on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Diemnsions of the rectangle
+1 -1
View File
@@ -55,7 +55,7 @@ namespace RAY::Drawables::Drawables2D {
Text &setFontSize(int size);
//! @brief Draw text on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Text, just text
+1 -1
View File
@@ -52,7 +52,7 @@ namespace RAY::Drawables::Drawables2D {
Triangle &setPositionC(Vector2);
//! @brief Draw triangle on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Position of A
+1 -1
View File
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables3D {
Circle &setRadius(const Vector3 &pos) const;
//! @brief Draw circle on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Radius of the circle
+1 -1
View File
@@ -58,7 +58,7 @@ namespace RAY::Drawables::Drawables3D {
Cylinder &setHeigth(float heigth) const;
//! @brief Draw cylinder on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Radius of the cylinder
+1 -1
View File
@@ -42,7 +42,7 @@ namespace RAY::Drawables::Drawables3D {
Grid &setSpacing(float spacing);
//! @brief Draw grid on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Grid slices
+1 -1
View File
@@ -46,7 +46,7 @@ namespace RAY::Drawables::Drawables3D {
Line &setEndPosition(const Vector3 &endPosition);
//! @brief Draw line on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief start position
+1 -1
View File
@@ -43,7 +43,7 @@ namespace RAY::Drawables::Drawables3D {
Plane &setDimensions(const Vector3 &dimensions);
//! @brief Draw plane on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief plane position
Vector3 _position;
+1 -1
View File
@@ -36,7 +36,7 @@ namespace RAY::Drawables::Drawables3D {
Point &setPosition(const Vector3 &Position);
//! @brief Draw point on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief point position
+1 -1
View File
@@ -46,7 +46,7 @@ namespace RAY::Drawables::Drawables3D {
Ray &setDirection(const Vector3 &dimensions);
//! @brief Draw ray on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief start position
+1 -1
View File
@@ -44,7 +44,7 @@ namespace RAY::Drawables::Drawables3D {
Sphere &setRadius(const Vector3 &pos) const;
//! @brief Draw sphere on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Radius of the sphere
+1 -1
View File
@@ -52,7 +52,7 @@ namespace RAY::Drawables::Drawables3D {
Triangle &setPositionC(Vector3);
//! @brief Draw triangle on window
void drawOn(Window &);
void drawOn(Canvas &);
private:
//! @brief Position of A
+2 -1
View File
@@ -12,6 +12,7 @@
#include <Vector.hpp>
#include "Drawables/IDrawable.hpp"
#include "Color.hpp"
#include "Canvas.hpp"
namespace RAY::Drawables::Drawables2D {
class ADrawable2D: public IDrawable
@@ -49,7 +50,7 @@ namespace RAY::Drawables::Drawables2D {
ADrawable2D &setColor(const Color &color);
//! @brief Draw drawble on window
virtual void drawOn(Window &) = 0;
virtual void drawOn(RAY::Canvas &) = 0;
private:
//! @brief Top-left position
+1 -1
View File
@@ -27,7 +27,7 @@ namespace RAY::Drawables::Drawables3D {
virtual ~ADrawable3D() = default;
//! @brief Draw drawble on window
virtual void drawOn(Window &) = 0;
virtual void drawOn(Canvas &) = 0;
//! @return the color of the ADrawable
+2 -2
View File
@@ -10,13 +10,13 @@
namespace RAY
{
class Window;
class Canvas;
namespace Drawables {
class IDrawable {
public:
virtual ~IDrawable() = 0;
virtual void drawOn(RAY::Window &) = 0;
virtual void drawOn(RAY::Canvas &) = 0;
protected:
private:
+3 -2
View File
@@ -12,6 +12,7 @@
#include <string>
#include "Canvas.hpp"
#include "IRessource.hpp"
#include "Drawables/IDrawable.hpp"
namespace RAY
{
@@ -22,7 +23,7 @@ namespace RAY
Image(const std::string &filename);
//! @brief A default copy constructor
Image(const Image &);
Image(const Image &) = default;
//! @brief A default constructor, no ressources loaded
Image();
@@ -48,7 +49,7 @@ namespace RAY
const ::Image &getImage(void) const;
//! @brief draw drawable
void draw(const Drawables::IDrawable &);
void draw(Drawables::IDrawable &);
protected:
private:
+2 -2
View File
@@ -26,7 +26,7 @@ namespace RAY
Texture(const Image &image);
//! @brief A default copy constructor
Texture(const Texture &);
Texture(const Texture &) = default;
//! @brief A default constructor, no ressources loaded
Texture();
@@ -53,7 +53,7 @@ namespace RAY
protected:
private:
//! @brief Texture, really, that's just it...
::Texture _image;
::Texture _texture;
};
}
+2 -2
View File
@@ -8,14 +8,14 @@
#include "Drawables/ADrawable2D.hpp"
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(const Vector2 &position, const RAY::Color &color):
_color(color), _position(position)
_position(position), _color(color)
{
}
RAY::Drawables::Drawables2D::ADrawable2D::ADrawable2D(int x, int y, const RAY::Color &color):
_color(color), _position({(float)x, (float)y})
_position({(float)x, (float)y}), _color(color)
{
}
+51
View File
@@ -0,0 +1,51 @@
/*
** EPITECH PROJECT, 2021
** Bomberman
** File description:
** Image
*/
#include "Drawables/Image.hpp"
RAY::Image::Image(const std::string &filename):
_image(LoadImage(filename.c_str()))
{
}
RAY::Image::Image()
{
}
RAY::Image::~Image()
{
UnloadImage(_image);
}
bool RAY::Image::load(const std::string &filename)
{
this->_image = LoadImage(filename.c_str());
return true;
}
bool RAY::Image::exportTo(const std::string &outputPath)
{
ExportImage(_image, outputPath.c_str());
return true;
}
bool RAY::Image::unload()
{
UnloadImage(_image);
return true;
}
const ::Image &RAY::Image::getImage(void) const
{
return _image;
}
void RAY::Image::draw(Drawables::IDrawable & drawable)
{
drawable.drawOn(*this);
}
+45
View File
@@ -0,0 +1,45 @@
/*
** EPITECH PROJECT, 2021
** Bomberman
** File description:
** Texture
*/
#include "Drawables/Texture.hpp"
RAY::Texture::Texture(const std::string &filename):
_texture(LoadTexture(filename.c_str()))
{
}
RAY::Texture::Texture(const Image &image):
_texture(LoadTextureFromImage(image))
{
}
RAY::Texture::Texture()
{
}
RAY::Texture::~Texture()
{
UnloadTexture(this->_texture);
}
bool RAY::Texture::load(const std::string &filename)
{
this->_texture = LoadTexture(filename.c_str());
return true;
}
Image RAY::Texture::toImage(void) const
{
return GetTextureData(_texture);
}
const ::Texture &RAY::Texture::getTexture(void) const
{
return this->_texture;
}