Skip to content

Commit

Permalink
Final update 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
angeluriot committed May 20, 2022
1 parent 9c0f11d commit 9bb5ce4
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 27 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ This program generate images of fractals like the Mandelbrot set, the Julia set,
# Summary

* **[Summary](#summary)**
* **[Video](#video)**
* **[Features](#features)**
* **[Install](#install)**
* [Skeleton project install](#skeleton-project-install)
Expand All @@ -41,12 +40,6 @@ This program generate images of fractals like the Mandelbrot set, the Julia set,

<br/>

# Video

Soon...

<br/>

# Features

* It can generate the Mandelbrot set, the Julia set, the Birning Ship, the Buddhabrot or Newton fractals
Expand Down
4 changes: 2 additions & 2 deletions imgui.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Window][InvisibleWindow]
Pos=0,0
Size=1920,1080
Size=1440,810
Collapsed=0

[Window][Menu]
Expand Down Expand Up @@ -34,5 +34,5 @@ Size=277,472
Collapsed=0

[Docking][Data]
DockSpace ID=0xF442860A Window=0xD8117908 Pos=0,0 Size=1920,1080 CentralNode=1 Selected=0x18B8C0DE
DockSpace ID=0xF442860A Window=0xD8117908 Pos=0,0 Size=1440,810 CentralNode=1 Selected=0x18B8C0DE

20 changes: 18 additions & 2 deletions sources/Simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class Simulator
{
public:

static Fractal* fractal;
static Fractal* fractal; // The fractal to compute.
static double area_width; // The width of the area on the screen.
static std::array<double, 2> position; // The center of the area on the screen.
static bool image_done;
static bool image_done; // True if the image is computed.

/**
* @brief Initialize the simulation.
Expand All @@ -36,9 +36,25 @@ class Simulator
*/
static void reset();

/**
* @brief Transform a screen position to a fractal position.
*
* @param position the screen position
* @return the fractal position
*/
static std::array<double, 2> screen_to_world(dim::Vector2int position);

/**
* @brief Transform a fractal position to a screen position.
*
* @param position the fractal position
* @return the screen position
*/
static dim::Vector2int world_to_screen(std::array<double, 2> position);

/**
* @brief Handle the events of the simulation.
*/
static void update();

/**
Expand Down
31 changes: 28 additions & 3 deletions sources/compute_shader/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,41 @@ class Image
{
public:

dim::Texture texture;
std::vector<dim::Color> data;
cl::Buffer buffer;
dim::Texture texture; // The texture filled with the image data.
std::vector<dim::Color> data; // The image data.
cl::Buffer buffer; // The OpenCL buffer containing the image data.

Image() = default;
Image(const Image& other) = default;

/**
* @brief Clear the texture and the data.
*
* @param width the new width of the image
* @param height the new height of the image
*/
void reset(unsigned int width, unsigned int height);

/**
* @brief Fill the image with a color.
*
* @param color the color to fill the image with
*/
void fill(const dim::Color& color);

/**
* @brief Update the texture with the image data.
*
* @param width the width of the image
* @param height the height of the image
*/
void update(unsigned int width, unsigned int height);

/**
* @brief Save the image.
*
* @param folder the folder to save the image to
*/
void save(std::string folder);
};

Expand Down
14 changes: 11 additions & 3 deletions sources/fractals/Buddhabrot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ class Buddhabrot : public Fractal
{
public:

int max_iterations;
int nb_points;
float brightness;
int nb_points; // The number of points to compute.
float brightness; // The brightness of the image.

Buddhabrot();
Buddhabrot(const Buddhabrot& other) = default;

Type get_type() const override;
void menu() override;
void reset() override;

/**
* @brief Compute the Buddhabrot fractal for a specific clor.
*
* @param points_buffer a buffer containing the points to compute
* @param color_id the color id of the points to compute
* @param current_max_iterations the current max iterations number
*/
void compute_color(const cl::Buffer& points_buffer, int color_id, int current_max_iterations);

void compute() override;
};

Expand Down
1 change: 0 additions & 1 deletion sources/fractals/BurningShip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class BurningShip : public Fractal
{
public:

int max_iterations;
int pallet_index;
bool smooth;

Expand Down
21 changes: 20 additions & 1 deletion sources/fractals/Fractal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,30 @@ class Fractal
Newton_2 = 5
};

static Image image;
static Image image; // The image of the fractal.

int max_iterations; // The max iterations number.

/**
* @brief Give the type of the fractal.
*
* @return the type of the fractal
*/
virtual Type get_type() const = 0;

/**
* @brief Show the menu of the fractal.
*/
virtual void menu() = 0;

/**
* @brief Reset the fractal settings.
*/
virtual void reset() = 0;

/**
* @brief Compute the fractal image.
*/
virtual void compute() = 0;
};

Expand Down
1 change: 0 additions & 1 deletion sources/fractals/Julia.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Julia : public Fractal
public:

std::array<float, 2> c;
int max_iterations;
int pallet_index;
bool smooth;

Expand Down
1 change: 0 additions & 1 deletion sources/fractals/Mandelbrot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Mandelbrot : public Fractal
{
public:

int max_iterations;
int pallet_index;
bool smooth;

Expand Down
1 change: 0 additions & 1 deletion sources/fractals/Newton_1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Newton_1 : public Fractal
{
public:

int max_iterations;
std::array<float, 2> p_1;
std::array<float, 2> p_2;
std::array<float, 2> p_3;
Expand Down
1 change: 0 additions & 1 deletion sources/fractals/Newton_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Newton_2 : public Fractal
{
public:

int max_iterations;
bool smooth;

Newton_2();
Expand Down
6 changes: 6 additions & 0 deletions sources/menu/Menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class Menu
static void display();
};

/**
* @brief Transform a double into a string.
*
* @param value the double value
* @return the resulting string
*/
std::string to_string(const double& value);

#endif
13 changes: 10 additions & 3 deletions sources/renderer/ColorPallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ class ColorPallet
{
public:

static std::vector<std::vector<dim::Color>> pallets;
static constexpr int rgb = 5;
static constexpr int black_or_white = 7;
static std::vector<std::vector<dim::Color>> pallets; // The list of color pallets.
static constexpr int rgb = 5; // The id of the RGB pallet.
static constexpr int black_or_white = 7; // The id of the black and white pallet.

/**
* @brief Show the color pallet menu.
*
* @param index the index of the color pallet
* @return true if the selected color pallet changed
*/
static bool menu(int& index);
};

Expand Down
2 changes: 1 addition & 1 deletion sources/renderer/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Renderer
{
public:

static dim::VertexBuffer screen;
static dim::VertexBuffer screen; // The screen buffer.

/**
* @brief Initialize the renderer.
Expand Down

0 comments on commit 9bb5ce4

Please sign in to comment.