Gorgon Game Engine
Gorgon::Graphics Namespace Reference

Contains generic 2D graphics related data structures and functions. More...

Namespaces

 Color
 Contains commonly used colors identified by XKCD survey containing 140000 people.
 
 HTMLRendererInternal
 
 internal
 Functions inside this namespace is designed for internal use, however, they might be used externally and will not have any impact on inner workings of the system.
 

Classes

class  AlphaShader
 
class  Animation
 A regular drawable animation. More...
 
class  AnimationProvider
 A regular drawable animation provider. More...
 
class  basic_AnimatedPointer
 Represents animated pointer. More...
 
class  basic_AnimationFrame
 
class  basic_LineProvider
 This class allows instancing of a line like image that is made out of three parts. More...
 
class  basic_MaskedObject
 
class  basic_MaskedObjectProvider
 This object creates a masked object from two graphics object. More...
 
class  basic_PointerProvider
 This class stores information that allows an animated pointer to be created. More...
 
class  basic_RectangleProvider
 This class allows instancing of a rectangle like image that is made out of three parts. More...
 
class  basic_ScalableObject
 
class  basic_ScalableObjectProvider
 This object creates a scalable object from a graphic object. More...
 
class  basic_StackedObject
 
class  basic_StackedObjectProvider
 This object creates an object that has two subobjects drawn on top of each other. More...
 
class  basic_TextureAnimation
 
class  basic_TextureAnimationInjection
 
class  basic_TextureAnimationInjection< Bitmap >
 
class  basic_TextureAnimationProvider
 
class  basic_TintedObject
 
class  basic_TintedObjectProvider
 This object creates a scalable object from a graphic object. More...
 
class  BasicFont
 This is the basic font, performing the minimal amount of operations necessary to render text on the screen. More...
 
class  Bitmap
 This object contains an bitmap image. More...
 
class  BitmapFont
 Bitmap fonts provide an easy way to render text on the screen. More...
 
class  BlankImage
 Pure color blank image, default size is 0x0, but can be drawn with any size. More...
 
class  DiscreteAnimation
 A discrete rectangular animation, this is most suitable for bitmap or texture animations. More...
 
class  DiscreteAnimationProvider
 This class provides discrete and rectangular animation which is suitable for bitmap and texture animations. More...
 
class  Drawable
 Represents a drawable object, that can be drawn to the given point. More...
 
class  DrawablePointer
 This class turns a drawable into a pointer. More...
 
class  EmptyImage
 This class is an empty image that will not draw anything if drawn on a layer. More...
 
class  FillShader
 
class  FontFamily
 
class  FreeType
 This class allows using font files for text rendering. More...
 
class  GlyphRange
 This class represents a range of glyphs. Both start and end is included. More...
 
class  GlyphRenderer
 Should be implemented by the systems aimed to render fonts on the screen. More...
 
class  HTMLRenderer
 
class  ILineProvider
 Interface for LineProviders. More...
 
class  Image
 This is an interface for solid texture based image. More...
 
class  ImageProvider
 
class  IMaskedObjectProvider
 For ease of use in resource system. More...
 
class  IRectangleProvider
 Interface for RectangleProviders. More...
 
class  IScalableObjectProvider
 For ease of use in resource system. More...
 
class  IStackedObjectProvider
 For ease of use in resource system. More...
 
class  ITintedObjectProvider
 For ease of use in resource system. More...
 
class  Layer
 This layer allows drawing texture images on. More...
 
class  Line
 This class allows drawing a line like image that is made out of three parts. More...
 
class  MaskedAlphaShader
 
class  MaskedFillShader
 
class  MaskedShader
 
class  Pointer
 Represents a pointer. More...
 
class  PointerStack
 This class manages a pointer stack that allows multiple pointers to be registered and switched. More...
 
class  Rectangle
 This class allows drawing a rectangle like image that is made out of nine parts. More...
 
class  RectangularAnimation
 Rectangular drawable animation. More...
 
class  RectangularAnimationProvider
 This class provides rectangular animations. More...
 
class  RectangularDrawable
 
class  RGBA
 This class represents a color information. More...
 
class  RGBAf
 Represents a four channel 32 bit float per channel color information. More...
 
class  SimpleShader
 
class  SizeController
 This class allows control over a sizable object. More...
 
class  SizelessDrawable
 A drawable object that does not have a size and requires a region to draw. More...
 
class  StyledRenderer
 This text renderer can style text according to the set parameters. More...
 
