Video Design Documentation

From FIFE development wiki
Jump to: navigation, search

This article is part of design documentation. Design 32.png

Design documentation describes how software is implemented or is about to be implemented. It focuses on system structure (e.g. dependencies), module interactions and relevant algorithms. Concepts described in these articles should form the terminology that is used when discussing about the software that forms FIFE.

This article is outdated and needs to be reviewed! Outdated.png

The content of this article is outdated and should be treated as such. We cannot guarantee the accuracy of the information presented here.

Introduction

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.

Functional summary

  • Backends (abstract interface, OpenGL, SDL)
  • Fonts (true type font, image font, sub image font)
  • Images (abstract image, SDLImage, GLImage)
  • Animations
  • Pool of images
  • Pool of animations
  • Location
  • Cursor

Main class diagram

Main video class diagram

Fonts class diagram

More detailed fonts class diagram

Detailed class description

AbstractFont

AbstractFont.png

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

AbstractImage

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

Animation

Animation.png

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

AnimationPool

AnimationPool.png

Pool for holding images. Extends pool, implements method for getting animation by index.

Cursor

Cursor.png

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

FontBase

FontBase.png

Font base class. Uses pool for rendered strings. Extends abstract font.

GLImage

GLImage.png

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.

Image

Image.png

Base class for images. Extends AbstractImage and ResourceClass.

ImageFontBase

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.

ImageLocation

ImageLocation.png

Contains information about the Location of a image, extends ResourceLocation. This class is used to give ResourceProvider the information where to find the data.

ImagePool

Pool for holding images, extends Pool.

RenderBackend

RenderBackend.png

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
  • Deinitialization
  • Main screen creation
  • Image creation, image creation from surface
  • Screen capturing to a file
  • Get clip area, get screen size, etc

RenderBackendOpenGL

RenderBackendOpenGL.png

The main class for OpenGL based renderer, extends RenderBackend.

RenderBackendSDL

RenderBackendSDL.png

The main class for SDL based renderer, extends RenderBackend.

SDLImage

SDLImage.png

The SDL implementation of the Image based class, extends Image.

SubImageFont

SubImageFont.png

Imagefont that is able to read glyphs from single image sheet, see e.g.guichan imagefontcollection, extends ImageFontBase.

TextRendererPool

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.

TrueTypeFont

TrueTypeFont.png

SDL True Type Font implementation of Font, extends FontBase. It uses the SDL_ttf library to display True Type Fonts with SDL.

Links

Libraries

Object pooling