GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  AL_SET_BLENDER (3)

NAME

al_set_blender - Allegro 5 API

CONTENTS

Synopsis
Description
See Also

SYNOPSIS

C]
#include <allegro5/allegro.h>

void al_set_blender(int op, int src, int dst) ]

DESCRIPTION

Sets the function to use for blending for the current thread.

Blending means, the source and destination colors are combined in drawing operations.

Assume the source color (e.g. color of a rectangle to draw, or pixel of a bitmap to draw) is given as its red/green/blue/alpha components (if the bitmap has no alpha it always is assumed to be fully opaque, so 255 for 8-bit or 1.0 for floating point): I]sr, sg, sb, sa]. And this color is drawn to a destination, which already has a color: I]dr, dg, db, da].

The conceptional formula used by Allegro to draw any pixel then depends on the C]op] parameter:
[bu] ALLEGRO_ADD
C]
 r = dr * dst + sr * src
 g = dg * dst + sg * src
 b = db * dst + sb * src
 a = da * dst + sa * src
]

[bu] ALLEGRO_DEST_MINUS_SRC
C]
 r = dr * dst - sr * src
 g = dg * dst - sg * src
 b = db * dst - sb * src
 a = da * dst - sa * src
]

[bu] ALLEGRO_SRC_MINUS_DEST
C]
 r = sr * src - dr * dst
 g = sg * src - dg * dst
 b = sb * src - db * dst
 a = sa * src - da * dst
]

Valid values for
C]src] and C]dst] passed to this function are
[bu] ALLEGRO_ZERO
C]
 src = 0
 dst = 0
]

[bu] ALLEGRO_ONE
C]
 src = 1
 dst = 1
]

[bu] ALLEGRO_ALPHA
C]
 src = sa
 dst = sa
]

[bu] ALLEGRO_INVERSE_ALPHA
C]
 src = 1 - sa
 dst = 1 - sa
]

Blending examples:

So for example, to restore the default of using premultiplied alpha blending, you would use (pseudo code)
C]
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA)
]

If you are using non-pre-multiplied alpha, you could use
C]
al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA)
]

Additive blending would be achieved with
C]
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE)
]

Copying the source to the destination (including alpha) unmodified
C]
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO)
]

SEE ALSO

al_set_separate_blender(3), al_get_blender(3)

Search for    or go to Top of page |  Section 3 |  Main Index


Allegro reference manual AL_SET_BLENDER (3)

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.