Neo  0.5.0
Developer Documentation
Neo2D::Canvas Class Reference

The Canvas class contains all widgets and renders them. More...

#include <Canvas.h>

Public Member Functions

 ~Canvas ()
 
 Canvas ()
 
 DISOWN (SpriteBatch *b) void addSpriteBatch(SpriteBatch *b)
 
void draw ()
 Draws the Canvas and its contents. More...
 
void update ()
 Updates the Canvas and all its children. More...
 
void clear ()
 Clears the Canvas by removing all children. More...
 
int getLayer ()
 Returns which layer this particular Canvas is at. More...
 
void setLayer (int nl)
 Sets the on which layer this Canvas will appear. More...
 
void addWidget (int w)
 Adds a widget to the Canvas. More...
 
Vector4 getClearColor ()
 Returns the clear color of the Canvas. More...
 
void setClearColor (Vector4 vec)
 Changes the clear color of the Canvas. More...
 
void enableRenderToTexture (const char *tex)
 Enables render to texture for the Canvas. More...
 
void enableRenderToTexture ()
 Enables the render to texture flag. More...
 
void disableRenderToTexture ()
 Disables the render to texture flag. More...
 
void setCameraOffset (Vector2 value)
 Sets the camera offset value that emulates a basic 2D camera. More...
 
Vector2 getCameraOffset ()
 Returns the current camera offset. More...
 

Static Public Member Functions

static CanvasgetInstance ()
 Returns the global canvas object that directly maps to the screen. More...
 

Detailed Description

The Canvas class contains all widgets and renders them.

A canvas contains all widgets, layouts, groups. All elements can be rendered directly to the screen or to a texture.

Author
Yannick Pflanzer

Constructor & Destructor Documentation

Neo2D::Canvas::~Canvas ( )
inline
Neo2D::Canvas::Canvas ( )
inline

Member Function Documentation

void Neo2D::Canvas::addWidget ( int  w)

Adds a widget to the Canvas.

The widget will be added to the update and render queue of this Canvas so it will display and operate properly. The object is actually a handle that is used to retrieve the widget from a global list of widgets.

Parameters
wThe widget handle from GuiSystem.
void Neo2D::Canvas::clear ( )

Clears the Canvas by removing all children.

Attention: No objects are deleted from memory!

void Neo2D::Canvas::disableRenderToTexture ( )
inline

Disables the render to texture flag.

This is useful to temporarily suspend and resume rendering to a texture when Canvas::enableRenderToTexture(const char* text) was already called.

See also
Canvas::enableRenderToTexture
Neo2D::Canvas::DISOWN ( SpriteBatch b)
inline
void Neo2D::Canvas::draw ( )

Draws the Canvas and its contents.

void Neo2D::Canvas::enableRenderToTexture ( const char *  tex)

Enables render to texture for the Canvas.

When render to texture is enabled the canvas will not render directly to the screen anymore. It will draw everything to the specified texture in memory instead which can be used as a widget of some sort or some texture in the game.

Attention: This will not overwrite the texture file on disk! It merely uses it to identify the surface to render to!

Parameters
texThe filename of the texture to render to.
void Neo2D::Canvas::enableRenderToTexture ( )
inline

Enables the render to texture flag.

This is useful to temporarily suspend and resume rendering to a texture when Canvas::enableRenderToTexture(const char* text) was already called.

See also
Canvas::enableRenderToTexture
Vector2 Neo2D::Canvas::getCameraOffset ( )
inline

Returns the current camera offset.

Returns
The current camera offset.
Vector4 Neo2D::Canvas::getClearColor ( )
inline

Returns the clear color of the Canvas.

Returns
The clear color as RGBA between 0.0f and 1.0f.
static Canvas* Neo2D::Canvas::getInstance ( )
inlinestatic

Returns the global canvas object that directly maps to the screen.

Returns
The Canavs object.
int Neo2D::Canvas::getLayer ( )
inline

Returns which layer this particular Canvas is at.

Canvases are sorted from low to high, meaning that higher values appear in front of lower values.

Returns
The current layer value.
void Neo2D::Canvas::setCameraOffset ( Vector2  value)
inline

Sets the camera offset value that emulates a basic 2D camera.

Parameters
valueThe new offset that should be applied.
void Neo2D::Canvas::setClearColor ( Vector4  vec)
inline

Changes the clear color of the Canvas.

Parameters
vecThe new clear color as RGBA between 0.0f and 1.0f
void Neo2D::Canvas::setLayer ( int  nl)
inline

Sets the on which layer this Canvas will appear.

Canvases are sorted from low to high, meaning that higher values appear in front of lower values.

Parameters
nlThe new layer value.
void Neo2D::Canvas::update ( )

Updates the Canvas and all its children.


The documentation for this class was generated from the following file: