CUGL 3.0
Cornell University Game Library
|
#include <CUScene2Texture.h>
Public Member Functions | |
Scene2Texture () | |
~Scene2Texture () | |
virtual void | dispose () override |
virtual bool | init () override |
bool | initWithHint (const Size hint) override |
bool | initWithHint (float width, float height) override |
virtual void | render () override |
std::shared_ptr< graphics::Texture > | getTexture () const |
Public Member Functions inherited from cugl::scene2::Scene2 | |
Scene2 () | |
~Scene2 () | |
virtual void | dispose () override |
virtual bool | init () override |
virtual bool | initWithHint (Size hint) override |
virtual bool | initWithHint (float width, float height) override |
Color4 | getColor () |
void | setColor (Color4 color) |
virtual std::string | toString (bool verbose=false) const override |
size_t | getChildCount () const |
std::shared_ptr< scene2::SceneNode > | getChild (unsigned int pos) |
const std::shared_ptr< scene2::SceneNode > & | getChild (unsigned int pos) const |
template<typename T > | |
std::shared_ptr< T > | getChild (unsigned int pos) const |
std::shared_ptr< scene2::SceneNode > | getChildByTag (unsigned int tag) const |
template<typename T > | |
std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
std::shared_ptr< scene2::SceneNode > | getChildByName (const std::string name) const |
template<typename T > | |
std::shared_ptr< T > | getChildByName (const std::string name) const |
std::vector< std::shared_ptr< scene2::SceneNode > > | getChildren () |
const std::vector< std::shared_ptr< scene2::SceneNode > > & | getChildren () const |
virtual void | addChild (const std::shared_ptr< scene2::SceneNode > &child) |
void | addChildWithTag (const std::shared_ptr< scene2::SceneNode > &child, unsigned int tag) |
void | addChildWithName (const std::shared_ptr< scene2::SceneNode > &child, const std::string name) |
void | swapChild (const std::shared_ptr< scene2::SceneNode > &child1, const std::shared_ptr< scene2::SceneNode > &child2, bool inherit=false) |
virtual void | removeChild (unsigned int pos) |
void | removeChild (const std::shared_ptr< scene2::SceneNode > &child) |
void | removeChildByTag (unsigned int tag) |
void | removeChildByName (const std::string name) |
virtual void | removeAllChildren () |
std::shared_ptr< graphics::SpriteBatch > | getSpriteBatch () const |
void | setSpriteBatch (const std::shared_ptr< graphics::SpriteBatch > &batch) |
virtual void | render () override |
Public Member Functions inherited from cugl::Scene | |
Scene () | |
~Scene () | |
virtual void | dispose () |
virtual bool | init () |
virtual bool | initWithHint (Size hint) |
virtual bool | initWithHint (float width, float height) |
const std::string | getName () const |
void | setName (const std::string name) |
std::shared_ptr< Camera > | getCamera () |
const std::shared_ptr< Camera > | getCamera () const |
virtual std::string | toString (bool verbose=false) const |
operator std::string () const | |
const Size | getSize () const |
const Rect | getBounds () const |
Vec3 | screenToWorldCoords (const Vec2 screenCoords) const |
Vec2 | worldToScreenCoords (const Vec3 worldCoords) const |
bool | isActive () const |
virtual void | setActive (bool value) |
virtual void | update (float timestep) |
virtual void | reset () |
virtual void | render () |
Static Public Member Functions | |
static std::shared_ptr< Scene2Texture > | alloc () |
static std::shared_ptr< Scene2Texture > | allocWithHint (const Size hint) |
static std::shared_ptr< Scene2Texture > | allocWithHint (float width, float height) |
Static Public Member Functions inherited from cugl::scene2::Scene2 | |
static std::shared_ptr< Scene2 > | alloc () |
static std::shared_ptr< Scene2 > | allocWithHint (const Size hint) |
static std::shared_ptr< Scene2 > | allocWithHint (float width, float height) |
Protected Attributes | |
std::shared_ptr< graphics::Texture > | _texture |
std::shared_ptr< graphics::RenderTarget > | _target |
Protected Attributes inherited from cugl::scene2::Scene2 | |
std::shared_ptr< graphics::SpriteBatch > | _batch |
std::vector< std::shared_ptr< scene2::SceneNode > > | _children |
Color4 | _color |
GLenum | _blendEquation |
GLenum | _srcFactor |
GLenum | _dstFactor |
Protected Attributes inherited from cugl::Scene | |
std::shared_ptr< Camera > | _camera |
std::string | _name |
Size | _size |
bool | _active |
This class provides the root node of an offscreen scene graph.
This subclass of Scene2
supports offscreen rendering to a texture. It has its own graphics::RenderTarget
, which is what it uses to render to. You can then access the result of this with getTexture()
. The rendering process ensures that the origin of the scene is rendered to the bottom left corner of the texture (and not the top right, as is the default in OpenGL), making it consist with sprite-based images used by the scene graph.
As a result, this class provides support for simple multi-pass rendering. Simply render to a scene to a texture in one pass, and then use that texture in future passes.
cugl::scene2::Scene2Texture::Scene2Texture | ( | ) |
Creates a new degenerate Scene2Texture on the stack.
The scene has no camera and must be initialized.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.
|
inline |
Deletes this scene, disposing all resources
|
inlinestatic |
|
inlinestatic |
Returns a newly allocated Scene2Texture with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
hint | The size hint |
|
inlinestatic |
Returns a newly allocated Scene2Texture with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
width | The width size hint |
height | The height size hint |
|
overridevirtual |
Disposes all of the resources used by this scene.
A disposed Scene2Texture can be safely reinitialized. Any children owned by this scene will be released. They will be deleted if no other object owns them.
Reimplemented from cugl::scene2::Scene2.
|
inline |
Returns the texture associated with this scene graph.
Rendering this scene graph will draw to the offscreen texture. This method returns that texture so that it can be used in subsequent passes.
|
overridevirtual |
Initializes a Scene to fill the entire screen.
Reimplemented from cugl::scene2::Scene2.
|
overridevirtual |
Initializes a Scene2Texture with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
hint | The size hint |
Reimplemented from cugl::scene2::Scene2.
|
inlineoverridevirtual |
Initializes a Scene2Texture with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
width | The width size hint |
height | The height size hint |
Reimplemented from cugl::scene2::Scene2.
|
overridevirtual |
Draws all of the children in this scene with the given SpriteBatch.
This method with draw using getSpriteBatch
. If not sprite batch has been assigned, nothing will be drawn.
Rendering happens by traversing the the scene graph using an "Pre-Order" tree traversal algorithm ( https://en.wikipedia.org/wiki/Tree_traversal#Pre-order ). That means that parents are always draw before (and behind children). To override this draw order, you should place an OrderedNode
in the scene graph to specify an alternative order.
Reimplemented from cugl::scene2::Scene2.
|
protected |
The offscreen buffer for rendering the texture.
|
protected |
The texture created by this scene