Video Engine

From Hero of Allacrost Wiki
Revision as of 15:54, 28 November 2017 by Roots (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This document explains how to use the wide array of features in the Allacrost Video Engine. The video engine is the largest and most complex component of the Allacrost engine, and thus this documentation is equally as long. The documentation for different areas of the video engine are provided on separate wiki pages for organization. This page contains an introduction to the basic workings of the video engine and links to the other documentation pages found below. The reader is strongly advised to read this documentation in the order that it is specified.

Video Engine Images

Video Engine Text

Video Engine GUI

Video Engine Visual Effects

Video Engine Feature List[edit]

The list below summarizes the major features available in the Allacrost video engine

  • Core features
    • Drawing images
    • Rotating, scaling, flipping
    • Compound images (e.g. TilesToObject())
    • Animations
    • Blend masks / autotiles (transition tiles)
  • GUI
    • Unicode text
    • Menu windows
    • Text boxes
    • Option boxes
  • Visual effects
    • Particles (snow, rain, sandstorms, etc.)
    • Full-screen overlays
    • Lightning
    • Image warping (e.g. Desert background in FF6 right out of Narsche)
    • Lighting
    • Hardware accelerated fog
    • Animated fog
    • Screen shaking
  • Miscellaneous
    • Screenshots
    • FPS display
    • Screen fading


Video Engine Summary
  • src/engine/video/
  • video.h
  • video.cpp
Include Header
  • #include "video.h"
  • hoa_video
Classes Defined
  • GameVideo (singleton name: VideoManager)
  • ImageDescriptor
  • StillImage
  • AnimatedImage
  • RenderedText
Libraries Used

Coordinate Systems[edit]

The coordinate system defines the units in terms of the left, right, bottom, and top edges of the screen. All of the art in the game is designed for a screen resolution of 1024x768, so the default coordinate system in Allacrost is the following.

VideoManager->SetCoordSys(0.0f, 1024.0f, 0.0f, 768.0f);

This may be overridden as in the case of map drawing where 1 unit corresponds to 1 32x32 tile.


To tell the position where an image should be drawn:

VideoManager->Move(100.0f, 60.0f); // move draw position to (100, 60)

You can also do “relative” movements:

VideoManager->MoveRelative(0.0f, 10.0f); // move draw position 10 units up, to (100, 70)

Draw flags[edit]

The video engine uses the following flags to control drawing:

VIDEO_X_LEFT   // x alignment
VIDEO_Y_TOP    // y alignment
VIDEO_X_FLIP   // x flip
VIDEO_Y_FLIP   // y flip
VIDEO_NO_BLEND // blend mode

To set the current draw flags, call SetDrawFlags() with all the flags you want to change, and a zero at the end, e.g:


Alignment flags[edit]

The alignment flags (VIDEO_X_LEFT, etc) tell the video engine which part of the image will be anchored to the current draw position. So, if you call Move(512, 384), and then use VIDEO_X_CENTER and VIDEO_Y_CENTER, then you'll get an image centered at the middle of the screen (assuming your coordinate system is 1024x768).

This is one of the most confusing parts of the video engine, so here is an image with some examples. The draw cursor (set by the Move() calls) is shown in red:

Video engine alignment.png

Flip flags[edit]

The flip flags are very simple. If you want to flip an image horizontally or vertically, use VIDEO_X_FLIP, VIDEO_Y_FLIP, or both at the same time.

Blend flags[edit]

Alpha blending is when you somehow combine the color you're drawing with the color that's already on the screen. The 2 kinds of blending available to you in the video engine are Blending (VIDEO_BLEND), and Additive Blending (VIDEO_BLEND_ADD). You can also turn off blending with VIDEO_NO_BLEND. Blending is like looking through a piece of colored glass, and is used in games for transparent objects. It does kind of a "cross-fade" between two images. For example, the menus in our game can use blending so that they are "see-through". Additive blending is for visuals such as fire, explosions, or halos. If you use a lot of additive blending, you end up with "saturation" and the resulting color is just white.

Here are some images that show the difference between the blending modes:

Video engine blending.jpg