Jump to content

Graphics Overview

From OpenBOR
Revision as of 00:51, 29 November 2026 by Dcurrent (talk | contribs) (Remove redundant index statement.)

Introduction

OpenBOR uses hardware rendering to draw and composite sprites, background layers, text, primitive shapes, subscreens, movie images, and mesh-map artwork. The GPU renders these graphics into a full-color logical screen, applies the selected output effects, and presents the result on the display.

Creators supply artwork and control positions, drawing layers, palettes, and effects through native settings or scripts. The CPU handles gameplay, asset decoding, drawing commands, sorting, and geometry preparation. The GPU handles image sampling, palette lookup, pixel composition, blending, and rendered output. Desktop versions use OpenGL, while Android uses OpenGL ES 3.0 or newer.

Main scenes and script-created screens use RGB32 color. Indexed source artwork remains useful for palette selection and remapping, and the GPU resolves those indices into the full-color scene.

The module's logical resolution determines its drawing area. Window size, fullscreen fitting, and display filters determine how that finished composition appears on the physical display. See Resolution and Resampling and Display Filters.

Source Graphics

Image requirements depend on the resource being loaded. Ordinary sprites use non-interlaced, 8-bit indexed PNG images. Primary backgrounds and mesh artwork also have true-color image paths. Separate companion images can supply opacity or drawing-depth data.

Graphic type Source format Use
Character and entity sprites Non-interlaced, 8-bit indexed PNG Animation frames, model palettes, remaps, and sprite effects.
Icons, fonts, and interface sprites Non-interlaced, 8-bit indexed PNG Sprite-based interface elements and text glyphs.
Ordinary stage layers and panels Non-interlaced, 8-bit indexed PNG Layer artwork loaded through the regular sprite or indexed-screen path.
Primary background image Indexed PNG or true-color RGB PNG The main background image. Indexed backgrounds can also establish the global palette.
Mesh-map artwork 8-bit indexed or 24-bit RGB PNG Texture applied to a mesh surface through its dedicated artwork loader. See Mesh Map.
Alpha mask Non-interlaced, 8-bit grayscale or indexed PNG Per-pixel opacity data supplied separately from sprite artwork.
Drawing-depth mask Single-channel, 16-bit grayscale PNG Per-pixel drawing-Z adjustments for sprites, screens, or mesh artwork.
Animated cutscene image Animated GIF Animated image playback through the cutscene and GIF systems.
Movie WebM containing VP8 video and optional Vorbis audio Movie playback into a screen or directly to the display. See Movie Player.

Save ordinary indexed artwork with an actual 8-bit PNG sample depth. Images containing only a few colors can still be saved by an editor as a 1-, 2-, or 4-bit indexed PNG, which does not meet the regular sprite loader's format requirement.

The sprite loader trims transparent borders and records the resulting offsets to preserve alignment. Keep matching alpha and depth companions aligned to the original source canvas. Previously loaded artwork can be reused, including shared image data drawn with different offsets or palettes.

Indexed Sprites and Palettes

Indexed sprites store color indices, while palettes assign an RGB color to each index. The GPU uses the selected palette when drawing the image. Changing a color set can therefore reuse the same sprite artwork instead of requiring another image for every character or costume variation.

Models can have their own palettes and alternate color sets. Frames can also retain their own palettes where the model configuration permits it. Palette selection, remapping, tinting, and channel controls remain available within hardware rendering.

Palette index zero supplies ordinary sprite cutout transparency. Separate alpha masks and drawmethod settings provide additional control over opacity and blending. The regular sprite path uses image indices and palette data; embedded PNG transparency metadata does not replace these controls.

True-Color Sprites

The standard animation-frame and loadsprite() paths use indexed source images. Full-color output is available through primary RGB backgrounds, RGB mesh artwork, subscreens, and compositions of multiple images.

For artwork assembled from indexed components, creators can combine aligned red, green, and blue channel images using drawmethod channel controls and blending. This is an optional composition technique for producing an RGB result from indexed sprite parts. The components use the same GPU drawing pipeline as other sprites.

