Video Engine
From Hero of Allacrost
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.
Contents |
Video Engine Feature List
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
Introduction
| Directory |
|
| Files |
|
| Include Header |
|
| Namespace |
|
| Classes Defined |
|
| Libraries Used |
Coordinate Systems
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.
Transformations
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
The video engine uses the following flags to control drawing:
VIDEO_X_LEFT // x alignment VIDEO_X_CENTER VIDEO_X_RIGHT VIDEO_Y_TOP // y alignment VIDEO_Y_CENTER VIDEO_Y_BOTTOM VIDEO_X_FLIP // x flip VIDEO_X_NOFLIP VIDEO_Y_FLIP // y flip VIDEO_Y_NOFLIP VIDEO_NO_BLEND // blend mode VIDEO_BLEND VIDEO_BLEND_ADD
To set the current draw flags, call SetDrawFlags() with all the flags you want to change, and a zero at the end, e.g:
VideoManager->SetDrawFlag(VIDEO_X_CENTER, VIDEO_Y_TOP, VIDEO_BLEND, 0);
Alignment flags
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:
Flip flags
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
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:


