Rendu
A lightweight rendering engine for experimentations
|
Utility presenting a canvas to the user, along with a brush tool to paint on it using different shapes. More...
#include <PaintingTool.hpp>
Public Member Functions | |
PaintingTool (unsigned int width, unsigned int height) | |
void | draw () |
void | update () |
void | resize (uint width, uint height) |
const Texture * | texture () const |
const Texture * | visuId () const |
Private Types | |
enum class | Mode : int { DRAW = 0 , ERASE } |
The effect of a brush stroke. | |
enum class | Shape : int { CIRCLE = 0 , SQUARE , DIAMOND , COUNT } |
The shape of the brush. | |
Private Attributes | |
Texture | _canvas |
Scene rendering buffer. | |
Texture | _visu |
Scene rendering buffer. | |
Program * | _brushShader |
Program for the brush and its outline. | |
std::vector< Mesh > | _brushes |
Brush shape geometries. | |
glm::vec3 | _bgColor = glm::vec3(0.0f) |
Canvas color. | |
glm::vec3 | _fgColor = glm::vec3(1.0f) |
Brush color. | |
glm::vec2 | _drawPos = glm::vec2(0.0f) |
Current brush position. | |
int | _radius = 40 |
Brush radius, in pixels. | |
Mode | _mode = Mode::DRAW |
Current brush effect. | |
Shape | _shape = Shape::CIRCLE |
Current brush shape. | |
bool | _shouldClear = true |
Clear the canvas at the next frame. | |
bool | _shouldDraw = false |
Apply the brush to the canvas at the next frame. | |
GPUAsyncTask | _readbackTask = 0 |
Handle for color picker task. | |
Utility presenting a canvas to the user, along with a brush tool to paint on it using different shapes.
PaintingTool::PaintingTool | ( | unsigned int | width, |
unsigned int | height | ||
) |
Constructor.
width | the canvas width |
height | the canvas height |
void PaintingTool::draw | ( | ) |
Draw the scene and effects
void PaintingTool::resize | ( | uint | width, |
uint | height | ||
) |
Handle a window resize event.
width | the new width |
height | the new height |
|
inline |
Canvas content texture.
void PaintingTool::update | ( | ) |
Perform once-per-frame update (buttons, GUI,...)
|
inline |
Texture containing the canvas and the brush shape outline, for visualisation.