Wraith  0.1.5
Basic 3D game engine in C++

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...

Collaboration diagram for Draw:

Functions

void Drawable::submitDrawRegistration ()
 Submit draw registration to current scene. More...
 
void Drawable::submitDrawDeregistration ()
 Submit draw deregistration to current scene. More...
 
void Drawable::submitDraw2DRegistration ()
 Submit draw 2D registration to current scene. More...
 
void Drawable::submitDraw2DDeregistration ()
 Submit draw 2D deregistration from current scene. More...
 
bool Drawable::isRegisteredForDraw () const
 Query if this object is registered for draw. More...
 
bool Drawable::isRegisteredForDraw2D () const
 Query if this object is registered for draw 2D. More...
 
virtual void Drawable::draw ()
 Draw callback this object. More...
 
virtual void Drawable::draw2D ()
 Draw2D callback for this object. More...
 

Detailed Description

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()
{
// Create Graphics Object
Model* pWindMillModel = ModelManager::GetModel("WindMill");
ShaderObject* pTextureShader = ShaderManager::GetDefaultShader(ShaderManager::DefaultShader::TEXTURE);
Texture* pWindMillTexture = TextureManager::GetTexture("WindMill");
_pGraphicsObject_WindMill = new GraphicsObject_TextureFlat(pWindMillModel, pTextureShader, pWindMillTexture);
// IMPORTANT: Submit Draw Registrations
}
void WindMill::draw() // The draw callback
{
// Get current camera
_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()
{
// Sprite
_pGameOverSprite = new Sprite("GameOverImage");
_pGameOverSprite->setPosition(250.0f, 250.0f);
// Submit Registration
// IMPORTANT: For sprites, you must render in draw2D() callback.
// Make sure to call submitDrawRegistration2D() for registration
}
void HUD::draw2D() // The draw2D callback
{
_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

Function Documentation

◆ draw()

void Drawable::draw ( )
privatevirtual

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.