[ Previous | Next | Contents | Glossary | Home | Search ]
The graPHIGS Programming Interface : Subroutine Reference

GPBLF - Set Blending Function

GPBLF (srcf,destf)

Purpose

Use GPBLF to insert a Set Blending Function structure element into the open structure following the element pointer, or to replace the element pointed at by the element pointer with a Set Blending Function structure element, depending upon the current edit mode.

Blending is a method of combining the colors of the primitive being rendered (called the source) with previously rendered output (called the destination) to create a new color for the destination. The blending function specifies how you combine the source and destination colors. Conceptually:

COLOR = ( srcf COLORsrc ) + ( destf COLORdest )

where srcf and destf are the source and destination blending functions respectively.

This element specifies the source blending function (srcf) and the destination blending function (destf) you use when you blend subsequent primitives with previously rendered output. Blending occurs when the Transparency Processing Mode of the view table entry is 3=BLEND or 4=BLEND_ALL

The traversal default for srcf is 3=SRCBF_SRC_ALPHA and for destf is 4=DSTBF_ONE_MINUS_SRC_ALPHA

If face distinguish mode is 1=NONE , then use these values to calculate the blending effects on both front and back facing portions of area primitives. If face distinguish mode is 2=COLOR_SURFACE_PROPERTIES , then use these values to calculate the blending effects on only front facing portions of area primitives.

The source and destination blending functions are selected by your application using the srcf and destf parameters for GPBLF as indicated in the following table:

Table 2. Blending Functions. Summary of source and destination blending functions.

% BORDER>Source
function
ID
srcf
Destination
function
ID
destf
1 0 1 0 2 1 2 1 3
src 3
src 4
1 - src 4
1 - src 5
dest 5
dest 6
1 - dest 6
1 - dest 7
Rdest , Gdest , Bdest , or
dest 7
Rsrc , Gsrc , Bsrc , or
src 8
1 - ( Rdest , Gdest , Bdest , or
dest ) 8
1 - ( Rsrc , Gsrc , Bsrc , or
src ) 9
min ( src , 1 - dest )    

For example, if srcf has the value 2=SRCBF_ONE and destf has the value 1=DSTBF_ZERO , then the blending function becomes:

COLOR = ( 1.0 COLORsrc ) + ( 0.0 COLORdest )

which causes the source color to replace the destination color.

In Table 2 the blending coefficients, also called alpha values (alpha), are floating point numbers in the range [0.0,1.0] where 0.0 is fully transparent and 1.0 is fully opaque (opposite of the definition of a transparency coefficient). The source blending coefficient (src ) is calculated from the source transparency coefficient (coeff) as follows:

src = 1.0 - coeff

where coeff is in the range [0.0,1.0] and is specified by the Set Transparency Coefficient procedure (GPTCO) , or by the transparency coefficient of the Set Surface Properties subroutine (GPSPR) . (These two subroutines set the same transparency coefficient). You can also specify the transparency coefficient as part of the vertex information of certain primitives. Alternately, you can directly supply alpha values and transparency coefficients as part of a texture map. Where available, the alpha buffer provides the destination blending coefficient (dest ) defined by some of the blending functions. If a blending function is not supported by the workstation, or if a destination blending function is specified on a workstation that does not have alpha buffers, then the element is ignored. Use GPQWDT to inquire the transparency facilities of a specific workstation.

A new blending coefficient is calculated from the blending equation and stored with each color (pixel) on those workstations which support alpha buffers. Those workstations which do not support alpha buffers do not support blending functions from Table 2 which include dest The dest value is typically stored as an integer in the range [0,255] The initial dest value for a view's shield can be specified using the Set Extended View Representation (GPXVR) .

Parameters

srcf-- specified by user, fullword integer

Source blending function (1=SRCBF_ZERO, 2=SRCBF_ONE, 3=SRCBF_SRC_ALPHA, 4=SRCBF_ONE_MINUS_SRC_ALPHA, 5=SRCBF_DST_ALPHA, 6=SRCBF_ONE_MINUS_DST_ALPHA, 7=SRCBF_DST_COLOR, 8=SRCBF_ONE_MINUS_DST_COLOR, 9=SRCBF_MIN_SRC_ALPHA_ONE_MINUS_DST_ALPHA ).

destf-- specified by user, fullword integer

Destination blending function (1=DSTBF_ZERO, 2=DSTBF_ONE, 3=DSTBF_SRC_ALPHA, 4=DSTBF_ONE_MINUS_SRC_ALPHA, 5=DSTBF_DST_ALPHA, 6=DSTBF_ONE_MINUS_DST_ALPHA, 7=DSTBF_SRC_COLOR, 8=DSTBF_ONE_MINUS_SRC_COLOR ).

Error Codes

5
FUNCTION REQUIRES STATE STOP OR NROP (NOT STCL)
629
BLENDING FUNCTION IS INVALID

Related Subroutines

GPBBLF
Set Back Blending Function
GPBSPR
Set Back Surface Properties
GPBTCO
Set Back Transparency Coefficient
GPQWDT
Inquire Workstation Description
GPSPR
Set Surface Properties
GPTCO
Set Transparency Coefficient
GPXVR
Set Extended View Representation

RCP code

201343507 (X'0C004213')


[ Previous | Next | Contents | Glossary | Home | Search ]