Ion
|
The Renderer class handles rendering ION scene graphs using OpenGL. More...
#include "renderer.h"
Public Types | |
enum | Flag { kProcessInfoRequests, kProcessReleases, kClearActiveTexture, kClearArrayBuffer, kClearCubemaps, kClearElementArrayBuffer, kClearFramebuffer, kClearSamplers, kClearShaderProgram, kClearTextures, kClearVertexArray, kRestoreActiveTexture, kRestoreArrayBuffer, kRestoreElementArrayBuffer, kRestoreFramebuffer, kRestoreShaderProgram, kRestoreStateTable, kRestoreVertexArray, kSaveActiveTexture, kSaveArrayBuffer, kSaveElementArrayBuffer, kSaveFramebuffer, kSaveShaderProgram, kSaveStateTable, kSaveVertexArray } |
The below flags determine what operations will be performed in a call to DrawScene(). More... | |
enum | ResourceType { kAttributeArray, kBufferObject, kFramebufferObject, kSampler, kShaderInputRegistry, kShaderProgram, kShader, kTexture } |
The types of resources created by the renderer. More... | |
enum | BufferObjectDataMapMode { kReadOnly, kReadWrite, kWriteOnly } |
The possible ways a BufferObject's data can be mapped. More... | |
typedef std::bitset< kNumFlags > | Flags |
Public Member Functions | |
Renderer (const GraphicsManagerPtr &gm) | |
The constructor is passed a GraphicsManager instance to use for rendering. More... | |
const Flags & | GetFlags () const |
Returns/sets rendering flags. More... | |
void | ClearFlag (Flag flag) |
void | ClearFlags (const Flags &flags) |
void | SetFlag (Flag flag) |
void | SetFlags (const Flags &flags) |
const GraphicsManagerPtr & | GetGraphicsManager () const |
Returns the GraphicsManager passed to the constructor. More... | |
gfx::ResourceManager * | GetResourceManager () const |
Returns the ResourceManager for this renderer. More... | |
void | BindFramebuffer (const FramebufferObjectPtr &fbo) |
Binds the passed FramebufferObject; all future calls to DrawScene() will be drawn into it. More... | |
const FramebufferObjectPtr | GetCurrentFramebuffer () const |
Returns the currently bound FramebufferObject. More... | |
template<typename T > | |
void | BindResource (T *holder) |
Immediately creates internal GL resources for the passed holder, uploading any data and binding the resource. More... | |
template<typename T > | |
void | CreateOrUpdateResource (T *holder) |
This function is useful for uploading data to the hardware at a time convenient to the caller when using multiple contexts. More... | |
void | CreateOrUpdateResources (const NodePtr &node) |
Traverses the scene rooted by the given node and creates or updates resources for ShaderPrograms, Textures, and Shapes that require it. More... | |
void | CreateOrUpdateShapeResources (const ShapePtr &shape) |
Creates or updates any resources necessary to draw the passed Shape, i.e., buffer data is uploaded. More... | |
template<typename T > | |
void | RequestForcedUpdate (T *holder) |
Mark an object for a forced update of GL resources. More... | |
void | RequestForcedUpdates (const NodePtr &node) |
Mark the passed object and its descendants for a forced resource update the next time CreateOrUpdateResources or DrawScene is called. More... | |
void | RequestForcedShapeUpdates (const ShapePtr &shape) |
Mark a shape's resources for a forced update the next time CreateOrUpdateResources or DrawScene is called. More... | |
void | ProcessStateTable (const StateTablePtr &state_table) |
Immediately updates OpenGL state with the settings in the passed StateTable. More... | |
template<typename T > | |
void | CreateResourceWithExternallyManagedId (T *holder, uint32 gl_id) |
This function is useful for wrapping an OpenGL object created outside of Ion, thus allowing it to be used with Ion objects. More... | |
void | SetInitialUniformValue (const Uniform &u) |
Sets the initial value of a Uniform to the passed value. More... | |
void | ResolveMultisampleFramebuffer (const FramebufferObjectPtr &ms_fbo, const FramebufferObjectPtr &dest_fbo) |
Resolve a multisampled framebuffer 'ms_fbo' into a single sampled framebuffer 'dest_fbo'. More... | |
virtual void | DrawScene (const NodePtr &node) |
Draws the scene rooted by the given node into the currently bound framebuffer. More... | |
void | ProcessResourceInfoRequests () |
Process any outstanding requests for information about internal resources that have been made through this Renderer's ResourceManager. More... | |
template<typename T > | |
uint32 | GetResourceGlId (T *holder) |
Returns the OpenGL ID for the passed resource. More... | |
void | SetTextureImageUnitRange (const math::Range1i &units) |
Sets the inclusive range of texture image units that the Renderer should use. More... | |
void | MapBufferObjectData (const BufferObjectPtr &buffer, BufferObjectDataMapMode mode) |
In the below MapBuffer functions the passed BufferObject is assigned a DataContainer (retrievable via BufferObject::GetMappedData()) with a pointer that is mapped to memory allocated by the graphics driver if the platform supports it. More... | |
void | MapBufferObjectDataRange (const BufferObjectPtr &buffer, BufferObjectDataMapMode mode, const math::Range1ui &range) |
This function maps a DataContainer with the size of the passed range. More... | |
void | UnmapBufferObjectData (const BufferObjectPtr &buffer) |
Unmaps a previously mapped BufferObject and makes the data available to the graphics hardware. More... | |
const ShaderProgramPtr & | GetDefaultShaderProgram () const |
Returns the default shader program that the Renderer uses if no other shader program is set. More... | |
void | UpdateStateFromOpenGL (int window_width, int window_height) |
A Renderer manages graphics state using a StateTable. More... | |
void | UpdateStateFromStateTable (const StateTablePtr &state_to_clear) |
This is more efficient than UpdateStateFromOpenGL(). More... | |
const StateTable & | GetStateTable () const |
Returns the StateTable that the Renderer believes to represent the current state of OpenGL. More... | |
void | UpdateDefaultFramebufferFromOpenGL () |
Updates the system default framebuffer to whatever framebuffer is currently bound. More... | |
void | ClearCachedBindings () |
Notifies the Renderer that it cannot rely on internally cached bindings; the next objects it encounters in a traversal will be rebound (even if they already are in OpenGL). More... | |
const ImagePtr | ReadImage (const math::Range2i &range, Image::Format format, const base::AllocatorPtr &allocator) |
Returns an image of the specified format that contains the contents of the hardware framebuffer. More... | |
void | PushDebugMarker (const std::string &marker) |
In non-production builds, pushes marker onto the Renderer's tracing stream marker stack, outputting the marker and indenting all calls until the next call to PopDebugMarker(). More... | |
void | PopDebugMarker () |
In non-production builds, pops a label off of the Renderer's tracing stream marker stack. More... | |
template<typename HolderType > | |
void | ClearResources (const HolderType *holder) |
Immediately clears the internal resources of the passed ResourceHolder. More... | |
void | ClearAllResources () |
Immediately clears all internal resources of the Renderer. More... | |
void | ReleaseResources () |
Immediately releases all internal resources of the Renderer which are pending release. More... | |
void | ClearTypedResources (ResourceType type) |
Immediately clears the internal resources of all ResourceHolders of the passed type. More... | |
size_t | GetGpuMemoryUsage (ResourceType type) const |
Returns the amount of GPU memory used by the passed resource type. More... | |
template<typename T > | |
ION_API void | BindResource (T *holder) |
template<typename T > | |
ION_API void | CreateOrUpdateResource (T *holder) |
template<> | |
ION_API void | CreateResourceWithExternallyManagedId (BufferObject *holder, uint32 gl_id) |
template<> | |
ION_API void | CreateResourceWithExternallyManagedId (IndexBuffer *holder, uint32 gl_id) |
template<> | |
ION_API void | CreateResourceWithExternallyManagedId (Texture *holder, uint32 gl_id) |
template<> | |
ION_API void | CreateResourceWithExternallyManagedId (CubeMapTexture *holder, uint32 gl_id) |
template<typename T > | |
ION_API void | RequestForcedUpdate (T *holder) |
template<typename T > | |
void | ClearResources (const T *holder) |
const AllocatorPtr & | GetAllocator () const |
Returns the Allocator that was used for the instance. More... | |
const AllocatorPtr & | GetNonNullAllocator () const |
Return our allocator, or the default allocator if the instance was declared on the stack. More... | |
const AllocatorPtr & | GetAllocatorForLifetime (AllocationLifetime lifetime) const |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More... | |
void * | operator new (size_t size) |
The standard no-parameter new operator uses the default Allocator. More... | |
void * | operator new (size_t size, AllocationLifetime lifetime) |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator) |
This overloaded version of the new operator takes the Allocator to use directly as a parameter. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator, void *ptr) |
Special operator new for using placement new with Allocatables. More... | |
void * | operator new (size_t size, void *ptr) |
The placement new operator is defined conventionally. More... | |
void | operator delete (void *ptr) |
Define the delete operator to use specialized functions dealing with an Allocator. More... | |
void | operator delete (void *ptr, AllocationLifetime lifetime) |
Windows requires these (or it issues C4291 warnings). More... | |
void | operator delete (void *ptr, const AllocatorPtr &allocator) |
void | operator delete (void *ptr, void *ptr2) |
The placement delete operator does nothing, as usual. More... | |
int | GetRefCount () const |
GetRefCount() is part of the interface necessary for SharedPtr. More... | |
Static Public Member Functions | |
static const Flags & | AllFlags () |
Convenience functions that return std::bitsets of Flags. More... | |
static const Flags & | AllClearFlags () |
static const Flags & | AllProcessFlags () |
static const Flags & | AllRestoreFlags () |
static const Flags & | AllSaveFlags () |
static void | DestroyStateCache (const portgfx::Visual *visual) |
Destroys the internal state cache associated with the passed Visual. More... | |
static void | DestroyCurrentStateCache () |
Destroys the internal state cache associated with the current Visual or GL context. More... | |
Static Public Attributes | |
static const int | kNumFlags = kSaveVertexArray + 1 |
static const int | kNumResourceTypes = kTexture + 1 |
Protected Member Functions | |
~Renderer () override | |
The destructor is protected because all base::Referent classes must have protected or private destructors. More... | |
The Renderer class handles rendering ION scene graphs using OpenGL.
It is also responsible for setting up the default shader program and global uniform values.
Definition at line 50 of file renderer.h.
typedef std::bitset<kNumFlags> ion::gfx::Renderer::Flags |
Definition at line 98 of file renderer.h.
The possible ways a BufferObject's data can be mapped.
Buffers mapped read-only must not be written to, and those mapped write-only must not be read from. Violating these rules may cause crashes or other unpredictable behavior.
Enumerator | |
---|---|
kReadOnly | |
kReadWrite | |
kWriteOnly |
Definition at line 117 of file renderer.h.
The below flags determine what operations will be performed in a call to DrawScene().
The default set of flags are the kProcess* flags.
Enumerator | |
---|---|
kProcessInfoRequests |
Process any outstanding requests for information about internal resources that have been made through this Renderer's ResourceManager. |
kProcessReleases |
Release any internal resources that have been marked for destruction, including OpenGL objects. |
kClearActiveTexture |
Whether to clear (set to 0) certain GL objects when drawing is finished. Both Ion's internal state and OpenGL are cleared. Note that the Restore flags below take precedence over these. |
kClearArrayBuffer | |
kClearCubemaps | |
kClearElementArrayBuffer | |
kClearFramebuffer | |
kClearSamplers | |
kClearShaderProgram | |
kClearTextures | |
kClearVertexArray | |
kRestoreActiveTexture |
Whether to restore certain GL state types when drawing is finished. Note that there is no support for restoring texture object state (what textures are bound where). |
kRestoreArrayBuffer | |
kRestoreElementArrayBuffer | |
kRestoreFramebuffer | |
kRestoreShaderProgram | |
kRestoreStateTable | |
kRestoreVertexArray | |
kSaveActiveTexture |
Whether to query OpenGL for current states and save them, which can be restored using the above kRestore* flags. Note that GL query operations can be slow, so these flags should be used sparingly. |
kSaveArrayBuffer | |
kSaveElementArrayBuffer | |
kSaveFramebuffer | |
kSaveShaderProgram | |
kSaveStateTable | |
kSaveVertexArray |
Definition at line 54 of file renderer.h.
The types of resources created by the renderer.
Enumerator | |
---|---|
kAttributeArray | |
kBufferObject | |
kFramebufferObject | |
kSampler | |
kShaderInputRegistry | |
kShaderProgram | |
kShader | |
kTexture |
Definition at line 101 of file renderer.h.
|
explicit |
The constructor is passed a GraphicsManager instance to use for rendering.
Renderer class.
Definition at line 4694 of file renderer.cc.
References DCHECK, ion::base::SharedPtr< T >::Get(), ion::base::Allocatable::GetAllocatorForLifetime(), and ion::base::kLongTerm.
|
overrideprotected |
The destructor is protected because all base::Referent classes must have protected or private destructors.
Definition at line 4704 of file renderer.cc.
References LOG, and ion::port::WARNING.
|
static |
Definition at line 4722 of file renderer.cc.
References kClearActiveTexture, kClearArrayBuffer, kClearCubemaps, kClearElementArrayBuffer, kClearFramebuffer, kClearSamplers, kClearShaderProgram, kClearTextures, and kClearVertexArray.
Referenced by AllFlags().
|
static |
Convenience functions that return std::bitsets of Flags.
Definition at line 4716 of file renderer.cc.
References AllClearFlags(), AllProcessFlags(), AllRestoreFlags(), and AllSaveFlags().
|
static |
Definition at line 4735 of file renderer.cc.
References kProcessInfoRequests, and kProcessReleases.
Referenced by AllFlags().
|
static |
Definition at line 4741 of file renderer.cc.
References kRestoreActiveTexture, kRestoreArrayBuffer, kRestoreElementArrayBuffer, kRestoreFramebuffer, kRestoreShaderProgram, kRestoreStateTable, and kRestoreVertexArray.
Referenced by AllFlags().
|
static |
Definition at line 4752 of file renderer.cc.
References kSaveActiveTexture, kSaveArrayBuffer, kSaveElementArrayBuffer, kSaveFramebuffer, kSaveShaderProgram, kSaveStateTable, and kSaveVertexArray.
Referenced by AllFlags().
void ion::gfx::Renderer::BindFramebuffer | ( | const FramebufferObjectPtr & | fbo | ) |
Binds the passed FramebufferObject; all future calls to DrawScene() will be drawn into it.
Passing a NULL pointer or an incomplete FramebufferObject will bind the default framebuffer. The default framebuffer is the one bound in OpenGL when the Renderer is created. Note that the Renderer stores only a weak reference to the framebuffer object, so if all FramebufferObjectPtrs to it are destroyed, the Renderer will revert to the default framebuffer.
Definition at line 4839 of file renderer.cc.
References DCHECK, ion::base::SharedPtr< T >::Get(), and kSaveFramebuffer.
Referenced by ResolveMultisampleFramebuffer().
void ion::gfx::Renderer::BindResource | ( | T * | holder | ) |
Immediately creates internal GL resources for the passed holder, uploading any data and binding the resource.
Note that unlike CreateOrUpdateResource() below, BindResource() only triggers an update if any changes are pending, or a resource needs to be created. At minimum, a resource will be bound (e.g., binding a texture or a buffer). This function can only be called with BufferObject, FramebufferObject, IndexBuffer, ShaderProgram, or Texture objects.
ION_API void ion::gfx::Renderer::BindResource | ( | T * | holder | ) |
Definition at line 4878 of file renderer.cc.
void ion::gfx::Renderer::ClearAllResources | ( | ) |
Immediately clears all internal resources of the Renderer.
Definition at line 5608 of file renderer.cc.
References kNumResourceTypes, and ReleaseResources().
void ion::gfx::Renderer::ClearCachedBindings | ( | ) |
Notifies the Renderer that it cannot rely on internally cached bindings; the next objects it encounters in a traversal will be rebound (even if they already are in OpenGL).
This function is also useful when changes are made to OpenGL state outside of the Renderer, for example directly through a GraphicsManager or another API, or if state changes are made in a different thread via a shared context.
Definition at line 4869 of file renderer.cc.
|
inline |
Definition at line 128 of file renderer.h.
|
inline |
Definition at line 129 of file renderer.h.
void ion::gfx::Renderer::ClearResources | ( | const HolderType * | holder | ) |
Immediately clears the internal resources of the passed ResourceHolder.
void ion::gfx::Renderer::ClearResources | ( | const T * | holder | ) |
Definition at line 5587 of file renderer.cc.
void ion::gfx::Renderer::ClearTypedResources | ( | ResourceType | type | ) |
Immediately clears the internal resources of all ResourceHolders of the passed type.
Definition at line 5614 of file renderer.cc.
References ReleaseResources().
void ion::gfx::Renderer::CreateOrUpdateResource | ( | T * | holder | ) |
This function is useful for uploading data to the hardware at a time convenient to the caller when using multiple contexts.
It updates the resource associated with the passed holder or creates one if none yet exists. It also ensures that the resource will be rebound the next time it is traversed so that it can be bound on another context. If you only want to ensure that an object has resources and is bound, use BindResource().
This function also ensures that any dependents of holder are also updated. For example, calling CreateOrUpdateResource() on a Texture will trigger an update on any dependent FramebufferObjects.
This function can only be called with AttributeArray, BufferObject, IndexBuffer, ShaderProgram, or Texture objects. Any data associated with the passed holder is sent to the graphics hardware; buffer and texture data is uploaded, shader programs are compiled and linked, etc., but no uniform values are sent nor vertex arrays created.
ION_API void ion::gfx::Renderer::CreateOrUpdateResource | ( | T * | holder | ) |
Definition at line 4899 of file renderer.cc.
void ion::gfx::Renderer::CreateOrUpdateResources | ( | const NodePtr & | node | ) |
Traverses the scene rooted by the given node and creates or updates resources for ShaderPrograms, Textures, and Shapes that require it.
Any disabled subtrees are skipped.
Definition at line 4965 of file renderer.cc.
References ion::base::SharedPtr< T >::Get().
void ion::gfx::Renderer::CreateOrUpdateShapeResources | ( | const ShapePtr & | shape | ) |
Creates or updates any resources necessary to draw the passed Shape, i.e., buffer data is uploaded.
Definition at line 5059 of file renderer.cc.
References ion::base::SharedPtr< T >::Get().
void ion::gfx::Renderer::CreateResourceWithExternallyManagedId | ( | T * | holder, |
uint32 | gl_id | ||
) |
This function is useful for wrapping an OpenGL object created outside of Ion, thus allowing it to be used with Ion objects.
This function behaves similarly to CreateOrUpdateResource() in that the resource is immediately created and data uploaded, etc. This function can only be called with BufferObject, IndexBuffer, or Texture objects. Calling this function with an invalid ID has no effect (nothing is created).
ION_API void ion::gfx::Renderer::CreateResourceWithExternallyManagedId | ( | BufferObject * | holder, |
uint32 | gl_id | ||
) |
Definition at line 4932 of file renderer.cc.
ION_API void ion::gfx::Renderer::CreateResourceWithExternallyManagedId | ( | IndexBuffer * | holder, |
uint32 | gl_id | ||
) |
Definition at line 4940 of file renderer.cc.
ION_API void ion::gfx::Renderer::CreateResourceWithExternallyManagedId | ( | Texture * | holder, |
uint32 | gl_id | ||
) |
Definition at line 4948 of file renderer.cc.
ION_API void ion::gfx::Renderer::CreateResourceWithExternallyManagedId | ( | CubeMapTexture * | holder, |
uint32 | gl_id | ||
) |
Definition at line 4957 of file renderer.cc.
|
static |
Destroys the internal state cache associated with the current Visual or GL context.
Definition at line 4790 of file renderer.cc.
References ion::portgfx::Visual::GetCurrentId().
|
static |
Destroys the internal state cache associated with the passed Visual.
Does nothing if the visual has no associated state cache.
Definition at line 4780 of file renderer.cc.
References ion::portgfx::Visual::GetId().
|
virtual |
Draws the scene rooted by the given node into the currently bound framebuffer.
Definition at line 5181 of file renderer.cc.
References ion::base::SharedPtr< T >::Get(), and kProcessInfoRequests.
|
inlineinherited |
Returns the Allocator that was used for the instance.
This will be NULL if the instance was declared on the stack or created with normal placement new.
Definition at line 68 of file allocatable.h.
References allocator_.
Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().
|
inlineinherited |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime.
Definition at line 78 of file allocatable.h.
References ion::base::Allocator::GetAllocatorForLifetime().
Referenced by ion::text::BasicBuilder::BuildVertexData(), ion::text::OutlineBuilder::BuildVertexData(), ion::gfxutils::ShaderManager::CreateShaderProgram(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), ion::text::DynamicFontImage::FindImageDataIndex(), Renderer(), and ion::gfx::UpdateStateTable().
const FramebufferObjectPtr ion::gfx::Renderer::GetCurrentFramebuffer | ( | ) | const |
Returns the currently bound FramebufferObject.
Note that this is related to the currently bound Visual or GL context, not simply the Renderer instance the function is called on. A return value of NULL indicates that either no framebuffer is bound or that the system default framebuffer (the framebuffer bound when the Renderer was created) is active. Note that calling BindFramebuffer() with a NULL FramebufferObject binds this default framebuffer (see above).
Definition at line 4857 of file renderer.cc.
Referenced by ResolveMultisampleFramebuffer().
|
inline |
Returns the default shader program that the Renderer uses if no other shader program is set.
Definition at line 301 of file renderer.h.
|
inline |
Returns/sets rendering flags.
Definition at line 127 of file renderer.h.
size_t ion::gfx::Renderer::GetGpuMemoryUsage | ( | ResourceType | type | ) | const |
Returns the amount of GPU memory used by the passed resource type.
Note that only BufferObjects, FrameBufferObjects, and (CubeMap)Textures are considered to use GPU memory.
Definition at line 5625 of file renderer.cc.
const GraphicsManagerPtr & ion::gfx::Renderer::GetGraphicsManager | ( | ) | const |
Returns the GraphicsManager passed to the constructor.
Definition at line 4763 of file renderer.cc.
Referenced by ResolveMultisampleFramebuffer(), and UpdateStateFromOpenGL().
|
inlineinherited |
Return our allocator, or the default allocator if the instance was declared on the stack.
Definition at line 72 of file allocatable.h.
References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().
|
inlineinherited |
GetRefCount() is part of the interface necessary for SharedPtr.
Definition at line 34 of file shareable.h.
Referenced by ion::base::Notifier::RemoveReceiver().
template ION_API uint32 ion::gfx::Renderer::GetResourceGlId< Texture > | ( | T * | holder | ) |
Returns the OpenGL ID for the passed resource.
Explicitly instantiate.
A new resource will be created if one does not already exist. This function must be called with a valid OpenGL context bound. Note that calling this function on an AttributeArray is a compile-time error.
Definition at line 5549 of file renderer.cc.
References id.
Referenced by ResolveMultisampleFramebuffer().
gfx::ResourceManager * ion::gfx::Renderer::GetResourceManager | ( | ) | const |
Returns the ResourceManager for this renderer.
The returned pointer has the same lifetime as this Renderer.
Definition at line 4767 of file renderer.cc.
const StateTable & ion::gfx::Renderer::GetStateTable | ( | ) | const |
Returns the StateTable that the Renderer believes to represent the current state of OpenGL.
Definition at line 5473 of file renderer.cc.
References ION_DECLARE_SAFE_STATIC_POINTER_WITH_CONSTRUCTOR, LOG, and ion::port::WARNING.
void ion::gfx::Renderer::MapBufferObjectData | ( | const BufferObjectPtr & | buffer, |
BufferObjectDataMapMode | mode | ||
) |
In the below MapBuffer functions the passed BufferObject is assigned a DataContainer (retrievable via BufferObject::GetMappedData()) with a pointer that is mapped to memory allocated by the graphics driver if the platform supports it.
If the platform does not support mapped buffers then a pointer is allocated using the BufferObject's Allocator instead. The BufferObject must be unmapped with UnmapBufferObjectData() for the data to be available for drawing. The mapped DataContainer's pointer is mapped using the passed access mode; do not violate the mode or unexpected behavior, such as crashes, may occur. No expectations should be made about the content of write-only buffers.
This function maps a DataContainer of the same size as the BufferObject.
Definition at line 5485 of file renderer.cc.
References ion::base::SharedPtr< T >::Get(), ION_PRETTY_FUNCTION, LOG, MapBufferObjectDataRange(), and ion::port::WARNING.
void ion::gfx::Renderer::MapBufferObjectDataRange | ( | const BufferObjectPtr & | buffer, |
BufferObjectDataMapMode | mode, | ||
const math::Range1ui & | range | ||
) |
This function maps a DataContainer with the size of the passed range.
Passing an empty range or a range larger than the size of the BufferObject does nothing but log a warning message. If the local platform does not support mapping ranges then a local pointer is allocated, and will be uploaded to the GPU via BufferSubData.
Definition at line 5498 of file renderer.cc.
References ion::base::SharedPtr< T >::Get(), ION_PRETTY_FUNCTION, LOG, and ion::port::WARNING.
Referenced by MapBufferObjectData().
|
inlineinherited |
Define the delete operator to use specialized functions dealing with an Allocator.
Definition at line 109 of file allocatable.h.
|
inlineinherited |
Windows requires these (or it issues C4291 warnings).
Definition at line 112 of file allocatable.h.
|
inlineinherited |
Definition at line 113 of file allocatable.h.
|
inlineinherited |
The placement delete operator does nothing, as usual.
Definition at line 118 of file allocatable.h.
|
inlineinherited |
The standard no-parameter new operator uses the default Allocator.
Definition at line 84 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.
Definition at line 88 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator takes the Allocator to use directly as a parameter.
If the Allocator pointer is NULL, this uses the default Allocator.
Definition at line 95 of file allocatable.h.
|
inlineinherited |
Special operator new for using placement new with Allocatables.
Definition at line 100 of file allocatable.h.
|
inlineinherited |
The placement new operator is defined conventionally.
Definition at line 105 of file allocatable.h.
void ion::gfx::Renderer::PopDebugMarker | ( | ) |
In non-production builds, pops a label off of the Renderer's tracing stream marker stack.
If the stack is empty and in production builds this does nothing.
Definition at line 5541 of file renderer.cc.
void ion::gfx::Renderer::ProcessResourceInfoRequests | ( | ) |
Process any outstanding requests for information about internal resources that have been made through this Renderer's ResourceManager.
Definition at line 5454 of file renderer.cc.
void ion::gfx::Renderer::ProcessStateTable | ( | const StateTablePtr & | state_table | ) |
Immediately updates OpenGL state with the settings in the passed StateTable.
Note that if the passed StateTable has a clear color, depth, or stencil value set, the clear will be immediately executed.
Definition at line 4925 of file renderer.cc.
void ion::gfx::Renderer::PushDebugMarker | ( | const std::string & | marker | ) |
In non-production builds, pushes marker
onto the Renderer's tracing stream marker stack, outputting the marker and indenting all calls until the next call to PopDebugMarker().
Does nothing in production builds.
Definition at line 5536 of file renderer.cc.
const ImagePtr ion::gfx::Renderer::ReadImage | ( | const math::Range2i & | range, |
Image::Format | format, | ||
const base::AllocatorPtr & | allocator | ||
) |
Returns an image of the specified format that contains the contents of the hardware framebuffer.
The passed range specifies the area to be read. The Allocator is used when creating the Image.
Definition at line 5524 of file renderer.cc.
void ion::gfx::Renderer::ReleaseResources | ( | ) |
Immediately releases all internal resources of the Renderer which are pending release.
Definition at line 5619 of file renderer.cc.
Referenced by ClearAllResources(), and ClearTypedResources().
void ion::gfx::Renderer::RequestForcedShapeUpdates | ( | const ShapePtr & | shape | ) |
Mark a shape's resources for a forced update the next time CreateOrUpdateResources or DrawScene is called.
Definition at line 5105 of file renderer.cc.
References ion::base::SharedPtr< T >::Get().
void ion::gfx::Renderer::RequestForcedUpdate | ( | T * | holder | ) |
Mark an object for a forced update of GL resources.
Calling this function is equivalent to modifying the object and then reverting it back to the initial state. See the documentation of CreateOrUpdateResource for a description of what a resource update entails.
ION_API void ion::gfx::Renderer::RequestForcedUpdate | ( | T * | holder | ) |
Definition at line 5069 of file renderer.cc.
void ion::gfx::Renderer::RequestForcedUpdates | ( | const NodePtr & | node | ) |
Mark the passed object and its descendants for a forced resource update the next time CreateOrUpdateResources or DrawScene is called.
Definition at line 5095 of file renderer.cc.
References ion::base::SharedPtr< T >::Get().
void ion::gfx::Renderer::ResolveMultisampleFramebuffer | ( | const FramebufferObjectPtr & | ms_fbo, |
const FramebufferObjectPtr & | dest_fbo | ||
) |
Resolve a multisampled framebuffer 'ms_fbo' into a single sampled framebuffer 'dest_fbo'.
Caller is responsible to make sure ms_fbo and dest_fbo are compatible for resolving.
Definition at line 5142 of file renderer.cc.
References BindFramebuffer(), ion::base::SharedPtr< T >::Get(), GetCurrentFramebuffer(), GetGraphicsManager(), GetResourceGlId(), ion::gfx::GraphicsManager::kFramebufferBlit, ion::gfx::GraphicsManager::kMultisampleFramebufferResolve, LOG, and ion::port::WARNING.
|
inline |
Definition at line 130 of file renderer.h.
|
inline |
Definition at line 131 of file renderer.h.
void ion::gfx::Renderer::SetInitialUniformValue | ( | const Uniform & | u | ) |
Sets the initial value of a Uniform to the passed value.
This value will be used when neither a Node being rendered nor any of its ancestors override the Uniform. In other words, a Uniform in a Node will override this value. All Uniforms start with an invalid initial value.
Definition at line 5129 of file renderer.cc.
References ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::GetRegistry(), and ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid().
void ion::gfx::Renderer::SetTextureImageUnitRange | ( | const math::Range1i & | units | ) |
Sets the inclusive range of texture image units that the Renderer should use.
This is useful to ensure that the Renderer does not interfere with other users of OpenGL. The Renderer will use the specified units if they are valid, or log an error message and make no changes otherwise. Note that to use all texture units, simply pass a range from 0 to a number greater than the maximum number of units (e.g., INT_MAX).
units
may result in unexpected rendering behavior, as not all textures may be bound properly. Definition at line 5580 of file renderer.cc.
void ion::gfx::Renderer::UnmapBufferObjectData | ( | const BufferObjectPtr & | buffer | ) |
Unmaps a previously mapped BufferObject and makes the data available to the graphics hardware.
Does nothing but log a warning message if called with an unmapped BufferObject.
Definition at line 5512 of file renderer.cc.
References ion::base::SharedPtr< T >::Get(), ION_PRETTY_FUNCTION, LOG, and ion::port::WARNING.
void ion::gfx::Renderer::UpdateDefaultFramebufferFromOpenGL | ( | ) |
Updates the system default framebuffer to whatever framebuffer is currently bound.
This allows applications to create new system framebuffers as needed and notify Ion that the default framebuffer has changed.
Definition at line 4863 of file renderer.cc.
void ion::gfx::Renderer::UpdateStateFromOpenGL | ( | int | window_width, |
int | window_height | ||
) |
A Renderer manages graphics state using a StateTable.
The Renderer initializes its StateTable to the OpenGL default settings and assumes that these settings are correct. If an application modifies these settings without the Renderer's knowledge (even if another Renderer is doing it), the application should call this function to let the Renderer update its state from OpenGL. The window dimensions must be passed in so that viewport and scissor box values can be set properly.
Definition at line 5460 of file renderer.cc.
References GetGraphicsManager(), and ion::gfx::UpdateStateTable().
void ion::gfx::Renderer::UpdateStateFromStateTable | ( | const StateTablePtr & | state_to_clear | ) |
This is more efficient than UpdateStateFromOpenGL().
Rather than querying OpenGL to learn what the current state is, the passed StateTable is used to update the Renderer's idea of what the current state of OpenGL is.
Definition at line 5467 of file renderer.cc.
|
static |
Definition at line 97 of file renderer.h.
|
static |
Definition at line 111 of file renderer.h.
Referenced by ClearAllResources().