Jump to content

Graphics Overview: Difference between revisions

From OpenBOR
Document RGB/RGBA sprites, native PNG transparency, and automatic trimming.
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
OpenBOR uses a software-composited graphics system designed primarily for sprite-based games. Images, background layers, entities, text, primitive shapes, and scripted subscreens are collected into a drawing queue, ordered by layer, rendered into a 32-bit logical screen, and finally presented by the platform video backend.
== Introduction ==


This arrangement separates game graphics from the physical display. Creators define the logical resolution and visual composition of a project, while OpenBOR handles window sizing, fullscreen scaling, aspect ratio, filtering, and final presentation.
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.


The basic pipeline is:<pre>
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.
Source images and generated graphics
 
                |
Main scenes and script-created screens use RGB32 color. Sprite artwork can use indexed palettes or RGB/RGBA color. Indexed artwork supports palette selection and remapping, while true-color sprites retain their stored colors and PNG transparency. The GPU composes both into the full-color scene.
                v
 
      Load, trim, and cache assets
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|Resolution]] and [[#Resampling and Display Filters|Resampling and Display Filters]].
                |
                v
      Build the sprite drawing queue
                |
                v
        Sort by layer and sort ID
                |
                v
Compose into the 32-bit logical screen
                |
                v
Optional software scaling or filtering
                |
                v
Present through SDL or OpenGL backend
</pre>


== Source Graphics ==
== Source Graphics ==
Regular OpenBOR graphics use PNG images. Character frames and most other sprites normally use non-interlaced indexed PNG files. Indexed images allow palette replacement and efficient storage while the finished display is rendered in full color.


True-color PNG images are also supported for backgrounds and background layers.
Sprite artwork accepts 8-bit indexed, 24-bit RGB, and 32-bit RGBA PNG images. OpenBOR reads transparency directly from RGB and RGBA sprite files. Fonts, backgrounds, screen-based layers, and mesh artwork use the source formats listed below. Separate companion images can provide additional opacity control or drawing-depth data.
 
{| class="wikitable"
{| class="wikitable"
!Graphic type
!Graphic type
!Recommended format
!Source format
!Notes
!Use
|-
|-
|Character and entity sprites
|Character and entity sprites
|Indexed PNG
|8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG
|Supports palettes, remaps, and automatic transparent-border trimming.
|Animation frames and sprite effects. Indexed frames support model palettes and remaps.
|-
|Icons and interface sprites
|8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG
|Sprite-based interface elements, player arrows, and other sprite artwork.
|-
|Fonts
|Non-interlaced, 8-bit indexed PNG
|Text glyphs and font palettes.
|-
|Sprite-based stage layers and panels
|8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG
|Layer artwork loaded as sprites, with native PNG transparency and sprite drawing effects.
|-
|Screen-based stage layers
|Non-interlaced, 8-bit indexed PNG
|Layer artwork loaded through the 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 geometry
|Single-channel, 16-bit grayscale PNG
|Defines mesh vertices, displacement along the selected X, Y, or Z axis, and holes. Supplies terrain geometry for collision and optional surface rendering. See [[Mesh Map]].
|-
|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]].
|-
|-
|Icons, fonts, and interface sprites
|Alpha mask
|Indexed PNG
|Non-interlaced, 8-bit grayscale or indexed PNG
|Drawn through the same sprite system as other graphic elements.
|Optional per-pixel opacity data supplied separately from sprite artwork.
|-
|-
|Backgrounds and stage layers
|Drawing-depth mask
|Indexed or true-color PNG
|Single-channel, 16-bit grayscale PNG
|Indexed backgrounds may provide the module palette. True-color backgrounds are loaded through the 32-bit image path.
|Per-pixel drawing-Z adjustments for sprites, screens, or mesh artwork.
|-
|-
|Animated cutscenes
|Animated cutscene image
|Animated GIF
|Animated GIF
|Played through the cutscene system. GIF is not a general-purpose sprite format.
|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]].
|}
|}
Transparent borders surrounding a sprite are trimmed when the image is loaded. OpenBOR preserves the original alignment by recording the trimmed offset, so creators do not normally need to crop every frame manually.


