TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Graphics Namespace Reference

Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring the world to life. More...

Classes

class  AnimatedSprite
 
class  AnimationSequence
 
class  BoxShape
 
class  Camera
 
class  CircleShape
 
class  Color
 
class  FullScreenQuad
 
class  Graphic
 
class  GraphicList
 
class  Line
 
class  LineContainer
 
class  OutlinedBoxShape
 
class  OutlinedCircleShape
 
class  OutlinedPolygonShape
 
class  PolygonShape
 
class  RenderTarget
 
class  Sprite
 
struct  SpriteFrame
 
class  SpriteManager
 
class  SpriteMap
 
class  SpriteSheet
 
class  Text
 
class  TextureManager
 

Typedefs

typedef float TexelSpace
 
typedef tbCore::uint16 PixelSpace
 
typedef TurtleBrains::Core::ResourceHandle< tbImplementation::TextureHandleSaverTextureHandle
 

Enumerations

enum  ColorPalette {
  ColorPalette::Opaque, ColorPalette::Transparent, ColorPalette::White, ColorPalette::Black,
  ColorPalette::Red, ColorPalette::Yellow, ColorPalette::Green, ColorPalette::Cyan,
  ColorPalette::Blue, ColorPalette::Magenta, ColorPalette::LightGrey, ColorPalette::LightGray = LightGrey,
  ColorPalette::Grey, ColorPalette::Gray = Grey, ColorPalette::DarkGrey, ColorPalette::DarkGray = DarkGrey,
  ColorPalette::Brown, ColorPalette::Purple, ColorPalette::MonkyBlue, ColorPalette::MonkyOrange
}
 
enum  GifOutputSize { Full, Half }
 
enum  AnchorLocation {
  kAnchorCenter = 0, kAnchorTopLeft, kAnchorTopCenter, kAnchorTopRight,
  kAnchorCenterLeft, kAnchorCenterRight, kAnchorBottomLeft, kAnchorBottomCenter,
  kAnchorBottomRight
}
 
enum  TargetType { Color, Depth, ColorAndDepth }
 
enum  TextureFormat { TextureFormat::ColorARGB8, TextureFormat::Depth16, TextureFormat::Depth24 }
 
enum  TextureWrapMode { Repeat, MirroredRepeat, ClampToEdge }
 

Functions

void SetActiveCamera (Camera &camera)
 
void SetActiveCamera (Camera *camera)
 
CameraGetActiveCamera (void)
 
void GifPerformCapture (const float deltaTime, const bool toggleCapture, const GifOutputSize &outputSize=GifOutputSize::Half)
 
void GifCaptureCleanup (void)
 
PixelSpace ScreenWidth (void)
 
PixelSpace ScreenHeight (void)
 
float ScreenAspectRatio (void)
 
tbMath::Vector2 ScreenCenter (void)
 
TextureHandle InvalidTexture (void)
 

Variables

SpriteManager theSpriteManager
 
const TextureHandlekBlankTexture
 
TextureManagertheTextureManager
 

Detailed Description

TODO: TurtleBrains: Documentation: This is still early in development and the Graphics framework is still being designed.

Requirements:
TurtleBrains::Application

Typedef Documentation

Represents a measurement in pixel space be it the width/height of an image in pixels, or the location on the screen or texture in pixels.

Represents a value from 0 to 1 in texture space for the width/height or location on a texture.

A TextureHandle is a unique value for each unique texture created with the TextureManager. Use the handle to access the textures properties and to destroy any resources associated.

Enumeration Type Documentation

These locations are used in the Sprite::SetOrigin() which takes an AnchorLocation.

Enumerator
kAnchorCenter 

This anchor will set the origin to the center of the Sprite horizontally and vertically.

kAnchorTopLeft 

This anchor will set the origin to the top-left corner, effectively: SetOrigin(0.0f, 0.0f).

kAnchorTopCenter 

This anchor will set the origin to the top and horizontal center of the Sprite.

kAnchorTopRight 

This anchor will set the origin to the top and right most corner of the Sprite.

kAnchorCenterLeft 

This anchor will set the origin to the center vertically and left most edge of the Sprite.

kAnchorCenterRight 

This anchor will set the origin to the center vertically and right most edge of the Sprite.

kAnchorBottomLeft 

This anchor will set the origin to the bottom and left most corner of the Sprite.

kAnchorBottomCenter 

This anchor will set the origin to the bottom edge and horizontal center of the Sprite.

kAnchorBottomRight 

This anchor will set the origin to the bottom and right most corner of the Sprite.

A simple palette that can be used to set/change colors quickly. This is one of the few ways to implicitly create a Color object, to be used directly with TurtleBrains::Graphic::SetColor().

Enumerator
Opaque 

Specifies a color that would represent fully opaque white, could be |'d (or'd) together with other colors.

Transparent 

Specifies a color that would represent fully transparent white, could be |'d (or'd) together with other colors.

White 

Specifies a color that would represent one of the many shades of white.

Black 

Specifies a color that would represent one of the many shades of black.

Red 

