Nox Engine
 
Loading...
Searching...
No Matches
FPS Struct Reference

A Text component that automatically calculates and displays the current FPS. More...

#include <Counters.h>

Inheritance diagram for FPS:
Inheritance graph
Collaboration diagram for FPS:
Collaboration graph

Public Member Functions

 FPS (std::string inStr)
 Constructs an FPS counter.
 
float calcAvg ()
 Calculates the average FPS over a sample of frames.
 
void update () override
 Updates the FPS calculation and the displayed text.
 
void reload () override
 Resets the frame counter history.
 
 Text (std::string inStr, int x, int y, float scale, SDL_Color color)
 Constructs a fully customized Text component.
 
 Text (std::string inStr, int x, int y, float scale)
 Constructs a Text component with a default color.
 
 Text (std::string inStr, int x, int y)
 Constructs a Text component with a default color and scale.
 
- Public Member Functions inherited from Text
 Text (std::string inStr, int x, int y, float scale, SDL_Color color)
 Constructs a fully customized Text component.
 
 Text (std::string inStr, int x, int y, float scale)
 Constructs a Text component with a default color.
 
 Text (std::string inStr, int x, int y)
 Constructs a Text component with a default color and scale.
 
void update () override
 Updates the destination rectangle for rendering.
 
void draw () override
 Draws the text texture to the screen.
 
void changeText (std::string text)
 Changes the text content and regenerates the texture.
 
void centreText (SDL_Rect &parentRect)
 Adjusts the text's position to be centered within a parent rectangle.
 
- Public Member Functions inherited from Component
virtual void init ()
 Called once when the component is added to an entity.
 

Public Attributes

int value
 The current FPS value.
 
- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Additional Inherited Members

- Protected Member Functions inherited from Text
void setTex (const char *text)
 Creates a new texture from a string of text.
 
- Protected Attributes inherited from Text
std::string data
 
float scale
 
SDL_TexturetextTex
 
SDL_Colour textColour
 
SDL_Rect destRect
 

Detailed Description

A Text component that automatically calculates and displays the current FPS.

Constructor & Destructor Documentation

◆ FPS()

FPS::FPS ( std::string  inStr)

Constructs an FPS counter.

Parameters
inStrThe prefix string to display (e.g., "FPS: ").
Here is the call graph for this function:

Member Function Documentation

◆ calcAvg()

float FPS::calcAvg ( )

Calculates the average FPS over a sample of frames.

Returns
The average frames per second.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reload()

void FPS::reload ( )
overridevirtual

Resets the frame counter history.

Reimplemented from Component.

◆ Text() [1/3]

Text::Text ( std::string  inStr,
int  x,
int  y 
)

Constructs a Text component with a default color and scale.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.

◆ Text() [2/3]

Text::Text ( std::string  inStr,
int  x,
int  y,
float  scale 
)

Constructs a Text component with a default color.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.
scaleThe rendering scale.

◆ Text() [3/3]

Text::Text ( std::string  inStr,
int  x,
int  y,
float  scale,
SDL_Color  color 
)

Constructs a fully customized Text component.

Parameters
inStrThe initial string to display.
xThe x-position.
yThe y-position.
scaleThe rendering scale.
colorThe color of the text.

◆ update()

void FPS::update ( )
overridevirtual

Updates the FPS calculation and the displayed text.

Reimplemented from Component.

Here is the call graph for this function:

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