Blitter

From OpenTTD
Jump to: navigation, search


The blitter's primary task is to draw sprites onto the screen. It has to handle colour remapping and transparency effects. Additional methods are provided to pre-encode the game's sprite data into a format preferred by the blitter.

The following blitters exist in SVN:

  • 8bpp-simple: 8bpp Simple Blitter (relative slow, but never wrong)
  • 8bpp-optimized: 8bpp Optimized Blitter (compression + all-ZoomLevel cache)
  • 8bpp-debug: 8bpp Debug Blitter (testing only)
  • 32bpp-simple: 32bpp Simple Blitter (no palette animation)
  • 32bpp-optimized: 32bpp Optimized Blitter (no palette animation)
  • 32bpp-anim: 32bpp Animation Blitter (palette animation)
  • null: Null Blitter (does nothing)

Methods

uint8 GetScreenDepth()

Get the screen depth this blitter works for. This is either: 8, 16, 24 or 32.

void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)

Draw an image to the screen, given an amount of params defined above.

void DrawColorMappingRect(void *dst, int width, int height, int pal)

Draw a colortable to the screen. This is: the color of the screen is read and is looked-up in the palette to match a new color, which then is put on the screen again.

Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator)

Convert a sprite from the loader to our own format.

The SpriteLoader calls this method for each real sprite that it loads. This function needs to convert the sprite data from RGBAM format to the blitter's preferred format. For 8bpp blitters, this will usually mean dropping the RGBA data and just using the indexed M part.

const char *GetRenderer()

Get the renderer this class depends on.

Personal tools