#include <OpenGUI_Renderer.h>
- preRenderSetup() - selectRenderContext() - clearContents() - doRenderOperation() (repeats as necessary) - selectRenderContext() - clearContents() - doRenderOperation() (repeats as necessary) - postRenderCleanup()
Public Member Functions | |
| Renderer () | |
| Constructor. | |
| virtual | ~Renderer () |
| virtual Destructor | |
Required | |
| virtual void | selectViewport (Viewport *activeViewport)=0 |
| This is called to tell the Renderer to change the active Viewport to the one provided. | |
| virtual void | preRenderSetup ()=0 |
| This is always called by the System exactly once every frame before the calls to doRenderOperation() begin for a Viewport. | |
| virtual void | doRenderOperation (RenderOperation &renderOp)=0 |
| This will be called for every render operation that needs to be performed. | |
| virtual void | postRenderCleanup ()=0 |
| This is always called by the System exactly once every frame after all of the calls to doRenderOperation() have been completed for a Viewport. | |
| virtual Texture * | createTextureFromFile (const std::string &filename)=0 |
| This is called whenever a texture needs to be created from a file. | |
| virtual Texture * | createTextureFromTextureData (const TextureData *textureData)=0 |
| Create a texture from a TextureData object (memory). | |
| virtual void | updateTextureFromTextureData (Texture *texture, const TextureData *textureData)=0 |
| Replaces an existing texture with the given TextureData. | |
| virtual void | destroyTexture (Texture *texturePtr)=0 |
| Destroy a previously created Texture object. | |
RenderToTexture Support (optional) | |
| virtual bool | supportsRenderToTexture () |
Renderer implementations that do support Render to Texture contexts should return true. The default is to return false. | |
| virtual void | selectRenderContext (RenderTexture *context) |
| This is called to set the current rendering context. | |
| virtual void | clearContents () |
| Should clear the contents of the current rendering context as appropriate. | |
| virtual RenderTexture * | createRenderTexture (const IVector2 &size) |
| Creates a render texture at the given size. | |
| virtual void | destroyRenderTexture (RenderTexture *texturePtr) |
| Destroy a previously created RenderTexture object. | |
Static Public Member Functions | |
| static Renderer & | getSingleton (void) |
| Retrieve the current singleton, if one exists. If none exists, this will cause an error. | |
| static Renderer * | getSingletonPtr (void) |
| Retrieve a pointer to the current singleton, if one exists. If none exists, this will return 0. | |
| OpenGUI::Renderer::Renderer | ( | ) | [inline] |
Constructor.
| virtual OpenGUI::Renderer::~Renderer | ( | ) | [inline, virtual] |
virtual Destructor
| virtual void OpenGUI::Renderer::clearContents | ( | ) | [inline, virtual] |
Should clear the contents of the current rendering context as appropriate.
When called, this function should clear the contents of the current rendering context.
| RenderTexture * OpenGUI::Renderer::createRenderTexture | ( | const IVector2 & | size | ) | [virtual] |
Creates a render texture at the given size.
If your renderer implementation supports render to texture, this is where those render textures will be created.
The given size will be a desired size that is not necessarily a power of 2. If the renderer does not support non power of 2 textures, it is up to the Renderer implementation to increase the texture size to a power of 2, and perform any UV remapping necessary to provide proper texel alignment when rendering to and from the texture.
| virtual Texture* OpenGUI::Renderer::createTextureFromFile | ( | const std::string & | filename | ) | [pure virtual] |
This is called whenever a texture needs to be created from a file.
Custom renderers are required to implement this function to provide the system a generalized method of creating a texture. Basically, this function is given a file name, and through any amount of smoke and magic, the system expects to receive back a pointer to a Texture object that can be later referenced within RenderOperation objects that are passed to doRenderOperation(). Most implementations simply load the data as necessary for their graphics API and store their graphics API specific texture handles in customized Texture objects.
The short explanation is: Texture objects are almost entirely for Renderer use only, and as such you can do nearly whatever you want with them, so long as they can be used later to signify which texture we want drawn on a set of polygons.
| filename | The filename of the source image data. |
| virtual Texture* OpenGUI::Renderer::createTextureFromTextureData | ( | const TextureData * | textureData | ) | [pure virtual] |
Create a texture from a TextureData object (memory).
The passed in TextureData object does not become the sole property of the createTextureFromTextureData() function. So it must not attempt to delete it. It is the responsibility of the TextureData creator to clean up the TextureData object when it is no longer needed. The caller must guarantee that the given TextureData object is valid for the entire lifetime of the texture. Meaning that it cannot be deleted until after destroyTexture() has been called to destroy the texture that is based upon the TextureData.
| void OpenGUI::Renderer::destroyRenderTexture | ( | RenderTexture * | texturePtr | ) | [virtual] |
Destroy a previously created RenderTexture object.
Whatever needs to happen to properly destroy a RenderTexture object, custom Renderers need to implement that functionality here.
new), it is also responsible for performing the delete of that RenderTexture. This function is called after OpenGUI is assured that no remaining handles to the texture remain, so if the Renderer does not delete the memory here, it will leak.| virtual void OpenGUI::Renderer::destroyTexture | ( | Texture * | texturePtr | ) | [pure virtual] |
Destroy a previously created Texture object.
Whatever needs to happen to properly destroy a Texture object, custom Renderers need to implement that functionality here.
new), it is also responsible for performing the delete of that Texture. This function is called after OpenGUI is assured that no remaining handles to the texture remain, so if the Renderer does not delete the memory here, it will leak. | virtual void OpenGUI::Renderer::doRenderOperation | ( | RenderOperation & | renderOp | ) | [pure virtual] |
This will be called for every render operation that needs to be performed.
This function is passed a RenderOperation object, by reference, for every render operation that needs to take place to properly draw the gui.
For any given render context, the RenderOperations passed to this object will always assume that 0,0 x 1,1 is the full range of the render target. 0,0 being the upper left, and 1,1 being the lower right.
Texture UVs are always expressed as values between 0.0 and 1.0. Texture::getUVs() is not currently used within OpenGUI.
The render operations provided to this function are guaranteed to be:
| Renderer & OpenGUI::Renderer::getSingleton | ( | void | ) | [static] |
Retrieve the current singleton, if one exists. If none exists, this will cause an error.
| Renderer * OpenGUI::Renderer::getSingletonPtr | ( | void | ) | [static] |
Retrieve a pointer to the current singleton, if one exists. If none exists, this will return 0.
| virtual void OpenGUI::Renderer::postRenderCleanup | ( | ) | [pure virtual] |
This is always called by the System exactly once every frame after all of the calls to doRenderOperation() have been completed for a Viewport.
Much like preRenderSetup(), this gives the renderer an opportunity to perform whatever tasks it feels are necessary to return the render system back to a usable state for the application.
| virtual void OpenGUI::Renderer::preRenderSetup | ( | ) | [pure virtual] |
This is always called by the System exactly once every frame before the calls to doRenderOperation() begin for a Viewport.
The primary purpose of this is to provide the renderer an opportunity to configure the projection matrix as it feels necessary, as well as set any graphics API options that will be used on all (or most) render operations.
It is guaranteed that this function will be called before the usage of any Viewport.
| virtual void OpenGUI::Renderer::selectRenderContext | ( | RenderTexture * | context | ) | [inline, virtual] |
This is called to set the current rendering context.
Calls to doRenderOperation() that occur after this function is called should draw to the RenderTexture that was last sent via this function.
| context | A pointer to the render texture that is to become the new context, or 0 (NULL) to set the context to the default context (current Viewport) as was previously selected by selectViewport() |
| virtual void OpenGUI::Renderer::selectViewport | ( | Viewport * | activeViewport | ) | [pure virtual] |
This is called to tell the Renderer to change the active Viewport to the one provided.
This function will never occur between a preRenderSetup()/postRenderCleanup() combination.
| bool OpenGUI::Renderer::supportsRenderToTexture | ( | ) | [virtual] |
Renderer implementations that do support Render to Texture contexts should return true. The default is to return false.
| virtual void OpenGUI::Renderer::updateTextureFromTextureData | ( | Texture * | texture, | |
| const TextureData * | textureData | |||
| ) | [pure virtual] |
Replaces an existing texture with the given TextureData.
This should cause a Renderer implementation to completely replace the contents of a texture with the newly provided data. The given texture pointer must remain valid, but other than that it doesn't matter how this is achieved internally. Renderer implementations can feel free to discard their hardware textures and rebuild from scratch if they choose.