Previously loaded sprites are cached and may share encoded image data when the same source image is used with different offsets.
Save indexed artwork as non-interlaced PNG with an actual 8-bit 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. RGB and RGBA sprites use eight bits per channel and support both non-interlaced and Adam7-interlaced PNG files.
 
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 indexed-sprite cutout transparency. Separate alpha masks and drawmethod settings provide additional control over opacity and blending. Indexed sprites follow this palette-index convention; embedded PNG palette-transparency metadata does not replace it.


=== True-Color Sprites ===
=== True-Color Sprites ===
OpenBOR is intentionally designed to render individual sprites using indexed color. This compact representation is one reason its software-driven graphics pipeline can withstand immense sprite loads without frame-rate loss. Indexed sprites also provide efficient palette replacement, remapping, tinting, and color-channel manipulation.


When RGB color is required, OpenBOR can produce a true-color image by compositing a meta-sprite from three indexed sprites:
OpenBOR loads 24-bit RGB and 32-bit RGBA PNG sprites directly, preserving their source colors. Use the normal image filename in animation frames, icons, player arrows, hole sprites, sprite layers, or script <code>loadsprite()</code> calls. The loader selects the source format automatically.
 
Models can mix indexed and true-color frames. Palette selection and remapping apply to indexed frames, while RGB and RGBA frames use their stored colors. Fill, tint, blending, chroma, Substitute, transforms, and resampling are available through the shared drawing system. See [[Drawmethod]] for drawing controls.
 
==== PNG Transparency ====
 
Save the sprite with transparency in the PNG and load it normally. OpenBOR uses the file's transparency automatically.
 
{| class="wikitable"
!PNG artwork
!Transparency
|-
|RGB without transparency metadata
|Every source pixel is opaque, including black.
|-
|RGB with a transparent-color entry (<code>tRNS</code>)
|The color designated in the file is transparent; other colors are opaque.
|-
|RGBA
|Each pixel's alpha controls its opacity. Zero is fully transparent, 255 is fully opaque, and intermediate values preserve partial transparency.
|}
 
PNG alpha controls the sprite's coverage while color effects and transforms are applied. Soft edges, translucent details, shadows, and reflections retain that coverage. Drawmethod chroma keys and separate opacity masks remain available for additional control.
 
=== Automatic Sprite Trimming ===


* Red channel.
OpenBOR removes fully transparent outer rows and columns before storing a sprite. Indexed sprites use their transparent index for trimming; RGB and RGBA sprites use the transparency saved in the PNG. Every pixel with nonzero alpha is retained, including alpha 1, so faint details and soft edges remain within the stored rectangle. Fully transparent artwork loads as an empty sprite.
* Green channel.
* Blue channel.


Each component is drawn at the same position using the corresponding channel drawmethod. OpenBOR composites the red, green, and blue components into the final true-color image during normal rendering.  
The engine retains the original canvas dimensions and crop offsets to preserve authored positioning. Keep optional opacity and drawing-depth companions aligned to the original image dimensions. The opacity mask follows the sprite's crop, while depth samples retain their original canvas coordinates.


'''Note:''' OpenBOR's software renderer is an artifact of an earlier console portability policy that has since been discontinued. Hardware-accelerated rendering and direct RGBA sprite support are currently in development.
Filtered and transformed drawing treats the removed space as transparent. Trimming therefore preserves the same outline and edge appearance as the original image.


