Video Design Documentation
- 1 Introduction
- 2 Functional summary
- 3 Main class diagram
- 4 Fonts class diagram
- 5 Detailed class description
- 5.1 AbstractFont
- 5.2 AbstractImage
- 5.3 Animation
- 5.4 AnimationPool
- 5.5 Cursor
- 5.6 FontBase
- 5.7 GLImage
- 5.8 Image
- 5.9 ImageFontBase
- 5.10 ImageLocation
- 5.11 ImagePool
- 5.12 RenderBackend
- 5.13 RenderBackendOpenGL
- 5.14 RenderBackendSDL
- 5.15 SDLImage
- 5.16 SubImageFont
- 5.17 TextRendererPool
- 5.18 TrueTypeFont
- 6 Links
Video provides low level video handling functionality and the abstraction between different rendering backends. Several primitive functions are provided by the render backend interface. This interface is implemented for two backends: OpenGL and SDL. In addition, abstract Image class is provided, it is reimplemented for different backends (such as, OpenGL and SDL). For text rendering, base abstract class is provided, which is reimplemented for different font types, such as image font, ttf font, sub image font, etc. Moreover, finding image data is necessary, and information about image location should be provided to resource provider. For this purpose, special image location class is implemented. To store the image or animation data and access it as quickly as possible image and animation pools are used, they inherit from generic pool class. A client of the pool can request an object from the pool and perform operations on the returned object. Mouse cursor handling is also done in video module, it provides functionality for drawing cursor, setting\getting type and managing dragging.
- Backends (abstract interface, OpenGL, SDL)
- Fonts (true type font, image font, sub image font)
- Images (abstract image, SDLImage, GLImage)
- Pool of images
- Pool of animations
Main class diagram
Fonts class diagram
Detailed class description
Pure abstract font interface, inherited by FontBase, provides abstract methods for next functionalities:
- Set\get spacing between rows in pixels
- Set\get spacing between letters
- Set\verify anti aliasing
- Get text as an image
- Get text as an image, but split text on multiple lines.
- Set\get set color of the text to be rendered
- Get text of given text
- Get height of the font
Pure abstract image interface, inherited by Image and RendererBackend. Provides abstract methods for next functionalities:
- Get surface, used by this image
- Get maximum width, occupied by this image
- Get maximum height, occupied by this image
- Get area of the image
- Put pixel with given coordinates and RGB color on the image
- Draw line between two points with given RGB color on the image
- Draw quad between four points with given RGB color on the image
- Get pixel RGBA values from given position
- Push\pop clip area to and from the clip stack
- Save image using given filename
- Enable\disable\check for alpha optimizer
A container of Images describing an animation, extends ResourceClass. ResourceClass contains information about resource, used to give the information where to find the data. Animation itself does not take care of animating the images. Instead it contains images having associated timestamps. It is the responsibility of the animation user to query frames based on current timestamp and show returned images on screen. Images are reference counted. Provides next functionalities:
- Adds frame into the animation
- Gets frame index
- Gets frame by timestamp
- Gets duration of the frame
- Sets animation direction
Pool for holding images. Extends pool, implements method for getting animation by index.
Cursor class manages mouse cursor handling. Provides next functionality:
- Cursor drawing
- Set\get current mouse cursor type
- Set\get current mouse drag cursor
- Get mouse cursor pool ID
Font base class. Uses pool for rendered strings. Extends abstract font.
Implements image using OpenGL. Extends Image class, contains a texture handle bound to the data given to the constructor, it draws a textured Quad to the screen.
Base class for images. Extends AbstractImage and ResourceClass.
ImageFont base class, extends FontBase. Just set the glyphs/placeholder in any derived class and the rendering is handled by this class. Also frees all glyph surfaces on destruction.
Contains information about the Location of a image, extends ResourceLocation. This class is used to give ResourceProvider the information where to find the data.
Pool for holding images, extends Pool.
Abstract interface for all render backends, extends AbstractImage and DynamicSingleton. Implements methods for next functionality:
- Name of the backend
- Start new frame
- End frame, frame is finished and ready for displaying
- Initialization of the backend
- Main screen creation
- Image creation, image creation from surface
- Screen capturing to a file
- Get clip area, get screen size, etc
The main class for OpenGL based renderer, extends RenderBackend.
The main class for SDL based renderer, extends RenderBackend.
The SDL implementation of the Image based class, extends Image.
Imagefont that is able to read glyphs from single image sheet, see e.g.guichan imagefontcollection, extends ImageFontBase.
Generic pool for rendered text, extends Pool. Caches a number of Images with text, as rendered by a Font. Makes sure no more than a maximum number of strings is pooled at a time. Automatically removes pooled strings not used for a minute. Doesn't use resources (apart from a minimum) if not used after a while.
SDL True Type Font implementation of Font, extends FontBase. It uses the SDL_ttf library to display True Type Fonts with SDL.