NDEVR
API Documentation
Renderer.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: Renderer
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "NDEVRGraphics/Headers/DLLInfo.h"
34#include "NDEVRGraphics/Headers/GraphicsUpdateArguments.h"
35#include "NDEVRGraphics/Headers/GraphicsPipeline.h"
36#include "Design/Headers/WindowInstance.h"
37#include "Base/Headers/Time.h"
38namespace NDEVR
39{
40 class VulkanSession;
41 class Model;
42 class ModelPipelineManager;
43 class GraphicsUpdater;
44 class Image;
52 class NDEVR_GRAPHICS_API Renderer
53 {
54 public:
62 virtual ~Renderer();
66 void render(bool wait_until_needed, bool force_render = true);
68 void renderLoop();
71 void setActive(bool is_active);
74 void setFPS(fltp08 fps) { m_fps = fps; }
77 fltp08 getFPS() const { return m_fps; }
82 void run();
88 {
89 return m_args.frame_time;
90 }
91
92 void cleanup() {
93 m_render_pipeline->cleanup();
94 }
95
97 void init(DesignObjectLookup* lookup);
101 {
102 return m_log;
103 }
104
105 void update();
108 GraphicsUpdater* updater() const { return m_updater; }
120 void setPostRenderFunction(const std::function<void()>& function) { m_post_render_function = function; }
127 void grabImage(Image* image);
130 void updateArgs(bool force_render);
136 DynamicPointer<GraphicsPipeline> pipeline() const { return m_render_pipeline; }
139 virtual void setCamera(const ConstPointer<Camera>& camera);
142 void setOverrideMaterial(UUID material);
143
148 void pause(TimeSpan span);
151 bool isActive() { return m_is_active; }
152 private:
153 bool _render(bool wait_until_needed, bool force_render);
155 fltp08 m_fps;
156 DynamicPointer<GraphicsPipeline> m_render_pipeline;
157 ConstPointer<Camera> m_camera;
158 GraphicsUpdater* m_updater = nullptr;
159 WindowInstance* m_window = nullptr;
160 UUID render_id;
161 LogPtr m_log;
162 std::function<void()> m_post_render_function;
163 bool m_is_active;
164 bool m_request_redraw;
165 volatile uint08 m_pause_time;
166 };
167}
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
A core class where all Design Objects including models, materials, and geometries are stored.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Options that are used for performing an update on a Graphics Engine call.
Responsible for updating resources or layouts of data in-between calls to render.
A root class that stores an an array of pixel data that can be displayed as an Image.
Definition Image.h:40
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A core class that represents a node on model hierarchy.
Definition Model.h:292
LogPtr log()
Returns the log pointer.
Definition Renderer.h:100
void setOverrideMaterial(UUID material)
Sets a material override for all rendered objects.
void grabImage(Image *image)
Grabs the current frame into an image immediately.
virtual ~Renderer()
Destructor.
void updateArgs(bool force_render)
Updates the render arguments from current state.
void setPostRenderFunction(const std::function< void()> &function)
Sets a function called after each render completes.
Definition Renderer.h:120
uint04 multisample() const
Returns the current multisample count.
fltp08 getFPS() const
Returns the target frames per second.
Definition Renderer.h:77
void run()
Starts the render thread.
DynamicPointer< GraphicsPipeline > pipeline() const
Returns the graphics pipeline.
Definition Renderer.h:136
bool isActive()
Checks whether this renderer is active.
Definition Renderer.h:151
void setActive(bool is_active)
Sets whether this renderer is active.
GraphicsUpdateArguments & getArguments()
Returns the render arguments.
Definition Renderer.h:111
void setFPS(fltp08 fps)
Sets the target frames per second.
Definition Renderer.h:74
Time getFrameStartTime() const
Returns the start time of the current frame.
Definition Renderer.h:87
void render(bool wait_until_needed, bool force_render=true)
Renders a single frame.
void grabImageNextRender(Image *image)
Queues an image grab for the next render.
void ensureLastRenderComplete()
Blocks until the last submitted render is complete.
void setupSurface()
Creates the rendering surface for the window.
GraphicsUpdater * updater() const
Returns the associated graphics updater.
Definition Renderer.h:108
void updatePipeline()
Recreates and updates the rendering pipeline.
void cleanup()
Cleans up all GPU resources.
Definition Renderer.h:92
void setWindowInstance(WindowInstance *window)
Sets the window instance for this renderer.
void renderLoop()
Enters the continuous render loop.
const DynamicPointer< GraphicsDevice > & device() const
Returns the graphics device.
void update()
Performs a single update cycle.
Renderer(const DynamicPointer< GraphicsPipeline > &pipeline, const ConstPointer< Camera > &camera, WindowInstance *instance, LogPtr log)
Constructs a renderer for a given pipeline, camera, and window.
void pause(TimeSpan span)
Pauses rendering for a duration.
void requestRedraw()
Requests a redraw on the next update cycle.
virtual void setCamera(const ConstPointer< Camera > &camera)
Sets the camera to render from.
void init(DesignObjectLookup *lookup)
Initializes the renderer with a design object lookup.
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
Creates and manages the resources necessary for converting a DesignObjectLookup into 3D rendered data...
Contains core information about a Viewport.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.