Warning: set_fog is deprecated since 1.10.
Sets the fog (also known as "depth cueing") settings for the this.
Fog settings are ignored.
A Stage will only use a linear fog progression, which depends solely on the distance from the viewer. The set_fog function in COGL exposes more of the underlying implementation, and allows changing the for progression function. It can be directly used by disabling the use_fog property and connecting a signal handler to the paint signal on the this, like:
clutter_stage_set_use_fog (stage, FALSE);
g_signal_connect (stage, "paint", G_CALLBACK (on_stage_paint), NULL);
The paint signal handler will call set_fog with the desired settings:
static void
on_stage_paint (ClutterActor *actor)
{
ClutterColor stage_color = { 0, };
CoglColor fog_color = { 0, };
// set the fog color to the stage background color
clutter_stage_get_color (CLUTTER_STAGE (actor), &stage_color);
cogl_color_init_from_4ub (&fog_color,
stage_color.red,
stage_color.green,
stage_color.blue,
stage_color.alpha);
// enable fog //
cogl_set_fog (&fog_color,
COGL_FOG_MODE_EXPONENTIAL, // mode
0.5, // density
5.0, 30.0); // z_near and z_far
}
The fogging functions only work correctly when the visible actors use unmultiplied alpha colors. By default Cogl will premultiply textures and set_source_color will premultiply colors, so unless you explicitly load your textures requesting an unmultiplied internal format and use set_color you can only use fogging with fully opaque actors. Support for premultiplied colors will improve in the future when we can depend on fragment shaders.
this |
the Stage |
fog |
a Fog structure |