For drawing the GameObject entity every frame. There are two draw callbacks: GameObject::draw() used for rendering models and GameObject::draw2D() used for rendering Sprite entities. NOTE: GameObject Entity must be registered (using GameObject::submitDrawRegistration() or GameObject::submitDraw2DRegistration())in order to process GameObject::draw and GameObject::draw2D callback.
More...
For drawing the GameObject entity every frame. There are two draw callbacks: GameObject::draw() used for rendering models and GameObject::draw2D() used for rendering Sprite entities. NOTE: GameObject Entity must be registered (using GameObject::submitDrawRegistration() or GameObject::submitDraw2DRegistration())in order to process GameObject::draw and GameObject::draw2D callback.
The Draw callback is called by the current Scene every frame. Here is an example of WindMill rendering it model. NOTE: this requires the use of SceneManager to get the current scene and getting the scene's current Camera.
WindMill::WindMill()
{
_pGraphicsObject_WindMill = new GraphicsObject_TextureFlat(pWindMillModel, pTextureShader, pWindMillTexture);
}
void WindMill::draw()
{
_pGraphicsObject_WindMill->render(pCamera);
}
void submitDrawRegistration()
Submit draw registration to current scene.
Definition: Drawable.cpp:31
static Model * GetModel(const MapKey &key)
Gets a model with user defined key.
Definition: ModelManager.h:144
static Scene * GetCurrentScene()
Gets the current scene.
Definition: SceneManager.h:130
Camera * getCurrentCamera() const
Gets the current camera.
Definition: Scene.cpp:63
static ShaderObject * GetDefaultShader(const DefaultShader defaultShader)
Gets default preloaded shader.
Definition: ShaderManager.h:118
static Texture * GetTexture(const MapKey &key)
Gets a texture with a user defined key.
Definition: TextureManager.h:124
Here is an example of a HUD rendering a "Game Over" image (using the Sprite). NOTE: rendering Sprite entities does need the use of access the current 2D camera.
HUD::HUD()
{
_pGameOverSprite =
new Sprite(
"GameOverImage");
_pGameOverSprite->setPosition(250.0f, 250.0f);
}
void HUD::draw2D()
{
_pGameOverSprite->render();
}
A sprite used to display 2D images.
Definition: Sprite.h:18
void submitDraw2DRegistration()
Submit draw 2D registration to current scene.
Definition: Drawable.cpp:60
◆ draw()
Draw callback this object.
To be implemented by user in object derived from GameObject (NOT directly derived from Drawable). Called ONLY by current active scene.
Reimplemented in TerrainObject.
◆ draw2D()
void Drawable::draw2D |
( |
| ) |
|
|
privatevirtual |
Draw2D callback for this object.
To be implemented by user in object derived from GameObject (NOT directly derived from Drawable). Called ONLY by current active scene. NOTE: Used only to render Sprite Entities
◆ isRegisteredForDraw()
bool Drawable::isRegisteredForDraw |
( |
| ) |
const |
|
protected |
Query if this object is registered for draw.
- Returns
- True if registered for draw, false if not.
◆ isRegisteredForDraw2D()
bool Drawable::isRegisteredForDraw2D |
( |
| ) |
const |
|
protected |
Query if this object is registered for draw 2D.
- Returns
- True if registered for draw2D, false if not.
◆ submitDraw2DDeregistration()
void Drawable::submitDraw2DDeregistration |
( |
| ) |
|
|
protected |
Submit draw 2D deregistration from current scene.
◆ submitDraw2DRegistration()
void Drawable::submitDraw2DRegistration |
( |
| ) |
|
|
protected |
Submit draw 2D registration to current scene.
◆ submitDrawDeregistration()
void Drawable::submitDrawDeregistration |
( |
| ) |
|
|
protected |
Submit draw deregistration to current scene.
◆ submitDrawRegistration()
void Drawable::submitDrawRegistration |
( |
| ) |
|
|
protected |
Submit draw registration to current scene.