See Drawmethod for palette selection, color channels, opacity, and blending controls.

Graphics Pipeline

The normal scene pipeline has five stages:

Stage Operation
Asset preparation Decode source files, preserve sprite alignment, and prepare reusable image and palette resources.
Drawing commands Native systems and scripts select images, geometry, positions, drawing layers, materials, and destination screens.
Ordering Sort queued entries by drawing layer and sort ID, retaining submission order for equal keys.
GPU composition Render into the logical screen or a subscreen with the selected transforms, sampling, colors, opacity, blending, and drawing depth.
Display presentation Apply the selected final-image effect, display scaling, and color adjustments before presenting the completed frame.

Asset Loading

OpenBOR decodes images into the source representation appropriate to the loader. Indexed sprites retain their indices and palette information; RGB images supply full-color pixels. GPU image and palette resources are cached for reuse.

Loading, decoding, and preparing an asset are separate from repeatedly drawing it. Normal scene rendering reuses the prepared resources. Palette changes can reuse an indexed image while changing the colors selected during drawing.

Drawing Queue

Native scene elements and ordinary script drawing submit commands to the sprite queue. Commands identify what to draw and how to draw it; they do not require creators to manage GPU textures or issue graphics-API calls.

Queued elements include:

  • Sprites and animation frames.
  • Background and foreground layers.
  • Text glyphs.
  • Dots, lines, and boxes.
  • Subscreens.
  • Textured mesh-map surfaces.

The queue holds up to 5,000 entries. Queued text normally contributes one entry per glyph. Entries submitted after the queue is full are not drawn. When a completed subscreen is submitted, that screen occupies one queue entry regardless of how many elements were composed into it.

Scripts can also draw directly into a subscreen. See Subscreens.

Layer Sorting

Each queued item has a drawing layer, represented by its drawing-Z value. Under ordinary layer ordering, lower values are drawn first and higher values appear in front. Drawing depth is independent of the screen position where an image appears.

OpenBOR sorts by drawing Z, then by the item's sort ID. Entries with equal values for both retain their submission order. Use explicit drawing layers to establish intentional foreground, background, and interface relationships.

Depth companions can adjust this priority for individual pixels. The original drawing layer remains the baseline, and the companion supplies the pixel's adjustment. See Drawing Depth.

GPU Composition

The GPU draws the ordered graphics into an RGB32 target. Main scenes and subscreens use the same rendering system. Shader operations perform palette lookup, image reconstruction, color effects, transparency, blending, and depth comparison where configured.

Transforms control the shape and placement submitted for drawing. Some effects use CPU-prepared geometry or sampling information, while the GPU renders the resulting pixels. Mesh artwork, curved images, sprites, and screens can use the shared material and sampling controls appropriate to their drawing paths.

The rendered scene normally remains in GPU storage for further composition and presentation. Drawing one subscreen into another, copying a screen, or reusing a captured composition can therefore remain within the GPU renderer. Explicit pixel reads and other operations that need a CPU-visible image synchronize the relevant screen when required.

Final Presentation

After scene composition, the selected Final Filter can process the completed image. The display stage then fits that result to the window or device display, applies its scaling filter and color adjustments, and presents the frame.

These operations use the GPU. SDL provides platform, window, and graphics-context integration; it is not a separate software scene compositor selected from the video menu.

Display presentation preserves the module's logical drawing coordinates. Enlarging the window changes the displayed size of the finished image. Changing the logical resolution changes the drawing area available to the game.

Draw Effects

Drawmethod is the shared collection of properties used to modify an image while drawing it. Entities, animation frames, stage layers, scripted sprites, screens, and mesh artwork expose the properties relevant to their drawing paths.