class  TextRenderer
 This class allows printing text on the screen. More...
 
class  TextShadow
 Describes how a text shadow should be. More...
 
class  Texture
 This class represents an image depends on a GL texture. More...
 
class  TextureImage
 This is a solid texture based image class. More...
 
class  TextureProvider
 
class  TextureSource
 This interface represents a GL texture source. More...
 
class  TextureTarget
 This interface defines a class that can be used as a common target for texture based drawing. More...
 

Typedefs

using AnimatedBitmapLineProvider = basic_LineProvider< BitmapAnimationProvider >
 
using AnimatedBitmapRectangleProvider = basic_RectangleProvider< BitmapAnimationProvider >
 
using AnimationStorage = Gorgon::Animation::basic_Storage< AnimationProvider >
 
using BitmapAnimation = BitmapAnimationProvider::AnimationType
 
using BitmapAnimationProvider = basic_TextureAnimationProvider< Bitmap, basic_TextureAnimation, basic_AnimationFrame< Bitmap > >
 
using BitmapLineProvider = basic_LineProvider< Bitmap >
 
using BitmapPointerProvider = basic_PointerProvider< BitmapAnimationProvider >
 
using BitmapRectangleProvider = basic_RectangleProvider< Bitmap >
 
using ConstBitmapAnimation = ConstBitmapAnimationProvider::AnimationType
 
using ConstBitmapAnimationProvider = basic_TextureAnimationProvider< const Bitmap, basic_TextureAnimation, basic_AnimationFrame< const Bitmap > >
 
using ConstBitmapPointerProvider = basic_PointerProvider< ConstBitmapAnimationProvider >
 
using ConstImageAnimation = ConstImageAnimationProvider::AnimationType
 
using ConstImageAnimationProvider = basic_TextureAnimationProvider< const Image, basic_TextureAnimation, basic_AnimationFrame< const Image > >
 
using DiscreteAnimationStorage = Gorgon::Animation::basic_Storage< DiscreteAnimationProvider >
 
using Glyph = Gorgon::Char
 Glyph is a symbol for a character. In Gorgon, glyphs are UTF32 chars. More...
 
using ImageAnimation = ImageAnimationProvider::AnimationType
 
using ImageAnimationProvider = basic_TextureAnimationProvider< Image, basic_TextureAnimation, basic_AnimationFrame< Image > >
 
using Instance = Gorgon::Animation::basic_Instance< RectangularAnimation >
 
using LineProvider = basic_LineProvider< RectangularAnimationProvider >
 
using MaskedBitmap = basic_MaskedObject< Bitmap >
 
using MaskedBitmapAnimation = basic_MaskedObject< BitmapAnimationProvider >
 
using MaskedBitmapAnimationProvider = basic_MaskedObjectProvider< BitmapAnimationProvider >
 
using MaskedBitmapProvider = basic_MaskedObjectProvider< Bitmap >
 
using MaskedObject = basic_MaskedObject< RectangularAnimationProvider >
 
using MaskedObjectProvider = basic_MaskedObjectProvider< RectangularAnimationProvider >
 
using PointerProvider = basic_PointerProvider< AnimationProvider >
 
using RectangleProvider = basic_RectangleProvider< RectangularAnimationProvider >
 
using RectangularAnimationStorage = Gorgon::Animation::basic_Storage< RectangularAnimationProvider >
 
using ScalableBitmap = basic_ScalableObject< Bitmap >
 
using ScalableBitmapAnimation = basic_ScalableObject< BitmapAnimationProvider >
 
using ScalableBitmapAnimationProvider = basic_ScalableObjectProvider< BitmapAnimationProvider >
 
using ScalableBitmapProvider = basic_ScalableObjectProvider< Bitmap >
 
using ScalableObject = basic_ScalableObject< RectangularAnimationProvider >
 
using ScalableObjectProvider = basic_ScalableObjectProvider< RectangularAnimationProvider >
 
using StackedBitmap = basic_StackedObject< Bitmap >
 
using StackedBitmapAnimation = basic_StackedObject< BitmapAnimationProvider >
 
using StackedBitmapAnimationProvider = basic_StackedObjectProvider< BitmapAnimationProvider >
 
using StackedBitmapProvider = basic_StackedObjectProvider< Bitmap >
 
using StackedObject = basic_StackedObject< RectangularAnimationProvider >
 
