NDEVR
API Documentation
GLESGraphicsSession.h
1#pragma once
2#include "GLESGraphicsDevice.h"
3#include "GLESCameraManager.h"
4#include "GLESImage.h"
5#include <NDEVR/GraphicsSession.h>
6#include <NDEVR/ViewportOptions.h>
7#include <NDEVR/GraphicsUpdateArguments.h>
8#include <NDEVR/Dictionary.h>
9#include <NDEVR/UUID.h>
10#include <QOpenGLTexture>
11#include <QOpenGLBuffer>
12#include <QOpenGLVertexArrayObject>
13namespace NDEVR
14{
15 class OpenGLBuffer;
16 class GLESShader;
17 class GLESRenderObject;
25 class GLESGraphicsSession : public GraphicsSession, public QObject
26 {
27 public:
32 virtual ~GLESGraphicsSession() override;
34 void clearAll();
36 virtual void readShader(const StringView&) override {}
45 virtual void postClearAll() override
46 {}
47
49 static UUID GLESRenderEngineID() { return UUID::CreateUUID("GLES Render Engine"); }
53 {
54 static DynamicPointer<GraphicsSession> s_session;
55 if (s_session.isNull())
56 {
59 {
61 s_session->setActive(active);
62 if (active)
63 GraphicsDevice::SetDefaultGraphicsDevice(s_session->device());
64 }, s_session.as<GLESGraphicsSession>().rawptr()));
65 }
66 return s_session;
67 }
68
70 void removeRenderGeometry(const Geometry& geo) override;
74 bool addRenderGeometry(const Geometry& geo) override;
75
78 virtual UUID uuid() override
79 {
80 return GLESRenderEngineID();
81 };
82
85 bool checkPipeline(bool add_if_needed);
90 bool checkPipeline(GeometryUpdateObject& geo_prop, bool add_if_needed);
93 virtual bool runCommand(GraphicsUpdateArguments&) override
94 {
95 return true;
96 }
97
102 virtual void commit(GraphicsUpdateArguments& args) override;
105 virtual void updateUniformBuffer(GraphicsUpdateArguments& args) override;
109 virtual bool createPipeline(GraphicsUpdateArguments& args) override;
112 virtual const ConstPointer<GraphicsDevice>& device() const override;
115 virtual const DynamicPointer<GraphicsDevice>& device() override;
118 virtual bool hasCommand() const override
119 {
120 return true;
121 }
122
124 virtual void drawFrame(GraphicsUpdateArguments& args) override;
126 virtual void ensureLastRenderComplete() override {};
128 virtual void cleanup() override {};
130 virtual void setWindowInstance(WindowInstance*) override {};
132 virtual void cleanResources() override {};
135 virtual void init(GraphicsUpdateArguments& args) override;
136 protected:
146 private:
147 bool m_is_init = false;
148 bool m_needs_pipeline_update = false;
149 };
150
151}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
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
static const DynamicPointer< GLESGraphicsDevice > & DefaultGLESDevice()
Returns the default shared GLES graphics device singleton.
virtual void init(GraphicsUpdateArguments &args) override
Initializes the graphics session for rendering.
DynamicPointer< GLESImageManager > m_image_manager
The shared image manager.
virtual bool runCommand(GraphicsUpdateArguments &) override
No-op command runner for the GLES session.
bool checkPipeline(GeometryUpdateObject &geo_prop, bool add_if_needed)
Validates and optionally creates the pipeline for a specific geometry.
DynamicPointer< GLESCameraManager > getCameraManager(const UUID &camera)
Returns or creates a camera manager for the given camera UUID.
Dictionary< UUID, DynamicPointer< GLESVertexManager > > m_vertex_managers
Per-scene vertex managers.
virtual bool hasCommand() const override
Checks whether there is a pending command.
virtual void drawFrame(GraphicsUpdateArguments &args) override
Draws one complete frame.
virtual void updateUniformBuffer(GraphicsUpdateArguments &args) override
Updates all uniform buffers for the current frame.
virtual const ConstPointer< GraphicsDevice > & device() const override
Returns the graphics device as a const pointer.
virtual void setWindowInstance(WindowInstance *) override
No-op window instance setter.
virtual ~GLESGraphicsSession() override
Destroys the session and releases all managed resources.
bool addRenderGeometry(const Geometry &geo) override
Adds a geometry to the render pipeline.
virtual bool createPipeline(GraphicsUpdateArguments &args) override
Creates or recreates the rendering pipeline.
virtual UUID uuid() override
Returns the UUID of this graphics session.
DynamicPointer< GLESGraphicsDevice > m_device
The GLES graphics device.
virtual DynamicPointer< GraphicsPipeline > createRenderPipeline() override
Creates a new render pipeline for a viewport.
Buffer< GeometryUpdateObject > m_geometries
All tracked geometry update objects.
static const DynamicPointer< GraphicsSession > & DefaultSession()
Returns the default singleton graphics session.
GLESGraphicsSession(const DynamicPointer< GLESGraphicsDevice > &device)
Constructs a GLESGraphicsSession for the given device.
virtual const DynamicPointer< GraphicsDevice > & device() override
Returns the graphics device as a mutable pointer.
void clearAll()
Clears all render objects, managers, and cached state.
Dictionary< UUID, DynamicPointer< GLESCameraManager > > m_camera_managers
Per-camera camera managers.
void removeRenderGeometry(const Geometry &geo) override
Removes a geometry from the render pipeline.
virtual void cleanup() override
No-op cleanup.
virtual void postClearAll() override
No-op post-clear callback.
virtual void cleanResources() override
No-op resource cleanup.
Dictionary< uint08, DynamicPointer< GLESMaterialManager > > m_material_managers
Per-material material managers.
DynamicPointer< GLESShaderManager > m_shader_manager
The shared shader manager.
static UUID GLESRenderEngineID()
Returns the UUID identifying the GLES render engine.
bool checkPipeline(bool add_if_needed)
Validates and optionally creates the render pipeline.
virtual void ensureLastRenderComplete() override
No-op to ensure the last render is complete.
DynamicPointer< GraphicsDevice > m_graphics_device
The abstract graphics device.
Dictionary< uint08, GLESRenderObject * > m_pipelines
Per-material render object pipelines.
virtual void commit(GraphicsUpdateArguments &args) override
Commits all pending changes to the GPU.
virtual void readShader(const StringView &) override
No-op shader reader for the GLES session.
virtual void checkModelStructure(GraphicsUpdateArguments &args)
Checks whether the model structure has changed and updates accordingly.
Structure responsible for handling the OpenGL data surrounding a particular Material object.
A root render Object for OpenGL, which consists of a set Material, Model, and Geometry that is used t...
A Shader for rendering default OpenGL logic to the graphics card.
Definition GLESShader.h:16
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
A GraphicsPipeline that is responsible for setting up and rendering the resources of a DesignObjectLo...
Options that are used for performing an update on a Graphics Engine call.
Buffer for storing data in the OpenGL engine, usually for rendering.
Definition GLBuffer.h:15
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
Definition QTTools.h:493
The core String View class for the NDEVR API.
Definition StringView.h:58
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
static UUID CreateUUID()
Contains core information about a Viewport.
The primary namespace for the NDEVR SDK.
Tracks a geometry and its last modification time for incremental updates.
static ApplicationOption< UUID > default_render_engine
The UUID of the default rendering engine to use.