Gem Illuminator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
Signals | Public Member Functions | Protected Slots | Protected Attributes | List of all members
PainterQML Class Reference

The PainterQML class is responsible for making our game visible within QML using Painter. This class is intended to be added and created within QML. As the element showing our game it recognizes resize events and update events needed by our application. Also it keeps our rendering alive. Furthermore, it is the interface between game logic and rendering. More...

#include <painterqml.h>

Inheritance diagram for PainterQML:

Signals

void isActiveChanged ()
 
void isAppActiveChanged ()
 
void isGameActiveChanged ()
 
void sceneChanged ()
 

Public Member Functions

 PainterQML (QQuickItem *parent=0)
 
virtual ~PainterQML ()
 
bool event (QEvent *ev) override
 Process incoming qt events. More...
 
bool isGameActive () const
 Checks if our painter and therfor aour game is active. Active means that the game should be updated and rendered. But updates and rendering will be done only if there are no reasons against (e.g. The app is not active) More...
 
void setIsGameActive (bool active)
 Sets active state of PainterQML. More...
 
QEvent::Type paintingDoneEventType ()
 Queries registered event type, that should be sent after rendering of current frame is done. More...
 
Q_INVOKABLE void reloadEnvMap ()
 Reloads environment map of game using Config. More...
 
Q_INVOKABLE void resetTimer ()
 Resets update timer. This method is provided to allow manual resetting update time. More...
 
Scenescene () const
 The scene that is painted by PainterQML. More...
 
void setScene (Scene *scene)
 Sets the scene which should be drawn by PainterQML. More...
 
bool isAppActive () const
 Checks if the PainterQML assumes the app is active or not. More...
 
void setIsAppActive (bool active)
 Informs the painter if app is active or not. Setting this attribute to false leads to pause of game (stop updating and rendering). More...
 
bool isActive () const
 Checks if the game will be updated. This means there is no reason to not update the game. More...
 

Protected Slots

void synchronize ()
 Synchronizes game logic and rendering. Because QML uses different threads for ui and rendering, synchronization between these threads has to be done. This slot is connected by PainterQML to corresponding signals of QQuickItem. More...
 
void cleanup ()
 Cleans up the rendering thread ressources. This slot is also connected by PainterQML to corresponding signal of QQuickItem. More...
 

Protected Attributes

bool m_isAppActive
 
bool m_isGameActive
 
bool m_isSceneDeletionRequired
 
bool m_isUpdatePending
 
Painterm_painter
 
int m_paintingDoneEventType
 
Scenem_scene
 
QTime * m_time
 

Detailed Description

The PainterQML class is responsible for making our game visible within QML using Painter. This class is intended to be added and created within QML. As the element showing our game it recognizes resize events and update events needed by our application. Also it keeps our rendering alive. Furthermore, it is the interface between game logic and rendering.

Constructor & Destructor Documentation

PainterQML::PainterQML ( QQuickItem *  parent = 0)
explicit
PainterQML::~PainterQML ( )
virtual

Member Function Documentation

void PainterQML::cleanup ( )
protectedslot

Cleans up the rendering thread ressources. This slot is also connected by PainterQML to corresponding signal of QQuickItem.

bool PainterQML::event ( QEvent *  ev)
override

Process incoming qt events.

Parameters
evEvent that should be handled.
Returns
Returns true if the event was handled by QObject.
bool PainterQML::isActive ( ) const

Checks if the game will be updated. This means there is no reason to not update the game.

Returns
void PainterQML::isActiveChanged ( )
signal
bool PainterQML::isAppActive ( ) const

Checks if the PainterQML assumes the app is active or not.

Returns
void PainterQML::isAppActiveChanged ( )
signal
bool PainterQML::isGameActive ( ) const

Checks if our painter and therfor aour game is active. Active means that the game should be updated and rendered. But updates and rendering will be done only if there are no reasons against (e.g. The app is not active)

Returns
Returns true if PainterQML is active.
See also
isAppActive(), isActive()
void PainterQML::isGameActiveChanged ( )
signal
QEvent::Type PainterQML::paintingDoneEventType ( )

Queries registered event type, that should be sent after rendering of current frame is done.

Returns
Returns registered event type
void PainterQML::reloadEnvMap ( )

Reloads environment map of game using Config.

void PainterQML::resetTimer ( )

Resets update timer. This method is provided to allow manual resetting update time.

Scene* PainterQML::scene ( ) const

The scene that is painted by PainterQML.

Returns
void PainterQML::sceneChanged ( )
signal
void PainterQML::setIsAppActive ( bool  active)

Informs the painter if app is active or not. Setting this attribute to false leads to pause of game (stop updating and rendering).

Parameters
active
void PainterQML::setIsGameActive ( bool  active)

Sets active state of PainterQML.

Parameters
active
void PainterQML::setScene ( Scene scene)

Sets the scene which should be drawn by PainterQML.

Parameters
scene
void PainterQML::synchronize ( )
protectedslot

Synchronizes game logic and rendering. Because QML uses different threads for ui and rendering, synchronization between these threads has to be done. This slot is connected by PainterQML to corresponding signals of QQuickItem.

Member Data Documentation

bool PainterQML::m_isAppActive
protected
bool PainterQML::m_isGameActive
protected
bool PainterQML::m_isSceneDeletionRequired
protected
bool PainterQML::m_isUpdatePending
protected
Painter* PainterQML::m_painter
protected
int PainterQML::m_paintingDoneEventType
protected
Scene* PainterQML::m_scene
protected
QTime* PainterQML::m_time
protected

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