== Graphics Pipeline ==
== Graphics Pipeline ==
The normal scene pipeline has five stages:
{| class="wikitable"
!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 ===
=== Asset Loading ===
OpenBOR decodes source images and converts them into an internal bitmap, sprite, or screen representation.


Sprites are trimmed and encoded for repeated drawing. Background images remain screen-like rectangular buffers. Indexed graphics retain palette information needed for palette replacement and other color effects.
OpenBOR decodes images into the source representation appropriate to the loader. Indexed sprites retain their indices and palette information; RGB and RGBA sprites retain their colors and native PNG transparency. Transparent sprite borders are trimmed while the original alignment is preserved. 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 ===
=== Drawing Queue ===
Game objects do not normally draw themselves directly to the physical display. Instead, OpenBOR submits drawing entries to the sprite queue.


Queue entries may include:
'''Unlimited drawing queue''' - Sprites, primitives, text, subscreens, and mesh surfaces share a dynamically expanding drawing queue with no artificial capacity limit. Queue management is entirely automatic and requires no configuration by creators.
 
Native engine systems and scripts submit drawing commands to the queue. Each command describes the graphic, its placement, drawing priority, and applicable effects. Queued elements include:


* Sprites and animation frames.
* Sprites and animation frames.
* Background layers.
* Background and foreground layers.
* Text glyphs.
* Graphic primitives (dots, lines, and boxes).
* Subscreens.
* Subscreens.
* Text glyphs.
* Textured mesh-map surfaces.
* Dots.
 
* Lines.
==== Automatic Expansion ====
* Boxes.
 
OpenBOR allocates an initial queue capacity of 256 entries during startup and expands it in blocks of 256 as needed. Existing drawing commands remain intact during expansion.
 
{| class="wikitable"
! Required entries
! Allocated capacity
|-
| 0–256
| 256
|-
| 257–512
| 512
|-
| 513–768
| 768
|-
| 769–1,024
| 1,024
|-
| 1,025–1,280
| 1,280
|-
| ...
| ...
|}
 
Allocated capacity is retained throughout the engine session. This provides a small initial memory footprint while allowing complex scenes to expand the queue according to demand. Subsequent frames and levels reuse the allocated storage without additional allocation overhead.
 
==== Sorting and Playback ====
 
Sorting and rendering operate exclusively on occupied entries, independent of allocated capacity.
 
OpenBOR uses a hybrid stable sorting algorithm. The engine first checks for an already ordered queue, then employs insertion sort for small queues or bottom-up merge sort for larger queues, providing O(n log n) worst-case sorting complexity.
 
Entries are sorted by drawing layer and then sort ID, preserving submission order where both values are equal. Sorting rearranges pointers rather than moving the drawing command records themselves. Sorting workspaces expand alongside the queue and retain their allocated capacity for reuse.
 
==== Entry Composition ====
 
Each submitted drawing command occupies one queue entry. Text normally contributes one entry per glyph.
 
Subscreens allow creators to compose multiple graphics into a single reusable image. Submitting a completed subscreen occupies one queue entry, regardless of the complexity of its contents.
 
Scripts can also draw directly into a subscreen. See [[Subscreens]] for immediate drawing, composition, and reuse.
 
==== Monitoring ====
 
The engine's debug display reports queue occupancy and allocated capacity:
 
<syntaxhighlight lang="text">
Queue: 724 / 1024 slots
</syntaxhighlight>
 
* '''724:''' Current number of occupied queue entries.
* '''1024:''' Currently allocated queue capacity.


The queue supports up to 5000 entries. Text is also composed from sprites, so every displayed character contributes to the queue total. Entries submitted after the limit is reached are not drawn.
The allocated capacity represents peak demand during the engine session, rounded upward to the nearest allocation block.


=== Layer Sorting ===
=== Layer Sorting ===
Each queued item has a drawing layer, internally represented by its queue Z value. Items with lower values are drawn first, while items with higher values are drawn later and therefore appear in front.


When two items have the same layer, OpenBOR uses a secondary sort ID to determine their order.<pre>
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.
Lower layer
    |
    | Background scenery
    | Stage objects
    | Entities and effects
    | HUD and interface
    v
Higher layer
</pre>This provides object-level Z ordering suitable for a game world with foreground and background depth.  


'''Tip:''' Use explicit layer adjustments for effects that must reliably appear in front of or behind another object. Submission order alone should not be treated as a substitute for layer control.
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.


=== Software Composition ===
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|Drawing Depth]].
Once sorted, the queue is rendered into OpenBOR's logical screen. The main logical screen is a 32-bit software buffer with the width and height selected by the module.


Draw effects, palette conversion, blending, transformations, clipping, and subscreen composition occur during this stage.
=== 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 ===
=== Final Presentation ===
After composition, OpenBOR passes the finished logical screen to the platform video backend. The backend may perform color conversion, software filtering, texture upload, display scaling, brightness adjustment, and final presentation.


SDL and OpenGL are presentation backends. Core sprite composition remains software based.
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.


This distinction is important:
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.


* Increasing the '''logical resolution''' provides more space and potential detail to the game.
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.
* Increasing the '''window or output size''' enlarges the finished image without changing the game's logical coordinate system.
* Display filtering changes how the enlarged image appears but does not add new source detail.