using StackedObjectProvider = basic_StackedObjectProvider< RectangularAnimationProvider >
 
using TextureRectangleProvider = basic_RectangleProvider< TextureProvider >
 
using TintedBitmap = basic_TintedObject< Bitmap >
 
using TintedBitmapAnimation = basic_TintedObject< BitmapAnimationProvider >
 
using TintedBitmapAnimationProvider = basic_TintedObjectProvider< BitmapAnimationProvider >
 
using TintedBitmapProvider = basic_TintedObjectProvider< Bitmap >
 
using TintedObject = basic_TintedObject< RectangularAnimationProvider >
 
using TintedObjectProvider = basic_TintedObjectProvider< RectangularAnimationProvider >
 

Enumerations

enum  Alignment { Start, Center, End }
 Defines how an object is aligned. More...
 
enum  ColorMode {
  Invalid, Automatic, RGB, BGR,
  Grayscale, Alpha, RGBA, BGRA,
  Grayscale_Alpha
}
 Color modes for images. More...
 
enum  Orientation { Horizontal, Vertical }
 2D orientation constants More...
 
enum  Placement {
  TopLeft, TopCenter, TopRight, MiddleLeft,
  MiddleCenter, MiddleRight, BottomLeft, BottomCenter,
  BottomRight
}
 Defines how an object is placed in a 2D axis system. More...
 
enum  PointerType {
  None, Arrow, Wait, No,
  Text, Hand, Drag
}
 Pointer types. More...
 
enum  ShaderMode { Normal, ToMask }
 
enum  TextAlignment { Left, Center, Right }
 Defines how a text is aligned. More...
 
enum  Tiling { None, Horizontal, Vertical, Both }
 Details which directions a texture should tile. More...
 

Functions

RGBA Blend (RGBA first, const RGBA &second)
 Blends two colors together, you do not need to use namespace if calling on an RGBA object. More...
 
RGBA Blend (RGBA first, const RGBA &second, float alpha)
 Blends two colors together, you do not need to use namespace if calling on an RGBA object. More...
 
Geometry::Point CalculateOffset (Placement place, Geometry::Size remainder)
 Returns the offset of the object according to the given placement rule when there is the given remainder between object size and the area its being drawn on. More...
 
int GetAlphaIndex (ColorMode mode)
 Returns the index of alpha channel. If alpha channel does not exists, this function returns -1. More...
 
unsigned long GetChannelsPerPixel (ColorMode mode)
 Returns bytes per pixel for the given color mode. More...
 
Alignment GetHorizontal (Placement placement)
 Returns horizontal alignment from a placement. More...
 
Alignment GetVertical (Placement placement)
 Returns vertical alignment from a placement. More...
 
bool HasAlpha (ColorMode mode)
 Returns if the given color mode has alpha channel. More...
 
void Initialize ()
 Initializes Graphics module, should be performed after an OpenGL context is created. More...
 
std::ostream & operator<< (std::ostream &stream, const RGBA &color)
 Prints the given color to the stream. More...
 
std::ostream & operator<< (std::ostream &stream, const RGBAf &color)
 Prints the given color to the stream. More...
 
std::istream & operator>> (std::istream &in, RGBA &color)
 Reads a color from the stream. More...
 
BitmapRectangleProvider Slice (const Bitmap &source, Geometry::Bounds center)
 Slices an image to create a rectangle. More...
 
BitmapRectangleProvider SliceHorizontal (const Bitmap &source, int t, int b, int tl, int tr, int l, int r, int bl, int br)
 Horizontally slices the given image. More...
 
BitmapRectangleProvider SliceVertical (const Bitmap &source, int l, int r, int tl, int bl, int t, int b, int tr, int br)
 Vertically slices the given image. More...
 
Tiling Tile (bool horizontal, bool vertical)
 Creates a Tiling class from the given horizontal, vertical tiling info. More...
 

Detailed Description

Contains generic 2D graphics related data structures and functions.

These functions are tied to underlying GL system through textures.

Typedef Documentation

◆ AnimatedBitmapLineProvider

◆ AnimatedBitmapRectangleProvider

◆ AnimationStorage

◆ BitmapAnimation

◆ BitmapAnimationProvider

◆ BitmapLineProvider

◆ BitmapPointerProvider

◆ BitmapRectangleProvider

◆ ConstBitmapAnimation

◆ ConstBitmapAnimationProvider

◆ ConstBitmapPointerProvider

◆ ConstImageAnimation

