NDEVR
API Documentation
GLESRenderObject.h
1#pragma once
2#include "GLBuffer.h"
3#include "GLESGraphicsDevice.h"
4#include <NDEVR/GraphicsUpdateArguments.h>
5#include <NDEVR/Material.h>
6#include <NDEVR/Geometry.h>
7#include <NDEVR/Model.h>
8#include <NDEVR/Matrix.h>
9#include <NDEVR/Pointer.h>
10#include <NDEVR/Set.h>
11class QOpenGLVertexArrayObject;
12namespace NDEVR
13{
14 class Camera;
23 {
24 private:
26 struct ModelProperties
27 {
31 ModelProperties(const Model& model, const Material& material)
32 : model(model)
33 , material(material)
34 {}
35 Model model;
36 Material material;
37 bool should_render = true;
38 };
40 struct GeoProperties
41 {
42 Time last_updated_time = Time(0);
43 Buffer<ModelProperties> model_parents;
44 Geometry geometry;
45 fltp04 pixel_thickness = Constant<fltp04>::Invalid;
46 uint04 vertex_start = 0;
47 uint04 vertex_size = 0;
48 uint04 primitive_start = 0;
49 uint04 primitive_size = 0;
50 uint04 matrix_start = 0;
51 uint04 matrix_size = 0;
52 uint04 matrix_visible_size = 0;
53 uint04 matrix_reserved = 0;
54 bool is_visible = true;
55 bool is_deleted = false;
56 };
57
58 public:
62 GLESRenderObject(const GLESRenderObject& instance) = delete;
66 void cleanup();
70 bool removeInstance(const Geometry& geo);
74 bool shouldRender(const Model& model) const;
86 bool hasOpacity() const;
89 bool hasImage() const;
92 bool isFilledShape() const;
98 uint01 parity() const { return m_parity; }
102 static GLint RenderType(PrimitiveMode mode);
109 bool hasCommand() const;
114 bool runCommand(GraphicsUpdateArguments& args, bool opacity_pass);
115
118 void setPrimitiveMode(const PrimitiveMode& type) { m_index_mode = type; }
127 const DynamicPointer<GLESMaterialManager>& materialManager() const { return m_material_manager; }
133 void setRelativeToCamera(bool reletive_to_camera);
136 const ConstPointer<GLESVertexManager>& vertexManager() const { return m_vertex_manager; }
139 PrimitiveMode indexMode() const { return m_index_mode; };
143 void addInstance(const Geometry& geo, const Material& material);
144 private:
148 void swapMatrixIdx(uint04 idx, uint04 swap_location);
151 void geometryUpdate(GeoProperties& props);
159 bool modelUpdate(GeoProperties& props, const Time& geo_mod_time, uint04 idx, uint04 matrix_index_count, bool& should_remove);
162 void updatePixelThickness(GeoProperties& props);
168 void processGeoUniformUpdates(GeoProperties& properties, GraphicsUpdateArguments& args, uint04& matrix_index, const Time& geo_mod_time);
175 void getMatrixUniformObject(const Geometry& mesh, const Model& model, Matrix<fltp04>& matrix, Vector<4, sint04>& offset, Vector<2, uint04>& flag) const;
176 private:
179 Dictionary<UUID, uint04> m_geometry_lookup;
180 Buffer<GeoProperties> m_geometries;
181 DynamicPointer<GLESVertexManager> m_vertex_manager;
182 DynamicPointer<GLESMaterialManager> m_material_manager;
183 Buffer<Matrix<fltp04>> m_model_matrix_uniforms;
184 Buffer<Vector<4, sint04>> m_model_offset_uniforms;
185 Buffer<Vector<2, uint04>> m_model_flag_uniforms;
186 DynamicPointer<OpenGLBuffer> m_matrix_instance_buffer;
187 DynamicPointer<OpenGLBuffer> m_offset_instance_buffer;
188 DynamicPointer<OpenGLBuffer> m_flags_instance_buffer;
190 uint04 m_vao = Constant<uint04>::Invalid;
191 volatile mutable bool m_needs_matrix_commit = false;
192 volatile mutable bool m_needs_flags_commit = false;
193 volatile mutable bool m_needs_offset_commit = false;
194 volatile mutable bool m_needs_geometry_commit = true;
195 uint01 m_parity = Constant<uint01>::Invalid;
196 bool m_is_integer_shader = false;
197 bool m_is_tbn_shader = false;
198 bool m_is_normal_shader = false;
199 bool m_relative_to_camera = false;
200 bool m_has_tangent = false;
201 };
202}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Structure responsible for handling the OpenGL data surrounding a particular Material object.
bool runCommand(GraphicsUpdateArguments &args, bool opacity_pass)
Executes the render command for this object.
GLESRenderObject(const DynamicPointer< GLESGraphicsDevice > &pipeline)
Constructs a GLESRenderObject for the given device.
void setParity(uint01 parity)
Sets the rendering parity.
bool hasOpacity() const
Checks whether any material has opacity.
void setMaterialManager(const DynamicPointer< GLESMaterialManager > &material_manager)
Sets the material manager for this render object.
void setRelativeToCamera(bool reletive_to_camera)
Sets whether rendering is relative to the camera position.
void setVertexManager(const DynamicPointer< GLESVertexManager > &vertex_manager)
Sets the vertex manager for this render object.
bool shouldRender(const Model &model) const
Checks whether the given model should be rendered.
bool hasImage() const
Checks whether any material has a texture image.
fltp04 fadeDistance() const
Returns the fade distance for this render object.
bool createPipeline(GraphicsUpdateArguments &args)
Creates or recreates the rendering pipeline for this object.
void cleanup()
Releases all GPU resources held by this render object.
~GLESRenderObject()
Destroys the render object and releases GPU resources.
void setPrimitiveMode(const PrimitiveMode &type)
Sets the primitive drawing mode.
void updateUniformBuffer(GraphicsUpdateArguments &args)
Updates uniform buffers for all geometry instances.
void setDevice(const DynamicPointer< GLESGraphicsDevice > &instance)
Sets the graphics device for this render object.
static GLint RenderType(PrimitiveMode mode)
Converts a PrimitiveMode to the corresponding OpenGL draw mode.
void commit(GraphicsUpdateArguments &args)
Commits pending buffer changes to the GPU.
uint01 parity() const
Returns the rendering parity of this object.
PrimitiveMode indexMode() const
Returns the primitive drawing mode.
void addInstance(const Geometry &geo, const Material &material)
Adds a geometry instance with the given material.
const DynamicPointer< GLESMaterialManager > & materialManager() const
Returns the material manager for this render object.
bool removeInstance(const Geometry &geo)
Removes a geometry instance from this render object.
const ConstPointer< GLESVertexManager > & vertexManager() const
Returns the vertex manager for this render object.
bool isFilledShape() const
Checks whether this render object draws filled shapes.
bool hasCommand() const
Checks whether there is a pending render command.
Manages vertex buffers for the OpenGL engine.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Options that are used for performing an update on a Graphics Engine call.
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
@ e_index_mode_size
The number of primitive modes. Used for sizing arrays.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
@ Outline
Line-based outline rendering of primitives.