== Draw Effects ==
== Draw Effects ==
Drawmethod is the common collection of properties OpenBOR uses to alter an item while drawing it. Entities, animation frames, stage layers, scripted sprites, and subscreens can expose some or all of these properties.
 
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.
 
{| class="wikitable"
{| class="wikitable"
!Effect group
!Effect group
Line 128: Line 246:
|-
|-
|Palette and color set
|Palette and color set
|Replace an indexed sprite's palette or select one of the model's available color sets.
|Select or replace the palette used to resolve indexed artwork.
|-
|-
|Blend
|Opacity and blending
|Apply transparency and supported blend modes, including alpha, negative alpha, overlay, hard light, dodge, and average blending.
|Control transparency and use blend modes such as alpha, negative alpha, overlay, hard light, dodge, and average blending.
|-
|-
|Tint and channels
|Tint and channels
|Tint an image, reduce individual red, green, or blue channels, or fill visible pixels with a specified color.
|Tint an image, adjust individual red, green, and blue channels, or fill covered pixels with a selected color.
|-
|-
|Orientation
|Chroma and Substitute
|Flip an image horizontally or vertically.
|Select colors for chroma coverage rules or replace matching final-output colors.
|-
|-
|Scale
|Placement and orientation
|Resize an image independently along its horizontal and vertical axes.
|Flip, scale, rotate, shear, or position an image with an affine transform.
|-
|-
|Rotation
|Clipping and repetition
|Rotate an image around its drawing center.
|Restrict destination coverage or repeat supported images with configurable spacing.
|-
|-
|Shift
|Water and plane effects
|Skew the image horizontally.
|Apply wave displacement and perspective-plane transformations.
|-
|-
|Clipping
|Curved surfaces
|Restrict drawing to a rectangular area.
|Bend an image into a configurable curve with tilt, perspective, and texture scrolling.
|-
|-
|Repetition
|Resampling
|Repeat supported layers or screens with configurable spacing.
|Choose how source pixels are reconstructed after scaling or transformation.
|-
|-
|Water and plane transformation
|Drawing depth
|Apply sine-wave distortion, shear, and perspective-like scaling effects.
|Adjust per-pixel drawing priority with a depth companion and an optional range override.
|}
|}
Drawmethod effects are evaluated by the software renderer. Transforming a large image or full-screen buffer is consequently more expensive than transforming a small sprite.


Not every drawing item supports every property in the same way. Some effects also select different drawing paths and may not combine meaningfully with every other effect.
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.


For property-level documentation and script access, see [[Drawmethod]].
=== Alpha Masks ===


=== Alpha Masks ===
Separate opacity 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. When used with RGB or RGBA sprite artwork, the mask provides additional control alongside the PNG's own transparency.
Alpha masks provide pixel-level control over blending. Instead of applying one transparency value uniformly across an entire sprite or screen, a mask determines the blending treatment of individual pixels.


This enables effects such as:
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.


* Soft or irregular transparency.
The alpha mask is separate from the sprite's palette, embedded PNG alpha, and drawing-depth companion. Keep it aligned to the artwork's original canvas. See [[Drawmethod]] for the mask format, interpretation, and assignment rules.
* Dissolves and materialization effects.
* Selective reflections and highlights.
* Layered lighting and shadow masks.
* Complex silhouettes and partial reveals.
* Localized blending across sprites, backgrounds, or subscreens.


Combined with drawmethods, color channels, and subscreen composition, alpha masks provide many effects ordinarily associated with a shader-driven graphics pipeline.
=== Drawing Depth ===


== Subscreens ==
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.
Subscreen are offscreen 32-bit drawing buffers allocated by script. Subscreens allow creators to assemble graphics separately and later insert the result into the main drawing queue.


Common uses include:
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.


* Picture-in-picture displays.
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. Fully transparent pixels leave both color and depth untouched.
* Mirrors, monitors, and video marquees.
* Animated title and menu compositions.
* Full-screen rotation or scaling.
* Localized color and distortion effects.
* Layer capture and recomposition.
* Custom HUD elements.
* Scripted cutscenes.
* Perspective and landscape effects.
* Temporary graphic caches.
* Other composite effects, including anaglyphs, mosaic transitions, “Predator”-style invisibility, multilayer masking, and more.