◆ ConstImageAnimationProvider

◆ DiscreteAnimationStorage

◆ Glyph

Glyph is a symbol for a character. In Gorgon, glyphs are UTF32 chars.

◆ ImageAnimation

◆ ImageAnimationProvider

◆ Instance

◆ LineProvider

◆ MaskedBitmap

◆ MaskedBitmapAnimation

◆ MaskedBitmapAnimationProvider

◆ MaskedBitmapProvider

◆ MaskedObject

◆ MaskedObjectProvider

◆ PointerProvider

◆ RectangleProvider

◆ RectangularAnimationStorage

◆ ScalableBitmap

◆ ScalableBitmapAnimation

◆ ScalableBitmapAnimationProvider

◆ ScalableBitmapProvider

◆ ScalableObject

◆ ScalableObjectProvider

◆ StackedBitmap

◆ StackedBitmapAnimation

◆ StackedBitmapAnimationProvider

◆ StackedBitmapProvider

◆ StackedObject

◆ StackedObjectProvider

◆ TextureRectangleProvider

◆ TintedBitmap

◆ TintedBitmapAnimation

◆ TintedBitmapAnimationProvider

◆ TintedBitmapProvider

◆ TintedObject

◆ TintedObjectProvider

Enumeration Type Documentation

◆ Alignment

enum Alignment
strong

Defines how an object is aligned.

Enumerator
Start 

Placed at the start of the axis.

Center 

Centered along the axis.

End 

Placed at the end of the axis.

◆ ColorMode

enum ColorMode
strong

Color modes for images.

Enumerator
Invalid 

This is used to mark invalid color data.

Automatic 

This is used by some functions to mark color mode should be determined automatically.

RGB 

24bit red, green, blue color mode that has red component in the lowest byte order

BGR 

24bit red, green, blue color mode that has blue component in the lowest byte order

Grayscale 

8bit gray scale color mode

Alpha 

8bit alpha only color mode

RGBA 

32bit red, green, blue and alpha channel image. Red component is in the lowest byte order and

BGRA 

32bit red, green, blue and alpha channel image.

Blue component is in the lowest byte order and alpha is in the highest byte order.

Grayscale_Alpha 

16bit gray scale image color mode with an alpha channel. Alpha channel is in the high byte

◆ Orientation

enum Orientation
strong

2D orientation constants

Enumerator
Horizontal 
Vertical 

◆ Placement

enum Placement
strong

Defines how an object is placed in a 2D axis system.

Enumerator
TopLeft 

Placed at top left.

TopCenter 

Placed at top center.

TopRight 

Placed at top right.

MiddleLeft 

Placed at middle left.

MiddleCenter 

Placed at the center.

MiddleRight 

Placed at middle right.

BottomLeft 

Placed at bottom.

BottomCenter 

Placed at bottom center.

BottomRight 

Placed at bottom right.

◆ PointerType

enum PointerType
strong

Pointer types.

Enumerator
None 

No pointer is selected or using default.

Arrow 

Arrow / Pointer.

Wait 

Wait / Hourglass.

No 

No / Not allowed.

Text 

Text / Beam pointer.

Hand 

Hand pointer.

Drag 

Drag / Closed hand pointer.

◆ ShaderMode

enum ShaderMode
strong
Enumerator
Normal 
ToMask 

◆ TextAlignment

enum TextAlignment
strong

Defines how a text is aligned.

Justification should be used as an independent flag as a text could both be justified and centered (for partial lines).

Enumerator
Left 

Text is aligned to left.

Center 

Text is aligned to center.

Right 

Text is aligned to right.

◆ Tiling

enum Tiling
strong

Details which directions a texture should tile.

If its not tiled for that direction, it will be stretched. If the target size is smaller, tiling causes partial draw instead of shrinking.

Enumerator
None 
Horizontal 
Vertical 
Both 

Function Documentation

◆ Blend() [1/2]

RGBA Gorgon::Graphics::Blend ( RGBA  first,
const RGBA second 
)

Blends two colors together, you do not need to use namespace if calling on an RGBA object.

References RGBA::Blend().

◆ Blend() [2/2]

RGBA Gorgon::Graphics::Blend ( RGBA  first,
const RGBA second,
float  alpha 
)

Blends two colors together, you do not need to use namespace if calling on an RGBA object.

References RGBA::Blend().

◆ CalculateOffset()

Geometry::Point Gorgon::Graphics::CalculateOffset ( Placement  place,
Geometry::Size  remainder 
)

Returns the offset of the object according to the given placement rule when there is the given remainder between object size and the area its being drawn on.

Typical usage: CalculateOffset(Placement::MiddleCenter, areasize - objectsize)

References Center, End, GetHorizontal(), GetVertical(), basic_Size< T_ >::Height, Start, and basic_Size< T_ >::Width.

◆ GetAlphaIndex()

int Gorgon::Graphics::GetAlphaIndex ( ColorMode  mode)

Returns the index of alpha channel. If alpha channel does not exists, this function returns -1.

References Alpha, Invalid, and RGBA.

◆ GetChannelsPerPixel()

unsigned long Gorgon::Graphics::GetChannelsPerPixel ( ColorMode  mode)

Returns bytes per pixel for the given color mode.

References Alpha, Grayscale, Invalid, RGB, and RGBA.

◆ GetHorizontal()

Alignment Gorgon::Graphics::GetHorizontal ( Placement  placement)

Returns horizontal alignment from a placement.

◆ GetVertical()

Alignment Gorgon::Graphics::GetVertical ( Placement  placement)

Returns vertical alignment from a placement.

◆ HasAlpha()

bool Gorgon::Graphics::HasAlpha ( ColorMode  mode)

Returns if the given color mode has alpha channel.

References Alpha.

◆ Initialize()

void Initialize ( )

Initializes Graphics module, should be performed after an OpenGL context is created.

Initializes the filesystem module.

There is a mechanism to ensure initialization is performed once.

References Gorgon::WindowManager::CurrentContext(), glBindBuffer, glBindVertexArray, glBufferData, glEnableVertexAttribArray, glGenBuffers, glGenVertexArrays, glVertexAttribIPointer, Gorgon::GL::LoadFunctions(), Gorgon::Graphics::internal::quadvbo, Gorgon::Graphics::internal::quadvertexindex, and Gorgon::Graphics::internal::vaos.

◆ operator<<() [1/2]

std::ostream& Gorgon::Graphics::operator<< ( std::ostream &  stream,
const RGBA color 
)

Prints the given color to the stream.

◆ operator<<() [2/2]

std::ostream& Gorgon::Graphics::operator<< ( std::ostream &  stream,
const RGBAf color 
)

Prints the given color to the stream.

◆ operator>>()

std::istream& Gorgon::Graphics::operator>> ( std::istream &  in,
RGBA color 
)

Reads a color from the stream.

This color can either be in full HTML format with # in front or a hex representation of the color with an optional 0x in front.

References RGBA::A, RGBA::B, RGBA::G, Gorgon::Graphics::internal::isspace(), and RGBA::R.

◆ Slice()

BitmapRectangleProvider Gorgon::Graphics::Slice ( const Bitmap source,
Geometry::Bounds  center 
)

Slices an image to create a rectangle.

Imagine a pound sign (#) slicing the image, center parameter is the central region of the pound sign. Currently this works only with bitmaps. This function will create an atlas out of the given image, thus, the source should be kept alive. Currently atlas functionality does not work.

References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, SliceHorizontal(), and basic_Bounds< T_ >::Top.

◆ SliceHorizontal()

BitmapRectangleProvider SliceHorizontal ( const Bitmap source,
int  t,
int  b,
int  tl,
int  tr,
int  l,
int  r,
int  bl,
int  br 
)

Horizontally slices the given image.

t and b slices the image to 3 parts then each part is further sliced by X offset pairs (tl, tr), (l, r), and (bl, br). Currently this works only with bitmaps. This function will create an atlas out of the given image, thus, the source should be kept alive. Currently atlas functionality does not work.

References Bitmap::Slice().

◆ SliceVertical()

BitmapRectangleProvider SliceVertical ( const Bitmap source,
int  l,
int  r,
int  tl,
int  bl,
int  t,
int  b,
int  tr,
int  br 
)

Vertically slices the given image.

l and r slices the image to 3 parts then each part is further sliced by Y offset pairs (tl, bl), (t, b), and (tr, br). Currently this works only with bitmaps. This function will create an atlas out of the given image, thus, the source should be kept alive. Currently atlas functionality does not work.

References Bitmap::Slice().

◆ Tile()

Tiling Gorgon::Graphics::Tile ( bool  horizontal,
bool  vertical 
)

Creates a Tiling class from the given horizontal, vertical tiling info.

References Horizontal, None, and Vertical.