diff --git a/README.md b/README.md index 55d2d06cff8e0df82e7d911ddc75a3e771b6bc26..7c1b53379a9fb9e5c8d372141c7f06928ed61251 100644 --- a/README.md +++ b/README.md @@ -101,31 +101,31 @@ Todo **Constructors and Destructors** -- `Drawer(Toolbox&)` +- **`Drawer(Toolbox&)`** - Notes: The argument is unused. It should be removed. -- `Drawer(const Drawer&) = default` -- `~Drawer() = default` +- **`Drawer(const Drawer&) = default`** +- **`~Drawer() = default`** **Public Function Members** -- `void start_drawing(const float x, const float y)`: +- **`void start_drawing(const float x, const float y)`** - Description: Start drawing at coordinates (`x`, `y`) (typically fingerdown location). Doesn't draw anything. - Preconditions: - Postconditions:Drawing start is set to (x, y). - Notes: Nothing is drawn by this function. (x, y) are typically the fingerdown coordinates. -- `bool draw(const float x, const float y, Toolbox& tb, bool drawing)` +- **`bool draw(const float x, const float y, Toolbox& tb, bool drawing)`** - Description: Draw a stroke from the last position to (x, y), with strokewidth controlled by `drawing` (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). - Preconditions: A `GL_ARRAY_BUFFER` is bound and the Opengl state is set as desired - Postconditions: The points of the new segment have been calculated and uploaded to the currently bound `GL_ARRAY_BUFFER`, a call to `glDrawArrays` has been done to draw the segment. Returns `true` if something was drawn, and `false` else (typically when new point is same as last point). - Notes: -- `void redraw(Toolbox&)` +- **`void redraw(Toolbox&)`** - Description: Redraws the last drawn stroke. - Preconditions: `draw` has been called at least once, and since the last call to `draw`, the then-bound `GL_ARRAY_BUFFER` has not been modified. - Postconditions: A drawcall `glDrawArrays` has been issued. - Notes: -- `void erase(const float x, const float y, Toolbox& tb)` **DEPRECATED** +- **`void erase(const float x, const float y, Toolbox& tb)`** **DEPRECATED** - Notes: Use `draw(x, y, tb, false)` instead. -- `int num_drawn()` +- **`int num_drawn()`** - Description: Returns the number of calls to `draw` and `erase` that have been performed by this object. - Preconditions: - Postconditions: @@ -134,7 +134,7 @@ Todo **Private Function Members** -- `bool calculate_points_(Toolbox& tb, bool drawing)` +- **`bool calculate_points_(Toolbox& tb, bool drawing)`** - Description: Calculate the triangulation of the stroke represented by the internal parameters, and store them in `points_`. The stroke width is controlled by `drawing` (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). - Preconditions: The points (`x0_`, `y0_`) and (`x1_`, `y1_`) are set as desired. @@ -168,18 +168,18 @@ This class handles all aspects of the `Zeichnen` / `Radieren` functionality. It **Constructors and Destructors** -- `DrawingHandler(Toolbox&)` +- **`DrawingHandler(Toolbox&)`** - Notes: `Toolbox` is needed to find shader sources and obtain handles to the damping and wave textures. -- `~DrawingHandler()` +- **`~DrawingHandler()`** **Public Function Members** -- `void update(Toolbox&)` +- **`void update(Toolbox&)`** - Description: Handles messages directed to it, parses events and takes the necessary actions (spawn / delete `Drawer`s, draw with `Drawer`s using correct infrastructure). - Preconditions: The object is initialized correctly. - Postconditions: The desired portions have been drawn to static damping and to the wave 1 texture. - Notes: -- `size_t num_drawers()` +- **`size_t num_drawers()`** - Description: Returns the current number of active `Drawer`s. - Preconditions: - Postconditions: @@ -187,14 +187,14 @@ This class handles all aspects of the `Zeichnen` / `Radieren` functionality. It **Private Function Members** -- `void draw_(Toolbox&)` +- **`void draw_(Toolbox&)`** - Notes: Does nothing. -- `bool in_wave_window_(const Toolbox&, const Pevent&) const` +- **`bool in_wave_window_(const Toolbox&, const Pevent&) const`** - Description: Check if an event is within the wave window. - Preconditions: - Postconditions: Returns `true` if the event is in the wave window, and `false` else (i.e. when event is in the GUI window). - Notes: -- `std::array<float, 2> drawerCoordinates_(const Pevent&, const Toolbox&)` +- **`std::array<float, 2> drawerCoordinates_(const Pevent&, const Toolbox&)`** - Description: Compute drawer coordinates of a `Pevent`. - Preconditions: - Postconditions: @@ -206,27 +206,12 @@ N/A **Private Data Members** -- `std::list<std::pair<Drawer, SDL_FingerID> > drawpairs_` - - List of `Drawer`s and the corresponding `SDL_FingerID` that spawned/controls them. - -- `int previous_mstate_` - - `tb.mstate` from previous frame - -- `float draw_value_, erase_value_` **DEPRECATED** - -- `GLuint vao_, vbo_` - - Vertex Array Object and Vertex Buffer Object that are used by the `Drawer`s - -- `GLuint fbo_, fbo_wave_` - - Framebuffers that target the static damping texture (`fbo_`) and the wave texture 1 (`fbo_wave_`) - -- `Shader shader_draw_` - - Shader that is used. +- `std::list<std::pair<Drawer, SDL_FingerID> > drawpairs_`: List of `Drawer`s and the corresponding `SDL_FingerID` that spawned/controls them. +- `int previous_mstate_`: `tb.mstate` from previous frame +- `float draw_value_, erase_value_`: **DEPRECATED** +- `GLuint vao_, vbo_`: Vertex Array Object and Vertex Buffer Object that are used by the `Drawer`s +- `GLuint fbo_, fbo_wave_`: Framebuffers that target the static damping texture (`fbo_`) and the wave texture 1 (`fbo_wave_`) +- `Shader shader_draw_`: Shader that is used. **Notes** @@ -250,45 +235,44 @@ Represents a rectangular block. Scaled down version of the previous `Block`, opt **Constructors and Destructors** -- `EfficientBlock()` -- `EfficientBlock(const EfficientBlock&)` -- `EfficientBlock(int w, int h, int xoffset, int yoffset)` - - Note that (`xoffset`, `yoffset`) are the coordinates of the lower left corner, with origin in the top left corner of the texture. +- **`EfficientBlock()`** +- **`EfficientBlock(const EfficientBlock&)`** +- **`EfficientBlock(int w, int h, int xoffset, int yoffset)`** + - Note: (`xoffset`, `yoffset`) are the coordinates of the lower left corner, with origin in the top left corner of the texture. **Public Function Members** -- `void request_removal()` +- **`void request_removal()`** - Description: Mark block for removal - Preconditions: - Postconditions: Block is marked for removal - Notes: -- `void translate(int new_x, int new_y)` +- **`void translate(int new_x, int new_y)`** - Description: Translate block to new (LLC) texel-coordinates. - Preconditions: - Postconditions: Block has been translated to (`new_x`, `new_y`). - Notes: -- `bool needs_removal() const` +- **`bool needs_removal() const`** - Description: Check if block is marked for removal. - Preconditions: - Postconditions: Returns `true` if block has been marked for removal, and `false` else. - Notes: -- `glm::ivec4 xywh() const` +- **`glm::ivec4 xywh() const`** - Description: Get coordinates and dimensions of block. - Preconditions: - Postconditions: Returns a `glm::ivec4`; `[0]`->x, `[1]`->y, `[2]`->width, `[3]`->height. - Notes: -- `bool is_inside(int x, int y) const` +- **`bool is_inside(int x, int y) const`** - Description: Check if a point lies within the block. - Preconditions: - Postconditions: Returns `true` if point (`x`, `y`) is inside the block, `false` else. - Notes: -- `int width() const` +- **`int width() const`** - Description: Get the width of the block. - Preconditions: - Postconditions: Returns the width of the block in texels. - Notes: -- `int height() const` +- **`int height() const`** - Description: Get the height of the block. - Preconditions: - Postconditions: Returns the height of the block in texels. @@ -325,13 +309,12 @@ Logs events directly from the `Toolbox` and sorts them by type in 16-deep circul **Constructors and Destructors** -- `EventLogger()` -- `EventLogger(const EventLogger&)` +- **`EventLogger()`** +- **`EventLogger(const EventLogger&)`** **Public Function Members** -- `void push_events(Toolbox&)` - +- **`void push_events(Toolbox&)`** - Description: Catch events from `Toolbox` - Preconditions: New events have been captured by the `Toolbox` - Postconditions: The events have been sorted into their corresponding circular buffer @@ -340,8 +323,7 @@ Logs events directly from the `Toolbox` and sorts them by type in 16-deep circul **Non-Member Functions** -- `std::string ptos(const Pevent&, const Toolbox&)` - +- **`std::string ptos(const Pevent&, const Toolbox&)`** - Description: Convert a `Pevent` to a `std::string`. - Preconditions: - Postconditions: Returns a `std::string` that describes the `Pevent`. @@ -383,7 +365,7 @@ Draws and controls all functionality related to the GUI. **Constructors and Destructors** -- `GuiHandler(float)` +- **`GuiHandler(float)`** **Public Function Members** @@ -392,11 +374,7 @@ Draws and controls all functionality related to the GUI. - Preconditions: Fully setup `Toolbox`, correct paths to images and fonts - Postconditions: Fonts and images have been loaded, ImGui is fully initialized. - Notes: - - - - **`void update(Toolbox& tb)`** - - Description: Update the GUI - Preconditions: - Postconditions: Tasks performed: @@ -405,7 +383,6 @@ Draws and controls all functionality related to the GUI. - Handle any input to the GUI, pass it on to ImGui for processing - Construct the GUI - Notes: - - **`void render(Toolbox& tb)`** - Description: Render the GUI to the screenbuffer. - Preconditions: @@ -481,9 +458,9 @@ Creates and stores the SDL and OpenGL infrastructures (window, renderer, context **Constructors and Destructors** -- `Infrastructure(SDL_Window*, SDL_RENDERER*, SDL_GLContext)` -- `Infrastructure()` -- `Infrastructure(const Infrastructure&)` +- **`Infrastructure(SDL_Window*, SDL_RENDERER*, SDL_GLContext)`** +- **`Infrastructure()`** +- **`Infrastructure(const Infrastructure&)`** **Public Function Members** @@ -492,27 +469,27 @@ Creates and stores the SDL and OpenGL infrastructures (window, renderer, context - Preconditions: N/A - Postconditions: The window is returned - Notes: N/A -- `SDL_Renderer* renderer() const` +- **`SDL_Renderer* renderer() const`** - Description: Return the renderer - Preconditions: N/A - Postconditions: The renderer is returned - Notes: N/A -- `SDL_Context context() const` +- **`SDL_Context context() const`** - Description: Return the context - Preconditions: N/A - Postconditions: The context is returned - Notes: N/A -- `bool init(const std::string name, const int width, const int height)` +- **`bool init(const std::string name, const int width, const int height)`** - Description: Initialize everything - Preconditions: `name` is the window name, `width` and `height` are width and height of the window in pixels - Postconditions: An OpenGL context has been created and connected to the `SDL_Window`. The OpenGL functions have been loaded via glad. - Notes: N/A -- `void destroy()` +- **`void destroy()`** - Description: Destruct all resources - Preconditions: N/A - Postconditions: All resources have been destroyed - Notes: N/A -- `void quit()` +- **`void quit()`** - Description: Quit the application - Preconditions: N/A - Postconditions: All resources have been destroyed and the application has quit @@ -549,11 +526,11 @@ Reads all input from SDL, preprocesses it and stores it in the `Toolbox` event c **Constructors and Destructors** -- `InputHandler()` +- **`InputHandler()`** **Public Function Members** -- `void update(Toolbox& tb)` +- **`void update(Toolbox& tb)`** - Description: Collect all current SDL events and store them as `Pevent`s in the toolbox `events` - Preconditions: N/A - Postconditions: The toolbox `events` have been updated @@ -603,12 +580,12 @@ if(m.target == MESSAGETARGET::WAVE){ **Constructors and Destructors** -- `Message()` -- `Message(BLOCKCHAINMESSAGE message)` -- `Message(DRAWERMESSAGE message)` -- `Message(GUIMESSAGE message)` -- `Message(WAVEMESSAGE message)` -- `Message(PATTERNMESSAGE message)` +- **`Message()`** +- **`Message(BLOCKCHAINMESSAGE message)`** +- **`Message(DRAWERMESSAGE message)`** +- **`Message(GUIMESSAGE message)`** +- **`Message(WAVEMESSAGE message)`** +- **`Message(PATTERNMESSAGE message)`** **Public Function Members** @@ -644,14 +621,14 @@ Handles the placement of predefined patterns. **Constructors and Destructors** -- `PatternHandler()` -- `PatternHandler(const PatternHandler&)` -- `PatternHandler(Toolbox& tb)` +- **`PatternHandler()`** +- **`PatternHandler(const PatternHandler&)`** +- **`PatternHandler(Toolbox& tb)`** - Notes: This constructor sets up the necessary OpenGL objects and loads the textures **Public Function Members** -- `void update(Toolbox& tb)` +- **`void update(Toolbox& tb)`** - Description: Checks the mailbox, and upon requests draws the desired structure into the static damping texture - Preconditions: Correctly constructed object - Postconditions: All messages concerning patterns have been handled @@ -659,7 +636,7 @@ Handles the placement of predefined patterns. **Private Function Members** -- `bool load_damping_texture_(const Toolbox& tb, const std::string file, GLuint* texture_target)` +- **`bool load_damping_texture_(const Toolbox& tb, const std::string file, GLuint* texture_target)`** - Description: Load a damping texture from file, upload it to the GPU and return the texture handler in the `GLuint` out argument. - Preconditions: `file` is the texture file without extension, `texture_target` is an out argument - Postconditions: The texture has been uploaded to the GPU and has handler `texture_target` @@ -688,8 +665,8 @@ Stores `SDL_Event`s in a more convenient way. **Constructors and Destructors** -- `Pevent()` -- `Pevent(const SDL_Event&)` +- **`Pevent()`** +- **`Pevent(const SDL_Event&)`** **Public Function Members** @@ -727,13 +704,13 @@ Constructs `Pevent` objects. **Constructors and Destructors** -- `PeventFactory()` -- `PeventFactory(const int screen_w, const int screen_h, const int texture_w, const int texture_h, const int texoffset_left, const int texoffset_right, const int texoffset_bottom, const int texoffset_top)` +- **`PeventFactory()`** +- **`PeventFactory(const int screen_w, const int screen_h, const int texture_w, const int texture_h, const int texoffset_left, const int texoffset_right, const int texoffset_bottom, const int texoffset_top)`** - This constructor should be changed to take a `Toolbox` instead. **Public Function Members** -- `Pevent operator()(const SDL_Event&) const` +- **`Pevent operator()(const SDL_Event&) const`** - Description: Generate a `Pevent` from and `SDL_Event` - Preconditions: N/A - Postconditions: Returns a `Pevent` that corresponds to the `SDL_Event` passed as argument. @@ -773,56 +750,56 @@ Shader stepshader((shader_path_ + "stepwave.vert").c_str(), (shader_path_ + "ste **Constructors and Destructors** -- `Shader()` -- `Shader(const char* vertexPath, const char* fragmentPath)` +- **`Shader()`** +- **`Shader(const char* vertexPath, const char* fragmentPath)`** - Notes: This is the correct way to initialize a shader from sources. -- `Shader(const Shader&)` -- `Shader& operator=(const Shader&)` -- `~Shader()` +- **`Shader(const Shader&)`** +- **`Shader& operator=(const Shader&)`** +- **`~Shader()`** **Public Function Members** -- `void clean_up()` +- **`void clean_up()`** - Description: Clean up the OpenGL resources associated with this shader - Preconditions: N/A - Postconditions: N/A - Notes: N/A -- `void use()` +- **`void use()`** - Description: Activates the shader - Preconditions: Correctly constructed object - Postconditions: The shader program is used - Notes: N/A -- `void setBool(const std::string& name, bool value) const` +- **`void setBool(const std::string& name, bool value) const`** - Description: Set a boolean uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setInt(const std::string& name, int value) const` +- **`void setInt(const std::string& name, int value) const`** - Description: Set an integer uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setFloat(const std::string& name, float value) const` +- **`void setFloat(const std::string& name, float value) const`** - Description: Set a float uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setVec2(const std::string& name, glm::vec2 value) const` +- **`void setVec2(const std::string& name, glm::vec2 value) const`** - Description: Set a vec2 uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setVec3(const std::string& name, glm::vec3 value) const` +- **`void setVec3(const std::string& name, glm::vec3 value) const`** - Description: Set a vec3 uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setVec4(const std::string& name, glm::vec4 value) const` +- **`void setVec4(const std::string& name, glm::vec4 value) const`** - Description: Set a vec4 uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` - Notes: N/A -- `void setMat(const std::string& name, glm::mat4 value) const` +- **`void setMat(const std::string& name, glm::mat4 value) const`** - Description: Set a mat4 uniform - Preconditions: `name` is the name of the target uniform, `value` the target value. - Postconditions: The target uniform has been set to `value` @@ -858,16 +835,16 @@ The drawcalls are issued at the very end of the update-cycle, all in one. **Constructors and Destructors** -- `SlimBlockchainHandler(Toolbox& tb)` +- **`SlimBlockchainHandler(Toolbox& tb)`** **Public Function Members** -- `void update(Toolbox& tb)` +- **`void update(Toolbox& tb)`** - Description: Update the toolbox - first handle messages, then handle events, update erase-/drawlists (dynamic and static) and finally draw the updated state to the dynamic damping and wave 1 textures. - Preconditions: Fully initialized object - Postconditions: The state has been updated and drawn to the necessary textures - Notes: N/A -- `size_t num_blocks()` +- **`size_t num_blocks()`** - Description: Get the current number of active blocks - Preconditions: N/A - Postconditions: The number of blocks is returned @@ -875,28 +852,28 @@ The drawcalls are issued at the very end of the update-cycle, all in one. **Private Function Members** -- `void clear_blocks_()` +- **`void clear_blocks_()`** - Description: Erases all current blocks - Preconditions: N/A - Postconditions: All blocks have been erased, `dragpairs_` and `blockchain_` are empty - Notes: N/A -- `void update_blocks_(const Toolbox&, bool reload_all)` +- **`void update_blocks_(const Toolbox&, bool reload_all)`** - Description: Updates the state of the block tracking. First, the draw-/eraselists are checked for duplicated inputs (e.g. draw at R, erase at R, draw at R', erase at R', draw at R''). Then the vertices of blocks to be drawn / erased are calculated, and the queues are executed in the order: erase dynamic blocks, draw static blocks, draw dynamic blocks. - Preconditions: N/A - Postconditions: N/A - Notes: N/A -- `bool in_wave_window_(const Toolbox&, const Pevent&) const` +- **`bool in_wave_window_(const Toolbox&, const Pevent&) const`** - Description: Check if a `Pevent` is within the wave window - Preconditions: N/A - Postconditions: Returns `true` if the passed `Pevent` is in the wave window, `false` else - Notes: N/A -- `void xywhs_to_vertices_(const Toolbox&, const std::vector<bool>& duplicates, const std::vector<glm::ivec4>& xywhs, std::vector<float>& vertices) const` +- **`void xywhs_to_vertices_(const Toolbox&, const std::vector<bool>& duplicates, const std::vector<glm::ivec4>& xywhs, std::vector<float>& vertices) const`** - Description: Calculate all vertices corresponding to the `EfficientBlock` `xywh` coordinates stored in `xywhs` and store them in `vertices`, while ignoring `xywhs[i]` if `duplicates[i] == true`. - Preconditions: N/A - Postconditions: The vertices corresponding to the non-duplicate marked `xywhs` coordinates have been calculated and are stored in `vertices`. Previous contents of `vertices` have been deleted. - Notes: If duplicates are not tracked (e.g. for static blocks, which can't be erased), pass `std::vector<bool>(xywhs.size(), false)` as `duplicates`. -- `void find_dynamic_duplicates_()` +- **`void find_dynamic_duplicates_()`** - Description: Find duplicates in the dynamic draw-/eraselists and store them in the members `drawlist_dynamic_duplicates_` and `eraselist_dynamic_duplicates_`, respectively - Preconditions: N/A - Postconditions: The dynamic duplicate storing members have been updated according to the current dynamic draw-/eraselists @@ -938,12 +915,12 @@ Keeps track of the time since the last user input, and resets the state of the a **Constructors and Destructors** -- `TimeoutHandler(int seconds_to_timeout)` +- **`TimeoutHandler(int seconds_to_timeout)`** - Notes: This constructs a timeout handler with timeout `seconds_to_timeout` **Public Function Members** -- `void update(Toolbox& tb)` +- **`void update(Toolbox& tb)`** - Description: Check how much time has passed since an event has last come in, and if it exceeds the timeout, post reset messages and reset the timer. - Preconditions: N/A - Postconditions: If the timer exceeds the timeout, a reset has been posted. If `tb.events` is not empty or the timer has exceeded the timeout, the timer has been reset. @@ -980,11 +957,11 @@ The Toolbox is passed from one component to the next, so each component has all **Constructors and Destructors** -- `Toolbox(const int screen_w, const int screen_h, const int texture_w, const int texture_h, const int texoffset_left, const int texoffset_right, const int texoffset_bottom, const int texoffset_top, const std::string shaderpath, const std::string texturepath, const std::string resourcepath)` +- **`Toolbox(const int screen_w, const int screen_h, const int texture_w, const int texture_h, const int texoffset_left, const int texoffset_right, const int texoffset_bottom, const int texoffset_top, const std::string shaderpath, const std::string texturepath, const std::string resourcepath)`** **Public Function Members** -- `void newFrame()` +- **`void newFrame()`** - Description: Start a new frame - Preconditions: N/A - Postconditions: `mailbox` and `events` have been cleared @@ -1025,7 +1002,7 @@ Handles simulation and rendering of the wave. **Constructors and Destructors** -- `WaveHandler(Toolbox&)` +- **`WaveHandler(Toolbox&)`** **Public Function Members**