The basic script allocation function is:<pre>
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.
void buffer = allocscreen(width, height);
</pre>For example:<syntaxhighlight lang="c" line="1">
void buffer;


void main() {
== Subscreens ==


    if(buffer == NULL()) {
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.
        buffer = allocscreen(320, 120);
    }


    clearscreen(buffer);
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.
    drawstringtoscreen(buffer, 8, 8, 0, "Subscreen example");


    /*
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.
    * Add the completed subscreen to the main drawing queue.
    */
    drawscreen(buffer, 0, 0, 1000);
}
</syntaxhighlight>Scripts may draw sprites, text, dots, lines, and boxes directly into a subscreen. The drawspriteq() function can also render a selected range of the current sprite queue into a supplied screen.


Relevant functions include:
See [[Subscreens]] for allocation, immediate drawing, queue capture, composition, ownership, and examples.


* allocscreen() - Allocate a 32-bit subscreen.
== Movies and Animated Images ==
* clearscreen() - Clear a subscreen.
* drawspritetoscreen() - Draw a sprite directly into a subscreen.
* drawstringtoscreen() - Draw text directly into a subscreen.
* drawdottoscreen() - Draw a dot directly into a subscreen.
* drawlinetoscreen() - Draw a line directly into a subscreen.
* drawboxtoscreen() - Draw a box directly into a subscreen.
* drawspriteq() - Render queued items into a screen, optionally limited by layer range.
* drawscreen() - Add a completed subscreen to the main drawing queue.


Subscreens may contain other subscreens or be passed through the drawing queue again. This permits nested and recursive visual effects, though creators should use such arrangements carefully. Once composited, a subscreen is submitted to the main drawing queue as a single item. Its internal sprites, text, primitives, and nested effects do not consume additional main-queue entries during that final draw. In addition to their other capabilities, this makes subscreens useful for consolidating complex visual assemblies, though creating the composition still carries its normal rendering and memory costs.
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.


'''Tip:''' Allocate reusable subscreens once instead of allocating a new buffer during every update. Keep each buffer only as large as the effect requires. Each 32-bit screen consumes approximately width * height * 4 bytes before any additional allocation overhead.  
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 ==
== Resolution ==
OpenBOR distinguishes the module's logical resolution from the final display 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 ===
=== Logical Resolution ===
The video setting in data/video.txt selects the width and height of the logical screen.


OpenBOR provides the following compatibility presets:
The <code>video</code> setting in <code>data/video.txt</code> selects the width and height of the main logical screen. The following presets are available:
 
{| class="wikitable"
{| class="wikitable"
!Mode
!Mode
Line 263: Line 345:
|960 × 540
|960 × 540
|}
|}
Example:<pre>
 
For the 960 × 540 preset:
 
<syntaxhighlight lang="text">
video 6
video 6
</pre>Custom logical resolutions use a width and height separated by a lowercase x:<pre>
</syntaxhighlight>
 
Custom dimensions use a width and height separated by a lowercase <code>x</code>:
 
<syntaxhighlight lang="text">
video 1280x720
video 1280x720
</pre>Preset resolutions are compatibility conveniences rather than graphical capability tiers. Custom dimensions allow projects to target widescreen, portrait, low-resolution pixel art, or other layouts.
</syntaxhighlight>


'''Note:''' Use widths divisible by four. OpenBOR's screen allocator aligns screen widths downward to a multiple of four.
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 <code>colourdepth</code> setting does not select a different scene format.


No single practical maximum resolution applies to every platform. Available memory, CPU performance, display backend texture limits, optional filter requirements, and target hardware all affect the usable size. Extremely large logical resolutions should therefore be tested on every supported platform.
When present on Windows or Linux, <code>data/videopc.txt</code> takes precedence over <code>data/video.txt</code>.


=== Display Resolution ===
=== Display Resolution ===
Window and fullscreen settings determine how the logical screen is presented. OpenBOR can enlarge or reduce the finished frame independently of the module's internal coordinates.


Display options include:
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 ==


* Windowed or fullscreen output.
OpenBOR provides three separate controls for image reconstruction and filtering. Each operates at a different stage:
* Adjustable window scaling.
* Preserved aspect ratio or stretching to the available display.
* Nearest-neighbor or linear presentation scaling, depending on backend and selected settings.
* Optional 2× software filters, including simple scaling, bilinear filtering, AdvanceMAME, scanlines, television simulation, and dot-matrix effects.
* SDL or OpenGL presentation where supported.


