2007-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/cogl/cogl.h: Add cogl_fog_set() abstracting the glFog() functions and enabling the GL_FOG flag. * clutter/cogl/gl/cogl.c: Add GL implementation of cogl_fog_set(). * clutter/cogl/gles/cogl.c: Add GL/ES implementation of cogl_fog_set(). * clutter.symbols: Add new symbols. * clutter/clutter-stage.h: Add API to enable depth cueing on the stage using a linear GL fog, and to set the parameters for it (#637). * clutter/clutter-stage.c (clutter_stage_paint): Enable the GL fog if the ClutterStage:use-fog property is true. * tests/test-depth.c: Test the new stage API.
This commit is contained in:
parent
2331fa7557
commit
9de04774d2
6
cogl.h
6
cogl.h
@ -201,6 +201,12 @@ cogl_get_viewport (ClutterFixed v[4]);
|
||||
void
|
||||
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha);
|
||||
|
||||
void
|
||||
cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_H__ */
|
||||
|
56
gl/cogl.c
56
gl/cogl.c
@ -165,7 +165,10 @@ cogl_paint_init (const ClutterColor *color)
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
glDisable (GL_LIGHTING);
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_FOG);
|
||||
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
|
||||
cogl_enable (CGL_ENABLE_BLEND);
|
||||
|
||||
@ -234,8 +237,9 @@ cogl_enable (gulong flags)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
__enable_flags |= CGL_ENABLE_BLEND;
|
||||
|
||||
__enable_flags |= CGL_ENABLE_BLEND;
|
||||
}
|
||||
}
|
||||
else if (__enable_flags & CGL_ENABLE_BLEND)
|
||||
{
|
||||
@ -246,21 +250,25 @@ cogl_enable (gulong flags)
|
||||
if (flags & CGL_ENABLE_TEXTURE_2D)
|
||||
{
|
||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_2D))
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
__enable_flags |= CGL_ENABLE_TEXTURE_2D;
|
||||
{
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
__enable_flags |= CGL_ENABLE_TEXTURE_2D;
|
||||
}
|
||||
}
|
||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_2D)
|
||||
{
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_2D;
|
||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_2D;
|
||||
}
|
||||
|
||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||
if (flags & CGL_ENABLE_TEXTURE_RECT)
|
||||
{
|
||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_RECT))
|
||||
{
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
__enable_flags |= CGL_ENABLE_TEXTURE_RECT;
|
||||
__enable_flags |= CGL_ENABLE_TEXTURE_RECT;
|
||||
}
|
||||
}
|
||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_RECT)
|
||||
{
|
||||
@ -272,14 +280,15 @@ cogl_enable (gulong flags)
|
||||
if (flags & CGL_ENABLE_ALPHA_TEST)
|
||||
{
|
||||
if (!(__enable_flags & CGL_ENABLE_ALPHA_TEST))
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
|
||||
__enable_flags |= CGL_ENABLE_ALPHA_TEST;
|
||||
{
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
__enable_flags |= CGL_ENABLE_ALPHA_TEST;
|
||||
}
|
||||
}
|
||||
else if (__enable_flags & CGL_ENABLE_ALPHA_TEST)
|
||||
{
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
__enable_flags &= ~CGL_ENABLE_ALPHA_TEST;
|
||||
__enable_flags &= ~CGL_ENABLE_ALPHA_TEST;
|
||||
}
|
||||
}
|
||||
|
||||
@ -712,3 +721,28 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
||||
*alpha = value;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed start,
|
||||
ClutterFixed stop)
|
||||
{
|
||||
GLfloat fogColor[4];
|
||||
|
||||
fogColor[0] = ((float) fog_color->red / 0xff * 1.0);
|
||||
fogColor[1] = ((float) fog_color->green / 0xff * 1.0);
|
||||
fogColor[2] = ((float) fog_color->blue / 0xff * 1.0);
|
||||
fogColor[3] = ((float) fog_color->alpha / 0xff * 1.0);
|
||||
|
||||
glEnable (GL_FOG);
|
||||
|
||||
glFogfv (GL_FOG_COLOR, fogColor);
|
||||
|
||||
glFogi (GL_FOG_MODE, GL_LINEAR);
|
||||
glHint (GL_FOG_HINT, GL_NICEST);
|
||||
|
||||
glFogf (GL_FOG_DENSITY, CLUTTER_FIXED_TO_FLOAT (density));
|
||||
glFogf (GL_FOG_START, CLUTTER_FIXED_TO_FLOAT (start));
|
||||
glFogf (GL_FOG_END, CLUTTER_FIXED_TO_FLOAT (stop));
|
||||
}
|
||||
|
32
gles/cogl.c
32
gles/cogl.c
@ -115,8 +115,11 @@ cogl_paint_init (const ClutterColor *color)
|
||||
0xff);
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
glDisable (GL_LIGHTING);
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_LIGHTING);
|
||||
glDisable (GL_FOG);
|
||||
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
|
||||
cogl_enable (CGL_ENABLE_BLEND);
|
||||
|
||||
@ -602,3 +605,28 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
||||
if (alpha)
|
||||
GE( glGetIntegerv(GL_ALPHA_BITS, alpha ) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
{
|
||||
GLfixed fogColor[4];
|
||||
|
||||
fogColor[0] = (fog_color->red << 16) / 0xff;
|
||||
fogColor[1] = (fog_color->green << 16) / 0xff;
|
||||
fogColor[2] = (fog_color->blue << 16) / 0xff;
|
||||
fogColor[3] = (fog_color->alpha << 16) / 0xff;
|
||||
|
||||
glEnable (GL_FOG);
|
||||
|
||||
glFogxv (GL_FOG_COLOR, fogColor);
|
||||
|
||||
glFogi (GL_FOG_MODE, GL_LINEAR);
|
||||
glHint (GL_FOG_HINT, GL_NICEST);
|
||||
|
||||
glFogx (GL_FOG_DENSITY, (GLfixed) density);
|
||||
glFogx (GL_FOG_START, (GLfixed) z_near);
|
||||
glFogx (GL_FOG_STOP, (GLfixed) z_far);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user