Specifies a color that would represent one of the many shades of red.

Yellow 

Specifies a color that would represent one of the many shades of yellow.

Green 

Specifies a color that would represent one of the many shades of green.

Cyan 

Specifies a color that would represent one of the many shades of cyan.

Blue 

Specifies a color that would represent one of the many shades of blue.

Magenta 

Specifies a color that would represent one of the many shades of magenta.

LightGrey 

Specifies a color that would represents a lighter of the many shades of grey.

LightGray 

An alias for LightGrey, for convenience / alternative spelling grey v gray.

Grey 

Specifies a color that would represents a middle of the many shades of grey

Gray 

An alias for Grey, for convenience / alternative spelling grey v gray.

DarkGrey 

Specifies a color that would represents a dark of the many shades of grey

DarkGray 

An alias for DarkGrey, for convenience / alternative spelling grey v gray.

Brown 

Specifies a color that would represents one of the many shades of brown.

Purple 

Specifies a color that would represents one of the many shades of purple.

MonkyBlue 

Specifies a color that would represents a specific shade of blue, now known as MonkyBlue.

MonkyOrange 

Specifies a color that would represents a specific shade of orange, now known as MonkyOrange.

Selects the format the texture should be stored as; some formats may be incompatible with certain use cases.

Enumerator
ColorARGB8 

32 bits per pixel, colored texture with alpha, red, green, blue channels each having 8 bits.

Depth16 

16 bits per pixel, depth texture.

Depth24 

24 bits per pixel, depth texture.

Choose a wrap-mode for how the texture coordinates behave outside the 0 to 1 range.

Enumerator
Repeat 

Set the texture to repeat, ignoring the integral part of the U or V coordinate.

MirroredRepeat 

Mirrored repeat, ignoring the integral part of the U or V coordinate only when even.

ClampToEdge 

ClampToEdge wrap mode will keep the U or V coordinate within 0 to 1 top stop at texture edge.

Function Documentation

Camera& TurtleBrains::Graphics::GetActiveCamera ( void  )

Retrieves the currently active camera, which there can only ever be one active camera and there is always an active camera.

void TurtleBrains::Graphics::GifCaptureCleanup ( void  )

This should be called during shutdown if GifPerformCapture had been called as it will wait until any worker threads cleanly end and join back to main thread.

void TurtleBrains::Graphics::GifPerformCapture ( const float  deltaTime,
const bool  toggleCapture,
const GifOutputSize &  outputSize = GifOutputSize::Half 
)

This is the only function that needs to be called, once per frame during Update().

Parameters
deltaTimeThe amount of time since the previous call to PerformCapture.
toggleCaptureTrue if the capture state should be toggled on/off or off/on depending on the current state. Typically this would be a value from IsKeyPressed().
outputSizeWill change the size of the GIF that is exported from FULL, to Half to reduce size for social media platforms, at the cost of reduced quality.
Note
if tb_without_threading is defined, or tb_web is defined, then there will be no gif capture support and this will effectively do nothing.
TextureHandle TurtleBrains::Graphics::InvalidTexture ( void  )

Grabs a value that no valid texture handle will be.

float TurtleBrains::Graphics::ScreenAspectRatio ( void  )

Computes and returns the aspect ratio of the screen, width/height. 1920/1080 ~= 1.77778.

tbMath::Vector2 TurtleBrains::Graphics::ScreenCenter ( void  )

Creates and returns a Vector2 object of the location of the center of the screen, half width / height.

PixelSpace TurtleBrains::Graphics::ScreenHeight ( void  )

Returns the height of the screen/window in pixels.

PixelSpace TurtleBrains::Graphics::ScreenWidth ( void  )

Returns the width of the screen/window in pixels.

void TurtleBrains::Graphics::SetActiveCamera ( Camera camera)

Sets the current camera to be inactive and sets the provided camera as an active camera that will not be cleaned up. It is expected the camera object provided will be in existance until it is no longer the active camera.

Parameters
cameraThe newly activated camera ready to apply to the view.
void TurtleBrains::Graphics::SetActiveCamera ( Camera camera)

Sets the current camera to be inactive and sets the provided camera as an active camera that will automatically be cleaned up by calling delete on the object once a new camera becomes active.

Parameters
cameraA pointer to a camera object that was allocated with new. This object will become the active camera ready to apply to the view, and will automatically get deleted once a new camera is activated.

Variable Documentation

const TextureHandle& TurtleBrains::Graphics::kBlankTexture

This is a small, white texture that is automatically loaded for rendering Lines without a separate shader.

Note
This is only valid after a Graphics Context has been created, and before it has been destroyed.
SpriteManager TurtleBrains::Graphics::theSpriteManager

Instead of creating your own SpriteManager object, this is a way to access it as a singleton. This may turn into a pointer to the object, although the SpriteManager api will remain the same.

TextureManager& TurtleBrains::Graphics::theTextureManager

Instead of creating your own TextureManager object, this is a way to access it as a singleton. This may turn into a pointer to the object, although the TextureManager API will remain the same.