Preserving aspect ratio may produce unused borders when the logical and physical displays have different shapes. Stretching fills the display but may distort the image.
{| class="wikitable"
!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.
|}


'''Tip:''' Select logical resolution according to the project's artwork, camera, interface, and target hardware. Use final display scaling to fit different monitors instead of rebuilding the game around every possible desktop resolution.
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 ==
== Performance Considerations ==
Graphics cost generally increases with the number of pixels processed, the number of queued items, and the complexity of effects applied to them.


For efficient rendering:
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.


* Choose a logical resolution appropriate for the artwork.
* Reuse loaded sprites and palettes when the artwork is unchanged. Use palette variation for color changes that do not require different shapes.
* Reuse subscreens rather than repeatedly allocating them.
* Retain and reuse subscreens. Rebuild cached compositions when their contents change.
* Keep temporary subscreens close to the required dimensions.
* Size temporary screens for the composition they need to hold.
* Avoid applying full-screen transformations when a smaller affected region is sufficient.
* Choose object resampling for the artwork and its transformation, independently of the final scene effect and display scaling.
* Remember that text consumes sprite queue entries.
* Use GPU drawing operations to assemble effects and inspect screen pixels when the script needs their values.
* Use explicit drawing layers instead of relying on incidental queue order.
* Account for queued text glyphs and other entries when building a complex interface. Subscreens can hold reusable interface compositions.
* Test blending, rotation, water effects, and multiple subscreens on lower-powered target devices.
* Establish ordinary ordering through drawing layers; use depth companions for artwork that needs local changes in drawing priority.
* Treat software filters and output scaling as presentation features rather than substitutes for suitable source artwork.
* 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 ==
== See Also ==


* [[Drawmethod]]
* [[Drawmethod]]
* [[Layer]]
* [[Subscreens]]
* [[Background]]
* [[Mesh Map]]
* [[Video]]
* [[Movie Player]]
* [[Script]]
* [[Script Overview]]
 
[[Category:Graphics]]
[[Category:Openbor]]

Latest revision as of 15:14, 29 November 2026

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. Sprite artwork can use indexed palettes or RGB/RGBA color. Indexed artwork supports palette selection and remapping, while true-color sprites retain their stored colors and PNG transparency. The GPU composes both 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

Sprite artwork accepts 8-bit indexed, 24-bit RGB, and 32-bit RGBA PNG images. OpenBOR reads transparency directly from RGB and RGBA sprite files. Fonts, backgrounds, screen-based layers, and mesh artwork use the source formats listed below. Separate companion images can provide additional opacity control or drawing-depth data.

Graphic type Source format Use
Character and entity sprites 8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG Animation frames and sprite effects. Indexed frames support model palettes and remaps.
Icons and interface sprites 8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG Sprite-based interface elements, player arrows, and other sprite artwork.
Fonts Non-interlaced, 8-bit indexed PNG Text glyphs and font palettes.
Sprite-based stage layers and panels 8-bit indexed, 24-bit RGB, or 32-bit RGBA PNG Layer artwork loaded as sprites, with native PNG transparency and sprite drawing effects.
Screen-based stage layers Non-interlaced, 8-bit indexed PNG Layer artwork loaded through the 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 geometry Single-channel, 16-bit grayscale PNG Defines mesh vertices, displacement along the selected X, Y, or Z axis, and holes. Supplies terrain geometry for collision and optional surface rendering. See Mesh Map.
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 Optional 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 indexed artwork as non-interlaced PNG with an actual 8-bit 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. RGB and RGBA sprites use eight bits per channel and support both non-interlaced and Adam7-interlaced PNG files.

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 indexed-sprite cutout transparency. Separate alpha masks and drawmethod settings provide additional control over opacity and blending. Indexed sprites follow this palette-index convention; embedded PNG palette-transparency metadata does not replace it.

True-Color Sprites

OpenBOR loads 24-bit RGB and 32-bit RGBA PNG sprites directly, preserving their source colors. Use the normal image filename in animation frames, icons, player arrows, hole sprites, sprite layers, or script loadsprite() calls. The loader selects the source format automatically.

