The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Translucent drawing

From Allegro Wiki
(Redirected from Transcluent drawing)
Jump to: navigation, search
This article is incomplete and needs some revision or has some pending TODOs. Please help Allegro by editing and finishing it. When the article becomes complete, you may remove this tag.


Introduction

Translucent drawing means rendering bitmaps so that the underlying image remains partially visible. The effect is often used to create shadows, lighting, "ghost" images and other effects. The teqhnique involves reading from both the source and destination bitmaps, so it's much slower than regular blitting.

Example

A very basic example: <highlightSyntax language="c"> //Set translucent drawing to use shadow_alpha as the alpha value set_trans_blender(0, 0, 0, shadow_alpha); drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);

//Draw a regular sprite draw_sprite(buffer, player_sprite, player_x, player_y);

//Draw the player's shadow using translucent drawing draw_trans_sprite(buffer, player_shadow, shadow_x, shadow_y);

//Return to regular drawing mode solid_mode(); </highlightSyntax>

Notes

  • Translucent drawing is extremely slow on video bitmaps. You should only use it on memory bitmaps.