Effect group Capabilities
Palette and color set Select or replace the palette used to resolve indexed artwork.
Opacity and blending Control transparency and use blend modes such as alpha, negative alpha, overlay, hard light, dodge, and average blending.
Tint and channels Tint an image, adjust individual red, green, and blue channels, or fill covered pixels with a selected color.
Chroma and Substitute Select colors for chroma coverage rules or replace matching final-output colors.
Placement and orientation Flip, scale, rotate, shear, or position an image with an affine transform.
Clipping and repetition Restrict destination coverage or repeat supported images with configurable spacing.
Water and plane effects Apply wave displacement and perspective-plane transformations.
Curved surfaces Bend an image into a configurable curve with tilt, perspective, and texture scrolling.
Resampling Choose how source pixels are reconstructed after scaling or transformation.
Drawing depth Adjust per-pixel drawing priority with a depth companion and an optional range override.

The GPU performs the rendered pixel operations selected by these controls. Geometry modes have their own combination rules, so select the intended transform path and combine its supported material effects. See Drawmethod for commands, properties, defaults, and examples.

Alpha Masks

Alpha masks provide per-pixel control over an image's contribution to the destination. The GPU samples the mask with the artwork and uses it during composition. Masked sprites can therefore contain fully visible, partially blended, and transparent regions within one image.

Masks are useful for soft edges, dissolves, selective highlights, reflections, lighting effects, and localized reveals. Combine them with drawmethods and subscreens to build the desired appearance.

The alpha mask is separate from the sprite's palette and from its drawing-depth companion. See Drawmethod for the mask format, interpretation, and assignment rules.

Drawing Depth

Drawing-depth companions let different portions of one sprite, screen, or mesh texture appear in front of or behind other drawing. For example, a wall image can contain a far portion that actors cover and a near portion that covers those actors.

Each sample in the 16-bit grayscale companion supplies an adjustment to the draw's existing Z. The GPU compares the resulting per-pixel values within the applicable depth pass; greater drawing Z takes priority. The default mapping treats sample 32768 as zero adjustment, with lower samples supplying negative adjustments and higher samples supplying positive adjustments. Drawmethod can override the adjustment range.

Ordinary queued drawing uses depth composition automatically when a companion is present. Immediate composition into a subscreen can use an explicit depth pass. Opaque and fully covered cutout pixels test and write depth; partially covered or blended pixels retain ordered composition while testing against depth.

Depth companions control drawing priority. Mesh geometry controls physical terrain and collision. See Drawmethod for drawing-depth authoring and Mesh Map for mesh geometry, textures, and their depth companions.

Subscreens

Subscreens are script-owned RGB32 drawing surfaces. Creators can assemble sprites, text, primitives, captured queue layers, movies, and mesh artwork into a screen, then draw that screen as one image in another screen or the main scene.

Normal subscreen composition and reuse are GPU operations. Screens support drawing effects, filtering, and transformations, making them useful for custom interfaces, picture-in-picture views, split-screen layouts, mirrors, cached compositions, and localized effects.

Reuse a screen while its dimensions and purpose remain appropriate. Drawing a composed screen avoids rebuilding its contents when those contents have not changed. Reading its rendered pixels for script inspection can require synchronization with CPU-visible storage, so perform those reads when the values are actually needed.

See Subscreens for allocation, immediate drawing, queue capture, composition, ownership, and examples.

Movies and Animated Images

OpenBOR supports animated GIF playback and a WebM movie system. GIF decoding produces indexed image data that the GPU resolves through palettes and composes into a retained screen. WebM movies use VP8 video with optional Vorbis audio; the GPU performs video color conversion, resampling, and composition after decoding.

Movies can be drawn into an RGB32 screen and participate in a composed scene, or use direct display presentation. Movies composed into the game scene receive that scene's final-image effect. Direct movie presentation has its own display path. See Movie Player for loading, playback control, drawing destinations, and supported formats.

Resolution

Logical resolution and display resolution serve different purposes. Choose the logical resolution for the game's artwork, camera, and interface, then use display settings to fit the result to the player's screen.

Logical Resolution

The video setting in data/video.txt selects the width and height of the main logical screen. The following presets are available:

Mode Logical resolution
0 320 × 240
1 480 × 272
2 640 × 480
3 720 × 480
4 800 × 480
5 800 × 600
6 960 × 540

For the 960 × 540 preset:

video 6

Custom dimensions use a width and height separated by a lowercase x:

video 1280x720

Presets are convenient size selections. Custom dimensions support other landscape, portrait, or pixel-art layouts. Requested screen widths are preserved, including odd widths. Main screens and subscreens use RGB32; the colourdepth setting does not select a different scene format.

When present on Windows or Linux, data/videopc.txt takes precedence over data/video.txt.

Display Resolution

Window and device display settings determine how the finished logical image is presented. Desktop Window Scale ranges from 0.25× through 8× in quarter steps. Android provides Automatic fitting or a centered Display Scale. Fullscreen and automatic fitting can preserve the image's aspect ratio or stretch it to the available display area.

Preserving aspect ratio can leave unused borders where the logical and physical displays have different shapes. Stretching fills the selected display area and changes the image's proportions.

For example, a 320 × 240 scene at 4× window scale occupies 1280 × 960 display pixels while retaining its 320 × 240 logical drawing area. The final-image filter can change the appearance of that output without changing the scene coordinates or requesting another increase in window size.

Resampling and Display Filters

OpenBOR provides three separate controls for image reconstruction and filtering. Each operates at a different stage:

Control What it affects Choices
Drawmethod resampling Individual images while they are drawn into a scene or subscreen. Nearest by default; Bilinear; cubic Catmull-Rom, Mitchell, and B-spline; Lanczos 2 and 3.
Final Filter The completed game scene before display scaling. Disabled, Bilinear, Advance Mame2x, Scanlines, Scanlines TV, TV 2x, or Dot Matrix.
Scaling Filter Sampling while fitting the completed image to the display. Nearest, Bilinear, or High Quality.

Drawmethod resampling gives creators control over particular objects. Nearest preserves hard source-pixel boundaries. Other modes reconstruct the image from neighboring samples and can suit scaled, rotated, curved, or perspective artwork. The choice belongs to that drawing operation; display settings do not replace it.

Final Filter applies an appearance to the whole scene. Enabled final effects produce a GPU image at twice the logical width and height, then that result is fitted to the selected display size. On desktop, a selected final effect is active in fullscreen or when the window scale is at least 2×. Below that window scale, the selection remains stored but inactive. Android applies the selected effect through its scene presenter.

Scaling Filter controls the final fit. Nearest retains hard pixel edges, Bilinear interpolates adjacent pixels, and High Quality uses sharp-bilinear sampling to retain sharper pixel interiors while smoothing transitions during display scaling.

The Bilinear choices in Final Filter and Scaling Filter are separate controls. Final Filter selects a completed-scene effect; Scaling Filter selects display sampling. Neither changes the logical resolution. See Drawmethod for per-object resampling.

Performance Considerations

Hardware rendering makes transforms, palette effects, filtering, and subscreen composition part of the normal drawing pipeline. Useful authoring decisions still include resource reuse, the amount of image coverage, and how often scripts need to inspect rendered pixels.

  • Reuse loaded sprites and palettes when the artwork is unchanged. Use palette variation for color changes that do not require different shapes.
  • Retain and reuse subscreens. Rebuild cached compositions when their contents change.
  • Size temporary screens for the composition they need to hold.
  • Choose object resampling for the artwork and its transformation, independently of the final scene effect and display scaling.
  • Use GPU drawing operations to assemble effects and inspect screen pixels when the script needs their values.
  • Account for queued text glyphs and other entries when building a complex interface. Subscreens can hold reusable interface compositions.
  • Establish ordinary ordering through drawing layers; use depth companions for artwork that needs local changes in drawing priority.
  • Evaluate large areas of layered blending, repeated full-screen effects, and detailed filtering as part of the complete scene.

Display scaling changes the size and sampling of the completed image. Choose source artwork and logical resolution for the intended visual detail, then select display settings for its presentation.

See Also