Models can mix indexed and true-color frames. Palette selection and remapping apply to indexed frames, while RGB and RGBA frames use their stored colors. Fill, tint, blending, chroma, Substitute, transforms, and resampling are available through the shared drawing system. See Drawmethod for drawing controls.

PNG Transparency

Save the sprite with transparency in the PNG and load it normally. OpenBOR uses the file's transparency automatically.

PNG artwork Transparency
RGB without transparency metadata Every source pixel is opaque, including black.
RGB with a transparent-color entry (tRNS) The color designated in the file is transparent; other colors are opaque.
RGBA Each pixel's alpha controls its opacity. Zero is fully transparent, 255 is fully opaque, and intermediate values preserve partial transparency.

PNG alpha controls the sprite's coverage while color effects and transforms are applied. Soft edges, translucent details, shadows, and reflections retain that coverage. Drawmethod chroma keys and separate opacity masks remain available for additional control.

Automatic Sprite Trimming

OpenBOR removes fully transparent outer rows and columns before storing a sprite. Indexed sprites use their transparent index for trimming; RGB and RGBA sprites use the transparency saved in the PNG. Every pixel with nonzero alpha is retained, including alpha 1, so faint details and soft edges remain within the stored rectangle. Fully transparent artwork loads as an empty sprite.

The engine retains the original canvas dimensions and crop offsets to preserve authored positioning. Keep optional opacity and drawing-depth companions aligned to the original image dimensions. The opacity mask follows the sprite's crop, while depth samples retain their original canvas coordinates.

Filtered and transformed drawing treats the removed space as transparent. Trimming therefore preserves the same outline and edge appearance as the original image.

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 and RGBA sprites retain their colors and native PNG transparency. Transparent sprite borders are trimmed while the original alignment is preserved. 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

Unlimited drawing queue - Sprites, primitives, text, subscreens, and mesh surfaces share a dynamically expanding drawing queue with no artificial capacity limit. Queue management is entirely automatic and requires no configuration by creators.

Native engine systems and scripts submit drawing commands to the queue. Each command describes the graphic, its placement, drawing priority, and applicable effects. Queued elements include:

  • Sprites and animation frames.
  • Background and foreground layers.
  • Text glyphs.
  • Graphic primitives (dots, lines, and boxes).
  • Subscreens.
  • Textured mesh-map surfaces.

Automatic Expansion

OpenBOR allocates an initial queue capacity of 256 entries during startup and expands it in blocks of 256 as needed. Existing drawing commands remain intact during expansion.

Required entries Allocated capacity
0–256 256
257–512 512
513–768 768
769–1,024 1,024
1,025–1,280 1,280
... ...

Allocated capacity is retained throughout the engine session. This provides a small initial memory footprint while allowing complex scenes to expand the queue according to demand. Subsequent frames and levels reuse the allocated storage without additional allocation overhead.

Sorting and Playback

Sorting and rendering operate exclusively on occupied entries, independent of allocated capacity.

OpenBOR uses a hybrid stable sorting algorithm. The engine first checks for an already ordered queue, then employs insertion sort for small queues or bottom-up merge sort for larger queues, providing O(n log n) worst-case sorting complexity.

Entries are sorted by drawing layer and then sort ID, preserving submission order where both values are equal. Sorting rearranges pointers rather than moving the drawing command records themselves. Sorting workspaces expand alongside the queue and retain their allocated capacity for reuse.

Entry Composition

Each submitted drawing command occupies one queue entry. Text normally contributes one entry per glyph.

Subscreens allow creators to compose multiple graphics into a single reusable image. Submitting a completed subscreen occupies one queue entry, regardless of the complexity of its contents.

Scripts can also draw directly into a subscreen. See Subscreens for immediate drawing, composition, and reuse.

Monitoring

The engine's debug display reports queue occupancy and allocated capacity:

Queue: 724 / 1024 slots
  • 724: Current number of occupied queue entries.
  • 1024: Currently allocated queue capacity.

The allocated capacity represents peak demand during the engine session, rounded upward to the nearest allocation block.

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

Separate opacity 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. When used with RGB or RGBA sprite artwork, the mask provides additional control alongside the PNG's own transparency.

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, embedded PNG alpha, and drawing-depth companion. Keep it aligned to the artwork's original canvas. 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. Fully transparent pixels leave both color and depth untouched.

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