Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PaintingTool.hpp
1#pragma once
2
3#include "resources/Texture.hpp"
4#include "resources/Mesh.hpp"
5
6#include "Common.hpp"
7
13
14public:
19 PaintingTool(unsigned int width, unsigned int height);
20
22 void draw();
23
25 void update();
26
31 void resize(uint width, uint height);
32
34
38 const Texture * texture() const { return &_canvas; }
39
43 const Texture * visuId() const { return &_visu; }
44
45private:
47 enum class Mode : int {
48 DRAW = 0,
49 ERASE
50 };
51
53 enum class Shape : int {
54 CIRCLE = 0,
55 SQUARE,
56 DIAMOND,
57 COUNT
58 };
59
62
64 std::vector<Mesh> _brushes;
65
66 glm::vec3 _bgColor = glm::vec3(0.0f);
67 glm::vec3 _fgColor = glm::vec3(1.0f);
68 glm::vec2 _drawPos = glm::vec2(0.0f);
69 int _radius = 40;
70 Mode _mode = Mode::DRAW;
71 Shape _shape = Shape::CIRCLE;
72 bool _shouldClear = true;
73 bool _shouldDraw = false;
74
75 GPUAsyncTask _readbackTask = 0;
76};
Utility presenting a canvas to the user, along with a brush tool to paint on it using different shape...
Definition: PaintingTool.hpp:12
glm::vec3 _bgColor
Canvas color.
Definition: PaintingTool.hpp:66
bool _shouldClear
Clear the canvas at the next frame.
Definition: PaintingTool.hpp:72
const Texture * texture() const
Definition: PaintingTool.hpp:38
Mode
The effect of a brush stroke.
Definition: PaintingTool.hpp:47
void update()
Definition: PaintingTool.cpp:102
GPUAsyncTask _readbackTask
Handle for color picker task.
Definition: PaintingTool.hpp:75
std::vector< Mesh > _brushes
Brush shape geometries.
Definition: PaintingTool.hpp:64
const Texture * visuId() const
Definition: PaintingTool.hpp:43
int _radius
Brush radius, in pixels.
Definition: PaintingTool.hpp:69
glm::vec3 _fgColor
Brush color.
Definition: PaintingTool.hpp:67
Texture _canvas
Scene rendering buffer.
Definition: PaintingTool.hpp:60
glm::vec2 _drawPos
Current brush position.
Definition: PaintingTool.hpp:68
void draw()
Definition: PaintingTool.cpp:55
Shape _shape
Current brush shape.
Definition: PaintingTool.hpp:71
Program * _brushShader
Program for the brush and its outline.
Definition: PaintingTool.hpp:63
Mode _mode
Current brush effect.
Definition: PaintingTool.hpp:70
void resize(uint width, uint height)
Definition: PaintingTool.cpp:154
Shape
The shape of the brush.
Definition: PaintingTool.hpp:53
bool _shouldDraw
Apply the brush to the canvas at the next frame.
Definition: PaintingTool.hpp:73
Texture _visu
Scene rendering buffer.
Definition: PaintingTool.hpp:61
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12