Merged clutter-ivan branch into trunk.
svn merge \ https://svn.o-hand.com/repos/clutter/trunk/clutter@2509 \ https://svn.o-hand.com/repos/clutter/branches/clutter-ivan@HEAD
1266
ChangeLog-ivan
Normal file
@ -22,9 +22,9 @@ GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0`
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/pango \
|
-I$(top_srcdir)/clutter/pango \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
|
||||||
$(clutter_json_include) \
|
$(clutter_json_include) \
|
||||||
|
-I$(top_builddir)/clutter \
|
||||||
-DCLUTTER_PREFIX=\""$(prefix)"\" \
|
-DCLUTTER_PREFIX=\""$(prefix)"\" \
|
||||||
-DCLUTTER_LIBDIR=\""$(libdir)"\" \
|
-DCLUTTER_LIBDIR=\""$(libdir)"\" \
|
||||||
-DCLUTTER_DATADIR=\""$(datadir)"\" \
|
-DCLUTTER_DATADIR=\""$(datadir)"\" \
|
||||||
@ -87,7 +87,7 @@ source_h = \
|
|||||||
$(srcdir)/clutter-types.h \
|
$(srcdir)/clutter-types.h \
|
||||||
$(srcdir)/clutter-units.h \
|
$(srcdir)/clutter-units.h \
|
||||||
$(srcdir)/clutter-util.h \
|
$(srcdir)/clutter-util.h \
|
||||||
$(srcdir)/clutter-version.h \
|
$(top_builddir)/clutter/clutter-version.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
clutter-marshal.h: stamp-clutter-marshal.h
|
clutter-marshal.h: stamp-clutter-marshal.h
|
||||||
@ -113,8 +113,7 @@ clutter-marshal.c: clutter-marshal.h Makefile
|
|||||||
clutter-enum-types.h: stamp-clutter-enum-types.h
|
clutter-enum-types.h: stamp-clutter-enum-types.h
|
||||||
@true
|
@true
|
||||||
stamp-clutter-enum-types.h: $(source_h) Makefile
|
stamp-clutter-enum-types.h: $(source_h) Makefile
|
||||||
( cd $(srcdir) && \
|
( $(GLIB_MKENUMS) \
|
||||||
$(GLIB_MKENUMS) \
|
|
||||||
--template $(srcdir)/clutter-enum-types.h.in \
|
--template $(srcdir)/clutter-enum-types.h.in \
|
||||||
$(source_h) ) >> xgen-ceth && \
|
$(source_h) ) >> xgen-ceth && \
|
||||||
(cmp xgen-ceth clutter-enum-types.h || cp xgen-ceth clutter-enum-types.h) && \
|
(cmp xgen-ceth clutter-enum-types.h || cp xgen-ceth clutter-enum-types.h) && \
|
||||||
@ -122,8 +121,7 @@ stamp-clutter-enum-types.h: $(source_h) Makefile
|
|||||||
echo timestamp > $(@F)
|
echo timestamp > $(@F)
|
||||||
|
|
||||||
clutter-enum-types.c: clutter-enum-types.h
|
clutter-enum-types.c: clutter-enum-types.h
|
||||||
( cd $(srcdir) && \
|
( $(GLIB_MKENUMS) \
|
||||||
$(GLIB_MKENUMS) \
|
|
||||||
--template $(srcdir)/clutter-enum-types.c.in \
|
--template $(srcdir)/clutter-enum-types.c.in \
|
||||||
$(source_h) ) >> xgen-cetc && \
|
$(source_h) ) >> xgen-cetc && \
|
||||||
cp xgen-cetc clutter-enum-types.c && \
|
cp xgen-cetc clutter-enum-types.c && \
|
||||||
@ -144,9 +142,9 @@ source_c = \
|
|||||||
clutter-behaviour-path.c \
|
clutter-behaviour-path.c \
|
||||||
clutter-behaviour-rotate.c \
|
clutter-behaviour-rotate.c \
|
||||||
clutter-behaviour-scale.c \
|
clutter-behaviour-scale.c \
|
||||||
|
clutter-clone-texture.c \
|
||||||
clutter-color.c \
|
clutter-color.c \
|
||||||
clutter-container.c \
|
clutter-container.c \
|
||||||
clutter-clone-texture.c \
|
|
||||||
clutter-effect.c \
|
clutter-effect.c \
|
||||||
clutter-entry.c \
|
clutter-entry.c \
|
||||||
clutter-enum-types.c \
|
clutter-enum-types.c \
|
||||||
|
@ -149,7 +149,7 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-units.h"
|
#include "clutter-units.h"
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
typedef struct _ShaderData ShaderData;
|
typedef struct _ShaderData ShaderData;
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ clutter_actor_real_pick (ClutterActor *self,
|
|||||||
if (clutter_actor_should_pick_paint (self))
|
if (clutter_actor_should_pick_paint (self))
|
||||||
{
|
{
|
||||||
cogl_color (color);
|
cogl_color (color);
|
||||||
cogl_rectangle (0,
|
cogl_fast_fill_rectangle (0,
|
||||||
0,
|
0,
|
||||||
clutter_actor_get_width(self),
|
clutter_actor_get_width(self),
|
||||||
clutter_actor_get_height(self));
|
clutter_actor_get_height(self));
|
||||||
@ -3762,7 +3762,6 @@ clutter_actor_set_rotationu (ClutterActor *self,
|
|||||||
x, y, z);
|
x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_actor_set_rotationx:
|
* clutter_actor_set_rotationx:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
@ -5255,6 +5254,8 @@ clutter_actor_set_custom_property (ClutterScriptable *scriptable,
|
|||||||
const gchar *name,
|
const gchar *name,
|
||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
|
CLUTTER_NOTE (SCRIPT, "in ClutterActor::set_custom_property('%s')", name);
|
||||||
|
|
||||||
if (strcmp (name, "rotation") == 0)
|
if (strcmp (name, "rotation") == 0)
|
||||||
{
|
{
|
||||||
RotationInfo *info;
|
RotationInfo *info;
|
||||||
|
@ -44,12 +44,14 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_PARENT_TEXTURE
|
PROP_PARENT_TEXTURE,
|
||||||
|
PROP_REPEAT_Y,
|
||||||
|
PROP_REPEAT_X
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterCloneTexture,
|
G_DEFINE_TYPE (ClutterCloneTexture,
|
||||||
@ -62,122 +64,20 @@ G_DEFINE_TYPE (ClutterCloneTexture,
|
|||||||
struct _ClutterCloneTexturePrivate
|
struct _ClutterCloneTexturePrivate
|
||||||
{
|
{
|
||||||
ClutterTexture *parent_texture;
|
ClutterTexture *parent_texture;
|
||||||
|
guint repeat_x : 1;
|
||||||
|
guint repeat_y : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
clone_texture_render_to_gl_quad (ClutterCloneTexture *ctexture,
|
|
||||||
int x_1,
|
|
||||||
int y_1,
|
|
||||||
int x_2,
|
|
||||||
int y_2)
|
|
||||||
{
|
|
||||||
gint qx1 = 0, qx2 = 0, qy1 = 0, qy2 = 0;
|
|
||||||
gint qwidth = 0, qheight = 0;
|
|
||||||
gint x, y, i = 0, lastx = 0, lasty = 0;
|
|
||||||
gint n_x_tiles, n_y_tiles;
|
|
||||||
gint pwidth, pheight;
|
|
||||||
float tx, ty;
|
|
||||||
|
|
||||||
ClutterCloneTexturePrivate *priv = ctexture->priv;
|
|
||||||
ClutterActor *parent_actor = CLUTTER_ACTOR (priv->parent_texture);
|
|
||||||
|
|
||||||
priv = ctexture->priv;
|
|
||||||
|
|
||||||
qwidth = x_2 - x_1;
|
|
||||||
qheight = y_2 - y_1;
|
|
||||||
|
|
||||||
if (!CLUTTER_ACTOR_IS_REALIZED (parent_actor))
|
|
||||||
clutter_actor_realize (parent_actor);
|
|
||||||
|
|
||||||
/* Only paint if parent is in a state to do so */
|
|
||||||
if (!clutter_texture_has_generated_tiles (priv->parent_texture))
|
|
||||||
return;
|
|
||||||
|
|
||||||
clutter_texture_get_base_size (priv->parent_texture, &pwidth, &pheight);
|
|
||||||
|
|
||||||
if (!clutter_texture_is_tiled (priv->parent_texture))
|
|
||||||
{
|
|
||||||
clutter_texture_bind_tile (priv->parent_texture, 0);
|
|
||||||
|
|
||||||
/* NPOTS textures *always* used if extension available
|
|
||||||
*/
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
{
|
|
||||||
tx = (float) pwidth;
|
|
||||||
ty = (float) pheight;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tx = (float) pwidth / clutter_util_next_p2 (pwidth);
|
|
||||||
ty = (float) pheight / clutter_util_next_p2 (pheight);
|
|
||||||
}
|
|
||||||
|
|
||||||
cogl_texture_quad (x_1, x_2, y_1, y_2,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
CLUTTER_FLOAT_TO_FIXED (tx),
|
|
||||||
CLUTTER_FLOAT_TO_FIXED (ty));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
clutter_texture_get_n_tiles (priv->parent_texture, &n_x_tiles, &n_y_tiles);
|
|
||||||
|
|
||||||
for (x = 0; x < n_x_tiles; x++)
|
|
||||||
{
|
|
||||||
lasty = 0;
|
|
||||||
|
|
||||||
for (y = 0; y < n_y_tiles; y++)
|
|
||||||
{
|
|
||||||
gint actual_w, actual_h;
|
|
||||||
gint xpos, ypos, xsize, ysize, ywaste, xwaste;
|
|
||||||
|
|
||||||
clutter_texture_bind_tile (priv->parent_texture, i);
|
|
||||||
|
|
||||||
clutter_texture_get_x_tile_detail (priv->parent_texture,
|
|
||||||
x, &xpos, &xsize, &xwaste);
|
|
||||||
|
|
||||||
clutter_texture_get_y_tile_detail (priv->parent_texture,
|
|
||||||
y, &ypos, &ysize, &ywaste);
|
|
||||||
|
|
||||||
actual_w = xsize - xwaste;
|
|
||||||
actual_h = ysize - ywaste;
|
|
||||||
|
|
||||||
tx = (float) actual_w / xsize;
|
|
||||||
ty = (float) actual_h / ysize;
|
|
||||||
|
|
||||||
qx1 = x_1 + lastx;
|
|
||||||
qx2 = qx1 + ((qwidth * actual_w ) / pwidth );
|
|
||||||
|
|
||||||
qy1 = y_1 + lasty;
|
|
||||||
qy2 = qy1 + ((qheight * actual_h) / pheight );
|
|
||||||
|
|
||||||
CLUTTER_NOTE (TEXTURE,
|
|
||||||
"rendering text tile x: %i, y: %i - %ix%i",
|
|
||||||
x, y,
|
|
||||||
actual_w, actual_h);
|
|
||||||
|
|
||||||
cogl_texture_quad (qx1, qx2, qy1, qy2,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
CLUTTER_FLOAT_TO_FIXED (tx),
|
|
||||||
CLUTTER_FLOAT_TO_FIXED (ty));
|
|
||||||
|
|
||||||
lasty += qy2 - qy1;
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
lastx += qx2 - qx1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_clone_texture_paint (ClutterActor *self)
|
clutter_clone_texture_paint (ClutterActor *self)
|
||||||
{
|
{
|
||||||
ClutterCloneTexturePrivate *priv;
|
ClutterCloneTexturePrivate *priv;
|
||||||
ClutterActor *parent_texture;
|
ClutterActor *parent_texture;
|
||||||
gint x_1, y_1, x_2, y_2;
|
gint x_1, y_1, x_2, y_2;
|
||||||
GLenum target_type;
|
|
||||||
ClutterColor col = { 0xff, 0xff, 0xff, 0xff };
|
ClutterColor col = { 0xff, 0xff, 0xff, 0xff };
|
||||||
|
CoglHandle cogl_texture;
|
||||||
|
ClutterFixed t_w, t_h;
|
||||||
|
guint tex_width, tex_height;
|
||||||
|
|
||||||
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
||||||
|
|
||||||
@ -199,20 +99,6 @@ clutter_clone_texture_paint (ClutterActor *self)
|
|||||||
|
|
||||||
cogl_push_matrix ();
|
cogl_push_matrix ();
|
||||||
|
|
||||||
/* FIXME: figure out nicer way of getting at this info...
|
|
||||||
*/
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) &&
|
|
||||||
clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)) == FALSE)
|
|
||||||
{
|
|
||||||
target_type = CGL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target_type = CGL_TEXTURE_2D;
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
col.alpha = clutter_actor_get_abs_opacity (self);
|
col.alpha = clutter_actor_get_abs_opacity (self);
|
||||||
cogl_color (&col);
|
cogl_color (&col);
|
||||||
|
|
||||||
@ -223,9 +109,30 @@ clutter_clone_texture_paint (ClutterActor *self)
|
|||||||
x_1, y_1, x_2, y_2,
|
x_1, y_1, x_2, y_2,
|
||||||
clutter_actor_get_opacity (self));
|
clutter_actor_get_opacity (self));
|
||||||
|
|
||||||
|
cogl_texture = clutter_texture_get_cogl_texture (priv->parent_texture);
|
||||||
|
|
||||||
|
if (cogl_texture == COGL_INVALID_HANDLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tex_width = cogl_texture_get_width (cogl_texture);
|
||||||
|
tex_height = cogl_texture_get_height (cogl_texture);
|
||||||
|
|
||||||
|
if (priv->repeat_x && tex_width > 0)
|
||||||
|
t_w = CFX_QDIV (CLUTTER_INT_TO_FIXED (x_2 - x_1),
|
||||||
|
CLUTTER_INT_TO_FIXED (tex_width));
|
||||||
|
else
|
||||||
|
t_w = CFX_ONE;
|
||||||
|
if (priv->repeat_y && tex_height > 0)
|
||||||
|
t_h = CFX_QDIV (CLUTTER_INT_TO_FIXED (y_2 - y_1),
|
||||||
|
CLUTTER_INT_TO_FIXED (tex_height));
|
||||||
|
else
|
||||||
|
t_h = CFX_ONE;
|
||||||
|
|
||||||
/* Parent paint translated us into position */
|
/* Parent paint translated us into position */
|
||||||
clone_texture_render_to_gl_quad (CLUTTER_CLONE_TEXTURE (self),
|
cogl_texture_rectangle (cogl_texture, 0, 0,
|
||||||
0, 0, x_2 - x_1, y_2 - y_1);
|
CLUTTER_INT_TO_FIXED (x_2 - x_1),
|
||||||
|
CLUTTER_INT_TO_FIXED (y_2 - y_1),
|
||||||
|
0, 0, t_w, t_h);
|
||||||
|
|
||||||
cogl_pop_matrix ();
|
cogl_pop_matrix ();
|
||||||
}
|
}
|
||||||
@ -295,12 +202,29 @@ clutter_clone_texture_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
||||||
|
ClutterCloneTexturePrivate *priv;
|
||||||
|
|
||||||
|
priv = ctexture->priv;
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_PARENT_TEXTURE:
|
case PROP_PARENT_TEXTURE:
|
||||||
set_parent_texture (ctexture, g_value_get_object (value));
|
set_parent_texture (ctexture, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_REPEAT_X:
|
||||||
|
if (priv->repeat_x != g_value_get_boolean (value))
|
||||||
|
{
|
||||||
|
priv->repeat_x = !priv->repeat_x;
|
||||||
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROP_REPEAT_Y:
|
||||||
|
if (priv->repeat_y != g_value_get_boolean (value))
|
||||||
|
{
|
||||||
|
priv->repeat_y = !priv->repeat_y;
|
||||||
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture));
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -314,12 +238,21 @@ clutter_clone_texture_get_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
||||||
|
ClutterCloneTexturePrivate *priv;
|
||||||
|
|
||||||
|
priv = ctexture->priv;
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_PARENT_TEXTURE:
|
case PROP_PARENT_TEXTURE:
|
||||||
g_value_set_object (value, ctexture->priv->parent_texture);
|
g_value_set_object (value, ctexture->priv->parent_texture);
|
||||||
break;
|
break;
|
||||||
|
case PROP_REPEAT_X:
|
||||||
|
g_value_set_boolean (value, priv->repeat_x);
|
||||||
|
break;
|
||||||
|
case PROP_REPEAT_Y:
|
||||||
|
g_value_set_boolean (value, priv->repeat_y);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -339,14 +272,32 @@ clutter_clone_texture_class_init (ClutterCloneTextureClass *klass)
|
|||||||
gobject_class->set_property = clutter_clone_texture_set_property;
|
gobject_class->set_property = clutter_clone_texture_set_property;
|
||||||
gobject_class->get_property = clutter_clone_texture_get_property;
|
gobject_class->get_property = clutter_clone_texture_get_property;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property
|
||||||
PROP_PARENT_TEXTURE,
|
(gobject_class, PROP_PARENT_TEXTURE,
|
||||||
g_param_spec_object ("parent-texture",
|
g_param_spec_object ("parent-texture",
|
||||||
"Parent Texture",
|
"Parent Texture",
|
||||||
"The parent texture to clone",
|
"The parent texture to clone",
|
||||||
CLUTTER_TYPE_TEXTURE,
|
CLUTTER_TYPE_TEXTURE,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(gobject_class, PROP_REPEAT_X,
|
||||||
|
g_param_spec_boolean ("repeat-x",
|
||||||
|
"Tile underlying pixbuf in x direction",
|
||||||
|
"Reapeat underlying pixbuf rather than scale "
|
||||||
|
"in x direction.",
|
||||||
|
FALSE,
|
||||||
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(gobject_class, PROP_REPEAT_Y,
|
||||||
|
g_param_spec_boolean ("repeat-y",
|
||||||
|
"Tile underlying pixbuf in y direction",
|
||||||
|
"Reapeat underlying pixbuf rather than scale "
|
||||||
|
"in y direction.",
|
||||||
|
FALSE,
|
||||||
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate));
|
g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,4 +42,6 @@
|
|||||||
#define clutter_shader_bind clutter_shader_bind_REPLACED_BY_clutter_shader_compile
|
#define clutter_shader_bind clutter_shader_bind_REPLACED_BY_clutter_shader_compile
|
||||||
#define clutter_shader_is_bound clutter_shader_is_bound_REPLACED_BY_clutter_shader_is_compiled
|
#define clutter_shader_is_bound clutter_shader_is_bound_REPLACED_BY_clutter_shader_is_compiled
|
||||||
|
|
||||||
|
#define clutter_texture_new_from_pixbuf clutter_texture_new_from_pixbuf_DEPRECATED_BY_clutter_texture_new_from_file_OR_clutter_texture_new_AND_clutter_texture_set_from_rgb_data
|
||||||
|
|
||||||
#endif /* CLUTTER_DEPRECATED_H */
|
#endif /* CLUTTER_DEPRECATED_H */
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
typedef struct ClutterFeatures
|
typedef struct ClutterFeatures
|
||||||
{
|
{
|
||||||
@ -53,6 +53,32 @@ typedef struct ClutterFeatures
|
|||||||
|
|
||||||
static ClutterFeatures* __features = NULL;
|
static ClutterFeatures* __features = NULL;
|
||||||
|
|
||||||
|
ClutterFeatureFlags
|
||||||
|
_clutter_features_from_cogl (guint cogl_flags)
|
||||||
|
{
|
||||||
|
ClutterFeatureFlags clutter_flags = 0;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_TEXTURE_RECTANGLE)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_TEXTURE_YUV)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_YUV;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_TEXTURE_READ_PIXELS)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_READ_PIXELS;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_SHADERS_GLSL)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
|
||||||
|
|
||||||
|
if (cogl_flags & COGL_FEATURE_OFFSCREEN)
|
||||||
|
clutter_flags |= CLUTTER_FEATURE_OFFSCREEN;
|
||||||
|
|
||||||
|
return clutter_flags;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_clutter_feature_init (void)
|
_clutter_feature_init (void)
|
||||||
{
|
{
|
||||||
@ -72,8 +98,8 @@ _clutter_feature_init (void)
|
|||||||
|
|
||||||
context = clutter_context_get_default ();
|
context = clutter_context_get_default ();
|
||||||
|
|
||||||
__features->flags = cogl_get_features()
|
__features->flags = (_clutter_features_from_cogl (cogl_get_features ())
|
||||||
|_clutter_backend_get_features (context->backend);
|
| _clutter_backend_get_features (context->backend));
|
||||||
|
|
||||||
__features->features_set = TRUE;
|
__features->features_set = TRUE;
|
||||||
|
|
||||||
|
@ -58,15 +58,16 @@ G_BEGIN_DECLS
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CLUTTER_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
|
CLUTTER_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
|
||||||
CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 2),
|
CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2),
|
||||||
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 3),
|
CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 3),
|
||||||
CLUTTER_FEATURE_TEXTURE_READ_PIXELS = (1 << 4),
|
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
|
||||||
CLUTTER_FEATURE_STAGE_STATIC = (1 << 5),
|
CLUTTER_FEATURE_TEXTURE_READ_PIXELS = (1 << 5),
|
||||||
CLUTTER_FEATURE_STAGE_USER_RESIZE = (1 << 6),
|
CLUTTER_FEATURE_STAGE_STATIC = (1 << 6),
|
||||||
CLUTTER_FEATURE_STAGE_CURSOR = (1 << 7),
|
CLUTTER_FEATURE_STAGE_USER_RESIZE = (1 << 7),
|
||||||
CLUTTER_FEATURE_SHADERS_GLSL = (1 << 8),
|
CLUTTER_FEATURE_STAGE_CURSOR = (1 << 8),
|
||||||
CLUTTER_FEATURE_OFFSCREEN = (1 << 9),
|
CLUTTER_FEATURE_SHADERS_GLSL = (1 << 9),
|
||||||
CLUTTER_FEATURE_STAGE_MULTIPLE = (1 << 10)
|
CLUTTER_FEATURE_OFFSCREEN = (1 << 10),
|
||||||
|
CLUTTER_FEATURE_STAGE_MULTIPLE = (1 << 11)
|
||||||
} ClutterFeatureFlags;
|
} ClutterFeatureFlags;
|
||||||
|
|
||||||
gboolean clutter_feature_available (ClutterFeatureFlags feature);
|
gboolean clutter_feature_available (ClutterFeatureFlags feature);
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include "clutter-marshal.h"
|
#include "clutter-marshal.h"
|
||||||
#include "clutter-enum-types.h"
|
#include "clutter-enum-types.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "clutter-version.h" /* For flavour define */
|
#include "clutter-version.h" /* For flavour define */
|
||||||
#include "clutter-frame-source.h"
|
#include "clutter-frame-source.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
/* main context */
|
/* main context */
|
||||||
static ClutterMainContext *ClutterCntx = NULL;
|
static ClutterMainContext *ClutterCntx = NULL;
|
||||||
@ -247,7 +247,6 @@ _clutter_do_pick (ClutterStage *stage,
|
|||||||
clutter_maybe_setup_viewport (stage);
|
clutter_maybe_setup_viewport (stage);
|
||||||
|
|
||||||
cogl_paint_init (&white);
|
cogl_paint_init (&white);
|
||||||
cogl_enable (0);
|
|
||||||
|
|
||||||
/* Disable dithering (if any) when doing the painting in pick mode */
|
/* Disable dithering (if any) when doing the painting in pick mode */
|
||||||
glDisable (GL_DITHER);
|
glDisable (GL_DITHER);
|
||||||
@ -349,12 +348,16 @@ clutter_main (void)
|
|||||||
loop = g_main_loop_new (NULL, TRUE);
|
loop = g_main_loop_new (NULL, TRUE);
|
||||||
main_loops = g_slist_prepend (main_loops, loop);
|
main_loops = g_slist_prepend (main_loops, loop);
|
||||||
|
|
||||||
|
#ifdef HAVE_CLUTTER_FRUITY_FOO
|
||||||
|
clutter_fruity_main ();
|
||||||
|
#else
|
||||||
if (g_main_loop_is_running (main_loops->data))
|
if (g_main_loop_is_running (main_loops->data))
|
||||||
{
|
{
|
||||||
clutter_threads_leave ();
|
clutter_threads_leave ();
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
clutter_threads_enter ();
|
clutter_threads_enter ();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
main_loops = g_slist_remove (main_loops, loop);
|
main_loops = g_slist_remove (main_loops, loop);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterRectangle, clutter_rectangle, CLUTTER_TYPE_ACTOR);
|
G_DEFINE_TYPE (ClutterRectangle, clutter_rectangle, CLUTTER_TYPE_ACTOR);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
: "unknown");
|
: "unknown");
|
||||||
cogl_push_matrix();
|
cogl_push_matrix();
|
||||||
|
|
||||||
cogl_enable (CGL_ENABLE_BLEND);
|
//cogl_enable (CGL_ENABLE_BLEND);
|
||||||
|
|
||||||
clutter_actor_get_geometry (self, &geom);
|
clutter_actor_get_geometry (self, &geom);
|
||||||
|
|
||||||
@ -101,20 +101,20 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
cogl_color (&tmp_col);
|
cogl_color (&tmp_col);
|
||||||
|
|
||||||
/* this sucks, but it's the only way to make a border */
|
/* this sucks, but it's the only way to make a border */
|
||||||
cogl_rectangle (priv->border_width, 0,
|
cogl_fast_fill_rectangle (priv->border_width, 0,
|
||||||
geom.width - priv->border_width,
|
geom.width - priv->border_width,
|
||||||
priv->border_width);
|
priv->border_width);
|
||||||
|
|
||||||
cogl_rectangle (geom.width - priv->border_width,
|
cogl_fast_fill_rectangle (geom.width - priv->border_width,
|
||||||
priv->border_width,
|
priv->border_width,
|
||||||
priv->border_width,
|
priv->border_width,
|
||||||
geom.height - priv->border_width);
|
geom.height - priv->border_width);
|
||||||
|
|
||||||
cogl_rectangle (0, geom.height - priv->border_width,
|
cogl_fast_fill_rectangle (0, geom.height - priv->border_width,
|
||||||
geom.width - priv->border_width,
|
geom.width - priv->border_width,
|
||||||
priv->border_width);
|
priv->border_width);
|
||||||
|
|
||||||
cogl_rectangle (0, 0,
|
cogl_fast_fill_rectangle (0, 0,
|
||||||
priv->border_width,
|
priv->border_width,
|
||||||
geom.height - priv->border_width);
|
geom.height - priv->border_width);
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
|
|
||||||
cogl_color (&tmp_col);
|
cogl_color (&tmp_col);
|
||||||
|
|
||||||
cogl_rectangle (priv->border_width,
|
cogl_fast_fill_rectangle (priv->border_width,
|
||||||
priv->border_width,
|
priv->border_width,
|
||||||
geom.width - priv->border_width * 2,
|
geom.width - priv->border_width * 2,
|
||||||
geom.height - priv->border_width * 2);
|
geom.height - priv->border_width * 2);
|
||||||
@ -138,7 +138,7 @@ clutter_rectangle_paint (ClutterActor *self)
|
|||||||
|
|
||||||
cogl_color (&tmp_col);
|
cogl_color (&tmp_col);
|
||||||
|
|
||||||
cogl_rectangle (0, 0, geom.width, geom.height);
|
cogl_fast_fill_rectangle (0, 0, geom.width, geom.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_pop_matrix();
|
cogl_pop_matrix();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <gmodule.h>
|
||||||
|
|
||||||
#include "clutter-actor.h"
|
#include "clutter-actor.h"
|
||||||
#include "clutter-behaviour.h"
|
#include "clutter-behaviour.h"
|
||||||
|
@ -160,6 +160,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <gmodule.h>
|
||||||
|
|
||||||
#include "clutter-actor.h"
|
#include "clutter-actor.h"
|
||||||
#include "clutter-alpha.h"
|
#include "clutter-alpha.h"
|
||||||
@ -927,6 +928,7 @@ clutter_script_parse_node (ClutterScript *script,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case G_TYPE_OBJECT:
|
case G_TYPE_OBJECT:
|
||||||
|
#ifdef USE_GDKPIXBUF
|
||||||
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
|
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
|
||||||
{
|
{
|
||||||
if (G_VALUE_HOLDS (&node_value, G_TYPE_STRING))
|
if (G_VALUE_HOLDS (&node_value, G_TYPE_STRING))
|
||||||
@ -983,6 +985,7 @@ clutter_script_parse_node (ClutterScript *script,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <cogl/cogl.h>
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
@ -403,9 +403,6 @@ bind_glsl_shader (ClutterShader *self,
|
|||||||
ClutterShaderPrivate *priv;
|
ClutterShaderPrivate *priv;
|
||||||
priv = self->priv;
|
priv = self->priv;
|
||||||
|
|
||||||
cogl_enable (CGL_FRAGMENT_SHADER);
|
|
||||||
cogl_enable (CGL_VERTEX_SHADER);
|
|
||||||
|
|
||||||
priv->program = cogl_create_program ();
|
priv->program = cogl_create_program ();
|
||||||
|
|
||||||
if (priv->vertex_is_glsl && priv->vertex_source)
|
if (priv->vertex_is_glsl && priv->vertex_source)
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#define __CLUTTER_STAGE_WINDOW_H__
|
#define __CLUTTER_STAGE_WINDOW_H__
|
||||||
|
|
||||||
#include <clutter/clutter-actor.h>
|
#include <clutter/clutter-actor.h>
|
||||||
|
#ifdef USE_GDKPIXBUF
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -28,12 +30,6 @@ struct _ClutterStageWindowIface
|
|||||||
gboolean cursor_visible);
|
gboolean cursor_visible);
|
||||||
void (* set_user_resizable) (ClutterStageWindow *stage_window,
|
void (* set_user_resizable) (ClutterStageWindow *stage_window,
|
||||||
gboolean is_resizable);
|
gboolean is_resizable);
|
||||||
|
|
||||||
GdkPixbuf * (* draw_to_pixbuf) (ClutterStageWindow *stage_window,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint width,
|
|
||||||
gint height);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType clutter_stage_window_get_type (void) G_GNUC_CONST;
|
GType clutter_stage_window_get_type (void) G_GNUC_CONST;
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
#include "clutter-version.h" /* For flavour */
|
#include "clutter-version.h" /* For flavour */
|
||||||
#include "clutter-id-pool.h"
|
#include "clutter-id-pool.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterStage, clutter_stage, CLUTTER_TYPE_GROUP);
|
G_DEFINE_TYPE (ClutterStage, clutter_stage, CLUTTER_TYPE_GROUP);
|
||||||
|
|
||||||
@ -1012,7 +1012,7 @@ clutter_stage_hide_cursor (ClutterStage *stage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_stage_snapshot
|
* clutter_stage_read_pixels:
|
||||||
* @stage: A #ClutterStage
|
* @stage: A #ClutterStage
|
||||||
* @x: x coordinate of the first pixel that is read from stage
|
* @x: x coordinate of the first pixel that is read from stage
|
||||||
* @y: y coordinate of the first pixel that is read from stage
|
* @y: y coordinate of the first pixel that is read from stage
|
||||||
@ -1021,31 +1021,65 @@ clutter_stage_hide_cursor (ClutterStage *stage)
|
|||||||
* @height: Height dimention of pixels to be read, or -1 for the
|
* @height: Height dimention of pixels to be read, or -1 for the
|
||||||
* entire stage height
|
* entire stage height
|
||||||
*
|
*
|
||||||
|
* Makes a screenshot of the stage in RGBA 8bit data, returns a
|
||||||
|
* linear buffer with @width*4 as rowstride.
|
||||||
* Gets a pixel based representation of the current rendered stage.
|
* Gets a pixel based representation of the current rendered stage.
|
||||||
*
|
*
|
||||||
* Return value: pixel representation as a #GdkPixbuf, or %NULL if
|
* Return value: a pointer to newly allocated memory with the buffer
|
||||||
* the backend does not support this operation
|
* that should be free with g_free, or NULL if the read back failed.
|
||||||
*/
|
*/
|
||||||
GdkPixbuf *
|
guchar *
|
||||||
clutter_stage_snapshot (ClutterStage *stage,
|
clutter_stage_read_pixels (ClutterStage *stage,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
ClutterStageWindow *impl;
|
guchar *pixels;
|
||||||
ClutterStageWindowIface *iface;
|
GLint viewport[4];
|
||||||
|
gint rowstride;
|
||||||
|
gint stage_x, stage_y, stage_width, stage_height;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
||||||
|
|
||||||
|
/* according to glReadPixels documentation pixels outside the viewport are
|
||||||
|
* undefined, but no error should be provoked, thus this is probably unnneed.
|
||||||
|
*/
|
||||||
g_return_val_if_fail (x >= 0 && y >= 0, NULL);
|
g_return_val_if_fail (x >= 0 && y >= 0, NULL);
|
||||||
|
|
||||||
impl = CLUTTER_STAGE_WINDOW (stage->priv->impl);
|
/* Force a redraw of the stage before reading back pixels */
|
||||||
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
|
clutter_stage_paint (CLUTTER_ACTOR (stage));
|
||||||
|
clutter_stage_ensure_current (stage);
|
||||||
|
|
||||||
if (iface->draw_to_pixbuf)
|
glGetIntegerv (GL_VIEWPORT, viewport);
|
||||||
return iface->draw_to_pixbuf (impl, x, y, width, height);
|
stage_x = viewport[0];
|
||||||
|
stage_y = viewport[1];
|
||||||
|
stage_width = viewport[2] - x;
|
||||||
|
stage_height = viewport[3] - y;
|
||||||
|
rowstride = width * 4;
|
||||||
|
|
||||||
return NULL;
|
pixels = g_malloc (height * rowstride);
|
||||||
|
|
||||||
|
/* check whether we need to read into a smaller temporary buffer */
|
||||||
|
glReadPixels (x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
|
||||||
|
/* vertically flip the buffer in-place */
|
||||||
|
for (y=0; y< height/2; y++)
|
||||||
|
{
|
||||||
|
guchar temprow[rowstride];
|
||||||
|
if (y != height-y-1) /* skip center row */
|
||||||
|
{
|
||||||
|
memcpy (temprow,
|
||||||
|
pixels + y * rowstride, rowstride);
|
||||||
|
memcpy (pixels + y * rowstride,
|
||||||
|
pixels + (height-y-1) * rowstride, rowstride);
|
||||||
|
memcpy (pixels + (height-y-1) * rowstride,
|
||||||
|
temprow,
|
||||||
|
rowstride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1161,6 +1195,7 @@ clutter_stage_set_title (ClutterStage *stage,
|
|||||||
priv->title = g_strdup (title);
|
priv->title = g_strdup (title);
|
||||||
|
|
||||||
impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
impl = CLUTTER_STAGE_WINDOW (priv->impl);
|
||||||
|
if (CLUTTER_STAGE_WINDOW_GET_IFACE(impl)->set_title != NULL)
|
||||||
CLUTTER_STAGE_WINDOW_GET_IFACE (impl)->set_title (impl, priv->title);
|
CLUTTER_STAGE_WINDOW_GET_IFACE (impl)->set_title (impl, priv->title);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (stage), "title");
|
g_object_notify (G_OBJECT (stage), "title");
|
||||||
|
@ -30,7 +30,10 @@
|
|||||||
#include <clutter/clutter-group.h>
|
#include <clutter/clutter-group.h>
|
||||||
#include <clutter/clutter-color.h>
|
#include <clutter/clutter-color.h>
|
||||||
#include <clutter/clutter-event.h>
|
#include <clutter/clutter-event.h>
|
||||||
|
|
||||||
|
#ifdef USE_GDKPIXBUF
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ void clutter_stage_hide_cursor (ClutterStage *stage);
|
|||||||
ClutterActor *clutter_stage_get_actor_at_pos (ClutterStage *stage,
|
ClutterActor *clutter_stage_get_actor_at_pos (ClutterStage *stage,
|
||||||
gint x,
|
gint x,
|
||||||
gint y);
|
gint y);
|
||||||
GdkPixbuf * clutter_stage_snapshot (ClutterStage *stage,
|
guchar *clutter_stage_read_pixels (ClutterStage *stage,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#define _HAVE_CLUTTER_TEXTURE_H
|
#define _HAVE_CLUTTER_TEXTURE_H
|
||||||
|
|
||||||
#include <clutter/clutter-actor.h>
|
#include <clutter/clutter-actor.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <cogl/cogl.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -38,11 +38,16 @@ G_BEGIN_DECLS
|
|||||||
#define CLUTTER_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_TEXTURE))
|
#define CLUTTER_IS_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_TEXTURE))
|
||||||
#define CLUTTER_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_TEXTURE, ClutterTextureClass))
|
#define CLUTTER_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_TEXTURE, ClutterTextureClass))
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_TEXTURE_HANDLE (clutter_texture_handle_get_type ())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterTextureError:
|
* ClutterTextureError:
|
||||||
* @CLUTTER_TEXTURE_ERROR_OUT_OF_MEMORY: OOM condition
|
* @CLUTTER_TEXTURE_ERROR_OUT_OF_MEMORY: OOM condition
|
||||||
* @CLUTTER_TEXTURE_ERROR_NO_YUV: YUV operation attempted but no YUV support
|
* @CLUTTER_TEXTURE_ERROR_NO_YUV: YUV operation attempted but no YUV support
|
||||||
* found
|
* found
|
||||||
|
* @CLUTTER_TEXTURE_ERROR_BAD_FORMAT: The requested format for
|
||||||
|
* clutter_texture_set_from_rgb_data or
|
||||||
|
* clutter_texture_set_from_yuv_data is unsupported.
|
||||||
*
|
*
|
||||||
* Error enumeration for #ClutterTexture
|
* Error enumeration for #ClutterTexture
|
||||||
*
|
*
|
||||||
@ -50,7 +55,8 @@ G_BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CLUTTER_TEXTURE_ERROR_OUT_OF_MEMORY,
|
CLUTTER_TEXTURE_ERROR_OUT_OF_MEMORY,
|
||||||
CLUTTER_TEXTURE_ERROR_NO_YUV
|
CLUTTER_TEXTURE_ERROR_NO_YUV,
|
||||||
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT
|
||||||
} ClutterTextureError;
|
} ClutterTextureError;
|
||||||
|
|
||||||
#define CLUTTER_TEXTURE_ERROR (clutter_texture_error_quark ())
|
#define CLUTTER_TEXTURE_ERROR (clutter_texture_error_quark ())
|
||||||
@ -107,9 +113,14 @@ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/
|
|||||||
} ClutterTextureFlags;
|
} ClutterTextureFlags;
|
||||||
|
|
||||||
GType clutter_texture_get_type (void) G_GNUC_CONST;
|
GType clutter_texture_get_type (void) G_GNUC_CONST;
|
||||||
|
GType clutter_texture_handle_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
ClutterActor *clutter_texture_new (void);
|
ClutterActor *clutter_texture_new (void);
|
||||||
ClutterActor *clutter_texture_new_from_pixbuf (GdkPixbuf *pixbuf);
|
ClutterActor *clutter_texture_new_from_file (const gchar *filename,
|
||||||
|
GError **error);
|
||||||
|
gboolean clutter_texture_set_from_file (ClutterTexture *texture,
|
||||||
|
const gchar *filename,
|
||||||
|
GError **error);
|
||||||
gboolean clutter_texture_set_from_rgb_data (ClutterTexture *texture,
|
gboolean clutter_texture_set_from_rgb_data (ClutterTexture *texture,
|
||||||
const guchar *data,
|
const guchar *data,
|
||||||
gboolean has_alpha,
|
gboolean has_alpha,
|
||||||
@ -138,33 +149,19 @@ gboolean clutter_texture_set_from_yuv_data (ClutterTexture *texture,
|
|||||||
gint height,
|
gint height,
|
||||||
ClutterTextureFlags flags,
|
ClutterTextureFlags flags,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean clutter_texture_set_pixbuf (ClutterTexture *texture,
|
|
||||||
GdkPixbuf *pixbuf,
|
|
||||||
GError **error);
|
|
||||||
GdkPixbuf * clutter_texture_get_pixbuf (ClutterTexture *texture);
|
|
||||||
void clutter_texture_get_base_size (ClutterTexture *texture,
|
void clutter_texture_get_base_size (ClutterTexture *texture,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height);
|
gint *height);
|
||||||
|
void clutter_texture_set_filter_quality (ClutterTexture *texture,
|
||||||
|
guint filter_quality);
|
||||||
|
guint clutter_texture_get_filter_quality (ClutterTexture *texture);
|
||||||
|
void clutter_texture_set_max_tile_waste (ClutterTexture *texture,
|
||||||
|
gint max_tile_waste);
|
||||||
|
gint clutter_texture_get_max_tile_waste (ClutterTexture *texture);
|
||||||
|
|
||||||
/* Below mainly for subclassed texture based actors */
|
CoglHandle clutter_texture_get_cogl_texture (ClutterTexture *texture);
|
||||||
|
void clutter_texture_set_cogl_texture (ClutterTexture *texture,
|
||||||
void clutter_texture_bind_tile (ClutterTexture *texture,
|
CoglHandle cogl_tex);
|
||||||
gint index_);
|
|
||||||
void clutter_texture_get_n_tiles (ClutterTexture *texture,
|
|
||||||
gint *n_x_tiles,
|
|
||||||
gint *n_y_tiles);
|
|
||||||
void clutter_texture_get_x_tile_detail (ClutterTexture *texture,
|
|
||||||
gint x_index,
|
|
||||||
gint *pos,
|
|
||||||
gint *size,
|
|
||||||
gint *waste);
|
|
||||||
void clutter_texture_get_y_tile_detail (ClutterTexture *texture,
|
|
||||||
gint y_index,
|
|
||||||
gint *pos,
|
|
||||||
gint *size,
|
|
||||||
gint *waste);
|
|
||||||
gboolean clutter_texture_has_generated_tiles (ClutterTexture *texture);
|
|
||||||
gboolean clutter_texture_is_tiled (ClutterTexture *texture);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = $(CLUTTER_COGL)
|
SUBDIRS = common $(CLUTTER_COGL)
|
||||||
|
|
||||||
EXTRA_DIST = cogl.h
|
EXTRA_DIST = cogl.h
|
||||||
|
|
||||||
|
25
clutter/cogl/TODO
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
============================
|
||||||
|
Cogl overhaul related tasks:
|
||||||
|
============================
|
||||||
|
|
||||||
|
MISC
|
||||||
|
|
||||||
|
- implemenent a 1 to 1 mapping of COGL_FEATURE flags
|
||||||
|
into CLUTTER_FEATURE flags before combining them
|
||||||
|
into final clutter flags value (clutter-feature.c)
|
||||||
|
|
||||||
|
TEXTURE
|
||||||
|
|
||||||
|
- cogl_texture_get_data, cogl_texture_set_region in GLES
|
||||||
|
|
||||||
|
- YUV texture format support (multitexturing + shader)
|
||||||
|
|
||||||
|
FBO
|
||||||
|
|
||||||
|
- add stencil, depth and other renderbuffers to fbos
|
||||||
|
|
||||||
|
- cogl_offscreen_new_multisample
|
||||||
|
|
||||||
|
- test cogl_offscreen_blit
|
||||||
|
|
||||||
|
- add "filter" argument to cogl_offscreen_blit
|
@ -1,290 +0,0 @@
|
|||||||
/*
|
|
||||||
* Clutter COGL
|
|
||||||
*
|
|
||||||
* A basic GL/GLES Abstraction/Utility Layer
|
|
||||||
*
|
|
||||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 OpenedHand
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* COGL
|
|
||||||
* ====
|
|
||||||
*
|
|
||||||
* 'cogl' is a very simple abstraction layer which wraps GL and GLES.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* !!!! DO NOT USE THIS API YET OUTSIDE OF CLUTTER CORE !!!!
|
|
||||||
* THE API WILL FLUCTUATE WILDLY
|
|
||||||
*
|
|
||||||
* TODO:
|
|
||||||
* - Use ClutterReal for fixed/float params.
|
|
||||||
* - Add Perspective/viewport setup
|
|
||||||
* - Add Features..
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __COGL_H__
|
|
||||||
#define __COGL_H__
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <clutter/clutter-color.h>
|
|
||||||
#include <clutter/clutter-feature.h>
|
|
||||||
#include <clutter/clutter-fixed.h>
|
|
||||||
#include <clutter/clutter-types.h>
|
|
||||||
|
|
||||||
#include "cogl-defines.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define CGL_ENABLE_BLEND (1<<1)
|
|
||||||
#define CGL_ENABLE_TEXTURE_2D (1<<2)
|
|
||||||
#define CGL_ENABLE_ALPHA_TEST (1<<3)
|
|
||||||
#define CGL_ENABLE_TEXTURE_RECT (1<<4)
|
|
||||||
|
|
||||||
typedef void (*CoglFuncPtr) (void);
|
|
||||||
|
|
||||||
CoglFuncPtr
|
|
||||||
cogl_get_proc_address (const gchar* name);
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
cogl_check_extension (const gchar *name, const gchar *ext);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_perspective (ClutterFixed fovy,
|
|
||||||
ClutterFixed aspect,
|
|
||||||
ClutterFixed zNear,
|
|
||||||
ClutterFixed zFar);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_setup_viewport (guint width,
|
|
||||||
guint height,
|
|
||||||
ClutterFixed fovy,
|
|
||||||
ClutterFixed aspect,
|
|
||||||
ClutterFixed z_near,
|
|
||||||
ClutterFixed z_far);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_paint_init (const ClutterColor *color);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_push_matrix (void);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_pop_matrix (void);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_scale (ClutterFixed x, ClutterFixed z);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_translate (gint x, gint y, gint z);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_rotatex (ClutterFixed angle, gint x, gint y, gint z);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_rotate (gint angle, gint x, gint y, gint z);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_color (const ClutterColor *color);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_clip_set (ClutterFixed x_offset,
|
|
||||||
ClutterFixed y_offset,
|
|
||||||
ClutterFixed width,
|
|
||||||
ClutterFixed height);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_clip_unset (void);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_enable (gulong flags);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_enable_depth_test (gboolean setting);
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
cogl_texture_can_size (COGLenum target,
|
|
||||||
COGLenum pixel_format,
|
|
||||||
COGLenum pixel_type,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_quad (gint x1,
|
|
||||||
gint x2,
|
|
||||||
gint y1,
|
|
||||||
gint y2,
|
|
||||||
ClutterFixed tx1,
|
|
||||||
ClutterFixed ty1,
|
|
||||||
ClutterFixed tx2,
|
|
||||||
ClutterFixed ty2);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_create (guint num, COGLuint *textures);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_destroy (guint num, const COGLuint *textures);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_bind (COGLenum target, COGLuint texture);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_alignment (COGLenum target,
|
|
||||||
guint alignment,
|
|
||||||
guint row_length);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_filters (COGLenum target,
|
|
||||||
COGLenum min_filter,
|
|
||||||
COGLenum max_filter);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_wrap (COGLenum target,
|
|
||||||
COGLenum wrap_s,
|
|
||||||
COGLenum wrap_t);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_image_2d (COGLenum target,
|
|
||||||
COGLint internal_format,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_sub_image_2d (COGLenum target,
|
|
||||||
gint xoff,
|
|
||||||
gint yoff,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_rectangle (gint x, gint y, guint width, guint height);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_trapezoid (gint y1,
|
|
||||||
gint x11,
|
|
||||||
gint x21,
|
|
||||||
gint y2,
|
|
||||||
gint x12,
|
|
||||||
gint x22);
|
|
||||||
void
|
|
||||||
cogl_alpha_func (COGLenum func,
|
|
||||||
ClutterFixed ref);
|
|
||||||
|
|
||||||
ClutterFeatureFlags
|
|
||||||
cogl_get_features ();
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_get_modelview_matrix (ClutterFixed m[16]);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_get_projection_matrix (ClutterFixed m[16]);
|
|
||||||
|
|
||||||
void
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
COGLhandle
|
|
||||||
cogl_create_shader (COGLenum shaderType);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_shader_destroy (COGLhandle handle);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_shader_source (COGLhandle shader,
|
|
||||||
const gchar *source);
|
|
||||||
void
|
|
||||||
cogl_shader_compile (COGLhandle shader_handle);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_shader_get_info_log (COGLhandle handle,
|
|
||||||
guint size,
|
|
||||||
gchar *buffer);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_shader_get_parameteriv (COGLhandle handle,
|
|
||||||
COGLenum pname,
|
|
||||||
COGLint *dest);
|
|
||||||
|
|
||||||
|
|
||||||
COGLhandle
|
|
||||||
cogl_create_program (void);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_program_destroy (COGLhandle handle);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_program_attach_shader (COGLhandle program_handle,
|
|
||||||
COGLhandle shader_handle);
|
|
||||||
|
|
||||||
/* 0 to use none */
|
|
||||||
void
|
|
||||||
cogl_program_link (COGLhandle program_handle);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_program_use (COGLhandle program_handle);
|
|
||||||
|
|
||||||
COGLint
|
|
||||||
cogl_program_get_uniform_location (COGLhandle program_int,
|
|
||||||
const gchar *uniform_name);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_program_uniform_1f (COGLint uniform_no,
|
|
||||||
gfloat value);
|
|
||||||
|
|
||||||
/* Offscreen - FBO support */
|
|
||||||
|
|
||||||
COGLuint
|
|
||||||
cogl_offscreen_create (COGLuint target_texture);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_destroy (COGLuint offscreen_handle);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_start (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height);
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_end (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __COGL_H__ */
|
|
874
clutter/cogl/cogl.h.in
Normal file
@ -0,0 +1,874 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COGL
|
||||||
|
* ====
|
||||||
|
*
|
||||||
|
* 'cogl' is a very simple abstraction layer which wraps GL and GLES.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* !!!! DO NOT USE THIS API YET OUTSIDE OF CLUTTER CORE !!!!
|
||||||
|
* THE API WILL FLUCTUATE WILDLY
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - Use ClutterReal for fixed/float params.
|
||||||
|
* - Add Perspective/viewport setup
|
||||||
|
* - Add Features..
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_H__
|
||||||
|
#define __COGL_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <clutter/clutter-color.h>
|
||||||
|
#include <clutter/clutter-feature.h>
|
||||||
|
#include <clutter/clutter-fixed.h>
|
||||||
|
#include <clutter/clutter-types.h>
|
||||||
|
|
||||||
|
#include <cogl/cogl-defines-@CLUTTER_COGL@.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Enum declarations */
|
||||||
|
|
||||||
|
#define COGL_PIXEL_FORMAT_24 2
|
||||||
|
#define COGL_PIXEL_FORMAT_32 3
|
||||||
|
#define COGL_A_BIT (1 << 4)
|
||||||
|
#define COGL_BGR_BIT (1 << 5)
|
||||||
|
#define COGL_AFIRST_BIT (1 << 6)
|
||||||
|
#define COGL_PREMULT_BIT (1 << 7)
|
||||||
|
#define COGL_UNORDERED_MASK 0x0F
|
||||||
|
#define COGL_UNPREMULT_MASK 0x7F
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglPixelFormat:
|
||||||
|
* @COGL_PIXEL_FORMAT_ANY:
|
||||||
|
* @COGL_PIXEL_FORMAT_A_8:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGB_888:
|
||||||
|
* @COGL_PIXEL_FORMAT_BGR_888:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
* @COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
|
* @COGL_PIXEL_FORMAT_ARGB_8888:
|
||||||
|
* @COGL_PIXEL_FORMAT_ABGR_8888:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_ARGB_8888_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_ABGR_8888_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGB_565:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_4444:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_5551:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_4444_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_RGBA_5551_PRE:
|
||||||
|
* @COGL_PIXEL_FORMAT_YUV:
|
||||||
|
* @COGL_PIXEL_FORMAT_G_8:
|
||||||
|
*
|
||||||
|
* Pixel formats used by COGL.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COGL_PIXEL_FORMAT_ANY = 0,
|
||||||
|
COGL_PIXEL_FORMAT_A_8 = 1 | COGL_A_BIT,
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24,
|
||||||
|
COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 | COGL_BGR_BIT),
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_8888 = COGL_PIXEL_FORMAT_32 | COGL_A_BIT,
|
||||||
|
COGL_PIXEL_FORMAT_BGRA_8888 = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_ARGB_8888 = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_AFIRST_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_ABGR_8888 = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_BGRA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_ARGB_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_ABGR_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_RGB_565 = 4,
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_4444 = 5 | COGL_A_BIT,
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_YUV = 7,
|
||||||
|
|
||||||
|
COGL_PIXEL_FORMAT_G_8 = 8
|
||||||
|
|
||||||
|
} CoglPixelFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglFeatureFlags:
|
||||||
|
* @COGL_FEATURE_TEXTURE_RECTANGLE:
|
||||||
|
* @COGL_FEATURE_TEXTURE_NPOT:
|
||||||
|
* @COGL_FEATURE_TEXTURE_YUV:
|
||||||
|
* @COGL_FEATURE_TEXTURE_READ_PIXELS:
|
||||||
|
* @COGL_FEATURE_SHADERS_GLSL:
|
||||||
|
* @COGL_FEATURE_OFFSCREEN:
|
||||||
|
* @COGL_FEATURE_OFFSCREEN_MULTISAMPLE:
|
||||||
|
* @COGL_FEATURE_OFFSCREEN_BLIT:
|
||||||
|
* @COGL_FEATURE_FOUR_CLIP_PLANES:
|
||||||
|
* @COGL_FEATURE_STENCIL_BUFFER:
|
||||||
|
*
|
||||||
|
* Flags for the supported features.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COGL_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
|
||||||
|
COGL_FEATURE_TEXTURE_NPOT = (1 << 2),
|
||||||
|
COGL_FEATURE_TEXTURE_YUV = (1 << 3),
|
||||||
|
COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4),
|
||||||
|
COGL_FEATURE_SHADERS_GLSL = (1 << 5),
|
||||||
|
COGL_FEATURE_OFFSCREEN = (1 << 6),
|
||||||
|
COGL_FEATURE_OFFSCREEN_MULTISAMPLE = (1 << 7),
|
||||||
|
COGL_FEATURE_OFFSCREEN_BLIT = (1 << 8),
|
||||||
|
COGL_FEATURE_FOUR_CLIP_PLANES = (1 << 9),
|
||||||
|
COGL_FEATURE_STENCIL_BUFFER = (1 << 10)
|
||||||
|
|
||||||
|
} CoglFeatureFlags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglBufferTarget:
|
||||||
|
* @COGL_WINDOW_BUFFER:
|
||||||
|
* @COGL_MASK_BUFFER:
|
||||||
|
* @COGL_OFFSCREEN_BUFFER:
|
||||||
|
*
|
||||||
|
* FIXME
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COGL_WINDOW_BUFFER = (1 << 1),
|
||||||
|
COGL_MASK_BUFFER = (1 << 2),
|
||||||
|
COGL_OFFSCREEN_BUFFER = (1 << 3)
|
||||||
|
|
||||||
|
} CoglBufferTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglTextureVertex:
|
||||||
|
* @x: Model x-coordinate
|
||||||
|
* @y: Model y-coordinate
|
||||||
|
* @z: Model z-coordinate
|
||||||
|
* @tx: Texture x-coordinate
|
||||||
|
* @ty: Texture y-coordinate
|
||||||
|
* @color: The color to use at this vertex. This is ignored if
|
||||||
|
* @use_color is %FALSE when calling cogl_texture_polygon().
|
||||||
|
*
|
||||||
|
* Used to specify vertex information when calling cogl_texture_polygon().
|
||||||
|
*/
|
||||||
|
struct _CoglTextureVertex
|
||||||
|
{
|
||||||
|
ClutterFixed x, y, z;
|
||||||
|
ClutterFixed tx, ty;
|
||||||
|
ClutterColor color;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _CoglTextureVertex CoglTextureVertex;
|
||||||
|
|
||||||
|
/* Context manipulation */
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_create_context (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_destroy_context (void);
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
|
#define COGL_INVALID_HANDLE NULL
|
||||||
|
|
||||||
|
typedef gpointer CoglHandle;
|
||||||
|
|
||||||
|
typedef void (* CoglFuncPtr) (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_features:
|
||||||
|
*
|
||||||
|
* Returns all of the features supported by COGL.
|
||||||
|
*
|
||||||
|
* Return value: A logical OR of all the supported COGL features.
|
||||||
|
*
|
||||||
|
* Since: 0.8
|
||||||
|
*/
|
||||||
|
ClutterFeatureFlags
|
||||||
|
cogl_get_features (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_features_available:
|
||||||
|
* @features: A bitmask of features to check for
|
||||||
|
*
|
||||||
|
* Checks whether the given COGL features are available. Multiple
|
||||||
|
* features can be checked for by or-ing them together with the '|'
|
||||||
|
* operator. %TRUE is only returned if all of the requested features
|
||||||
|
* are available.
|
||||||
|
*
|
||||||
|
* Return value: %TRUE if the features are available, %FALSE otherwise.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
cogl_features_available (CoglFeatureFlags features);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_proc_address:
|
||||||
|
* @name: the name of the function.
|
||||||
|
*
|
||||||
|
* Gets a pointer to a given GL or GL ES extension function. This acts
|
||||||
|
* as a wrapper around glXGetProcAddress() or whatever is the
|
||||||
|
* appropriate function for the current backend.
|
||||||
|
*
|
||||||
|
* Return value: a pointer to the requested function or %NULL if the
|
||||||
|
* function is not available.
|
||||||
|
*/
|
||||||
|
CoglFuncPtr
|
||||||
|
cogl_get_proc_address (const gchar* name);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_check_extension (const gchar *name,
|
||||||
|
const gchar *ext);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_bitmasks:
|
||||||
|
* @red: Return location for the number of red bits or %NULL
|
||||||
|
* @green: Return location for the number of green bits or %NULL
|
||||||
|
* @blue: Return location for the number of blue bits or %NULL
|
||||||
|
* @alpha: Return location for the number of alpha bits or %NULL
|
||||||
|
*
|
||||||
|
* Gets the number of bitplanes used for each of the color components
|
||||||
|
* in the color buffer. Pass %NULL for any of the arguments if the
|
||||||
|
* value is not required.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_get_bitmasks (gint *red,
|
||||||
|
gint *green,
|
||||||
|
gint *blue,
|
||||||
|
gint *alpha);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_perspective (ClutterFixed fovy,
|
||||||
|
ClutterFixed aspect,
|
||||||
|
ClutterFixed zNear,
|
||||||
|
ClutterFixed zFar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_setup_viewport:
|
||||||
|
* @width: Width of the viewport
|
||||||
|
* @height: Height of the viewport
|
||||||
|
* @fovy: Field of view angle in degrees
|
||||||
|
* @aspect: Aspect ratio to determine the field of view along the x-axis
|
||||||
|
* @z_near: Nearest visible point along the z-axis
|
||||||
|
* @z_far: Furthest visible point along the z-axis
|
||||||
|
*
|
||||||
|
* Replaces the current viewport and projection matrix with the given
|
||||||
|
* values. The viewport is placed at the top left corner of the window
|
||||||
|
* with the given width and height. The projection matrix is replaced
|
||||||
|
* with one that has a viewing angle of @fovy along the y-axis and a
|
||||||
|
* view scaled according to @aspect along the x-axis. The view is
|
||||||
|
* clipped according to @z_near and @z_far on the z-axis.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_setup_viewport (guint width,
|
||||||
|
guint height,
|
||||||
|
ClutterFixed fovy,
|
||||||
|
ClutterFixed aspect,
|
||||||
|
ClutterFixed z_near,
|
||||||
|
ClutterFixed z_far);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_push_matrix:
|
||||||
|
*
|
||||||
|
* Store the current model-view matrix on the matrix stack. The matrix
|
||||||
|
* can later be restored with cogl_pop_matrix().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_push_matrix (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_pop_matrix:
|
||||||
|
*
|
||||||
|
* Restore the current model-view matrix from the matrix stack.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_pop_matrix (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_scale:
|
||||||
|
* @x: Amount to scale along the x-axis
|
||||||
|
* @y: Amount to scale along the y-axis
|
||||||
|
*
|
||||||
|
* Multiplies the current model-view matrix by one that scales the x
|
||||||
|
* and y axes by the given values.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_scale (ClutterFixed x, ClutterFixed y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_translatex:
|
||||||
|
* @x: Distance to translate along the x-axis
|
||||||
|
* @y: Distance to translate along the y-axis
|
||||||
|
* @z: Distance to translate along the z-axis
|
||||||
|
*
|
||||||
|
* Multiplies the current model-view matrix by one that translates the
|
||||||
|
* model along all three axes according to the given values.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_translate:
|
||||||
|
* @x: Distance to translate along the x-axis
|
||||||
|
* @y: Distance to translate along the y-axis
|
||||||
|
* @z: Distance to translate along the z-axis
|
||||||
|
*
|
||||||
|
* Integer version of cogl_translatex(). Multiplies the current
|
||||||
|
* model-view matrix by one that translates the model along all three
|
||||||
|
* axes according to the given values.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_translate (gint x, gint y, gint z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_rotatex:
|
||||||
|
* @angle: Angle in degrees to rotate.
|
||||||
|
* @x: X-component of vertex to rotate around.
|
||||||
|
* @y: Y-component of vertex to rotate around.
|
||||||
|
* @z: Z-component of vertex to rotate around.
|
||||||
|
*
|
||||||
|
* Multiplies the current model-view matrix by one that rotates the
|
||||||
|
* model around the vertex specified by @x, @y and @z. The rotation
|
||||||
|
* follows the right-hand thumb rule so for example rotating by 10
|
||||||
|
* degrees about the vertex (0, 0, 1) causes a small counter-clockwise
|
||||||
|
* rotation.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_rotatex (ClutterFixed angle, gint x, gint y, gint z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_rotate:
|
||||||
|
* @angle: Angle in degrees to rotate.
|
||||||
|
* @x: X-component of vertex to rotate around.
|
||||||
|
* @y: Y-component of vertex to rotate around.
|
||||||
|
* @z: Z-component of vertex to rotate around.
|
||||||
|
*
|
||||||
|
* Integer version of cogl_rotatex(). Multiplies the current
|
||||||
|
* model-view matrix by one that rotates the model around the vertex
|
||||||
|
* specified by @x, @y and @z.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_rotate (gint angle, gint x, gint y, gint z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_modelview_matrix:
|
||||||
|
* @m: pointer to a 4x4 array of #ClutterFixed<!-- -->s to receive the matrix
|
||||||
|
*
|
||||||
|
* Stores the current model-view matrix in @m. The matrix is in
|
||||||
|
* column-major order.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_get_modelview_matrix (ClutterFixed m[16]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_projection_matrix:
|
||||||
|
* @m: pointer to a 4x4 array of #ClutterFixed<!-- -->s to receive the matrix
|
||||||
|
*
|
||||||
|
* Stores the current projection matrix in @m. The matrix is in
|
||||||
|
* column-major order.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_get_projection_matrix (ClutterFixed m[16]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_get_viewport:
|
||||||
|
* @v: pointer to a 4 element array of #ClutterFixed<!-- -->s to
|
||||||
|
* receive the viewport dimensions.
|
||||||
|
*
|
||||||
|
* Stores the current viewport in @v. @v[0] and @v[1] get the x and y
|
||||||
|
* position of the viewport and @v[2] and @v[3] get the width and
|
||||||
|
* height.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_get_viewport (ClutterFixed v[4]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_clip_set:
|
||||||
|
* @x_offset: left edge of the clip rectangle
|
||||||
|
* @y_offset: top edge of the clip rectangle
|
||||||
|
* @width: width of the clip rectangle
|
||||||
|
* @height: height of the clip rectangle
|
||||||
|
*
|
||||||
|
* Specifies a rectangular clipping area for all subsequent drawing
|
||||||
|
* operations. Any drawing commands that extend outside the rectangle
|
||||||
|
* will be clipped so that only the portion inside the rectangle will
|
||||||
|
* be displayed. The rectangle dimensions are transformed by the
|
||||||
|
* current model-view matrix.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_clip_set (ClutterFixed x_offset,
|
||||||
|
ClutterFixed y_offset,
|
||||||
|
ClutterFixed width,
|
||||||
|
ClutterFixed height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_clip_unset:
|
||||||
|
*
|
||||||
|
* Removes the current clipping rectangle so that all drawing
|
||||||
|
* operations extend to full size of the viewport again.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_clip_unset (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_enable_depth_test:
|
||||||
|
* @setting: %TRUE to enable depth testing or %FALSE to disable.
|
||||||
|
*
|
||||||
|
* Sets whether depth testing is enabled. If it is disabled then the
|
||||||
|
* order that actors are layered on the screen depends solely on the
|
||||||
|
* order specified using clutter_actor_raise() and
|
||||||
|
* clutter_actor_lower(), otherwise it will also take into account the
|
||||||
|
* actor's depth. Depth testing is disabled by default.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_enable_depth_test (gboolean setting);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_alpha_func (COGLenum func,
|
||||||
|
ClutterFixed ref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_fog_set:
|
||||||
|
* @fog_color: The color of the fog
|
||||||
|
* @density: Ignored
|
||||||
|
* @z_near: Position along z-axis where no fogging should be applied
|
||||||
|
* @z_far: Position along z-axes where full fogging should be applied
|
||||||
|
*
|
||||||
|
* Enables fogging. Fogging causes vertices that are further away from
|
||||||
|
* the eye to be rendered with a different color. The color is
|
||||||
|
* linearly interpolated so that vertices at @z_near are drawn fully
|
||||||
|
* with their original color and vertices at @z_far are drawn fully
|
||||||
|
* with @fog_color. Fogging will remain enabled until the next call to
|
||||||
|
* cogl_paint_init().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_fog_set (const ClutterColor *fog_color,
|
||||||
|
ClutterFixed density,
|
||||||
|
ClutterFixed z_near,
|
||||||
|
ClutterFixed z_far);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_paint_init:
|
||||||
|
* @color: Background color to clear to
|
||||||
|
*
|
||||||
|
* Clears the color buffer to @color. The depth buffer and stencil
|
||||||
|
* buffers are also cleared and fogging and lighting are disabled.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_paint_init (const ClutterColor *color);
|
||||||
|
|
||||||
|
/* Textures api */
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_new_with_size (guint width,
|
||||||
|
guint height,
|
||||||
|
gint max_waste,
|
||||||
|
CoglPixelFormat internal_format);
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_new_from_file (const gchar *filename,
|
||||||
|
gint max_waste,
|
||||||
|
CoglPixelFormat internal_format,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_new_from_data (guint width,
|
||||||
|
guint height,
|
||||||
|
gint max_waste,
|
||||||
|
CoglPixelFormat format,
|
||||||
|
CoglPixelFormat internal_format,
|
||||||
|
guint rowstride,
|
||||||
|
const guchar *data);
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_new_from_foreign (GLuint gl_handle,
|
||||||
|
GLenum gl_target,
|
||||||
|
GLuint width,
|
||||||
|
GLuint height,
|
||||||
|
GLuint x_pot_waste,
|
||||||
|
GLuint y_pot_waste,
|
||||||
|
CoglPixelFormat format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_is_texture:
|
||||||
|
* @handle: A CoglHandle
|
||||||
|
*
|
||||||
|
* Gets whether the given handle references an existing texture object.
|
||||||
|
*
|
||||||
|
* Return value: %TRUE if the handle references a texture,
|
||||||
|
* %FALSE otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
cogl_is_texture (CoglHandle handle);
|
||||||
|
|
||||||
|
guint
|
||||||
|
cogl_texture_get_width (CoglHandle handle);
|
||||||
|
|
||||||
|
guint
|
||||||
|
cogl_texture_get_height (CoglHandle handle);
|
||||||
|
|
||||||
|
CoglPixelFormat
|
||||||
|
cogl_texture_get_format (CoglHandle handle);
|
||||||
|
|
||||||
|
guint
|
||||||
|
cogl_texture_get_rowstride (CoglHandle handle);
|
||||||
|
|
||||||
|
gint
|
||||||
|
cogl_texture_get_max_waste (CoglHandle handle);
|
||||||
|
|
||||||
|
COGLenum
|
||||||
|
cogl_texture_get_min_filter (CoglHandle handle);
|
||||||
|
|
||||||
|
COGLenum
|
||||||
|
cogl_texture_get_mag_filter (CoglHandle handle);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_texture_is_sliced (CoglHandle handle);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_texture_get_gl_texture (CoglHandle handle,
|
||||||
|
GLuint *out_gl_handle,
|
||||||
|
GLenum *out_gl_target);
|
||||||
|
|
||||||
|
gint
|
||||||
|
cogl_texture_get_data (CoglHandle handle,
|
||||||
|
CoglPixelFormat format,
|
||||||
|
guint rowstride,
|
||||||
|
guchar *data);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_texture_set_filters (CoglHandle handle,
|
||||||
|
COGLenum min_filter,
|
||||||
|
COGLenum mag_filter);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_texture_set_region (CoglHandle handle,
|
||||||
|
gint src_x,
|
||||||
|
gint src_y,
|
||||||
|
gint dst_x,
|
||||||
|
gint dst_y,
|
||||||
|
guint dst_width,
|
||||||
|
guint dst_height,
|
||||||
|
gint width,
|
||||||
|
gint height,
|
||||||
|
CoglPixelFormat format,
|
||||||
|
guint rowstride,
|
||||||
|
const guchar *data);
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_ref (CoglHandle handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_texture_unref (CoglHandle handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_texture_rectangle (CoglHandle handle,
|
||||||
|
ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2,
|
||||||
|
ClutterFixed tx1,
|
||||||
|
ClutterFixed ty1,
|
||||||
|
ClutterFixed tx2,
|
||||||
|
ClutterFixed ty2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_texture_polygon:
|
||||||
|
* @handle: A CoglHandle for a texture
|
||||||
|
* @n_vertices: The length of the vertices array
|
||||||
|
* @vertices: An array of #CoglTextureVertex structs
|
||||||
|
* @use_color: %TRUE if the color member of #CoglTextureVertex should be used
|
||||||
|
*
|
||||||
|
* Draws a polygon from a texture with the given model and texture
|
||||||
|
* coordinates. This can be used to draw arbitrary shapes textured
|
||||||
|
* with a COGL texture. If @use_color is %TRUE then the current COGL
|
||||||
|
* color will be changed for each vertex using the value specified in
|
||||||
|
* the color member of #CoglTextureVertex. This can be used for
|
||||||
|
* example to make the texture fade out by setting the alpha value of
|
||||||
|
* the color.
|
||||||
|
*
|
||||||
|
* All of the texture coordinates must be in the range [0,1] and
|
||||||
|
* repeating the texture is not supported.
|
||||||
|
*
|
||||||
|
* Because of the way this function is implemented it will currently
|
||||||
|
* only work if either the texture is not sliced or the backend is not
|
||||||
|
* OpenGL ES and the minifying and magnifying functions are both set
|
||||||
|
* to CGL_NEAREST.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_texture_polygon (CoglHandle handle,
|
||||||
|
guint n_vertices,
|
||||||
|
CoglTextureVertex *vertices,
|
||||||
|
gboolean use_color);
|
||||||
|
|
||||||
|
/* Primitives API */
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_color (const ClutterColor *color);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_fast_fill_rectangle (gint x,
|
||||||
|
gint y,
|
||||||
|
guint width,
|
||||||
|
guint height);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_fast_fill_rectanglex (ClutterFixed x,
|
||||||
|
ClutterFixed y,
|
||||||
|
ClutterFixed width,
|
||||||
|
ClutterFixed height);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_fast_fill_trapezoid (gint y1,
|
||||||
|
gint x11,
|
||||||
|
gint x21,
|
||||||
|
gint y2,
|
||||||
|
gint x12,
|
||||||
|
gint x22);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_fast_fill_trapezoidx (ClutterFixed y1,
|
||||||
|
ClutterFixed x11,
|
||||||
|
ClutterFixed x21,
|
||||||
|
ClutterFixed y2,
|
||||||
|
ClutterFixed x12,
|
||||||
|
ClutterFixed x22);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_fill ();
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_stroke ();
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_move_to (ClutterFixed x,
|
||||||
|
ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_move_to_rel (ClutterFixed x,
|
||||||
|
ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_line_to (ClutterFixed x,
|
||||||
|
ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_line_to_rel (ClutterFixed x,
|
||||||
|
ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_h_line_to (ClutterFixed x);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_v_line_to (ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_h_line_to_rel (ClutterFixed x);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_v_line_to_rel (ClutterFixed y);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_arc (ClutterFixed center_x,
|
||||||
|
ClutterFixed center_y,
|
||||||
|
ClutterFixed radius_x,
|
||||||
|
ClutterFixed radius_y,
|
||||||
|
ClutterAngle angle_1,
|
||||||
|
ClutterAngle angle_2,
|
||||||
|
ClutterAngle angle_step);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_arc_rel (ClutterFixed center_x,
|
||||||
|
ClutterFixed center_y,
|
||||||
|
ClutterFixed radius_x,
|
||||||
|
ClutterFixed radius_y,
|
||||||
|
ClutterAngle angle_1,
|
||||||
|
ClutterAngle angle_2,
|
||||||
|
ClutterAngle angle_step);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_bezier2_to (ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_bezier2_to_rel (ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_bezier3_to (ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2,
|
||||||
|
ClutterFixed x3,
|
||||||
|
ClutterFixed y3);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_bezier3_to_rel (ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2,
|
||||||
|
ClutterFixed x3,
|
||||||
|
ClutterFixed y3);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_path_close ();
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_line (ClutterFixed x1,
|
||||||
|
ClutterFixed y1,
|
||||||
|
ClutterFixed x2,
|
||||||
|
ClutterFixed y2);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_polyline (ClutterFixed *coords,
|
||||||
|
gint num_points);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_polygon (ClutterFixed *coords,
|
||||||
|
gint num_points);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_rectangle (ClutterFixed x,
|
||||||
|
ClutterFixed y,
|
||||||
|
ClutterFixed width,
|
||||||
|
ClutterFixed height);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_arc (ClutterFixed center_x,
|
||||||
|
ClutterFixed center_y,
|
||||||
|
ClutterFixed radius_x,
|
||||||
|
ClutterFixed radius_y,
|
||||||
|
ClutterAngle angle_1,
|
||||||
|
ClutterAngle angle_2,
|
||||||
|
ClutterAngle angle_step);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_ellipse (ClutterFixed center_x,
|
||||||
|
ClutterFixed center_y,
|
||||||
|
ClutterFixed radius_x,
|
||||||
|
ClutterFixed radius_y,
|
||||||
|
ClutterAngle angle_step);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_round_rectangle (ClutterFixed x,
|
||||||
|
ClutterFixed y,
|
||||||
|
ClutterFixed width,
|
||||||
|
ClutterFixed height,
|
||||||
|
ClutterFixed radius,
|
||||||
|
ClutterAngle arc_step);
|
||||||
|
|
||||||
|
|
||||||
|
COGLhandle
|
||||||
|
cogl_create_shader (COGLenum shaderType);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_shader_destroy (COGLhandle handle);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_shader_source (COGLhandle shader,
|
||||||
|
const gchar *source);
|
||||||
|
void
|
||||||
|
cogl_shader_compile (COGLhandle shader_handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_shader_get_info_log (COGLhandle handle,
|
||||||
|
guint size,
|
||||||
|
gchar *buffer);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_shader_get_parameteriv (COGLhandle handle,
|
||||||
|
COGLenum pname,
|
||||||
|
COGLint *dest);
|
||||||
|
|
||||||
|
|
||||||
|
COGLhandle
|
||||||
|
cogl_create_program (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_program_destroy (COGLhandle handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_program_attach_shader (COGLhandle program_handle,
|
||||||
|
COGLhandle shader_handle);
|
||||||
|
|
||||||
|
/* 0 to use none */
|
||||||
|
void
|
||||||
|
cogl_program_link (COGLhandle program_handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_program_use (COGLhandle program_handle);
|
||||||
|
|
||||||
|
COGLint
|
||||||
|
cogl_program_get_uniform_location (COGLhandle program_int,
|
||||||
|
const gchar *uniform_name);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_program_uniform_1f (COGLint uniform_no,
|
||||||
|
gfloat value);
|
||||||
|
|
||||||
|
/* Offscreen api */
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_to_texture (CoglHandle texhandle);
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_multisample ();
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_ref (CoglHandle handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_unref (CoglHandle handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int src_w,
|
||||||
|
int src_h,
|
||||||
|
int dst_x,
|
||||||
|
int dst_y,
|
||||||
|
int dst_w,
|
||||||
|
int dst_h);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __COGL_H__ */
|
23
clutter/cogl/common/Makefile.am
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
INCLUDES = \
|
||||||
|
-I$(top_srcdir) \
|
||||||
|
-I$(top_srcdir)/clutter \
|
||||||
|
-I$(top_srcdir)/clutter/cogl \
|
||||||
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
|
-I$(top_builddir)/clutter \
|
||||||
|
-I$(top_builddir)/clutter/cogl \
|
||||||
|
$(CLUTTER_CFLAGS) \
|
||||||
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
|
$(GCC_FLAGS)
|
||||||
|
|
||||||
|
LDADD = $(CLUTTER_LIBS)
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libclutter-cogl-common.la
|
||||||
|
EXTRA_DIST = stb_image.c
|
||||||
|
|
||||||
|
libclutter_cogl_common_la_SOURCES = \
|
||||||
|
cogl-util.h \
|
||||||
|
cogl-bitmap.h \
|
||||||
|
cogl-util.c \
|
||||||
|
cogl-bitmap.c \
|
||||||
|
cogl-bitmap-fallback.c \
|
||||||
|
cogl-bitmap-pixbuf.c
|
369
clutter/cogl/common/cogl-bitmap-fallback.c
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-bitmap.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* TO rgba */
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_g_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
dst[1] = src[0];
|
||||||
|
dst[2] = src[0];
|
||||||
|
dst[3] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgb_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[2];
|
||||||
|
dst[3] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_bgr_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[2];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[0];
|
||||||
|
dst[3] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_bgra_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[2];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[0];
|
||||||
|
dst[3] = src[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_argb_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[1];
|
||||||
|
dst[1] = src[2];
|
||||||
|
dst[2] = src[3];
|
||||||
|
dst[3] = src[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_abgr_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[3];
|
||||||
|
dst[1] = src[2];
|
||||||
|
dst[2] = src[1];
|
||||||
|
dst[3] = src[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_rgba (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[2];
|
||||||
|
dst[3] = src[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FROM rgba */
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_g (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = (src[0] + src[1] + src[2]) / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_rgb (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_bgr (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[2];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_bgra (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[2];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[0];
|
||||||
|
dst[3] = src[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_argb (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[3];
|
||||||
|
dst[1] = src[0];
|
||||||
|
dst[2] = src[1];
|
||||||
|
dst[3] = src[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_rgba_to_abgr (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = src[3];
|
||||||
|
dst[1] = src[2];
|
||||||
|
dst[2] = src[1];
|
||||||
|
dst[3] = src[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (Un)Premultiplication */
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_unpremult_alpha_0 (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
dst[0] = 0;
|
||||||
|
dst[1] = 0;
|
||||||
|
dst[2] = 0;
|
||||||
|
dst[3] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_unpremult_alpha_last (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
guchar alpha = src[3];
|
||||||
|
|
||||||
|
dst[0] = (((src[0] >> 16) & 0xff) * 255 ) / alpha;
|
||||||
|
dst[1] = (((src[1] >> 8) & 0xff) * 255 ) / alpha;
|
||||||
|
dst[2] = (((src[2] >> 0) & 0xff) * 255 ) / alpha;
|
||||||
|
dst[3] = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
_cogl_unpremult_alpha_first (const guchar *src, guchar *dst)
|
||||||
|
{
|
||||||
|
guchar alpha = src[0];
|
||||||
|
|
||||||
|
dst[0] = alpha;
|
||||||
|
dst[1] = (((src[1] >> 16) & 0xff) * 255 ) / alpha;
|
||||||
|
dst[2] = (((src[2] >> 8) & 0xff) * 255 ) / alpha;
|
||||||
|
dst[3] = (((src[3] >> 0) & 0xff) * 255 ) / alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
|
||||||
|
{
|
||||||
|
if (src == dst)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
switch (src & COGL_UNORDERED_MASK)
|
||||||
|
{
|
||||||
|
case COGL_PIXEL_FORMAT_G_8:
|
||||||
|
case COGL_PIXEL_FORMAT_24:
|
||||||
|
case COGL_PIXEL_FORMAT_32:
|
||||||
|
|
||||||
|
if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 &&
|
||||||
|
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 &&
|
||||||
|
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8)
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
return ((format & COGL_UNORDERED_MASK) == COGL_PIXEL_FORMAT_32);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format)
|
||||||
|
{
|
||||||
|
guchar *src;
|
||||||
|
guchar *dst;
|
||||||
|
gint src_bpp;
|
||||||
|
gint dst_bpp;
|
||||||
|
gint x,y;
|
||||||
|
guchar temp_rgba[4] = {0,0,0,0};
|
||||||
|
|
||||||
|
/* Make sure conversion supported */
|
||||||
|
if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
src_bpp = _cogl_get_format_bpp (bmp->format);
|
||||||
|
dst_bpp = _cogl_get_format_bpp (dst_format);
|
||||||
|
|
||||||
|
/* Initialize destination bitmap */
|
||||||
|
*dst_bmp = *bmp;
|
||||||
|
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
|
||||||
|
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
|
||||||
|
(dst_format & COGL_UNPREMULT_MASK));
|
||||||
|
|
||||||
|
/* Allocate a new buffer to hold converted data */
|
||||||
|
dst_bmp->data = g_malloc (sizeof(guchar)
|
||||||
|
* dst_bmp->height
|
||||||
|
* dst_bmp->rowstride);
|
||||||
|
|
||||||
|
/* FIXME: Optimize */
|
||||||
|
for (y = 0; y < bmp->height; y++)
|
||||||
|
{
|
||||||
|
src = (guchar*)bmp->data + y * bmp->rowstride;
|
||||||
|
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
|
||||||
|
|
||||||
|
for (x = 0; x < bmp->width; x++)
|
||||||
|
{
|
||||||
|
/* FIXME: Would be nice to at least remove this inner
|
||||||
|
* branching, but not sure it can be done without
|
||||||
|
* rewriting of the whole loop */
|
||||||
|
switch (bmp->format & COGL_UNPREMULT_MASK)
|
||||||
|
{
|
||||||
|
case COGL_PIXEL_FORMAT_G_8:
|
||||||
|
_cogl_g_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_888:
|
||||||
|
_cogl_rgb_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_BGR_888:
|
||||||
|
_cogl_bgr_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
_cogl_rgba_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
|
_cogl_bgra_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||||
|
_cogl_argb_to_rgba (src, temp_rgba); break;
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||||
|
_cogl_abgr_to_rgba (src, temp_rgba); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (dst_format & COGL_UNPREMULT_MASK)
|
||||||
|
{
|
||||||
|
case COGL_PIXEL_FORMAT_G_8:
|
||||||
|
_cogl_rgba_to_g (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_RGB_888:
|
||||||
|
_cogl_rgba_to_rgb (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_BGR_888:
|
||||||
|
_cogl_rgba_to_bgr (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
_cogl_rgba_to_rgba (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||||
|
_cogl_rgba_to_bgra (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||||
|
_cogl_rgba_to_argb (temp_rgba, dst); break;
|
||||||
|
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||||
|
_cogl_rgba_to_abgr (temp_rgba, dst); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
src += src_bpp;
|
||||||
|
dst += dst_bpp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp)
|
||||||
|
{
|
||||||
|
guchar *src;
|
||||||
|
guchar *dst;
|
||||||
|
gint bpp;
|
||||||
|
gint x,y;
|
||||||
|
|
||||||
|
/* Make sure format supported for un-premultiplication */
|
||||||
|
if (!_cogl_bitmap_fallback_can_unpremult (bmp->format))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
bpp = _cogl_get_format_bpp (bmp->format);
|
||||||
|
|
||||||
|
/* Initialize destination bitmap */
|
||||||
|
*dst_bmp = *bmp;
|
||||||
|
dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK);
|
||||||
|
|
||||||
|
/* Allocate a new buffer to hold converted data */
|
||||||
|
dst_bmp->data = g_malloc (sizeof(guchar)
|
||||||
|
* dst_bmp->height
|
||||||
|
* dst_bmp->rowstride);
|
||||||
|
|
||||||
|
/* FIXME: Optimize */
|
||||||
|
for (y = 0; y < bmp->height; y++)
|
||||||
|
{
|
||||||
|
src = (guchar*)bmp->data + y * bmp->rowstride;
|
||||||
|
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
|
||||||
|
|
||||||
|
for (x = 0; x < bmp->width; x++)
|
||||||
|
{
|
||||||
|
/* FIXME: Would be nice to at least remove this inner
|
||||||
|
* branching, but not sure it can be done without
|
||||||
|
* rewriting of the whole loop */
|
||||||
|
if (bmp->format & COGL_AFIRST_BIT)
|
||||||
|
{
|
||||||
|
if (src[0] == 0)
|
||||||
|
_cogl_unpremult_alpha_0 (src, dst);
|
||||||
|
else
|
||||||
|
_cogl_unpremult_alpha_first (src, dst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (src[3] == 0)
|
||||||
|
_cogl_unpremult_alpha_0 (src, dst);
|
||||||
|
else
|
||||||
|
_cogl_unpremult_alpha_last (src, dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
src += bpp;
|
||||||
|
dst += bpp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_from_file (CoglBitmap *bmp,
|
||||||
|
const gchar *filename)
|
||||||
|
{
|
||||||
|
/* FIXME: use jpeglib, libpng, etc. manually maybe */
|
||||||
|
return FALSE;
|
||||||
|
}
|
197
clutter/cogl/common/cogl-bitmap-pixbuf.c
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-bitmap.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef USE_GDKPIXBUF
|
||||||
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_can_unpremult (CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_convert (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_unpremult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_GDKPIXBUF
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||||
|
const gchar *filename,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
gboolean has_alpha;
|
||||||
|
GdkColorspace color_space;
|
||||||
|
CoglPixelFormat pixel_format;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
|
gint rowstride;
|
||||||
|
gint bits_per_sample;
|
||||||
|
gint n_channels;
|
||||||
|
gint last_row_size;
|
||||||
|
guchar *pixels;
|
||||||
|
guchar *out_data;
|
||||||
|
guchar *out;
|
||||||
|
gint r;
|
||||||
|
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
if (bmp == NULL) return FALSE;
|
||||||
|
|
||||||
|
/* Load from file using GdkPixbuf */
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file (filename, error);
|
||||||
|
if (pixbuf == NULL) return FALSE;
|
||||||
|
|
||||||
|
/* Get pixbuf properties */
|
||||||
|
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||||
|
color_space = gdk_pixbuf_get_colorspace (pixbuf);
|
||||||
|
width = gdk_pixbuf_get_width (pixbuf);
|
||||||
|
height = gdk_pixbuf_get_height (pixbuf);
|
||||||
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
|
bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
|
||||||
|
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
|
||||||
|
|
||||||
|
/* The docs say this is the right way */
|
||||||
|
last_row_size = width * ((n_channels * bits_per_sample + 7) / 8);
|
||||||
|
|
||||||
|
/* According to current docs this should be true and so
|
||||||
|
* the translation to cogl pixel format below valid */
|
||||||
|
g_assert (bits_per_sample == 8);
|
||||||
|
|
||||||
|
if (has_alpha)
|
||||||
|
g_assert (n_channels == 4);
|
||||||
|
else
|
||||||
|
g_assert (n_channels == 3);
|
||||||
|
|
||||||
|
/* Translate to cogl pixel format */
|
||||||
|
switch (color_space)
|
||||||
|
{
|
||||||
|
case GDK_COLORSPACE_RGB:
|
||||||
|
/* The only format supported by GdkPixbuf so far */
|
||||||
|
pixel_format = has_alpha ?
|
||||||
|
COGL_PIXEL_FORMAT_RGBA_8888 :
|
||||||
|
COGL_PIXEL_FORMAT_RGB_888;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Ouch, spec changed! */
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Any way to destroy pixbuf but retain pixel data? */
|
||||||
|
|
||||||
|
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
|
out_data = (guchar*) g_malloc ((height - 1) * rowstride + last_row_size);
|
||||||
|
out = out_data;
|
||||||
|
|
||||||
|
/* Copy up to last row */
|
||||||
|
for (r = 0; r < height-1; ++r)
|
||||||
|
{
|
||||||
|
memcpy (out, pixels, rowstride);
|
||||||
|
pixels += rowstride;
|
||||||
|
out += rowstride;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy last row */
|
||||||
|
memcpy (out, pixels, last_row_size);
|
||||||
|
|
||||||
|
/* Destroy GdkPixbuf object */
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
|
/* Store bitmap info */
|
||||||
|
bmp->data = out_data;
|
||||||
|
bmp->format = pixel_format;
|
||||||
|
bmp->width = width;
|
||||||
|
bmp->height = height;
|
||||||
|
bmp->rowstride = rowstride;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include "stb_image.c"
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||||
|
const gchar *filename,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gint stb_pixel_format;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
|
guchar *pixels;
|
||||||
|
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
if (bmp == NULL) return FALSE;
|
||||||
|
|
||||||
|
/* Load from file using stb */
|
||||||
|
pixels = stbi_load (filename, &width, &height, &stb_pixel_format, STBI_rgb_alpha);
|
||||||
|
if (pixels == NULL) return FALSE;
|
||||||
|
|
||||||
|
/* Store bitmap info */
|
||||||
|
bmp->data = pixels;
|
||||||
|
bmp->format = COGL_PIXEL_FORMAT_RGBA_8888;
|
||||||
|
bmp->width = width;
|
||||||
|
bmp->height = height;
|
||||||
|
bmp->rowstride = width * 4;
|
||||||
|
|
||||||
|
g_print ("we successfully used stb_image to load %s\n", filename);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
150
clutter/cogl/common/cogl-bitmap.c
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-bitmap.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
gint
|
||||||
|
_cogl_get_format_bpp (CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
gint bpp_lut[] = {
|
||||||
|
0, /* invalid */
|
||||||
|
1, /* A_8 */
|
||||||
|
3, /* 888 */
|
||||||
|
4, /* 8888 */
|
||||||
|
2, /* 565 */
|
||||||
|
2, /* 4444 */
|
||||||
|
2, /* 5551 */
|
||||||
|
2, /* YUV */
|
||||||
|
1 /* G_8 */
|
||||||
|
};
|
||||||
|
|
||||||
|
return bpp_lut [format & COGL_UNORDERED_MASK];
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format)
|
||||||
|
{
|
||||||
|
CoglBitmap tmp_bmp = *bmp;
|
||||||
|
CoglBitmap new_bmp = *bmp;
|
||||||
|
gboolean new_bmp_owner = FALSE;
|
||||||
|
|
||||||
|
/* Is base format different (not considering premult status)? */
|
||||||
|
if ((bmp->format & COGL_UNPREMULT_MASK) !=
|
||||||
|
(dst_format & COGL_UNPREMULT_MASK))
|
||||||
|
{
|
||||||
|
/* Try converting using imaging library */
|
||||||
|
if (!_cogl_bitmap_convert (&new_bmp, &tmp_bmp, dst_format))
|
||||||
|
{
|
||||||
|
/* ... or try fallback */
|
||||||
|
if (!_cogl_bitmap_fallback_convert (&new_bmp, &tmp_bmp, dst_format))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update bitmap with new data */
|
||||||
|
new_bmp = tmp_bmp;
|
||||||
|
new_bmp_owner = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do we need to unpremultiply */
|
||||||
|
if ((bmp->format & COGL_PREMULT_BIT) == 0 &&
|
||||||
|
(dst_format & COGL_PREMULT_BIT) > 0)
|
||||||
|
{
|
||||||
|
/* Try unpremultiplying using imaging library */
|
||||||
|
if (!_cogl_bitmap_unpremult (&new_bmp, &tmp_bmp))
|
||||||
|
{
|
||||||
|
/* ... or try fallback */
|
||||||
|
if (!_cogl_bitmap_fallback_unpremult (&new_bmp, &tmp_bmp))
|
||||||
|
{
|
||||||
|
if (new_bmp_owner)
|
||||||
|
g_free (new_bmp.data);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update bitmap with new data */
|
||||||
|
if (new_bmp_owner)
|
||||||
|
g_free (new_bmp.data);
|
||||||
|
|
||||||
|
new_bmp = tmp_bmp;
|
||||||
|
new_bmp_owner = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do we need to premultiply */
|
||||||
|
if ((bmp->format & COGL_PREMULT_BIT) > 0 &&
|
||||||
|
(dst_format & COGL_PREMULT_BIT) == 0)
|
||||||
|
{
|
||||||
|
/* FIXME: implement premultiplication */
|
||||||
|
if (new_bmp_owner)
|
||||||
|
g_free (new_bmp.data);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Output new bitmap info */
|
||||||
|
*dst_bmp = new_bmp;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||||
|
CoglBitmap *dst,
|
||||||
|
gint src_x,
|
||||||
|
gint src_y,
|
||||||
|
gint dst_x,
|
||||||
|
gint dst_y,
|
||||||
|
gint width,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
guchar *srcdata;
|
||||||
|
guchar *dstdata;
|
||||||
|
gint bpp;
|
||||||
|
gint line;
|
||||||
|
|
||||||
|
/* Intended only for fast copies when format is equal! */
|
||||||
|
g_assert (src->format == dst->format);
|
||||||
|
bpp = _cogl_get_format_bpp (src->format);
|
||||||
|
|
||||||
|
srcdata = src->data + src_y * src->rowstride + src_x * bpp;
|
||||||
|
dstdata = dst->data + dst_y * dst->rowstride + dst_x * bpp;
|
||||||
|
|
||||||
|
for (line=0; line<height; ++line)
|
||||||
|
{
|
||||||
|
memcpy (dstdata, srcdata, width * bpp);
|
||||||
|
srcdata += src->rowstride;
|
||||||
|
dstdata += dst->rowstride;
|
||||||
|
}
|
||||||
|
}
|
95
clutter/cogl/common/cogl-bitmap.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_BITMAP_H
|
||||||
|
#define __COGL_BITMAP_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
typedef struct _CoglBitmap CoglBitmap;
|
||||||
|
|
||||||
|
struct _CoglBitmap
|
||||||
|
{
|
||||||
|
guchar *data;
|
||||||
|
CoglPixelFormat format;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
|
gint rowstride;
|
||||||
|
};
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_can_unpremult (CoglPixelFormat format);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_convert (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format);
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_unpremult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||||
|
const gchar *filename,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_fallback_from_file (CoglBitmap *bmp,
|
||||||
|
const gchar *filename);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||||
|
CoglBitmap *dst_bmp,
|
||||||
|
CoglPixelFormat dst_format);
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||||
|
CoglBitmap *dst,
|
||||||
|
gint src_x,
|
||||||
|
gint src_y,
|
||||||
|
gint dst_x,
|
||||||
|
gint dst_y,
|
||||||
|
gint width,
|
||||||
|
gint height);
|
||||||
|
|
||||||
|
#endif /* __COGL_BITMAP_H */
|
51
clutter/cogl/common/cogl-util.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_util_next_p2:
|
||||||
|
* @a: Value to get the next power
|
||||||
|
*
|
||||||
|
* Calculates the next power greater than @a.
|
||||||
|
*
|
||||||
|
* Return value: The next power after @a.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cogl_util_next_p2 (int a)
|
||||||
|
{
|
||||||
|
int rval=1;
|
||||||
|
|
||||||
|
while(rval < a)
|
||||||
|
rval <<= 1;
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
32
clutter/cogl/common/cogl-util.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_UTIL_H
|
||||||
|
#define __COGL_UTIL_H
|
||||||
|
|
||||||
|
int
|
||||||
|
cogl_util_next_p2 (int a);
|
||||||
|
|
||||||
|
#endif /* __COGL_UTIL_H */
|
3772
clutter/cogl/common/stb_image.c
Normal file
@ -1,10 +1,15 @@
|
|||||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter
|
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||||
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h \
|
libclutterinclude_HEADERS = $(top_builddir)/clutter/cogl/cogl.h \
|
||||||
$(top_srcdir)/clutter/cogl/gl/cogl-defines.h
|
$(top_builddir)/clutter/cogl/cogl-defines-gl.h
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter/cogl \
|
||||||
|
-I$(top_srcdir)/clutter/cogl/common \
|
||||||
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
|
-I$(top_builddir)/clutter \
|
||||||
|
-I$(top_builddir)/clutter/cogl \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
@ -14,6 +19,18 @@ LDADD = $(CLUTTER_LIBS)
|
|||||||
noinst_LTLIBRARIES = libclutter-cogl.la
|
noinst_LTLIBRARIES = libclutter-cogl.la
|
||||||
|
|
||||||
libclutter_cogl_la_SOURCES = \
|
libclutter_cogl_la_SOURCES = \
|
||||||
$(top_srcdir)/clutter/cogl/cogl.h \
|
$(top_builddir)/clutter/cogl/cogl.h \
|
||||||
$(top_srcdir)/clutter/cogl/gl/cogl-defines.h \
|
$(top_builddir)/clutter/cogl/gl/cogl-defines.h \
|
||||||
cogl.c
|
cogl-defines.h \
|
||||||
|
cogl-internal.h \
|
||||||
|
cogl-primitives.h \
|
||||||
|
cogl-texture.h \
|
||||||
|
cogl-fbo.h \
|
||||||
|
cogl-context.h \
|
||||||
|
cogl.c \
|
||||||
|
cogl-primitives.c \
|
||||||
|
cogl-texture.c \
|
||||||
|
cogl-fbo.c \
|
||||||
|
cogl-context.c
|
||||||
|
|
||||||
|
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||||
|
114
clutter/cogl/gl/cogl-context.c
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
#include "cogl-context.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static CoglContext *_context = NULL;
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_create_context ()
|
||||||
|
{
|
||||||
|
if (_context != NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Allocate context memory */
|
||||||
|
_context = (CoglContext*) g_malloc (sizeof (CoglContext));
|
||||||
|
|
||||||
|
/* Init default values */
|
||||||
|
_context->feature_flags = 0;
|
||||||
|
_context->features_cached = FALSE;
|
||||||
|
|
||||||
|
_context->enable_flags = 0;
|
||||||
|
_context->color_alpha = 255;
|
||||||
|
|
||||||
|
_context->path_nodes = NULL;
|
||||||
|
_context->path_nodes_cap = 0;
|
||||||
|
_context->path_nodes_size = 0;
|
||||||
|
|
||||||
|
_context->texture_handles = NULL;
|
||||||
|
|
||||||
|
_context->fbo_handles = NULL;
|
||||||
|
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||||
|
|
||||||
|
_context->pf_glGenRenderbuffersEXT = NULL;
|
||||||
|
_context->pf_glBindRenderbufferEXT = NULL;
|
||||||
|
_context->pf_glRenderbufferStorageEXT = NULL;
|
||||||
|
_context->pf_glGenFramebuffersEXT = NULL;
|
||||||
|
_context->pf_glBindFramebufferEXT = NULL;
|
||||||
|
_context->pf_glFramebufferTexture2DEXT = NULL;
|
||||||
|
_context->pf_glFramebufferRenderbufferEXT = NULL;
|
||||||
|
_context->pf_glCheckFramebufferStatusEXT = NULL;
|
||||||
|
_context->pf_glDeleteFramebuffersEXT = NULL;
|
||||||
|
_context->pf_glBlitFramebufferEXT = NULL;
|
||||||
|
_context->pf_glRenderbufferStorageMultisampleEXT = NULL;
|
||||||
|
|
||||||
|
_context->pf_glCreateProgramObjectARB = NULL;
|
||||||
|
_context->pf_glCreateShaderObjectARB = NULL;
|
||||||
|
_context->pf_glShaderSourceARB = NULL;
|
||||||
|
_context->pf_glCompileShaderARB = NULL;
|
||||||
|
_context->pf_glAttachObjectARB = NULL;
|
||||||
|
_context->pf_glLinkProgramARB = NULL;
|
||||||
|
_context->pf_glUseProgramObjectARB = NULL;
|
||||||
|
_context->pf_glGetUniformLocationARB = NULL;
|
||||||
|
_context->pf_glDeleteObjectARB = NULL;
|
||||||
|
_context->pf_glGetInfoLogARB = NULL;
|
||||||
|
_context->pf_glGetObjectParameterivARB = NULL;
|
||||||
|
_context->pf_glUniform1fARB = NULL;
|
||||||
|
|
||||||
|
/* Init OpenGL state */
|
||||||
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glColorMask (TRUE, TRUE, TRUE, FALSE);
|
||||||
|
cogl_enable (0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_destroy_context ()
|
||||||
|
{
|
||||||
|
if (_context == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free (_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglContext *
|
||||||
|
_cogl_context_get_default ()
|
||||||
|
{
|
||||||
|
/* Create if doesn't exist yet */
|
||||||
|
if (_context == NULL)
|
||||||
|
cogl_create_context ();
|
||||||
|
|
||||||
|
return _context;
|
||||||
|
}
|
95
clutter/cogl/gl/cogl-context.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_CONTEXT_H
|
||||||
|
#define __COGL_CONTEXT_H
|
||||||
|
|
||||||
|
#include "cogl-primitives.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Features cache */
|
||||||
|
CoglFeatureFlags feature_flags;
|
||||||
|
gboolean features_cached;
|
||||||
|
|
||||||
|
/* Enable cache */
|
||||||
|
gulong enable_flags;
|
||||||
|
guint8 color_alpha;
|
||||||
|
|
||||||
|
/* Primitives */
|
||||||
|
CoglFixedVec2 path_start;
|
||||||
|
CoglFixedVec2 path_pen;
|
||||||
|
CoglFloatVec2 *path_nodes;
|
||||||
|
guint path_nodes_cap;
|
||||||
|
guint path_nodes_size;
|
||||||
|
CoglFixedVec2 path_nodes_min;
|
||||||
|
CoglFixedVec2 path_nodes_max;
|
||||||
|
|
||||||
|
/* Textures */
|
||||||
|
GArray *texture_handles;
|
||||||
|
|
||||||
|
/* Framebuffer objects */
|
||||||
|
GArray *fbo_handles;
|
||||||
|
CoglBufferTarget draw_buffer;
|
||||||
|
|
||||||
|
/* Relying on glext.h to define these */
|
||||||
|
PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT;
|
||||||
|
PFNGLBINDRENDERBUFFEREXTPROC pf_glBindRenderbufferEXT;
|
||||||
|
PFNGLRENDERBUFFERSTORAGEEXTPROC pf_glRenderbufferStorageEXT;
|
||||||
|
PFNGLGENFRAMEBUFFERSEXTPROC pf_glGenFramebuffersEXT;
|
||||||
|
PFNGLBINDFRAMEBUFFEREXTPROC pf_glBindFramebufferEXT;
|
||||||
|
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pf_glFramebufferTexture2DEXT;
|
||||||
|
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pf_glFramebufferRenderbufferEXT;
|
||||||
|
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pf_glCheckFramebufferStatusEXT;
|
||||||
|
PFNGLDELETEFRAMEBUFFERSEXTPROC pf_glDeleteFramebuffersEXT;
|
||||||
|
PFNGLBLITFRAMEBUFFEREXTPROC pf_glBlitFramebufferEXT;
|
||||||
|
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC pf_glRenderbufferStorageMultisampleEXT;
|
||||||
|
|
||||||
|
PFNGLCREATEPROGRAMOBJECTARBPROC pf_glCreateProgramObjectARB;
|
||||||
|
PFNGLCREATESHADEROBJECTARBPROC pf_glCreateShaderObjectARB;
|
||||||
|
PFNGLSHADERSOURCEARBPROC pf_glShaderSourceARB;
|
||||||
|
PFNGLCOMPILESHADERARBPROC pf_glCompileShaderARB;
|
||||||
|
PFNGLATTACHOBJECTARBPROC pf_glAttachObjectARB;
|
||||||
|
PFNGLLINKPROGRAMARBPROC pf_glLinkProgramARB;
|
||||||
|
PFNGLUSEPROGRAMOBJECTARBPROC pf_glUseProgramObjectARB;
|
||||||
|
PFNGLGETUNIFORMLOCATIONARBPROC pf_glGetUniformLocationARB;
|
||||||
|
PFNGLDELETEOBJECTARBPROC pf_glDeleteObjectARB;
|
||||||
|
PFNGLGETINFOLOGARBPROC pf_glGetInfoLogARB;
|
||||||
|
PFNGLGETOBJECTPARAMETERIVARBPROC pf_glGetObjectParameterivARB;
|
||||||
|
PFNGLUNIFORM1FARBPROC pf_glUniform1fARB;
|
||||||
|
|
||||||
|
} CoglContext;
|
||||||
|
|
||||||
|
CoglContext *
|
||||||
|
_cogl_context_get_default ();
|
||||||
|
|
||||||
|
/* Obtains the context and returns retval if NULL */
|
||||||
|
#define _COGL_GET_CONTEXT(ctxvar, retval) \
|
||||||
|
CoglContext *ctxvar = _cogl_context_get_default (); \
|
||||||
|
if (ctxvar == NULL) return retval;
|
||||||
|
|
||||||
|
#define NO_RETVAL
|
||||||
|
|
||||||
|
#endif /* __COGL_CONTEXT_H */
|
390
clutter/cogl/gl/cogl-fbo.c
Normal file
@ -0,0 +1,390 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
#include "cogl-texture.h"
|
||||||
|
#include "cogl-fbo.h"
|
||||||
|
#include "cogl-context.h"
|
||||||
|
|
||||||
|
/* Expecting EXT functions not to be defined - redirect to pointers in context */
|
||||||
|
#define glGenRenderbuffersEXT ctx->pf_glGenRenderbuffersEXT
|
||||||
|
#define glBindRenderbufferEXT ctx->pf_glBindRenderbufferEXT
|
||||||
|
#define glRenderbufferStorageEXT ctx->pf_glRenderbufferStorageEXT
|
||||||
|
#define glGenFramebuffersEXT ctx->pf_glGenFramebuffersEXT
|
||||||
|
#define glBindFramebufferEXT ctx->pf_glBindFramebufferEXT
|
||||||
|
#define glFramebufferTexture2DEXT ctx->pf_glFramebufferTexture2DEXT
|
||||||
|
#define glFramebufferRenderbufferEXT ctx->pf_glFramebufferRenderbufferEXT
|
||||||
|
#define glCheckFramebufferStatusEXT ctx->pf_glCheckFramebufferStatusEXT
|
||||||
|
#define glDeleteFramebuffersEXT ctx->pf_glDeleteFramebuffersEXT
|
||||||
|
#define glBlitFramebufferEXT ctx->pf_glBlitFramebufferEXT
|
||||||
|
#define glRenderbufferStorageMultisampleEXT ctx->pf_glRenderbufferStorageMultisampleEXT
|
||||||
|
|
||||||
|
static gint
|
||||||
|
_cogl_fbo_handle_find (CoglHandle handle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if (ctx->fbo_handles == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i=0; i < ctx->fbo_handles->len; ++i)
|
||||||
|
if (g_array_index (ctx->fbo_handles, CoglHandle, i) == handle)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CoglHandle
|
||||||
|
_cogl_fbo_handle_new (CoglFbo *fbo)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
CoglHandle handle = (CoglHandle)fbo;
|
||||||
|
|
||||||
|
if (ctx->fbo_handles == NULL)
|
||||||
|
ctx->fbo_handles = g_array_new (FALSE, FALSE, sizeof (CoglHandle));
|
||||||
|
|
||||||
|
g_array_append_val (ctx->fbo_handles, handle);
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_fbo_handle_release (CoglHandle handle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if ( (i = _cogl_fbo_handle_find (handle)) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_array_remove_index_fast (ctx->fbo_handles, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CoglFbo*
|
||||||
|
_cogl_fbo_pointer_from_handle (CoglHandle handle)
|
||||||
|
{
|
||||||
|
return (CoglFbo*) handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_is_offscreen_buffer (CoglHandle handle)
|
||||||
|
{
|
||||||
|
if (handle == COGL_INVALID_HANDLE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return _cogl_fbo_handle_find (handle) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
CoglTexture *tex;
|
||||||
|
CoglFbo *fbo;
|
||||||
|
CoglTexSliceSpan *x_span;
|
||||||
|
CoglTexSliceSpan *y_span;
|
||||||
|
GLuint tex_gl_handle;
|
||||||
|
GLuint fbo_gl_handle;
|
||||||
|
GLenum status;
|
||||||
|
|
||||||
|
/* Make texhandle is a valid texture object */
|
||||||
|
if (!cogl_is_texture (texhandle))
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
tex = _cogl_texture_pointer_from_handle (texhandle);
|
||||||
|
|
||||||
|
/* The texture must not be sliced */
|
||||||
|
if (tex->slice_gl_handles == NULL)
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
if (tex->slice_gl_handles->len != 1)
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
/* Pick the single texture slice width, height and GL id */
|
||||||
|
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
||||||
|
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
|
||||||
|
tex_gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
|
||||||
|
|
||||||
|
/* Generate framebuffer */
|
||||||
|
glGenFramebuffersEXT (1, &fbo_gl_handle);
|
||||||
|
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo_gl_handle) );
|
||||||
|
GE( glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||||
|
tex->gl_target, tex_gl_handle, 0) );
|
||||||
|
|
||||||
|
/* Make sure it's complete */
|
||||||
|
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
|
||||||
|
|
||||||
|
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
|
{
|
||||||
|
GE( glDeleteFramebuffersEXT (1, &fbo_gl_handle) );
|
||||||
|
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
|
||||||
|
|
||||||
|
/* Allocate and init a CoglFbo object (store non-wasted size
|
||||||
|
for subsequent blits and viewport setup) */
|
||||||
|
fbo = (CoglFbo*) g_malloc (sizeof (CoglFbo));
|
||||||
|
fbo->ref_count = 1;
|
||||||
|
fbo->width = x_span->size - x_span->waste;
|
||||||
|
fbo->height = y_span->size - y_span->waste;
|
||||||
|
fbo->gl_handle = fbo_gl_handle;
|
||||||
|
|
||||||
|
return _cogl_fbo_handle_new (fbo);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_multisample ()
|
||||||
|
{
|
||||||
|
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE))
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_ref (CoglHandle handle)
|
||||||
|
{
|
||||||
|
CoglFbo *fbo;
|
||||||
|
|
||||||
|
if (!cogl_is_offscreen_buffer (handle))
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
fbo = _cogl_fbo_pointer_from_handle (handle);
|
||||||
|
|
||||||
|
fbo->ref_count++;
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_unref (CoglHandle handle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
CoglFbo *fbo;
|
||||||
|
|
||||||
|
/* Make sure this is a valid fbo handle */
|
||||||
|
if (!cogl_is_offscreen_buffer (handle))
|
||||||
|
return;
|
||||||
|
|
||||||
|
fbo = _cogl_fbo_pointer_from_handle (handle);
|
||||||
|
|
||||||
|
if (--fbo->ref_count < 1)
|
||||||
|
{
|
||||||
|
/* Release handle and destroy object */
|
||||||
|
GE( glDeleteFramebuffersEXT (1, &fbo->gl_handle) );
|
||||||
|
|
||||||
|
_cogl_fbo_handle_release (handle);
|
||||||
|
|
||||||
|
g_free (fbo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int src_w,
|
||||||
|
int src_h,
|
||||||
|
int dst_x,
|
||||||
|
int dst_y,
|
||||||
|
int dst_w,
|
||||||
|
int dst_h)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CoglFbo *src_fbo;
|
||||||
|
CoglFbo *dst_fbo;
|
||||||
|
|
||||||
|
/* Make sure these are valid fbo handles */
|
||||||
|
if (!cogl_is_offscreen_buffer (src_buffer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!cogl_is_offscreen_buffer (dst_buffer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
src_fbo = _cogl_fbo_pointer_from_handle (src_buffer);
|
||||||
|
dst_fbo = _cogl_fbo_pointer_from_handle (dst_buffer);
|
||||||
|
|
||||||
|
/* Copy (and scale) a region from one to another framebuffer */
|
||||||
|
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
|
||||||
|
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
|
||||||
|
GE( glBlitFramebufferEXT (src_x, src_y, src_x + src_w, src_y + src_h,
|
||||||
|
dst_x, dst_y, dst_x + dst_w, dst_y + dst_h,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CoglFbo *src_fbo;
|
||||||
|
CoglFbo *dst_fbo;
|
||||||
|
|
||||||
|
/* Make sure these are valid fbo handles */
|
||||||
|
if (!cogl_is_offscreen_buffer (src_buffer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!cogl_is_offscreen_buffer (dst_buffer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
src_fbo = _cogl_fbo_pointer_from_handle (src_buffer);
|
||||||
|
dst_fbo = _cogl_fbo_pointer_from_handle (dst_buffer);
|
||||||
|
|
||||||
|
/* Copy (and scale) whole image from one to another framebuffer */
|
||||||
|
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
|
||||||
|
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
|
||||||
|
GE( glBlitFramebufferEXT (0, 0, src_fbo->width, src_fbo->height,
|
||||||
|
0, 0, dst_fbo->width, dst_fbo->height,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
CoglFbo *fbo = NULL;
|
||||||
|
|
||||||
|
if (target == COGL_OFFSCREEN_BUFFER)
|
||||||
|
{
|
||||||
|
/* Make sure it is a valid fbo handle */
|
||||||
|
if (!cogl_is_offscreen_buffer (offscreen))
|
||||||
|
return;
|
||||||
|
|
||||||
|
fbo = _cogl_fbo_pointer_from_handle (offscreen);
|
||||||
|
|
||||||
|
/* Check current draw buffer target */
|
||||||
|
if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER)
|
||||||
|
{
|
||||||
|
/* Push the viewport and matrix setup if redirecting
|
||||||
|
from a non-screen buffer */
|
||||||
|
GE( glPushAttrib (GL_VIEWPORT_BIT) );
|
||||||
|
|
||||||
|
GE( glMatrixMode (GL_PROJECTION) );
|
||||||
|
GE( glPushMatrix () );
|
||||||
|
GE( glLoadIdentity () );
|
||||||
|
|
||||||
|
GE( glMatrixMode (GL_MODELVIEW) );
|
||||||
|
GE( glPushMatrix () );
|
||||||
|
GE( glLoadIdentity () );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Override viewport and matrix setup if redirecting
|
||||||
|
from another offscreen buffer */
|
||||||
|
GE( glMatrixMode (GL_PROJECTION) );
|
||||||
|
GE( glLoadIdentity () );
|
||||||
|
|
||||||
|
GE( glMatrixMode (GL_MODELVIEW) );
|
||||||
|
GE( glLoadIdentity () );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup new viewport and matrices */
|
||||||
|
GE( glViewport (0, 0, fbo->width, fbo->height) );
|
||||||
|
GE( glTranslatef (-1.0f, -1.0f, 0.0f) );
|
||||||
|
GE( glScalef (2.0f / fbo->width, 2.0f / fbo->height, 1.0f) );
|
||||||
|
|
||||||
|
/* Bind offscreen framebuffer object */
|
||||||
|
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) );
|
||||||
|
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||||
|
|
||||||
|
/* Some implementation require a clear before drawing
|
||||||
|
to an fbo. Luckily it is affected by scissor test. */
|
||||||
|
/* FIXME: test where exactly this is needed end whether
|
||||||
|
a glClear with 0 argument is enough */
|
||||||
|
GE( glPushAttrib (GL_SCISSOR_BIT) );
|
||||||
|
GE( glScissor (0,0,0,0) );
|
||||||
|
GE( glEnable (GL_SCISSOR_TEST) );
|
||||||
|
GE( glClear (GL_COLOR_BUFFER_BIT) );
|
||||||
|
GE( glPopAttrib () );
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ((target & COGL_WINDOW_BUFFER) ||
|
||||||
|
(target & COGL_MASK_BUFFER))
|
||||||
|
{
|
||||||
|
/* Check current draw buffer target */
|
||||||
|
if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER)
|
||||||
|
{
|
||||||
|
/* Pop viewport and matrices if redirecting back
|
||||||
|
from an offscreen buffer */
|
||||||
|
GE( glPopAttrib () );
|
||||||
|
|
||||||
|
GE( glMatrixMode (GL_PROJECTION) );
|
||||||
|
GE( glPopMatrix () );
|
||||||
|
|
||||||
|
GE( glMatrixMode (GL_MODELVIEW) );
|
||||||
|
GE( glPopMatrix () );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bind window framebuffer object */
|
||||||
|
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
|
||||||
|
|
||||||
|
|
||||||
|
if (target == COGL_WINDOW_BUFFER)
|
||||||
|
{
|
||||||
|
/* Draw to RGB channels */
|
||||||
|
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE) );
|
||||||
|
}
|
||||||
|
else if (target == COGL_MASK_BUFFER)
|
||||||
|
{
|
||||||
|
/* Draw only to ALPHA channel */
|
||||||
|
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Draw to all channels */
|
||||||
|
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store new target */
|
||||||
|
ctx->draw_buffer = target;
|
||||||
|
}
|
38
clutter/cogl/gl/cogl-fbo.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_FBO_H
|
||||||
|
#define __COGL_FBO_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
guint ref_count;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
GLuint gl_handle;
|
||||||
|
|
||||||
|
} CoglFbo;
|
||||||
|
|
||||||
|
#endif /* __COGL_FBO_H */
|
61
clutter/cogl/gl/cogl-internal.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_INTERNAL_H
|
||||||
|
#define __COGL_INTERNAL_H
|
||||||
|
|
||||||
|
#define COGL_DEBUG 0
|
||||||
|
|
||||||
|
#if COGL_DEBUG
|
||||||
|
#define GE(x...) G_STMT_START { \
|
||||||
|
GLenum err; \
|
||||||
|
(x); \
|
||||||
|
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||||
|
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||||
|
(char *)error_string(err), \
|
||||||
|
__FILE__, __LINE__); \
|
||||||
|
} \
|
||||||
|
} G_STMT_END
|
||||||
|
#else
|
||||||
|
#define GE(x) (x);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define COGL_ENABLE_BLEND (1<<1)
|
||||||
|
#define COGL_ENABLE_TEXTURE_2D (1<<2)
|
||||||
|
#define COGL_ENABLE_ALPHA_TEST (1<<3)
|
||||||
|
#define COGL_ENABLE_TEXTURE_RECT (1<<4)
|
||||||
|
#define COGL_ENABLE_VERTEX_ARRAY (1<<5)
|
||||||
|
#define COGL_ENABLE_TEXCOORD_ARRAY (1<<6)
|
||||||
|
|
||||||
|
gint
|
||||||
|
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_enable (gulong flags);
|
||||||
|
|
||||||
|
gulong
|
||||||
|
cogl_get_enable ();
|
||||||
|
|
||||||
|
#endif /* __COGL_INTERNAL_H */
|
1092
clutter/cogl/gl/cogl-primitives.c
Normal file
61
clutter/cogl/gl/cogl-primitives.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_PRIMITIVES_H
|
||||||
|
#define __COGL_PRIMITIVES_H
|
||||||
|
|
||||||
|
typedef struct _CoglFixedVec2 CoglFixedVec2;
|
||||||
|
typedef struct _CoglFloatVec2 CoglFloatVec2;
|
||||||
|
typedef struct _CoglBezQuad CoglBezQuad;
|
||||||
|
typedef struct _CoglBezCubic CoglBezCubic;
|
||||||
|
|
||||||
|
struct _CoglFixedVec2
|
||||||
|
{
|
||||||
|
ClutterFixed x;
|
||||||
|
ClutterFixed y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglFloatVec2
|
||||||
|
{
|
||||||
|
GLfloat x;
|
||||||
|
GLfloat y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglBezQuad
|
||||||
|
{
|
||||||
|
CoglFixedVec2 p1;
|
||||||
|
CoglFixedVec2 p2;
|
||||||
|
CoglFixedVec2 p3;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglBezCubic
|
||||||
|
{
|
||||||
|
CoglFixedVec2 p1;
|
||||||
|
CoglFixedVec2 p2;
|
||||||
|
CoglFixedVec2 p3;
|
||||||
|
CoglFixedVec2 p4;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __COGL_PRIMITIVES_H */
|
2303
clutter/cogl/gl/cogl-texture.c
Normal file
64
clutter/cogl/gl/cogl-texture.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_TEXTURE_H
|
||||||
|
#define __COGL_TEXTURE_H
|
||||||
|
|
||||||
|
#include "cogl-bitmap.h"
|
||||||
|
|
||||||
|
typedef struct _CoglTexture CoglTexture;
|
||||||
|
typedef struct _CoglTexSliceSpan CoglTexSliceSpan;
|
||||||
|
typedef struct _CoglSpanIter CoglSpanIter;
|
||||||
|
|
||||||
|
struct _CoglTexSliceSpan
|
||||||
|
{
|
||||||
|
gint start;
|
||||||
|
gint size;
|
||||||
|
gint waste;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglTexture
|
||||||
|
{
|
||||||
|
guint ref_count;
|
||||||
|
CoglBitmap bitmap;
|
||||||
|
gboolean bitmap_owner;
|
||||||
|
GLenum gl_target;
|
||||||
|
GLenum gl_intformat;
|
||||||
|
GLenum gl_format;
|
||||||
|
GLenum gl_type;
|
||||||
|
GArray *slice_x_spans;
|
||||||
|
GArray *slice_y_spans;
|
||||||
|
GArray *slice_gl_handles;
|
||||||
|
gint max_waste;
|
||||||
|
COGLenum min_filter;
|
||||||
|
COGLenum mag_filter;
|
||||||
|
gboolean is_foreign;
|
||||||
|
GLint wrap_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
CoglTexture*
|
||||||
|
_cogl_texture_pointer_from_handle (CoglHandle handle);
|
||||||
|
|
||||||
|
#endif /* __COGL_TEXTURE_H */
|
@ -39,23 +39,12 @@
|
|||||||
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gulong __enable_flags = 0;
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
#include "cogl-context.h"
|
||||||
|
|
||||||
/* FBO Procs */
|
|
||||||
typedef void (*GenFramebuffers) (GLsizei n, GLuint *ids);
|
|
||||||
typedef void (*BindFramebuffer) (GLenum target, GLuint framebuffer);
|
|
||||||
typedef void (*FramebufferTexture2D) (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture,
|
|
||||||
GLint level);
|
|
||||||
typedef GLenum (*CheckFramebufferStatus)(GLenum target);
|
|
||||||
typedef void (*DeleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
|
|
||||||
|
|
||||||
static GenFramebuffers _gen_framebuffers = NULL;
|
|
||||||
static BindFramebuffer _bind_framebuffer = NULL;
|
|
||||||
static FramebufferTexture2D _framebuffer_texture_2d = NULL;
|
|
||||||
static CheckFramebufferStatus _check_framebuffer_status = NULL;
|
|
||||||
static DeleteFramebuffers _delete_framebuffers = NULL;
|
|
||||||
|
|
||||||
|
/* GL error to string conversion */
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
struct token_string
|
struct token_string
|
||||||
{
|
{
|
||||||
@ -89,19 +78,21 @@ error_string(GLenum errorCode)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COGL_DEBUG
|
|
||||||
#define GE(x...) G_STMT_START { \
|
/* Expecting ARB functions not to be defined */
|
||||||
GLenum err; \
|
#define glCreateProgramObjectARB ctx->pf_glCreateProgramObjectARB
|
||||||
(x); \
|
#define glCreateShaderObjectARB ctx->pf_glCreateShaderObjectARB
|
||||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
#define glShaderSourceARB ctx->pf_glShaderSourceARB
|
||||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
#define glCompileShaderARB ctx->pf_glCompileShaderARB
|
||||||
(char *)error_string(err), \
|
#define glAttachObjectARB ctx->pf_glAttachObjectARB
|
||||||
__FILE__, __LINE__); \
|
#define glLinkProgramARB ctx->pf_glLinkProgramARB
|
||||||
} \
|
#define glUseProgramObjectARB ctx->pf_glUseProgramObjectARB
|
||||||
} G_STMT_END
|
#define glGetUniformLocationARB ctx->pf_glGetUniformLocationARB
|
||||||
#else
|
#define glDeleteObjectARB ctx->pf_glDeleteObjectARB
|
||||||
#define GE(x) (x);
|
#define glGetInfoLogARB ctx->pf_glGetInfoLogARB
|
||||||
#endif
|
#define glGetObjectParameterivARB ctx->pf_glGetObjectParameterivARB
|
||||||
|
#define glUniform1fARB ctx->pf_glUniform1fARB
|
||||||
|
|
||||||
|
|
||||||
CoglFuncPtr
|
CoglFuncPtr
|
||||||
cogl_get_proc_address (const gchar* name)
|
cogl_get_proc_address (const gchar* name)
|
||||||
@ -217,9 +208,6 @@ cogl_paint_init (const ClutterColor *color)
|
|||||||
* glDepthFunc (GL_LEQUAL);
|
* glDepthFunc (GL_LEQUAL);
|
||||||
* glAlphaFunc (GL_GREATER, 0.1);
|
* glAlphaFunc (GL_GREATER, 0.1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cogl_enable (CGL_ENABLE_BLEND);
|
|
||||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: inline most of these */
|
/* FIXME: inline most of these */
|
||||||
@ -272,59 +260,155 @@ cogl_rotate (gint angle, gint x, gint y, gint z)
|
|||||||
glRotatef ((float)angle, (float)x, (float)y, (float)z);
|
glRotatef ((float)angle, (float)x, (float)y, (float)z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
cogl_toggle_flag (CoglContext *ctx,
|
||||||
|
gulong new_flags,
|
||||||
|
gulong flag,
|
||||||
|
GLenum gl_flag)
|
||||||
|
{
|
||||||
|
/* Toggles and caches a single enable flag on or off
|
||||||
|
* by comparing to current state
|
||||||
|
*/
|
||||||
|
if (new_flags & flag)
|
||||||
|
{
|
||||||
|
if (!(ctx->enable_flags & flag))
|
||||||
|
{
|
||||||
|
GE( glEnable (gl_flag) );
|
||||||
|
ctx->enable_flags |= flag;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ctx->enable_flags & flag)
|
||||||
|
{
|
||||||
|
GE( glDisable (gl_flag) );
|
||||||
|
ctx->enable_flags &= ~flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
cogl_toggle_client_flag (CoglContext *ctx,
|
||||||
|
gulong new_flags,
|
||||||
|
gulong flag,
|
||||||
|
GLenum gl_flag)
|
||||||
|
{
|
||||||
|
/* Toggles and caches a single client-side enable flag
|
||||||
|
* on or off by comparing to current state
|
||||||
|
*/
|
||||||
|
if (new_flags & flag)
|
||||||
|
{
|
||||||
|
if (!(ctx->enable_flags & flag))
|
||||||
|
{
|
||||||
|
GE( glEnableClientState (gl_flag) );
|
||||||
|
ctx->enable_flags |= flag;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ctx->enable_flags & flag)
|
||||||
|
{
|
||||||
|
GE( glDisableClientState (gl_flag) );
|
||||||
|
ctx->enable_flags &= ~flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_enable (gulong flags)
|
cogl_enable (gulong flags)
|
||||||
{
|
{
|
||||||
/* This function essentially caches glEnable state() in the
|
/* This function essentially caches glEnable state() in the
|
||||||
* hope of lessening number GL traffic.
|
* hope of lessening number GL traffic.
|
||||||
*/
|
*/
|
||||||
if (flags & CGL_ENABLE_BLEND)
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (cogl_toggle_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_BLEND,
|
||||||
|
GL_BLEND))
|
||||||
{
|
{
|
||||||
if (!(__enable_flags & CGL_ENABLE_BLEND))
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
|
cogl_toggle_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_TEXTURE_2D,
|
||||||
|
GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
cogl_toggle_client_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_VERTEX_ARRAY,
|
||||||
|
GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
cogl_toggle_client_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_TEXCOORD_ARRAY,
|
||||||
|
GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||||
|
cogl_toggle_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_TEXTURE_RECT,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
gulong
|
||||||
|
cogl_get_enable ()
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
|
|
||||||
|
return ctx->enable_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
cogl_enable (gulong flags)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (flags & COGL_ENABLE_BLEND)
|
||||||
|
{
|
||||||
|
if (!(ctx->enable_flags & COGL_ENABLE_BLEND))
|
||||||
{
|
{
|
||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
__enable_flags |= CGL_ENABLE_BLEND;
|
ctx->enable_flags |= COGL_ENABLE_BLEND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (__enable_flags & CGL_ENABLE_BLEND)
|
else if (ctx->enable_flags & COGL_ENABLE_BLEND)
|
||||||
{
|
{
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
__enable_flags &= ~CGL_ENABLE_BLEND;
|
ctx->enable_flags &= ~COGL_ENABLE_BLEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & CGL_ENABLE_TEXTURE_2D)
|
if (flags & COGL_ENABLE_TEXTURE_2D)
|
||||||
{
|
{
|
||||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_2D))
|
if (!(ctx->enable_flags & COGL_ENABLE_TEXTURE_2D))
|
||||||
{
|
{
|
||||||
glEnable (GL_TEXTURE_2D);
|
glEnable (GL_TEXTURE_2D);
|
||||||
__enable_flags |= CGL_ENABLE_TEXTURE_2D;
|
ctx->enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_2D)
|
else if (ctx->enable_flags & COGL_ENABLE_TEXTURE_2D)
|
||||||
{
|
{
|
||||||
glDisable (GL_TEXTURE_2D);
|
glDisable (GL_TEXTURE_2D);
|
||||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_2D;
|
ctx->enable_flags &= ~COGL_ENABLE_TEXTURE_2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||||
if (flags & CGL_ENABLE_TEXTURE_RECT)
|
if (flags & COGL_ENABLE_TEXTURE_RECT)
|
||||||
{
|
{
|
||||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_RECT))
|
if (!(ctx->enable_flags & COGL_ENABLE_TEXTURE_RECT))
|
||||||
{
|
{
|
||||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||||
__enable_flags |= CGL_ENABLE_TEXTURE_RECT;
|
ctx->enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_RECT)
|
else if (ctx->enable_flags & COGL_ENABLE_TEXTURE_RECT)
|
||||||
{
|
{
|
||||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_RECT;
|
ctx->enable_flags &= ~COGL_ENABLE_TEXTURE_RECT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
cogl_enable_depth_test (gboolean setting)
|
cogl_enable_depth_test (gboolean setting)
|
||||||
{
|
{
|
||||||
@ -345,7 +429,15 @@ cogl_enable_depth_test (gboolean setting)
|
|||||||
void
|
void
|
||||||
cogl_color (const ClutterColor *color)
|
cogl_color (const ClutterColor *color)
|
||||||
{
|
{
|
||||||
glColor4ub (color->red, color->green, color->blue, color->alpha);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
glColor4ub (color->red,
|
||||||
|
color->green,
|
||||||
|
color->blue,
|
||||||
|
color->alpha);
|
||||||
|
|
||||||
|
/* Store alpha for proper blending enables */
|
||||||
|
ctx->color_alpha = color->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -353,6 +445,27 @@ cogl_clip_set (ClutterFixed x_offset,
|
|||||||
ClutterFixed y_offset,
|
ClutterFixed y_offset,
|
||||||
ClutterFixed width,
|
ClutterFixed width,
|
||||||
ClutterFixed height)
|
ClutterFixed height)
|
||||||
|
{
|
||||||
|
if (cogl_features_available (COGL_FEATURE_FOUR_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
GLdouble eqn_left[4] = { 1.0, 0, 0,
|
||||||
|
-CLUTTER_FIXED_TO_FLOAT (x_offset) };
|
||||||
|
GLdouble eqn_right[4] = { -1.0, 0, 0,
|
||||||
|
CLUTTER_FIXED_TO_FLOAT (x_offset + width) };
|
||||||
|
GLdouble eqn_top[4] = { 0, 1.0, 0, -CLUTTER_FIXED_TO_FLOAT (y_offset) };
|
||||||
|
GLdouble eqn_bottom[4] = { 0, -1.0, 0, CLUTTER_FIXED_TO_FLOAT
|
||||||
|
(y_offset + height) };
|
||||||
|
|
||||||
|
GE( glClipPlane (GL_CLIP_PLANE0, eqn_left) );
|
||||||
|
GE( glClipPlane (GL_CLIP_PLANE1, eqn_right) );
|
||||||
|
GE( glClipPlane (GL_CLIP_PLANE2, eqn_top) );
|
||||||
|
GE( glClipPlane (GL_CLIP_PLANE3, eqn_bottom) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE0) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE1) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE2) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE3) );
|
||||||
|
}
|
||||||
|
else if (cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||||
{
|
{
|
||||||
GE( glEnable (GL_STENCIL_TEST) );
|
GE( glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
@ -372,177 +485,22 @@ cogl_clip_set (ClutterFixed x_offset,
|
|||||||
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||||
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_clip_unset (void)
|
cogl_clip_unset (void)
|
||||||
|
{
|
||||||
|
if (cogl_features_available (COGL_FEATURE_FOUR_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
GE( glDisable (GL_CLIP_PLANE3) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE2) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE1) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE0) );
|
||||||
|
}
|
||||||
|
else if (cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||||
{
|
{
|
||||||
GE( glDisable (GL_STENCIL_TEST) );
|
GE( glDisable (GL_STENCIL_TEST) );
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
cogl_texture_can_size (COGLenum target,
|
|
||||||
COGLenum pixel_format,
|
|
||||||
COGLenum pixel_type,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
|
||||||
#ifdef GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB
|
|
||||||
if (target == CGL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
GLint max_size = 0;
|
|
||||||
|
|
||||||
GE( glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_size) );
|
|
||||||
|
|
||||||
return (max_size && width <= max_size && height <= max_size);
|
|
||||||
}
|
|
||||||
else /* Assumes CGL_TEXTURE_2D */
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
GLint new_width = 0;
|
|
||||||
|
|
||||||
GE( glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
|
|
||||||
width, height, 0 /* border */,
|
|
||||||
pixel_format, pixel_type, NULL) );
|
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0,
|
|
||||||
GL_TEXTURE_WIDTH, &new_width) );
|
|
||||||
|
|
||||||
return new_width != 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_quad (gint x1,
|
|
||||||
gint x2,
|
|
||||||
gint y1,
|
|
||||||
gint y2,
|
|
||||||
ClutterFixed tx1,
|
|
||||||
ClutterFixed ty1,
|
|
||||||
ClutterFixed tx2,
|
|
||||||
ClutterFixed ty2)
|
|
||||||
{
|
|
||||||
gdouble txf1, tyf1, txf2, tyf2;
|
|
||||||
|
|
||||||
txf1 = CLUTTER_FIXED_TO_DOUBLE (tx1);
|
|
||||||
tyf1 = CLUTTER_FIXED_TO_DOUBLE (ty1);
|
|
||||||
txf2 = CLUTTER_FIXED_TO_DOUBLE (tx2);
|
|
||||||
tyf2 = CLUTTER_FIXED_TO_DOUBLE (ty2);
|
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
|
||||||
glTexCoord2f (txf2, tyf2); glVertex2i (x2, y2);
|
|
||||||
glTexCoord2f (txf1, tyf2); glVertex2i (x1, y2);
|
|
||||||
glTexCoord2f (txf1, tyf1); glVertex2i (x1, y1);
|
|
||||||
glTexCoord2f (txf2, tyf1); glVertex2i (x2, y1);
|
|
||||||
glEnd ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_create (guint num, COGLuint *textures)
|
|
||||||
{
|
|
||||||
GE( glGenTextures (num, textures) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_destroy (guint num, const COGLuint *textures)
|
|
||||||
{
|
|
||||||
GE( glDeleteTextures (num, textures) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_bind (COGLenum target, COGLuint texture)
|
|
||||||
{
|
|
||||||
GE( glBindTexture (target, texture) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_alignment (COGLenum target,
|
|
||||||
guint alignment,
|
|
||||||
guint row_length)
|
|
||||||
{
|
|
||||||
GE( glPixelStorei (GL_UNPACK_ROW_LENGTH, row_length) );
|
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, alignment) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_filters (COGLenum target,
|
|
||||||
COGLenum min_filter,
|
|
||||||
COGLenum max_filter)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_MAG_FILTER, max_filter) );
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_MIN_FILTER, min_filter) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_wrap (COGLenum target,
|
|
||||||
COGLenum wrap_s,
|
|
||||||
COGLenum wrap_t)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap_s) );
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap_s) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_image_2d (COGLenum target,
|
|
||||||
COGLint internal_format,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels)
|
|
||||||
{
|
|
||||||
GE( glTexImage2D (target,
|
|
||||||
0, /* No mipmap support as yet */
|
|
||||||
internal_format,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
0, /* 0 pixel border */
|
|
||||||
format,
|
|
||||||
type,
|
|
||||||
pixels) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_sub_image_2d (COGLenum target,
|
|
||||||
gint xoff,
|
|
||||||
gint yoff,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels)
|
|
||||||
{
|
|
||||||
GE( glTexSubImage2D (target,
|
|
||||||
0,
|
|
||||||
xoff,
|
|
||||||
yoff,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
format,
|
|
||||||
type,
|
|
||||||
pixels));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_rectangle (gint x, gint y, guint width, guint height)
|
|
||||||
{
|
|
||||||
GE( glRecti (x, y, x + width, y + height) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Should use ClutterReal or Fixed */
|
|
||||||
void
|
|
||||||
cogl_trapezoid (gint y1,
|
|
||||||
gint x11,
|
|
||||||
gint x21,
|
|
||||||
gint y2,
|
|
||||||
gint x12,
|
|
||||||
gint x22)
|
|
||||||
{
|
|
||||||
GE( glBegin (GL_QUADS) );
|
|
||||||
GE( glVertex2i (x11, y1) );
|
|
||||||
GE( glVertex2i (x21, y1) );
|
|
||||||
GE( glVertex2i (x22, y2) );
|
|
||||||
GE( glVertex2i (x12, y2) );
|
|
||||||
GE( glEnd () );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -649,13 +607,17 @@ cogl_setup_viewport (guint width,
|
|||||||
GE( glTranslatef (0.0f, -1.0 * height, 0.0f) );
|
GE( glTranslatef (0.0f, -1.0 * height, 0.0f) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ClutterFeatureFlags
|
static void
|
||||||
cogl_get_features ()
|
_cogl_features_init ()
|
||||||
{
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
ClutterFeatureFlags flags = 0;
|
ClutterFeatureFlags flags = 0;
|
||||||
const gchar *gl_extensions;
|
const gchar *gl_extensions;
|
||||||
|
int max_clip_planes = 0;
|
||||||
|
int stencil_bits = 0;
|
||||||
|
|
||||||
flags = CLUTTER_FEATURE_TEXTURE_READ_PIXELS;
|
flags = COGL_FEATURE_TEXTURE_READ_PIXELS;
|
||||||
|
|
||||||
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
@ -663,53 +625,194 @@ cogl_get_features ()
|
|||||||
if (cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions) ||
|
if (cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions) ||
|
||||||
cogl_check_extension ("GL_EXT_texture_rectangle", gl_extensions))
|
cogl_check_extension ("GL_EXT_texture_rectangle", gl_extensions))
|
||||||
{
|
{
|
||||||
flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
|
flags |= COGL_FEATURE_TEXTURE_RECTANGLE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
|
||||||
|
{
|
||||||
|
flags |= COGL_FEATURE_TEXTURE_NPOT;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GL_YCBCR_MESA
|
#ifdef GL_YCBCR_MESA
|
||||||
if (cogl_check_extension ("GL_MESA_ycbcr_texture", gl_extensions))
|
if (cogl_check_extension ("GL_MESA_ycbcr_texture", gl_extensions))
|
||||||
{
|
{
|
||||||
flags |= CLUTTER_FEATURE_TEXTURE_YUV;
|
flags |= COGL_FEATURE_TEXTURE_YUV;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cogl_check_extension ("GL_ARB_vertex_shader", gl_extensions) &&
|
if (cogl_check_extension ("GL_ARB_shader_objects", gl_extensions) &&
|
||||||
|
cogl_check_extension ("GL_ARB_vertex_shader", gl_extensions) &&
|
||||||
cogl_check_extension ("GL_ARB_fragment_shader", gl_extensions))
|
cogl_check_extension ("GL_ARB_fragment_shader", gl_extensions))
|
||||||
{
|
{
|
||||||
flags |= CLUTTER_FEATURE_SHADERS_GLSL;
|
ctx->pf_glCreateProgramObjectARB =
|
||||||
|
(PFNGLCREATEPROGRAMOBJECTARBPROC)
|
||||||
|
cogl_get_proc_address ("glCreateProgramObjectARB");
|
||||||
|
|
||||||
|
ctx->pf_glCreateShaderObjectARB =
|
||||||
|
(PFNGLCREATESHADEROBJECTARBPROC)
|
||||||
|
cogl_get_proc_address ("glCreateShaderObjectARB");
|
||||||
|
|
||||||
|
ctx->pf_glShaderSourceARB =
|
||||||
|
(PFNGLSHADERSOURCEARBPROC)
|
||||||
|
cogl_get_proc_address ("glShaderSourceARB");
|
||||||
|
|
||||||
|
ctx->pf_glCompileShaderARB =
|
||||||
|
(PFNGLCOMPILESHADERARBPROC)
|
||||||
|
cogl_get_proc_address ("glCompileShaderARB");
|
||||||
|
|
||||||
|
ctx->pf_glAttachObjectARB =
|
||||||
|
(PFNGLATTACHOBJECTARBPROC)
|
||||||
|
cogl_get_proc_address ("glAttachObjectARB");
|
||||||
|
|
||||||
|
ctx->pf_glLinkProgramARB =
|
||||||
|
(PFNGLLINKPROGRAMARBPROC)
|
||||||
|
cogl_get_proc_address ("glLinkProgramARB");
|
||||||
|
|
||||||
|
ctx->pf_glUseProgramObjectARB =
|
||||||
|
(PFNGLUSEPROGRAMOBJECTARBPROC)
|
||||||
|
cogl_get_proc_address ("glUseProgramObjectARB");
|
||||||
|
|
||||||
|
ctx->pf_glGetUniformLocationARB =
|
||||||
|
(PFNGLGETUNIFORMLOCATIONARBPROC)
|
||||||
|
cogl_get_proc_address ("glGetUniformLocationARB");
|
||||||
|
|
||||||
|
ctx->pf_glDeleteObjectARB =
|
||||||
|
(PFNGLDELETEOBJECTARBPROC)
|
||||||
|
cogl_get_proc_address ("glDeleteObjectARB");
|
||||||
|
|
||||||
|
ctx->pf_glGetInfoLogARB =
|
||||||
|
(PFNGLGETINFOLOGARBPROC)
|
||||||
|
cogl_get_proc_address ("glGetInfoLogARB");
|
||||||
|
|
||||||
|
ctx->pf_glGetObjectParameterivARB =
|
||||||
|
(PFNGLGETOBJECTPARAMETERIVARBPROC)
|
||||||
|
cogl_get_proc_address ("glGetObjectParameterivARB");
|
||||||
|
|
||||||
|
ctx->pf_glUniform1fARB =
|
||||||
|
(PFNGLUNIFORM1FARBPROC)
|
||||||
|
cogl_get_proc_address ("glUniform1fARB");
|
||||||
|
|
||||||
|
if (ctx->pf_glCreateProgramObjectARB &&
|
||||||
|
ctx->pf_glCreateShaderObjectARB &&
|
||||||
|
ctx->pf_glShaderSourceARB &&
|
||||||
|
ctx->pf_glCompileShaderARB &&
|
||||||
|
ctx->pf_glAttachObjectARB &&
|
||||||
|
ctx->pf_glLinkProgramARB &&
|
||||||
|
ctx->pf_glUseProgramObjectARB &&
|
||||||
|
ctx->pf_glGetUniformLocationARB &&
|
||||||
|
ctx->pf_glDeleteObjectARB &&
|
||||||
|
ctx->pf_glGetInfoLogARB &&
|
||||||
|
ctx->pf_glGetObjectParameterivARB &&
|
||||||
|
ctx->pf_glUniform1fARB)
|
||||||
|
flags |= COGL_FEATURE_SHADERS_GLSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (cogl_check_extension ("GL_EXT_framebuffer_object", gl_extensions) ||
|
if (cogl_check_extension ("GL_EXT_framebuffer_object", gl_extensions) ||
|
||||||
cogl_check_extension ("GL_ARB_framebuffer_object", gl_extensions))
|
cogl_check_extension ("GL_ARB_framebuffer_object", gl_extensions))
|
||||||
{
|
{
|
||||||
_gen_framebuffers =
|
ctx->pf_glGenRenderbuffersEXT =
|
||||||
(GenFramebuffers) cogl_get_proc_address ("glGenFramebuffersEXT");
|
(PFNGLGENRENDERBUFFERSEXTPROC)
|
||||||
|
cogl_get_proc_address ("glGenRenderbuffersEXT");
|
||||||
|
|
||||||
_bind_framebuffer =
|
ctx->pf_glBindRenderbufferEXT =
|
||||||
(BindFramebuffer) cogl_get_proc_address ("glBindFramebufferEXT");
|
(PFNGLBINDRENDERBUFFEREXTPROC)
|
||||||
|
cogl_get_proc_address ("glBindRenderbufferEXT");
|
||||||
|
|
||||||
_framebuffer_texture_2d =
|
ctx->pf_glRenderbufferStorageEXT =
|
||||||
(FramebufferTexture2D)
|
(PFNGLRENDERBUFFERSTORAGEEXTPROC)
|
||||||
|
cogl_get_proc_address ("glRenderbufferStorageEXT");
|
||||||
|
|
||||||
|
ctx->pf_glGenFramebuffersEXT =
|
||||||
|
(PFNGLGENFRAMEBUFFERSEXTPROC)
|
||||||
|
cogl_get_proc_address ("glGenFramebuffersEXT");
|
||||||
|
|
||||||
|
ctx->pf_glBindFramebufferEXT =
|
||||||
|
(PFNGLBINDFRAMEBUFFEREXTPROC)
|
||||||
|
cogl_get_proc_address ("glBindFramebufferEXT");
|
||||||
|
|
||||||
|
ctx->pf_glFramebufferTexture2DEXT =
|
||||||
|
(PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)
|
||||||
cogl_get_proc_address ("glFramebufferTexture2DEXT");
|
cogl_get_proc_address ("glFramebufferTexture2DEXT");
|
||||||
|
|
||||||
_check_framebuffer_status =
|
ctx->pf_glFramebufferRenderbufferEXT =
|
||||||
(CheckFramebufferStatus)
|
(PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)
|
||||||
|
cogl_get_proc_address ("glFramebufferRenderbufferEXT");
|
||||||
|
|
||||||
|
ctx->pf_glCheckFramebufferStatusEXT =
|
||||||
|
(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
|
||||||
cogl_get_proc_address ("glCheckFramebufferStatusEXT");
|
cogl_get_proc_address ("glCheckFramebufferStatusEXT");
|
||||||
|
|
||||||
_delete_framebuffers =
|
ctx->pf_glDeleteFramebuffersEXT =
|
||||||
(DeleteFramebuffers)
|
(PFNGLDELETEFRAMEBUFFERSEXTPROC)
|
||||||
cogl_get_proc_address ("glDeleteFramebuffersEXT");
|
cogl_get_proc_address ("glDeleteFramebuffersEXT");
|
||||||
|
|
||||||
if (_gen_framebuffers
|
if (ctx->pf_glGenRenderbuffersEXT &&
|
||||||
&& _bind_framebuffer
|
ctx->pf_glBindRenderbufferEXT &&
|
||||||
&& _framebuffer_texture_2d
|
ctx->pf_glRenderbufferStorageEXT &&
|
||||||
&& _check_framebuffer_status
|
ctx->pf_glGenFramebuffersEXT &&
|
||||||
&& _delete_framebuffers)
|
ctx->pf_glBindFramebufferEXT &&
|
||||||
flags |= CLUTTER_FEATURE_OFFSCREEN;
|
ctx->pf_glFramebufferTexture2DEXT &&
|
||||||
|
ctx->pf_glFramebufferRenderbufferEXT &&
|
||||||
|
ctx->pf_glCheckFramebufferStatusEXT &&
|
||||||
|
ctx->pf_glDeleteFramebuffersEXT)
|
||||||
|
flags |= COGL_FEATURE_OFFSCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
if (cogl_check_extension ("GL_EXT_framebuffer_blit", gl_extensions))
|
||||||
|
{
|
||||||
|
ctx->pf_glBlitFramebufferEXT =
|
||||||
|
(PFNGLBLITFRAMEBUFFEREXTPROC)
|
||||||
|
cogl_get_proc_address ("glBlitFramebufferEXT");
|
||||||
|
|
||||||
|
if (ctx->pf_glBlitFramebufferEXT)
|
||||||
|
flags |= COGL_FEATURE_OFFSCREEN_BLIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cogl_check_extension ("GL_EXT_framebuffer_multisample", gl_extensions))
|
||||||
|
{
|
||||||
|
ctx->pf_glRenderbufferStorageMultisampleEXT =
|
||||||
|
(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
|
||||||
|
cogl_get_proc_address ("glRenderbufferStorageMultisampleEXT");
|
||||||
|
|
||||||
|
if (ctx->pf_glRenderbufferStorageMultisampleEXT)
|
||||||
|
flags |= COGL_FEATURE_OFFSCREEN_MULTISAMPLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GE( glGetIntegerv (GL_STENCIL_BITS, &stencil_bits) );
|
||||||
|
if (stencil_bits > 0)
|
||||||
|
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
||||||
|
|
||||||
|
GE( glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
||||||
|
if (max_clip_planes >= 4)
|
||||||
|
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
||||||
|
|
||||||
|
/* Cache features */
|
||||||
|
ctx->feature_flags = flags;
|
||||||
|
ctx->features_cached = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClutterFeatureFlags
|
||||||
|
cogl_get_features ()
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
|
|
||||||
|
if (!ctx->features_cached)
|
||||||
|
_cogl_features_init ();
|
||||||
|
|
||||||
|
return ctx->feature_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_features_available (CoglFeatureFlags features)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
|
|
||||||
|
if (!ctx->features_cached)
|
||||||
|
_cogl_features_init ();
|
||||||
|
|
||||||
|
return (ctx->feature_flags & features) == features;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -835,217 +938,79 @@ cogl_fog_set (const ClutterColor *fog_color,
|
|||||||
glFogf (GL_FOG_END, CLUTTER_FIXED_TO_FLOAT (stop));
|
glFogf (GL_FOG_END, CLUTTER_FIXED_TO_FLOAT (stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FBOs - offscreen */
|
|
||||||
|
|
||||||
COGLuint
|
|
||||||
cogl_offscreen_create (COGLuint target_texture)
|
|
||||||
{
|
|
||||||
#ifdef GL_FRAMEBUFFER_EXT
|
|
||||||
COGLuint handle;
|
|
||||||
GLenum status;
|
|
||||||
|
|
||||||
if (_gen_framebuffers == NULL
|
|
||||||
|| _bind_framebuffer == NULL
|
|
||||||
|| _framebuffer_texture_2d == NULL
|
|
||||||
|| _check_framebuffer_status == NULL)
|
|
||||||
{
|
|
||||||
/* tmp warning - need error reporting */
|
|
||||||
g_warning("Missing GL_FRAMEBUFFER_EXT API\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gen_framebuffers (1, &handle);
|
|
||||||
_bind_framebuffer (GL_FRAMEBUFFER_EXT, handle);
|
|
||||||
|
|
||||||
_framebuffer_texture_2d (GL_FRAMEBUFFER_EXT,
|
|
||||||
GL_COLOR_ATTACHMENT0_EXT,
|
|
||||||
GL_TEXTURE_RECTANGLE_ARB,
|
|
||||||
target_texture,
|
|
||||||
0);
|
|
||||||
|
|
||||||
status = _check_framebuffer_status (GL_FRAMEBUFFER_EXT);
|
|
||||||
|
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
|
||||||
{
|
|
||||||
_delete_framebuffers (1, &handle);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_bind_framebuffer (GL_FRAMEBUFFER_EXT, 0);
|
|
||||||
|
|
||||||
return handle;
|
|
||||||
#else
|
|
||||||
/* tmp warning - need error reporting */
|
|
||||||
g_warning("No GL_FRAMEBUFFER_EXT\n");
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_destroy (COGLuint offscreen_handle)
|
|
||||||
{
|
|
||||||
if (_delete_framebuffers)
|
|
||||||
_delete_framebuffers (1, &offscreen_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_start (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
/* FIXME: silly we need to pass width / height to init viewport */
|
|
||||||
#ifdef GL_FRAMEBUFFER_EXT
|
|
||||||
|
|
||||||
if (_bind_framebuffer == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_bind_framebuffer (GL_FRAMEBUFFER_EXT, offscreen_handle);
|
|
||||||
|
|
||||||
glViewport (0, 0, width, height);
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glTranslatef (-1.0f, -1.0f, 0.0f);
|
|
||||||
glScalef (2.0f / (float)width, 2.0f / (float)height, 1.0f);
|
|
||||||
|
|
||||||
/* Clear the scene, appears needed on some backends - OSX */
|
|
||||||
glClearColor (0.0, 0.0, 0.0, 0.0);
|
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_end (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
/* FIXME: silly we need to pass width / height to reset to */
|
|
||||||
if (_bind_framebuffer == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef GL_FRAMEBUFFER_EXT
|
|
||||||
glViewport (0, 0, width, height);
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
_bind_framebuffer (GL_FRAMEBUFFER_EXT, 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Shader Magic follows */
|
/* Shader Magic follows */
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
|
|
||||||
#define PROC(rettype, retval, procname, args...) \
|
|
||||||
static rettype (*proc) (args) = NULL; \
|
|
||||||
if (proc == NULL) \
|
|
||||||
{ \
|
|
||||||
proc = (void*)cogl_get_proc_address (#procname);\
|
|
||||||
if (!proc)\
|
|
||||||
{\
|
|
||||||
g_warning ("failed to lookup proc: %s", #procname);\
|
|
||||||
return retval;\
|
|
||||||
}\
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define PROC(rettype, retval, procname, ...) \
|
|
||||||
static rettype (*proc) (__VA_ARGS__) = NULL; \
|
|
||||||
if (proc == NULL) \
|
|
||||||
{ \
|
|
||||||
proc = (void*)cogl_get_proc_address (#procname);\
|
|
||||||
if (!proc)\
|
|
||||||
{\
|
|
||||||
g_warning ("failed to lookup proc: %s", #procname);\
|
|
||||||
return retval;\
|
|
||||||
}\
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
COGLhandle
|
COGLhandle
|
||||||
cogl_create_program (void)
|
cogl_create_program (void)
|
||||||
{
|
{
|
||||||
PROC (GLhandleARB, 0, glCreateProgramObjectARB, void);
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
return proc ();
|
return glCreateProgramObjectARB ();
|
||||||
}
|
}
|
||||||
|
|
||||||
COGLhandle
|
COGLhandle
|
||||||
cogl_create_shader (COGLenum shaderType)
|
cogl_create_shader (COGLenum shaderType)
|
||||||
{
|
{
|
||||||
PROC (GLhandleARB, 0, glCreateShaderObjectARB, GLenum);
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
return proc (shaderType);
|
return glCreateShaderObjectARB (shaderType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_shader_source (COGLhandle shader,
|
cogl_shader_source (COGLhandle shader,
|
||||||
const gchar *source)
|
const gchar *source)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glShaderSourceARB, GLhandleARB, GLsizei, const GLcharARB **, const GLint *)
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (shader, 1, &source, NULL);
|
glShaderSourceARB (shader, 1, &source, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_shader_compile (COGLhandle shader_handle)
|
cogl_shader_compile (COGLhandle shader_handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glCompileShaderARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (shader_handle);
|
glCompileShaderARB (shader_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_program_attach_shader (COGLhandle program_handle,
|
cogl_program_attach_shader (COGLhandle program_handle,
|
||||||
COGLhandle shader_handle)
|
COGLhandle shader_handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glAttachObjectARB, GLhandleARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (program_handle, shader_handle);
|
glAttachObjectARB (program_handle, shader_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_program_link (COGLhandle program_handle)
|
cogl_program_link (COGLhandle program_handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glLinkProgramARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (program_handle);
|
glLinkProgramARB (program_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_program_use (COGLhandle program_handle)
|
cogl_program_use (COGLhandle program_handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glUseProgramObjectARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (program_handle);
|
glUseProgramObjectARB (program_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
COGLint
|
COGLint
|
||||||
cogl_program_get_uniform_location (COGLhandle program_handle,
|
cogl_program_get_uniform_location (COGLhandle program_handle,
|
||||||
const gchar *uniform_name)
|
const gchar *uniform_name)
|
||||||
{
|
{
|
||||||
PROC (GLint,0, glGetUniformLocationARB, GLhandleARB, const GLcharARB *)
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
return proc (program_handle, uniform_name);
|
return glGetUniformLocationARB (program_handle, uniform_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_program_destroy (COGLhandle handle)
|
cogl_program_destroy (COGLhandle handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glDeleteObjectARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (handle);
|
glDeleteObjectARB (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_shader_destroy (COGLhandle handle)
|
cogl_shader_destroy (COGLhandle handle)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glDeleteObjectARB, GLhandleARB);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (handle);
|
glDeleteObjectARB (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1054,8 +1019,8 @@ cogl_shader_get_info_log (COGLhandle handle,
|
|||||||
gchar *buffer)
|
gchar *buffer)
|
||||||
{
|
{
|
||||||
COGLint len;
|
COGLint len;
|
||||||
PROC (GLvoid,, glGetInfoLogARB, GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (handle, size-1, &len, buffer);
|
glGetInfoLogARB (handle, size-1, &len, buffer);
|
||||||
buffer[len]='\0';
|
buffer[len]='\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,15 +1029,14 @@ cogl_shader_get_parameteriv (COGLhandle handle,
|
|||||||
COGLenum pname,
|
COGLenum pname,
|
||||||
COGLint *dest)
|
COGLint *dest)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glGetObjectParameterivARB, GLhandleARB, GLenum, GLint*)
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (handle, pname, dest);
|
glGetObjectParameterivARB (handle, pname, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_program_uniform_1f (COGLint uniform_no,
|
cogl_program_uniform_1f (COGLint uniform_no,
|
||||||
gfloat value)
|
gfloat value)
|
||||||
{
|
{
|
||||||
PROC (GLvoid,, glUniform1fARB, GLint, GLfloat);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
proc (uniform_no, value);
|
glUniform1fARB (uniform_no, value);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter
|
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||||
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h \
|
libclutterinclude_HEADERS = $(top_builddir)/clutter/cogl/cogl.h \
|
||||||
$(top_srcdir)/clutter/cogl/gles/cogl-defines.h
|
$(top_builddir)/clutter/cogl/cogl-defines-gles.h
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter/cogl \
|
||||||
|
-I$(top_srcdir)/clutter/cogl/common \
|
||||||
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
|
-I$(top_builddir)/clutter \
|
||||||
|
-I$(top_builddir)/clutter/cogl \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
@ -14,6 +19,18 @@ LDADD = $(CLUTTER_LIBS)
|
|||||||
noinst_LTLIBRARIES = libclutter-cogl.la
|
noinst_LTLIBRARIES = libclutter-cogl.la
|
||||||
|
|
||||||
libclutter_cogl_la_SOURCES = \
|
libclutter_cogl_la_SOURCES = \
|
||||||
$(top_srcdir)/clutter/cogl/cogl.h \
|
$(top_builddir)/clutter/cogl/cogl.h \
|
||||||
$(top_srcdir)/clutter/cogl/gl/cogl-defines.h \
|
$(top_builddir)/clutter/cogl/gles/cogl-defines.h \
|
||||||
cogl.c
|
cogl-defines.h \
|
||||||
|
cogl-internal.h \
|
||||||
|
cogl-primitives.h \
|
||||||
|
cogl-texture.h \
|
||||||
|
cogl-fbo.h \
|
||||||
|
cogl-context.h \
|
||||||
|
cogl.c \
|
||||||
|
cogl-primitives.c \
|
||||||
|
cogl-texture.c \
|
||||||
|
cogl-fbo.c \
|
||||||
|
cogl-context.c
|
||||||
|
|
||||||
|
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||||
|
96
clutter/cogl/gles/cogl-context.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
#include "cogl-context.h"
|
||||||
|
|
||||||
|
static CoglContext *_context = NULL;
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_create_context ()
|
||||||
|
{
|
||||||
|
if (_context != NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Allocate context memory */
|
||||||
|
_context = (CoglContext*) g_malloc (sizeof (CoglContext));
|
||||||
|
|
||||||
|
/* Init default values */
|
||||||
|
_context->feature_flags = 0;
|
||||||
|
_context->features_cached = FALSE;
|
||||||
|
|
||||||
|
_context->enable_flags = 0;
|
||||||
|
_context->color_alpha = 255;
|
||||||
|
|
||||||
|
_context->path_nodes = NULL;
|
||||||
|
_context->path_nodes_cap = 0;
|
||||||
|
_context->path_nodes_size = 0;
|
||||||
|
|
||||||
|
_context->texture_handles = NULL;
|
||||||
|
_context->texture_vertices_size = 0;
|
||||||
|
_context->texture_vertices = NULL;
|
||||||
|
|
||||||
|
_context->fbo_handles = NULL;
|
||||||
|
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||||
|
|
||||||
|
/* Init OpenGL state */
|
||||||
|
glTexEnvx (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glColorMask (TRUE, TRUE, TRUE, FALSE);
|
||||||
|
cogl_enable (0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_destroy_context ()
|
||||||
|
{
|
||||||
|
if (_context == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_context->texture_vertices)
|
||||||
|
g_free (_context->texture_vertices);
|
||||||
|
|
||||||
|
g_free (_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglContext *
|
||||||
|
_cogl_context_get_default ()
|
||||||
|
{
|
||||||
|
/* Create if doesn't exists yet */
|
||||||
|
if (_context == NULL)
|
||||||
|
cogl_create_context ();
|
||||||
|
|
||||||
|
return _context;
|
||||||
|
}
|
78
clutter/cogl/gles/cogl-context.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_CONTEXT_H
|
||||||
|
#define __COGL_CONTEXT_H
|
||||||
|
|
||||||
|
#include "cogl-primitives.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GLfixed v[3];
|
||||||
|
GLfixed t[2];
|
||||||
|
GLfixed c[4];
|
||||||
|
} CoglTextureGLVertex;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Features cache */
|
||||||
|
CoglFeatureFlags feature_flags;
|
||||||
|
gboolean features_cached;
|
||||||
|
|
||||||
|
/* Enable cache */
|
||||||
|
gulong enable_flags;
|
||||||
|
guint8 color_alpha;
|
||||||
|
|
||||||
|
/* Primitives */
|
||||||
|
CoglFixedVec2 path_start;
|
||||||
|
CoglFixedVec2 path_pen;
|
||||||
|
CoglFixedVec2 *path_nodes;
|
||||||
|
guint path_nodes_cap;
|
||||||
|
guint path_nodes_size;
|
||||||
|
CoglFixedVec2 path_nodes_min;
|
||||||
|
CoglFixedVec2 path_nodes_max;
|
||||||
|
|
||||||
|
/* Textures */
|
||||||
|
GArray *texture_handles;
|
||||||
|
CoglTextureGLVertex *texture_vertices;
|
||||||
|
gulong texture_vertices_size;
|
||||||
|
|
||||||
|
/* Framebuffer objects */
|
||||||
|
GArray *fbo_handles;
|
||||||
|
CoglBufferTarget draw_buffer;
|
||||||
|
|
||||||
|
} CoglContext;
|
||||||
|
|
||||||
|
CoglContext *
|
||||||
|
_cogl_context_get_default ();
|
||||||
|
|
||||||
|
/* Obtains the context and returns retval if NULL */
|
||||||
|
#define _COGL_GET_CONTEXT(ctxvar, retval) \
|
||||||
|
CoglContext *ctxvar = _cogl_context_get_default (); \
|
||||||
|
if (ctxvar == NULL) return retval;
|
||||||
|
|
||||||
|
#define NO_RETVAL
|
||||||
|
|
||||||
|
#endif /* __COGL_CONTEXT_H */
|
@ -444,18 +444,6 @@ typedef GLuint COGLhandle;
|
|||||||
|
|
||||||
/* extras */
|
/* extras */
|
||||||
|
|
||||||
#define CGL_TEXTURE_2D GL_TEXTURE_2D
|
|
||||||
#define CGL_ARGB GL_ARGB
|
|
||||||
|
|
||||||
/* FIXME: There is no BGR support in GLES - so with below BGR textures are
|
|
||||||
* borked. Will likely need a feature flag and some coversion..
|
|
||||||
*/
|
|
||||||
#define CGL_BGR GL_RGB
|
|
||||||
#define CGL_BGRA GL_RGBA
|
|
||||||
|
|
||||||
/* Its unlikely we support this */
|
|
||||||
#define CGL_TEXTURE_RECTANGLE_ARB 0
|
|
||||||
|
|
||||||
/* YUV textures also unsupported */
|
/* YUV textures also unsupported */
|
||||||
#define CGL_YCBCR_MESA 0
|
#define CGL_YCBCR_MESA 0
|
||||||
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
|
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
|
188
clutter/cogl/gles/cogl-fbo.c
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
#include "cogl-texture.h"
|
||||||
|
#include "cogl-fbo.h"
|
||||||
|
#include "cogl-context.h"
|
||||||
|
|
||||||
|
/* Expecting EXT functions not to be defined - redirect to pointers in context */
|
||||||
|
#define glGenRenderbuffersEXT ctx->pf_glGenRenderbuffersEXT
|
||||||
|
#define glBindRenderbufferEXT ctx->pf_glBindRenderbufferEXT
|
||||||
|
#define glRenderbufferStorageEXT ctx->pf_glRenderbufferStorageEXT
|
||||||
|
#define glGenFramebuffersEXT ctx->pf_glGenFramebuffersEXT
|
||||||
|
#define glBindFramebufferEXT ctx->pf_glBindFramebufferEXT
|
||||||
|
#define glFramebufferTexture2DEXT ctx->pf_glFramebufferTexture2DEXT
|
||||||
|
#define glFramebufferRenderbufferEXT ctx->pf_glFramebufferRenderbufferEXT
|
||||||
|
#define glCheckFramebufferStatusEXT ctx->pf_glCheckFramebufferStatusEXT
|
||||||
|
#define glDeleteFramebuffersEXT ctx->pf_glDeleteFramebuffersEXT
|
||||||
|
#define glBlitFramebufferEXT ctx->pf_glBlitFramebufferEXT
|
||||||
|
#define glRenderbufferStorageMultisampleEXT ctx->pf_glRenderbufferStorageMultisampleEXT
|
||||||
|
|
||||||
|
static gint
|
||||||
|
_cogl_fbo_handle_find (CoglHandle handle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if (ctx->fbo_handles == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i=0; i < ctx->fbo_handles->len; ++i)
|
||||||
|
if (g_array_index (ctx->fbo_handles, CoglHandle, i) == handle)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
static CoglHandle
|
||||||
|
_cogl_fbo_handle_new (CoglFbo *fbo)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
CoglHandle handle = (CoglHandle)fbo;
|
||||||
|
|
||||||
|
if (ctx->fbo_handles == NULL)
|
||||||
|
ctx->fbo_handles = g_array_new (FALSE, FALSE, sizeof (CoglHandle));
|
||||||
|
|
||||||
|
g_array_append_val (ctx->fbo_handles, handle);
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_fbo_handle_release (CoglHandle handle)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if ( (i = _cogl_fbo_handle_find (handle)) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_array_remove_index_fast (ctx->fbo_handles, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CoglFbo*
|
||||||
|
_cogl_fbo_pointer_from_handle (CoglHandle handle)
|
||||||
|
{
|
||||||
|
return (CoglFbo*) handle;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_is_offscreen_buffer (CoglHandle handle)
|
||||||
|
{
|
||||||
|
if (handle == COGL_INVALID_HANDLE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return _cogl_fbo_handle_find (handle) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||||
|
{
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_new_multisample ()
|
||||||
|
{
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_offscreen_ref (CoglHandle handle)
|
||||||
|
{
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_unref (CoglHandle handle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int src_w,
|
||||||
|
int src_h,
|
||||||
|
int dst_x,
|
||||||
|
int dst_y,
|
||||||
|
int dst_w,
|
||||||
|
int dst_h)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||||
|
CoglHandle dst_buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case COGL_OFFSCREEN_BUFFER:
|
||||||
|
|
||||||
|
/* Not supported */
|
||||||
|
return;
|
||||||
|
|
||||||
|
case COGL_WINDOW_BUFFER:
|
||||||
|
|
||||||
|
/* Draw to RGB channels */
|
||||||
|
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COGL_MASK_BUFFER:
|
||||||
|
|
||||||
|
/* Draw only to ALPHA channel */
|
||||||
|
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
case COGL_WINDOW_BUFFER & COGL_MASK_BUFFER:
|
||||||
|
|
||||||
|
/* Draw to all channels */
|
||||||
|
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store new target */
|
||||||
|
ctx->draw_buffer = target;
|
||||||
|
}
|
38
clutter/cogl/gles/cogl-fbo.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_FBO_H
|
||||||
|
#define __COGL_FBO_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
guint ref_count;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
GLuint gl_handle;
|
||||||
|
|
||||||
|
} CoglFbo;
|
||||||
|
|
||||||
|
#endif /* __COGL_FBO_H */
|
63
clutter/cogl/gles/cogl-internal.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_INTERNAL_H
|
||||||
|
#define __COGL_INTERNAL_H
|
||||||
|
|
||||||
|
#define COGL_DEBUG 0
|
||||||
|
|
||||||
|
#if COGL_DEBUG
|
||||||
|
#define GE(x...) { \
|
||||||
|
GLenum err; \
|
||||||
|
(x); \
|
||||||
|
fprintf(stderr, "%s\n", #x); \
|
||||||
|
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||||
|
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||||
|
(char *)error_string(err), \
|
||||||
|
__FILE__, __LINE__); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define GE(x) (x);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define COGL_ENABLE_BLEND (1<<1)
|
||||||
|
#define COGL_ENABLE_TEXTURE_2D (1<<2)
|
||||||
|
#define COGL_ENABLE_ALPHA_TEST (1<<3)
|
||||||
|
#define COGL_ENABLE_TEXTURE_RECT (1<<4)
|
||||||
|
#define COGL_ENABLE_VERTEX_ARRAY (1<<5)
|
||||||
|
#define COGL_ENABLE_TEXCOORD_ARRAY (1<<6)
|
||||||
|
#define COGL_ENABLE_COLOR_ARRAY (1<<7)
|
||||||
|
|
||||||
|
gint
|
||||||
|
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_enable (gulong flags);
|
||||||
|
|
||||||
|
gulong
|
||||||
|
cogl_get_enable ();
|
||||||
|
|
||||||
|
#endif /* __COGL_INTERNAL_H */
|
1112
clutter/cogl/gles/cogl-primitives.c
Normal file
54
clutter/cogl/gles/cogl-primitives.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_PRIMITIVES_H
|
||||||
|
#define __COGL_PRIMITIVES_H
|
||||||
|
|
||||||
|
typedef struct _CoglFixedVec2 CoglFixedVec2;
|
||||||
|
typedef struct _CoglBezQuad CoglBezQuad;
|
||||||
|
typedef struct _CoglBezCubic CoglBezCubic;
|
||||||
|
|
||||||
|
struct _CoglFixedVec2
|
||||||
|
{
|
||||||
|
ClutterFixed x;
|
||||||
|
ClutterFixed y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglBezQuad
|
||||||
|
{
|
||||||
|
CoglFixedVec2 p1;
|
||||||
|
CoglFixedVec2 p2;
|
||||||
|
CoglFixedVec2 p3;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglBezCubic
|
||||||
|
{
|
||||||
|
CoglFixedVec2 p1;
|
||||||
|
CoglFixedVec2 p2;
|
||||||
|
CoglFixedVec2 p3;
|
||||||
|
CoglFixedVec2 p4;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __COGL_PRIMITIVES_H */
|
2185
clutter/cogl/gles/cogl-texture.c
Normal file
63
clutter/cogl/gles/cogl-texture.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_TEXTURE_H
|
||||||
|
#define __COGL_TEXTURE_H
|
||||||
|
|
||||||
|
#include "cogl-bitmap.h"
|
||||||
|
|
||||||
|
typedef struct _CoglTexture CoglTexture;
|
||||||
|
typedef struct _CoglTexSliceSpan CoglTexSliceSpan;
|
||||||
|
typedef struct _CoglSpanIter CoglSpanIter;
|
||||||
|
|
||||||
|
struct _CoglTexSliceSpan
|
||||||
|
{
|
||||||
|
gint start;
|
||||||
|
gint size;
|
||||||
|
gint waste;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _CoglTexture
|
||||||
|
{
|
||||||
|
guint ref_count;
|
||||||
|
CoglBitmap bitmap;
|
||||||
|
gboolean bitmap_owner;
|
||||||
|
GLenum gl_target;
|
||||||
|
GLenum gl_intformat;
|
||||||
|
GLenum gl_format;
|
||||||
|
GLenum gl_type;
|
||||||
|
GArray *slice_x_spans;
|
||||||
|
GArray *slice_y_spans;
|
||||||
|
GArray *slice_gl_handles;
|
||||||
|
gint max_waste;
|
||||||
|
COGLenum min_filter;
|
||||||
|
COGLenum mag_filter;
|
||||||
|
gboolean is_foreign;
|
||||||
|
};
|
||||||
|
|
||||||
|
CoglTexture*
|
||||||
|
_cogl_texture_pointer_from_handle (CoglHandle handle);
|
||||||
|
|
||||||
|
#endif /* __COGL_TEXTURE_H */
|
51
clutter/cogl/gles/cogl-util.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "cogl.h"
|
||||||
|
#include "cogl-internal.h"
|
||||||
|
#include "cogl-util.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_util_next_p2:
|
||||||
|
* @a: Value to get the next power
|
||||||
|
*
|
||||||
|
* Calculates the next power greater than @a.
|
||||||
|
*
|
||||||
|
* Return value: The next power after @a.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cogl_util_next_p2 (int a)
|
||||||
|
{
|
||||||
|
int rval=1;
|
||||||
|
|
||||||
|
while(rval < a)
|
||||||
|
rval <<= 1;
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
32
clutter/cogl/gles/cogl-util.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Clutter COGL
|
||||||
|
*
|
||||||
|
* A basic GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_UTIL_H
|
||||||
|
#define __COGL_UTIL_H
|
||||||
|
|
||||||
|
int
|
||||||
|
cogl_util_next_p2 (int a);
|
||||||
|
|
||||||
|
#endif /* __COGL_UTIL_H */
|
@ -32,16 +32,12 @@
|
|||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#include "cogl-internal.h"
|
||||||
#define PIXEL_TYPE GL_UNSIGNED_BYTE
|
#include "cogl-util.h"
|
||||||
#else
|
#include "cogl-context.h"
|
||||||
#define PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static gulong __enable_flags = 0;
|
|
||||||
|
|
||||||
#define COGL_DEBUG 0
|
|
||||||
|
|
||||||
|
/* GL error to string conversion */
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
struct token_string
|
struct token_string
|
||||||
{
|
{
|
||||||
@ -75,20 +71,6 @@ error_string(GLenum errorCode)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COGL_DEBUG
|
|
||||||
#define GE(x...) { \
|
|
||||||
GLenum err; \
|
|
||||||
(x); \
|
|
||||||
fprintf(stderr, "%s\n", #x); \
|
|
||||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
|
||||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
|
||||||
(char *)error_string(err), \
|
|
||||||
__FILE__, __LINE__); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define GE(x) (x);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CoglFuncPtr
|
CoglFuncPtr
|
||||||
cogl_get_proc_address (const gchar* name)
|
cogl_get_proc_address (const gchar* name)
|
||||||
@ -117,9 +99,6 @@ cogl_paint_init (const ClutterColor *color)
|
|||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
glDisable (GL_LIGHTING);
|
glDisable (GL_LIGHTING);
|
||||||
glDisable (GL_FOG);
|
glDisable (GL_FOG);
|
||||||
|
|
||||||
cogl_enable (CGL_ENABLE_BLEND);
|
|
||||||
glTexEnvx (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: inline most of these */
|
/* FIXME: inline most of these */
|
||||||
@ -173,53 +152,98 @@ cogl_rotate (gint angle, gint x, gint y, gint z)
|
|||||||
CLUTTER_INT_TO_FIXED(z)) );
|
CLUTTER_INT_TO_FIXED(z)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
cogl_toggle_flag (CoglContext *ctx,
|
||||||
|
gulong new_flags,
|
||||||
|
gulong flag,
|
||||||
|
GLenum gl_flag)
|
||||||
|
{
|
||||||
|
/* Toggles and caches a single enable flag on or off
|
||||||
|
* by comparing to current state
|
||||||
|
*/
|
||||||
|
if (new_flags & flag)
|
||||||
|
{
|
||||||
|
if (!(ctx->enable_flags & flag))
|
||||||
|
{
|
||||||
|
GE( glEnable (gl_flag) );
|
||||||
|
ctx->enable_flags |= flag;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ctx->enable_flags & flag)
|
||||||
|
{
|
||||||
|
GE( glDisable (gl_flag) );
|
||||||
|
ctx->enable_flags &= ~flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
cogl_toggle_client_flag (CoglContext *ctx,
|
||||||
|
gulong new_flags,
|
||||||
|
gulong flag,
|
||||||
|
GLenum gl_flag)
|
||||||
|
{
|
||||||
|
/* Toggles and caches a single client-side enable flag
|
||||||
|
* on or off by comparing to current state
|
||||||
|
*/
|
||||||
|
if (new_flags & flag)
|
||||||
|
{
|
||||||
|
if (!(ctx->enable_flags & flag))
|
||||||
|
{
|
||||||
|
GE( glEnableClientState (gl_flag) );
|
||||||
|
ctx->enable_flags |= flag;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ctx->enable_flags & flag)
|
||||||
|
{
|
||||||
|
GE( glDisableClientState (gl_flag) );
|
||||||
|
ctx->enable_flags &= ~flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_enable (gulong flags)
|
cogl_enable (gulong flags)
|
||||||
{
|
{
|
||||||
/* This function essentially caches glEnable state() in the
|
/* This function essentially caches glEnable state() in the
|
||||||
* hope of lessening number GL traffic.
|
* hope of lessening number GL traffic.
|
||||||
*/
|
*/
|
||||||
if (flags & CGL_ENABLE_BLEND)
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (cogl_toggle_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_BLEND,
|
||||||
|
GL_BLEND))
|
||||||
{
|
{
|
||||||
if (!(__enable_flags & CGL_ENABLE_BLEND))
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
{
|
|
||||||
GE( glEnable (GL_BLEND) );
|
|
||||||
GE( glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) );
|
|
||||||
}
|
|
||||||
__enable_flags |= CGL_ENABLE_BLEND;
|
|
||||||
}
|
|
||||||
else if (__enable_flags & CGL_ENABLE_BLEND)
|
|
||||||
{
|
|
||||||
GE( glDisable (GL_BLEND) );
|
|
||||||
__enable_flags &= ~CGL_ENABLE_BLEND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & CGL_ENABLE_TEXTURE_2D)
|
cogl_toggle_flag (ctx, flags,
|
||||||
{
|
COGL_ENABLE_TEXTURE_2D,
|
||||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_2D))
|
GL_TEXTURE_2D);
|
||||||
GE( glEnable (GL_TEXTURE_2D) );
|
|
||||||
__enable_flags |= CGL_ENABLE_TEXTURE_2D;
|
cogl_toggle_client_flag (ctx, flags,
|
||||||
}
|
COGL_ENABLE_VERTEX_ARRAY,
|
||||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_2D)
|
GL_VERTEX_ARRAY);
|
||||||
{
|
|
||||||
GE( glDisable (GL_TEXTURE_2D) );
|
cogl_toggle_client_flag (ctx, flags,
|
||||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_2D;
|
COGL_ENABLE_TEXCOORD_ARRAY,
|
||||||
|
GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
cogl_toggle_client_flag (ctx, flags,
|
||||||
|
COGL_ENABLE_COLOR_ARRAY,
|
||||||
|
GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
gulong
|
||||||
if (flags & CGL_ENABLE_TEXTURE_RECT)
|
cogl_get_enable ()
|
||||||
{
|
{
|
||||||
if (!(__enable_flags & CGL_ENABLE_TEXTURE_RECT))
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
glEnable (GL_TEXTURE_RECTANGLE_);
|
|
||||||
|
|
||||||
__enable_flags |= CGL_ENABLE_TEXTURE_RECT;
|
return ctx->enable_flags;
|
||||||
}
|
|
||||||
else if (__enable_flags & CGL_ENABLE_TEXTURE_RECT)
|
|
||||||
{
|
|
||||||
glDisable (GL_TEXTURE_RECTANGLE_);
|
|
||||||
__enable_flags &= ~CGL_ENABLE_TEXTURE_RECT;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -242,6 +266,8 @@ cogl_enable_depth_test (gboolean setting)
|
|||||||
void
|
void
|
||||||
cogl_color (const ClutterColor *color)
|
cogl_color (const ClutterColor *color)
|
||||||
{
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
#if 0 /*HAVE_GLES_COLOR4UB*/
|
#if 0 /*HAVE_GLES_COLOR4UB*/
|
||||||
|
|
||||||
/* NOTE: seems SDK_OGLES-1.1_LINUX_PCEMULATION_2.02.22.0756 has this call
|
/* NOTE: seems SDK_OGLES-1.1_LINUX_PCEMULATION_2.02.22.0756 has this call
|
||||||
@ -267,25 +293,9 @@ cogl_color (const ClutterColor *color)
|
|||||||
(color->blue << 16) / 0xff,
|
(color->blue << 16) / 0xff,
|
||||||
(color->alpha << 16) / 0xff));
|
(color->alpha << 16) / 0xff));
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
/* Store alpha for proper blending enables */
|
||||||
cogl_rectangle_internal (ClutterFixed x,
|
ctx->color_alpha = color->alpha;
|
||||||
ClutterFixed y,
|
|
||||||
ClutterFixed width,
|
|
||||||
ClutterFixed height)
|
|
||||||
{
|
|
||||||
GLfixed rect_verts[8] = {
|
|
||||||
x, y,
|
|
||||||
x + width, y,
|
|
||||||
x, y + height,
|
|
||||||
x + width, y + height
|
|
||||||
};
|
|
||||||
|
|
||||||
GE( glEnableClientState (GL_VERTEX_ARRAY) );
|
|
||||||
GE( glVertexPointer (2, GL_FIXED, 0, rect_verts) );
|
|
||||||
GE( glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
|
|
||||||
GE( glDisableClientState (GL_VERTEX_ARRAY) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -293,6 +303,24 @@ cogl_clip_set (ClutterFixed x_offset,
|
|||||||
ClutterFixed y_offset,
|
ClutterFixed y_offset,
|
||||||
ClutterFixed width,
|
ClutterFixed width,
|
||||||
ClutterFixed height)
|
ClutterFixed height)
|
||||||
|
{
|
||||||
|
if (cogl_features_available (COGL_FEATURE_FOUR_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
GLfixed eqn_left[4] = { CFX_ONE, 0, 0, -x_offset };
|
||||||
|
GLfixed eqn_right[4] = { -CFX_ONE, 0, 0, x_offset + width };
|
||||||
|
GLfixed eqn_top[4] = { 0, CFX_ONE, 0, -y_offset };
|
||||||
|
GLfixed eqn_bottom[4] = { 0, -CFX_ONE, 0, y_offset + height };
|
||||||
|
|
||||||
|
GE( glClipPlanex (GL_CLIP_PLANE0, eqn_left) );
|
||||||
|
GE( glClipPlanex (GL_CLIP_PLANE1, eqn_right) );
|
||||||
|
GE( glClipPlanex (GL_CLIP_PLANE2, eqn_top) );
|
||||||
|
GE( glClipPlanex (GL_CLIP_PLANE3, eqn_bottom) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE0) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE1) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE2) );
|
||||||
|
GE( glEnable (GL_CLIP_PLANE3) );
|
||||||
|
}
|
||||||
|
else if (cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||||
{
|
{
|
||||||
GE( glEnable (GL_STENCIL_TEST) );
|
GE( glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
@ -304,189 +332,29 @@ cogl_clip_set (ClutterFixed x_offset,
|
|||||||
|
|
||||||
GE( glColor4x (CFX_ONE, CFX_ONE, CFX_ONE, CFX_ONE ) );
|
GE( glColor4x (CFX_ONE, CFX_ONE, CFX_ONE, CFX_ONE ) );
|
||||||
|
|
||||||
cogl_rectangle_internal (x_offset, y_offset, width, height);
|
cogl_fast_fill_rectanglex (x_offset, y_offset, width, height);
|
||||||
|
|
||||||
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||||
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_clip_unset (void)
|
cogl_clip_unset (void)
|
||||||
|
{
|
||||||
|
if (cogl_features_available (COGL_FEATURE_FOUR_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
GE( glDisable (GL_CLIP_PLANE3) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE2) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE1) );
|
||||||
|
GE( glDisable (GL_CLIP_PLANE0) );
|
||||||
|
}
|
||||||
|
else if (cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||||
{
|
{
|
||||||
GE( glDisable (GL_STENCIL_TEST) );
|
GE( glDisable (GL_STENCIL_TEST) );
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
cogl_texture_can_size (COGLenum target,
|
|
||||||
COGLenum pixel_format,
|
|
||||||
COGLenum pixel_type,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
|
||||||
/* FIXME: How we get this is likely GLES implementation dependant. */
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_quad (gint x1,
|
|
||||||
gint x2,
|
|
||||||
gint y1,
|
|
||||||
gint y2,
|
|
||||||
ClutterFixed tx1,
|
|
||||||
ClutterFixed ty1,
|
|
||||||
ClutterFixed tx2,
|
|
||||||
ClutterFixed ty2)
|
|
||||||
{
|
|
||||||
#define FIX CLUTTER_INT_TO_FIXED
|
|
||||||
|
|
||||||
GLfixed quadVerts[] = {
|
|
||||||
FIX(x1), FIX(y1), 0,
|
|
||||||
FIX(x2), FIX(y1), 0,
|
|
||||||
FIX(x2), FIX(y2), 0,
|
|
||||||
FIX(x2), FIX(y2), 0,
|
|
||||||
FIX(x1), FIX(y2), 0,
|
|
||||||
FIX(x1), FIX(y1), 0
|
|
||||||
};
|
|
||||||
|
|
||||||
GLfixed quadTex[] = {
|
|
||||||
tx1, ty1,
|
|
||||||
tx2, ty1,
|
|
||||||
tx2, ty2,
|
|
||||||
tx2, ty2,
|
|
||||||
tx1, ty2,
|
|
||||||
tx1, ty1
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef FIX
|
|
||||||
|
|
||||||
GE( glEnableClientState(GL_VERTEX_ARRAY) );
|
|
||||||
GE( glEnableClientState(GL_TEXTURE_COORD_ARRAY) );
|
|
||||||
GE( glVertexPointer(3, GL_FIXED, 0, quadVerts) );
|
|
||||||
GE( glTexCoordPointer(2, GL_FIXED, 0, quadTex) );
|
|
||||||
GE( glDrawArrays(GL_TRIANGLES, 0, 6) );
|
|
||||||
GE( glDisableClientState(GL_TEXTURE_COORD_ARRAY) );
|
|
||||||
GE( glDisableClientState(GL_VERTEX_ARRAY) );
|
|
||||||
|
|
||||||
/* Note also see glDrawTexxOES for potential optimisation */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_create (guint num, COGLuint *textures)
|
|
||||||
{
|
|
||||||
GE( glGenTextures (num, textures) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_textures_destroy (guint num, const COGLuint *textures)
|
|
||||||
{
|
|
||||||
GE( glDeleteTextures (num, textures) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_bind (COGLenum target, COGLuint texture)
|
|
||||||
{
|
|
||||||
GE( glBindTexture (target, texture) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_alignment (COGLenum target,
|
|
||||||
guint alignment,
|
|
||||||
guint row_length)
|
|
||||||
{
|
|
||||||
/* GE( glPixelStorei (GL_UNPACK_ROW_LENGTH, row_length) ); */
|
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, alignment) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_filters (COGLenum target,
|
|
||||||
COGLenum min_filter,
|
|
||||||
COGLenum max_filter)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_MAG_FILTER, max_filter) );
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_MIN_FILTER, min_filter) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_set_wrap (COGLenum target,
|
|
||||||
COGLenum wrap_s,
|
|
||||||
COGLenum wrap_t)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap_s) );
|
|
||||||
GE( glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap_s) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_image_2d (COGLenum target,
|
|
||||||
COGLint internal_format,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels)
|
|
||||||
{
|
|
||||||
GE( glTexImage2D (target,
|
|
||||||
0,
|
|
||||||
format, /* HACK: For gles we set the internal_format equal
|
|
||||||
* to the pixel format. This is for RGB data (i.e
|
|
||||||
* jpgs) which seem to need a matching internal
|
|
||||||
* format rather than RGBA (which is used by GL)
|
|
||||||
*.
|
|
||||||
* This fix isn't ideal..
|
|
||||||
*/
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
0,
|
|
||||||
format,
|
|
||||||
type,
|
|
||||||
pixels) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_texture_sub_image_2d (COGLenum target,
|
|
||||||
gint xoff,
|
|
||||||
gint yoff,
|
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
COGLenum format,
|
|
||||||
COGLenum type,
|
|
||||||
const guchar* pixels)
|
|
||||||
{
|
|
||||||
GE( glTexSubImage2D (target,
|
|
||||||
0,
|
|
||||||
xoff,
|
|
||||||
yoff,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
format,
|
|
||||||
type,
|
|
||||||
pixels));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_rectangle (gint x,
|
|
||||||
gint y,
|
|
||||||
guint width,
|
|
||||||
guint height)
|
|
||||||
{
|
|
||||||
cogl_rectangle_internal (CLUTTER_INT_TO_FIXED (x),
|
|
||||||
CLUTTER_INT_TO_FIXED (y),
|
|
||||||
CLUTTER_INT_TO_FIXED (width),
|
|
||||||
CLUTTER_INT_TO_FIXED (height));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Should use ClutterReal or Fixed */
|
|
||||||
void
|
|
||||||
cogl_trapezoid (gint y1,
|
|
||||||
gint x11,
|
|
||||||
gint x21,
|
|
||||||
gint y2,
|
|
||||||
gint x12,
|
|
||||||
gint x22)
|
|
||||||
{
|
|
||||||
/* FIXME */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_alpha_func (COGLenum func,
|
cogl_alpha_func (COGLenum func,
|
||||||
ClutterFixed ref)
|
ClutterFixed ref)
|
||||||
@ -591,11 +459,49 @@ cogl_setup_viewport (guint w,
|
|||||||
GE( glTranslatex (0, -CFX_ONE * height, 0) );
|
GE( glTranslatex (0, -CFX_ONE * height, 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_features_init ()
|
||||||
|
{
|
||||||
|
ClutterFeatureFlags flags = 0;
|
||||||
|
int stencil_bits = 0;
|
||||||
|
int max_clip_planes = 0;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
flags = COGL_FEATURE_TEXTURE_READ_PIXELS;
|
||||||
|
|
||||||
|
GE( glGetIntegerv (GL_STENCIL_BITS, &stencil_bits) );
|
||||||
|
if (stencil_bits > 0)
|
||||||
|
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
||||||
|
|
||||||
|
GE( glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
||||||
|
if (max_clip_planes >= 4)
|
||||||
|
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
||||||
|
|
||||||
|
ctx->feature_flags = flags;
|
||||||
|
ctx->features_cached = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ClutterFeatureFlags
|
ClutterFeatureFlags
|
||||||
cogl_get_features ()
|
cogl_get_features ()
|
||||||
{
|
{
|
||||||
/* Suck */
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
return 0;
|
|
||||||
|
if (!ctx->features_cached)
|
||||||
|
_cogl_features_init ();
|
||||||
|
|
||||||
|
return ctx->feature_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cogl_features_available (CoglFeatureFlags features)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
|
|
||||||
|
if (!ctx->features_cached)
|
||||||
|
_cogl_features_init ();
|
||||||
|
|
||||||
|
return (ctx->feature_flags & features) == features;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -654,39 +560,6 @@ cogl_fog_set (const ClutterColor *fog_color,
|
|||||||
glFogx (GL_FOG_END, (GLfixed) z_far);
|
glFogx (GL_FOG_END, (GLfixed) z_far);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offscreen - TODO: possible support from FBO's/PBuffers
|
|
||||||
* See;
|
|
||||||
* http://www.khronos.org/message_boards/viewtopic.php?t=589
|
|
||||||
* http://www.gamedev.net/community/forums/topic.asp?topic_id=369739
|
|
||||||
*
|
|
||||||
* Likely requires EGL 1.3 for eglBindTexImage
|
|
||||||
*/
|
|
||||||
COGLuint
|
|
||||||
cogl_offscreen_create (COGLuint target_texture)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_destroy (COGLuint offscreen_handle)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_start (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cogl_offscreen_redirect_end (COGLuint offscreen_handle,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Shaders, no support on regular OpenGL 1.1 */
|
/* Shaders, no support on regular OpenGL 1.1 */
|
||||||
|
|
||||||
COGLhandle
|
COGLhandle
|
||||||
|
@ -52,40 +52,7 @@ static void
|
|||||||
clutter_backend_egl_ensure_context (ClutterBackend *backend,
|
clutter_backend_egl_ensure_context (ClutterBackend *backend,
|
||||||
ClutterStage *stage)
|
ClutterStage *stage)
|
||||||
{
|
{
|
||||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
/* not doing anything since we only have one context */
|
||||||
|
|
||||||
if (stage == NULL)
|
|
||||||
{
|
|
||||||
CLUTTER_NOTE (BACKEND, "Clearing EGL context");
|
|
||||||
eglMakeCurrent (backend_egl->edpy,
|
|
||||||
EGL_NO_SURFACE,
|
|
||||||
EGL_NO_SURFACE,
|
|
||||||
EGL_NO_CONTEXT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ClutterStageWindow *impl;
|
|
||||||
ClutterStageEGL *stage_egl;
|
|
||||||
|
|
||||||
impl = _clutter_stage_get_window (stage);
|
|
||||||
g_assert (impl != NULL);
|
|
||||||
|
|
||||||
stage_egl = CLUTTER_STAGE_EGL (impl);
|
|
||||||
|
|
||||||
if (!backend_egl->egl_context)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
|
||||||
eglMakeCurrent (backend_egl->edpy,
|
|
||||||
EGL_NO_SURFACE,
|
|
||||||
EGL_NO_SURFACE,
|
|
||||||
EGL_NO_CONTEXT);
|
|
||||||
else
|
|
||||||
eglMakeCurrent (backend_egl->edpy,
|
|
||||||
stage_egl->egl_surface,
|
|
||||||
stage_egl->egl_surface,
|
|
||||||
backend_egl->egl_context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -101,15 +68,11 @@ clutter_backend_egl_redraw (ClutterBackend *backend,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
g_assert (CLUTTER_IS_STAGE_EGL (impl));
|
g_assert (CLUTTER_IS_STAGE_EGL (impl));
|
||||||
|
|
||||||
stage_egl = CLUTTER_STAGE_EGL (impl);
|
stage_egl = CLUTTER_STAGE_EGL (impl);
|
||||||
|
|
||||||
clutter_actor_paint (CLUTTER_ACTOR (stage_egl));
|
eglWaitNative (EGL_CORE_NATIVE_ENGINE);
|
||||||
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
||||||
/* Why this paint is done in backend as likely GL windowing system
|
eglWaitGL();
|
||||||
* specific calls, like swapping buffers.
|
|
||||||
*/
|
|
||||||
/* clutter_feature_wait_for_vblank (); */
|
|
||||||
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
|
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +112,7 @@ clutter_backend_egl_create_stage (ClutterBackend *backend,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
backend_egl->stage = stage_egl;
|
backend_egl->stage = CLUTTER_ACTOR (stage_egl);
|
||||||
|
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
@ -158,7 +121,6 @@ static void
|
|||||||
clutter_backend_egl_init_events (ClutterBackend *backend)
|
clutter_backend_egl_init_events (ClutterBackend *backend)
|
||||||
{
|
{
|
||||||
_clutter_events_init (backend);
|
_clutter_events_init (backend);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GOptionEntry entries[] =
|
static const GOptionEntry entries[] =
|
||||||
@ -166,14 +128,6 @@ static const GOptionEntry entries[] =
|
|||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static ClutterActor *
|
|
||||||
clutter_backend_egl_get_stage (ClutterBackend *backend)
|
|
||||||
{
|
|
||||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
|
||||||
|
|
||||||
return backend_egl->stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_backend_egl_finalize (GObject *gobject)
|
clutter_backend_egl_finalize (GObject *gobject)
|
||||||
{
|
{
|
||||||
@ -199,7 +153,7 @@ clutter_backend_egl_dispose (GObject *gobject)
|
|||||||
if (backend_egl->edpy)
|
if (backend_egl->edpy)
|
||||||
{
|
{
|
||||||
eglTerminate (backend_egl->edpy);
|
eglTerminate (backend_egl->edpy);
|
||||||
backend_egl->edpy = NULL;
|
backend_egl->edpy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (clutter_backend_egl_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_backend_egl_parent_class)->dispose (gobject);
|
||||||
@ -264,7 +218,7 @@ clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
|
|||||||
backend_class->pre_parse = clutter_backend_egl_pre_parse;
|
backend_class->pre_parse = clutter_backend_egl_pre_parse;
|
||||||
backend_class->post_parse = clutter_backend_egl_post_parse;
|
backend_class->post_parse = clutter_backend_egl_post_parse;
|
||||||
backend_class->init_events = clutter_backend_egl_init_events;
|
backend_class->init_events = clutter_backend_egl_init_events;
|
||||||
backend_class->create_stage = clutter_backend_egl_init_stage;
|
backend_class->create_stage = clutter_backend_egl_create_stage;
|
||||||
backend_class->ensure_context = clutter_backend_egl_ensure_context;
|
backend_class->ensure_context = clutter_backend_egl_ensure_context;
|
||||||
backend_class->redraw = clutter_backend_egl_redraw;
|
backend_class->redraw = clutter_backend_egl_redraw;
|
||||||
backend_class->get_features = clutter_backend_egl_get_features;
|
backend_class->get_features = clutter_backend_egl_get_features;
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
#ifndef __CLUTTER_BACKEND_EGL_H__
|
#ifndef __CLUTTER_BACKEND_EGL_H__
|
||||||
#define __CLUTTER_BACKEND_EGL_H__
|
#define __CLUTTER_BACKEND_EGL_H__
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include <clutter/clutter-backend.h>
|
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/egl.h>
|
#include <GLES/egl.h>
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <clutter/clutter-backend.h>
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_BACKEND_EGL (clutter_backend_egl_get_type ())
|
#define CLUTTER_TYPE_BACKEND_EGL (clutter_backend_egl_get_type ())
|
||||||
@ -40,6 +39,7 @@ G_BEGIN_DECLS
|
|||||||
typedef struct _ClutterBackendEGL ClutterBackendEGL;
|
typedef struct _ClutterBackendEGL ClutterBackendEGL;
|
||||||
typedef struct _ClutterBackendEGLClass ClutterBackendEGLClass;
|
typedef struct _ClutterBackendEGLClass ClutterBackendEGLClass;
|
||||||
|
|
||||||
|
|
||||||
struct _ClutterBackendEGL
|
struct _ClutterBackendEGL
|
||||||
{
|
{
|
||||||
ClutterBackend parent_instance;
|
ClutterBackend parent_instance;
|
||||||
|
@ -35,8 +35,7 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
EGLDisplay
|
EGLDisplay clutter_egl_display (void);
|
||||||
clutter_egl_display (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "clutter-backend-egl.h"
|
|
||||||
#include "clutter-stage-egl.h"
|
#include "clutter-stage-egl.h"
|
||||||
#include "clutter-egl.h"
|
#include "clutter-egl.h"
|
||||||
|
#include "clutter-backend-egl.h"
|
||||||
|
|
||||||
#include "../clutter-main.h"
|
#include "../clutter-main.h"
|
||||||
#include "../clutter-feature.h"
|
#include "../clutter-feature.h"
|
||||||
@ -29,12 +29,21 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
|
|||||||
static void
|
static void
|
||||||
clutter_stage_egl_show (ClutterActor *actor)
|
clutter_stage_egl_show (ClutterActor *actor)
|
||||||
{
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl, CLUTTER_ACTOR_MAPPED);
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_MAPPED);
|
||||||
|
|
||||||
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->show (actor);
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->show (actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_egl_hide (ClutterActor *actor)
|
clutter_stage_egl_hide (ClutterActor *actor)
|
||||||
{
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_egl, CLUTTER_ACTOR_MAPPED);
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_MAPPED);
|
||||||
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->hide (actor);
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->hide (actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +73,6 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
EGLConfig configs[2];
|
EGLConfig configs[2];
|
||||||
EGLint config_count;
|
EGLint config_count;
|
||||||
EGLBoolean status;
|
EGLBoolean status;
|
||||||
ClutterPerspective perspective;
|
|
||||||
gboolean is_offscreen;
|
gboolean is_offscreen;
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
||||||
@ -81,7 +89,7 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
EGL_BLUE_SIZE, 5,
|
EGL_BLUE_SIZE, 5,
|
||||||
EGL_DEPTH_SIZE, 16,
|
EGL_DEPTH_SIZE, 16,
|
||||||
EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
||||||
EGL_STENCIL_SIZE, EGL_DONT_CARE,
|
EGL_STENCIL_SIZE, 2,
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
EGL_NONE };
|
EGL_NONE };
|
||||||
|
|
||||||
@ -108,12 +116,20 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
stage_egl->egl_surface = EGL_NO_SURFACE;
|
stage_egl->egl_surface = EGL_NO_SURFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (backend_egl->egl_context)
|
||||||
|
{
|
||||||
|
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
|
||||||
|
backend_egl->egl_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
stage_egl->egl_surface =
|
stage_egl->egl_surface =
|
||||||
eglCreateWindowSurface (backend_egl->edpy,
|
eglCreateWindowSurface (backend_egl->edpy,
|
||||||
configs[0],
|
configs[0],
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
g_critical ("Unable to create an EGL surface");
|
g_critical ("Unable to create an EGL surface");
|
||||||
@ -136,7 +152,8 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
stage_egl->surface_width,
|
stage_egl->surface_width,
|
||||||
stage_egl->surface_height);
|
stage_egl->surface_height);
|
||||||
|
|
||||||
if (G_UNLIKELY (backend_egl->egl_context == None))
|
|
||||||
|
if (G_UNLIKELY (backend_egl->egl_context == NULL))
|
||||||
{
|
{
|
||||||
CLUTTER_NOTE (GL, "Creating EGL Context");
|
CLUTTER_NOTE (GL, "Creating EGL Context");
|
||||||
|
|
||||||
@ -154,11 +171,20 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this will make sure to set the current context */
|
|
||||||
CLUTTER_NOTE (BACKEND, "Marking stage as realized and setting context");
|
CLUTTER_NOTE (BACKEND, "Marking stage as realized and setting context");
|
||||||
CLUTTER_ACTOR_SET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_REALIZED);
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_REALIZED);
|
||||||
CLUTTER_ACTOR_SET_FLAGS (stage_egl, CLUTTER_ACTOR_REALIZED);
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl, CLUTTER_ACTOR_REALIZED);
|
||||||
clutter_stage_ensure_current (stage_egl->wrapper);
|
|
||||||
|
|
||||||
|
/* eglnative can have only one context */
|
||||||
|
status = eglMakeCurrent (backend_egl->edpy,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
backend_egl->egl_context);
|
||||||
|
|
||||||
|
if (status != EGL_TRUE)
|
||||||
|
g_warning ("eglMakeCurrent");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -167,6 +193,7 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_SYNC_MATRICES);
|
CLUTTER_SET_PRIVATE_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +239,6 @@ clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||||
ClutterStageClass *stage_class = CLUTTER_STAGE_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = clutter_stage_egl_dispose;
|
gobject_class->dispose = clutter_stage_egl_dispose;
|
||||||
|
|
||||||
@ -232,10 +258,18 @@ clutter_stage_egl_set_fullscreen (ClutterStageWindow *stage_window,
|
|||||||
G_OBJECT_TYPE_NAME (stage_window));
|
G_OBJECT_TYPE_NAME (stage_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ClutterActor *
|
||||||
|
clutter_stage_egl_get_wrapper (ClutterStageWindow *stage_window)
|
||||||
|
{
|
||||||
|
return CLUTTER_ACTOR (CLUTTER_STAGE_EGL (stage_window)->wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||||
{
|
{
|
||||||
iface->set_fullscreen = clutter_stage_egl_set_fullscreen;
|
iface->set_fullscreen = clutter_stage_egl_set_fullscreen;
|
||||||
|
iface->set_title = NULL;
|
||||||
|
iface->get_wrapper = clutter_stage_egl_get_wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <clutter/clutter-stage.h>
|
#include <clutter/clutter-stage.h>
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/egl.h>
|
#include <GLES/egl.h>
|
||||||
|
#include "clutter-backend-egl.h"
|
||||||
|
|
||||||
#define CLUTTER_TYPE_STAGE_EGL (clutter_stage_egl_get_type ())
|
#define CLUTTER_TYPE_STAGE_EGL (clutter_stage_egl_get_type ())
|
||||||
#define CLUTTER_STAGE_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_EGL, ClutterStageEGL))
|
#define CLUTTER_STAGE_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_EGL, ClutterStageEGL))
|
||||||
@ -28,6 +30,7 @@ struct _ClutterStageEGL
|
|||||||
|
|
||||||
/* the stage wrapper */
|
/* the stage wrapper */
|
||||||
ClutterStage *wrapper;
|
ClutterStage *wrapper;
|
||||||
|
ClutterBackendEGL *backend;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClutterStageEGLClass
|
struct _ClutterStageEGLClass
|
||||||
|
@ -104,6 +104,47 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
2,
|
2,
|
||||||
&config_count);
|
&config_count);
|
||||||
|
|
||||||
|
int c;
|
||||||
|
int num_configs;
|
||||||
|
EGLConfig *all_configs;
|
||||||
|
|
||||||
|
eglGetConfigs (clutter_eglx_display(), NULL, 0, &num_configs);
|
||||||
|
|
||||||
|
all_configs = g_malloc (num_configs * sizeof (EGLConfig));
|
||||||
|
|
||||||
|
eglGetConfigs (clutter_eglx_display(),
|
||||||
|
all_configs,
|
||||||
|
num_configs,
|
||||||
|
&num_configs);
|
||||||
|
|
||||||
|
for (c=0; c<num_configs; ++c)
|
||||||
|
{
|
||||||
|
EGLint red=-1, green=-1, blue=-1, alpha=-1, stencil=-1;
|
||||||
|
eglGetConfigAttrib (clutter_eglx_display(),
|
||||||
|
all_configs[c],
|
||||||
|
EGL_RED_SIZE, &red);
|
||||||
|
eglGetConfigAttrib (clutter_eglx_display(),
|
||||||
|
all_configs[c],
|
||||||
|
EGL_GREEN_SIZE, &green);
|
||||||
|
eglGetConfigAttrib (clutter_eglx_display(),
|
||||||
|
all_configs[c],
|
||||||
|
EGL_BLUE_SIZE, &blue);
|
||||||
|
eglGetConfigAttrib (clutter_eglx_display(),
|
||||||
|
all_configs[c],
|
||||||
|
EGL_ALPHA_SIZE, &alpha);
|
||||||
|
eglGetConfigAttrib (clutter_eglx_display(),
|
||||||
|
all_configs[c],
|
||||||
|
EGL_STENCIL_SIZE, &stencil);
|
||||||
|
printf("EGLConfig === R:%d G:%d B:%d A:%d S:%d \n",
|
||||||
|
red, green, blue, alpha, stencil);
|
||||||
|
}
|
||||||
|
|
||||||
|
int max_tex_units = 0;
|
||||||
|
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_tex_units);
|
||||||
|
printf("Texture units: %d\n", max_tex_units);
|
||||||
|
|
||||||
|
g_free (all_configs);
|
||||||
|
|
||||||
if (status != EGL_TRUE)
|
if (status != EGL_TRUE)
|
||||||
g_warning ("eglGetConfigs failed");
|
g_warning ("eglGetConfigs failed");
|
||||||
|
|
||||||
@ -208,26 +249,9 @@ clutter_stage_egl_dispose (GObject *gobject)
|
|||||||
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbuf *
|
|
||||||
clutter_stage_egl_draw_to_pixbuf (ClutterStageWindow *stage_window,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
ClutterStage *stage = CLUTTER_STAGE (stage_window);
|
|
||||||
|
|
||||||
g_warning ("Stages of type `%s' do not support "
|
|
||||||
"ClutterStageWindow::draw_to_pixbuf",
|
|
||||||
G_OBJECT_TYPE_NAME (stage));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||||
{
|
{
|
||||||
iface->draw_to_pixbuf = clutter_stage_egl_draw_to_pixbuf;
|
|
||||||
|
|
||||||
/* the rest is inherited from ClutterStageX11 */
|
/* the rest is inherited from ClutterStageX11 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
clutter/fruity/Makefile.am
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
libclutterincludedir = $(includedir)/clutter-@CLUTTER_MAJORMINOR@/clutter
|
||||||
|
|
||||||
|
INCLUDES = \
|
||||||
|
-DG_LOG_DOMAIN=\"ClutterFruity\" \
|
||||||
|
-I$(top_srcdir) \
|
||||||
|
-I$(top_srcdir)/clutter \
|
||||||
|
$(CLUTTER_CFLAGS) \
|
||||||
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
|
$(GCC_FLAGS) \
|
||||||
|
-xobjective-c
|
||||||
|
|
||||||
|
LDADD = $(CLUTTER_LIBS)
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libclutter-fruity.la
|
||||||
|
|
||||||
|
libclutter_fruity_la_SOURCES = \
|
||||||
|
clutter-backend-fruity.h \
|
||||||
|
clutter-backend-fruity.c \
|
||||||
|
clutter-stage-fruity.h \
|
||||||
|
clutter-stage-fruity.c \
|
||||||
|
clutter-fruity.h \
|
||||||
|
clutter-fruity.c
|
257
clutter/fruity/clutter-backend-fruity.c
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "clutter-backend-fruity.h"
|
||||||
|
#include "clutter-stage-fruity.h"
|
||||||
|
#include "../clutter-private.h"
|
||||||
|
#include "../clutter-main.h"
|
||||||
|
#include "../clutter-debug.h"
|
||||||
|
|
||||||
|
static ClutterBackendEGL *backend_singleton = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (ClutterBackendEGL, clutter_backend_egl, CLUTTER_TYPE_BACKEND);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_backend_egl_pre_parse (ClutterBackend *backend,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_backend_egl_post_parse (ClutterBackend *backend,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL(backend);
|
||||||
|
EGLBoolean status;
|
||||||
|
|
||||||
|
backend_egl->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
|
status = eglInitialize (backend_egl->edpy,
|
||||||
|
&backend_egl->egl_version_major,
|
||||||
|
&backend_egl->egl_version_minor);
|
||||||
|
|
||||||
|
if (status != EGL_TRUE)
|
||||||
|
{
|
||||||
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||||
|
CLUTTER_INIT_ERROR_BACKEND,
|
||||||
|
"Unable to Initialize EGL");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND, "EGL Reports version %i.%i",
|
||||||
|
backend_egl->egl_version_major,
|
||||||
|
backend_egl->egl_version_minor);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_ensure_context (ClutterBackend *backend,
|
||||||
|
ClutterStage *stage)
|
||||||
|
{
|
||||||
|
/* not doing anything since we only have one context */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_redraw (ClutterBackend *backend,
|
||||||
|
ClutterStage *stage)
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||||
|
ClutterStageEGL *stage_egl;
|
||||||
|
ClutterStageWindow *impl;
|
||||||
|
|
||||||
|
impl = _clutter_stage_get_window (stage);
|
||||||
|
if (!impl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_assert (CLUTTER_IS_STAGE_EGL (impl));
|
||||||
|
stage_egl = CLUTTER_STAGE_EGL (impl);
|
||||||
|
|
||||||
|
eglWaitNative (EGL_CORE_NATIVE_ENGINE);
|
||||||
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
||||||
|
eglWaitGL();
|
||||||
|
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ClutterActor *
|
||||||
|
clutter_backend_egl_create_stage (ClutterBackend *backend,
|
||||||
|
ClutterStage *wrapper,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||||
|
ClutterStageEGL *stage_egl;
|
||||||
|
ClutterActor *stage;
|
||||||
|
|
||||||
|
if (backend_egl->stage)
|
||||||
|
{
|
||||||
|
g_warning ("The EGL native backend does not support multiple stages");
|
||||||
|
return backend_egl->stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
stage = g_object_new (CLUTTER_TYPE_STAGE_FRUITY, NULL);
|
||||||
|
|
||||||
|
stage_egl = CLUTTER_STAGE_EGL (stage);
|
||||||
|
stage_egl->backend = backend_egl;
|
||||||
|
stage_egl->wrapper = wrapper;
|
||||||
|
|
||||||
|
_clutter_stage_set_window (wrapper, CLUTTER_STAGE_WINDOW (stage));
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (stage), "clutter-backend", backend);
|
||||||
|
|
||||||
|
clutter_actor_realize (stage);
|
||||||
|
|
||||||
|
if (!CLUTTER_ACTOR_IS_REALIZED (stage))
|
||||||
|
{
|
||||||
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||||
|
CLUTTER_INIT_ERROR_INTERNAL,
|
||||||
|
"Unable to realize the main stage");
|
||||||
|
g_object_unref (stage);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_egl->stage = CLUTTER_ACTOR (stage_egl);
|
||||||
|
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_init_events (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GOptionEntry entries[] =
|
||||||
|
{
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_finalize (GObject *gobject)
|
||||||
|
{
|
||||||
|
if (backend_singleton)
|
||||||
|
backend_singleton = NULL;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (clutter_backend_egl_parent_class)->finalize (gobject);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_dispose (GObject *gobject)
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (gobject);
|
||||||
|
|
||||||
|
_clutter_events_uninit (CLUTTER_BACKEND (backend_egl));
|
||||||
|
|
||||||
|
if (backend_egl->egl_context)
|
||||||
|
{
|
||||||
|
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
|
||||||
|
backend_egl->egl_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backend_egl->edpy)
|
||||||
|
{
|
||||||
|
eglTerminate (backend_egl->edpy);
|
||||||
|
backend_egl->edpy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (clutter_backend_egl_parent_class)->dispose (gobject);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GObject *
|
||||||
|
clutter_backend_egl_constructor (GType gtype,
|
||||||
|
guint n_params,
|
||||||
|
GObjectConstructParam *params)
|
||||||
|
{
|
||||||
|
GObjectClass *parent_class;
|
||||||
|
GObject *retval;
|
||||||
|
|
||||||
|
if (!backend_singleton)
|
||||||
|
{
|
||||||
|
parent_class = G_OBJECT_CLASS (clutter_backend_egl_parent_class);
|
||||||
|
retval = parent_class->constructor (gtype, n_params, params);
|
||||||
|
|
||||||
|
backend_singleton = CLUTTER_BACKEND_EGL (retval);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_warning ("Attempting to create a new backend object. This should "
|
||||||
|
"never happen, so we return the singleton instance.");
|
||||||
|
|
||||||
|
return g_object_ref (backend_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ClutterFeatureFlags
|
||||||
|
clutter_backend_egl_get_features (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND, "Checking features\n"
|
||||||
|
"GL_VENDOR: %s\n"
|
||||||
|
"GL_RENDERER: %s\n"
|
||||||
|
"GL_VERSION: %s\n"
|
||||||
|
"EGL_VENDOR: %s\n"
|
||||||
|
"EGL_VERSION: %s\n"
|
||||||
|
"EGL_EXTENSIONS: %s\n",
|
||||||
|
glGetString (GL_VENDOR),
|
||||||
|
glGetString (GL_RENDERER),
|
||||||
|
glGetString (GL_VERSION),
|
||||||
|
eglQueryString (backend_egl->edpy, EGL_VENDOR),
|
||||||
|
eglQueryString (backend_egl->edpy, EGL_VERSION),
|
||||||
|
eglQueryString (backend_egl->edpy, EGL_EXTENSIONS));
|
||||||
|
|
||||||
|
return CLUTTER_FEATURE_STAGE_STATIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->constructor = clutter_backend_egl_constructor;
|
||||||
|
gobject_class->dispose = clutter_backend_egl_dispose;
|
||||||
|
gobject_class->finalize = clutter_backend_egl_finalize;
|
||||||
|
|
||||||
|
backend_class->pre_parse = clutter_backend_egl_pre_parse;
|
||||||
|
backend_class->post_parse = clutter_backend_egl_post_parse;
|
||||||
|
backend_class->init_events = clutter_backend_egl_init_events;
|
||||||
|
backend_class->create_stage = clutter_backend_egl_create_stage;
|
||||||
|
backend_class->ensure_context = clutter_backend_egl_ensure_context;
|
||||||
|
backend_class->redraw = clutter_backend_egl_redraw;
|
||||||
|
backend_class->get_features = clutter_backend_egl_get_features;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_backend_egl_init (ClutterBackendEGL *backend_egl)
|
||||||
|
{
|
||||||
|
ClutterBackend *backend = CLUTTER_BACKEND (backend_egl);
|
||||||
|
|
||||||
|
clutter_backend_set_resolution (backend, 96.0);
|
||||||
|
clutter_backend_set_double_click_time (backend, 250);
|
||||||
|
clutter_backend_set_double_click_distance (backend, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
_clutter_backend_impl_get_type (void)
|
||||||
|
{
|
||||||
|
return clutter_backend_egl_get_type ();
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLDisplay
|
||||||
|
clutter_egl_display (void)
|
||||||
|
{
|
||||||
|
return backend_singleton->edpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *rpl_malloc (size_t allocation)
|
||||||
|
{
|
||||||
|
return g_malloc (allocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rpl_free (void *ptr)
|
||||||
|
{
|
||||||
|
g_free (ptr);
|
||||||
|
}
|
82
clutter/fruity/clutter-backend-fruity.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/* Clutter.
|
||||||
|
* An OpenGL based 'interactive canvas' library.
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
* Copyright (C) 2006-2007 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CLUTTER_BACKEND_EGL_H__
|
||||||
|
#define __CLUTTER_BACKEND_EGL_H__
|
||||||
|
|
||||||
|
/*#ifdef HAVE_CLUTTER_FRUITY */
|
||||||
|
/* extra include needed for the GLES header for arm-apple-darwin */
|
||||||
|
#include <CoreSurface/CoreSurface.h>
|
||||||
|
/*#endif*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <GLES/egl.h>
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <clutter/clutter-backend.h>
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_BACKEND_FRUITY (clutter_backend_egl_get_type ())
|
||||||
|
#define CLUTTER_BACKEND_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_FRUITY, ClutterBackendEGL))
|
||||||
|
#define CLUTTER_IS_BACKEND_EGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_FRUITY))
|
||||||
|
#define CLUTTER_BACKEND_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_FRUITY, ClutterBackendEGLClass))
|
||||||
|
#define CLUTTER_IS_BACKEND_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_FRUITY))
|
||||||
|
#define CLUTTER_BACKEND_EGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_FRUITY, ClutterBackendEGLClass))
|
||||||
|
|
||||||
|
typedef struct _ClutterBackendEGL ClutterBackendEGL;
|
||||||
|
typedef struct _ClutterBackendEGLClass ClutterBackendEGLClass;
|
||||||
|
|
||||||
|
|
||||||
|
struct _ClutterBackendEGL
|
||||||
|
{
|
||||||
|
ClutterBackend parent_instance;
|
||||||
|
|
||||||
|
/* EGL Specific */
|
||||||
|
EGLDisplay edpy;
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
EGLContext egl_context;
|
||||||
|
|
||||||
|
gint egl_version_major;
|
||||||
|
gint egl_version_minor;
|
||||||
|
|
||||||
|
/* main stage singleton */
|
||||||
|
ClutterActor *stage;
|
||||||
|
|
||||||
|
/* event source */
|
||||||
|
GSource *event_source;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _ClutterBackendEGLClass
|
||||||
|
{
|
||||||
|
ClutterBackendClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType clutter_backend_egl_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void _clutter_events_init (ClutterBackend *backend);
|
||||||
|
void _clutter_events_uninit (ClutterBackend *backend);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CLUTTER_BACKEND_EGL_H__ */
|
197
clutter/fruity/clutter-fruity.c
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
#include <clutter/clutter.h>
|
||||||
|
#include "clutter-backend-fruity.h"
|
||||||
|
#include "clutter-stage-fruity.h"
|
||||||
|
#include "../clutter-main.h"
|
||||||
|
#include "../clutter-private.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <GraphicsServices/GraphicsServices.h>
|
||||||
|
#include <OpenGLES/gl.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#import <UIKit/UIView.h>
|
||||||
|
#import <UIKit/UITextView.h>
|
||||||
|
#import <UIKit/UIHardware.h>
|
||||||
|
#import <UIKit/UINavigationBar.h>
|
||||||
|
#import <UIKit/UIView-Geometry.h>
|
||||||
|
#include "clutter-fruity.h"
|
||||||
|
|
||||||
|
static EGLDisplay mEGLDisplay;
|
||||||
|
static EGLContext mEGLContext;
|
||||||
|
static EGLSurface mEGLSurface;
|
||||||
|
static CoreSurfaceBufferRef mScreenSurface;
|
||||||
|
static gboolean alive = TRUE;
|
||||||
|
|
||||||
|
@interface StageView : UIView
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
static CoreSurfaceBufferRef CreateSurface(int w, int h)
|
||||||
|
{
|
||||||
|
int pitch = w * 2, allocSize = 2 * w * h;
|
||||||
|
char *pixelFormat = "565L";
|
||||||
|
CFMutableDictionaryRef dict;
|
||||||
|
|
||||||
|
dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferGlobal, kCFBooleanTrue);
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferMemoryRegion, CFSTR("PurpleGFXMem"));
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferPitch, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pitch));
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferWidth, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &w));
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferHeight, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &h));
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferPixelFormat, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, pixelFormat));
|
||||||
|
CFDictionarySetValue(dict, kCoreSurfaceBufferAllocSize, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &allocSize));
|
||||||
|
return CoreSurfaceBufferCreate(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@implementation StageView
|
||||||
|
|
||||||
|
- (void) mouseDown:(GSEvent*)event
|
||||||
|
{
|
||||||
|
CGPoint location= GSEventGetLocationInWindow(event);
|
||||||
|
ClutterBackendEGL *backend_fruity = CLUTTER_BACKEND_EGL (clutter_get_default_backend());
|
||||||
|
ClutterStage *stage = CLUTTER_STAGE_EGL(backend_fruity->stage)->wrapper;
|
||||||
|
ClutterEvent *cev;
|
||||||
|
float x = location.x;
|
||||||
|
float y = location.y;
|
||||||
|
|
||||||
|
cev = clutter_event_new (CLUTTER_BUTTON_PRESS);
|
||||||
|
cev->button.x = x;
|
||||||
|
cev->button.y = y;
|
||||||
|
cev->button.button = 1;
|
||||||
|
cev->button.time = clutter_get_timestamp () / 1000;
|
||||||
|
cev->any.stage = stage;
|
||||||
|
|
||||||
|
clutter_do_event (cev);
|
||||||
|
clutter_event_free (cev);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseUp:(GSEvent*)event
|
||||||
|
{
|
||||||
|
ClutterEvent *cev;
|
||||||
|
ClutterBackendEGL *backend_fruity = CLUTTER_BACKEND_EGL (clutter_get_default_backend());
|
||||||
|
ClutterStage *stage = CLUTTER_STAGE_EGL(backend_fruity->stage)->wrapper;
|
||||||
|
CGPoint location= GSEventGetLocationInWindow(event);
|
||||||
|
float x = location.x;
|
||||||
|
float y = location.y;
|
||||||
|
|
||||||
|
cev = clutter_event_new (CLUTTER_BUTTON_RELEASE);
|
||||||
|
cev->button.x = x;
|
||||||
|
cev->button.y = y;
|
||||||
|
cev->button.button = 1;
|
||||||
|
cev->button.time = clutter_get_timestamp () / 1000;
|
||||||
|
cev->any.stage = stage;
|
||||||
|
clutter_do_event (cev);
|
||||||
|
clutter_event_free (cev);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseDragged:(GSEvent*)event
|
||||||
|
{
|
||||||
|
ClutterEvent *cev;
|
||||||
|
ClutterBackendEGL *backend_fruity = CLUTTER_BACKEND_EGL (clutter_get_default_backend());
|
||||||
|
ClutterStage *stage = CLUTTER_STAGE_EGL(backend_fruity->stage)->wrapper;
|
||||||
|
CGPoint location= GSEventGetLocationInWindow(event);
|
||||||
|
float x = location.x;
|
||||||
|
float y = location.y;
|
||||||
|
|
||||||
|
cev = clutter_event_new (CLUTTER_MOTION);
|
||||||
|
cev->motion.x = x;
|
||||||
|
cev->motion.y = y;
|
||||||
|
cev->motion.time = clutter_get_timestamp () / 1000;
|
||||||
|
cev->any.stage = stage;
|
||||||
|
clutter_do_event (cev);
|
||||||
|
clutter_event_free (cev);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface ClutterUIKit : UIApplication
|
||||||
|
{
|
||||||
|
StageView *stage_view;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClutterUIKit
|
||||||
|
|
||||||
|
- (void) applicationDidFinishLaunching: (id) unused
|
||||||
|
{
|
||||||
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
[UIHardware _setStatusBarHeight:0.0f];
|
||||||
|
[self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0];
|
||||||
|
|
||||||
|
CGRect screenRect = [UIHardware fullScreenApplicationContentRect];
|
||||||
|
UIWindow* window = [[UIWindow alloc] initWithContentRect: screenRect];
|
||||||
|
|
||||||
|
[window orderFront: self];
|
||||||
|
[window makeKey: self];
|
||||||
|
[window _setHidden: NO];
|
||||||
|
|
||||||
|
[NSTimer
|
||||||
|
scheduledTimerWithTimeInterval:0.0025
|
||||||
|
target: self
|
||||||
|
selector: @selector(update)
|
||||||
|
userInfo: nil
|
||||||
|
repeats: YES
|
||||||
|
];
|
||||||
|
|
||||||
|
StageView *stageView = [StageView alloc];
|
||||||
|
[stageView initWithFrame: screenRect];
|
||||||
|
[window setContentView: stageView];
|
||||||
|
|
||||||
|
stage_view = stageView;
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillTerminate
|
||||||
|
{
|
||||||
|
/* FIXME: here we should do things to shut down the uikit application */
|
||||||
|
[stage_view release];
|
||||||
|
ClutterBackendEGL *backend_fruity = CLUTTER_BACKEND_EGL (clutter_get_default_backend());
|
||||||
|
ClutterStageEGL *stage_fruity;
|
||||||
|
stage_fruity = CLUTTER_STAGE_EGL(backend_fruity->stage);
|
||||||
|
|
||||||
|
alive = FALSE;
|
||||||
|
clutter_actor_unrealize (CLUTTER_ACTOR (stage_fruity));
|
||||||
|
clutter_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillSuspend
|
||||||
|
{
|
||||||
|
ClutterBackendEGL *backend_fruity = CLUTTER_BACKEND_EGL (clutter_get_default_backend());
|
||||||
|
ClutterStageEGL *stage_fruity;
|
||||||
|
stage_fruity = CLUTTER_STAGE_EGL(backend_fruity->stage);
|
||||||
|
alive = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidResumeFromUnderLock
|
||||||
|
{
|
||||||
|
alive = TRUE;
|
||||||
|
[stage_view setNeedsDisplay];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) update
|
||||||
|
{
|
||||||
|
if (alive && g_main_context_pending (NULL))
|
||||||
|
g_main_context_iteration (NULL, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
void clutter_fruity_main (void)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
UIApplicationMain(0, NULL, [ClutterUIKit class]);
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
48
clutter/fruity/clutter-fruity.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Clutter.
|
||||||
|
*
|
||||||
|
* An OpenGL based 'interactive canvas' library.
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CLUTTER_FRUITY_H__
|
||||||
|
#define __CLUTTER_FRUITY_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#if HAVE_CLUTTER_FRUITY
|
||||||
|
/* extra include needed for the GLES header for arm-apple-darwin */
|
||||||
|
#include <CoreSurface/CoreSurface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <GLES/egl.h>
|
||||||
|
|
||||||
|
#include <clutter/clutter-stage.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
EGLDisplay clutter_egl_display (void);
|
||||||
|
void clutter_uikit_main (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CLUTTER_EGL_H__ */
|
279
clutter/fruity/clutter-stage-fruity.c
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "clutter-stage-fruity.h"
|
||||||
|
#include "clutter-fruity.h"
|
||||||
|
#include "clutter-backend-fruity.h"
|
||||||
|
|
||||||
|
#include "../clutter-main.h"
|
||||||
|
#include "../clutter-feature.h"
|
||||||
|
#include "../clutter-color.h"
|
||||||
|
#include "../clutter-util.h"
|
||||||
|
#include "../clutter-event.h"
|
||||||
|
#include "../clutter-enum-types.h"
|
||||||
|
#include "../clutter-private.h"
|
||||||
|
#include "../clutter-debug.h"
|
||||||
|
#include "../clutter-units.h"
|
||||||
|
#include "../clutter-stage.h"
|
||||||
|
#include "../clutter-stage-window.h"
|
||||||
|
|
||||||
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
|
||||||
|
clutter_stage_egl,
|
||||||
|
CLUTTER_TYPE_ACTOR,
|
||||||
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
||||||
|
clutter_stage_window_iface_init));
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_show (ClutterActor *actor)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl, CLUTTER_ACTOR_MAPPED);
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_MAPPED);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->show (actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_hide (ClutterActor *actor)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_egl, CLUTTER_ACTOR_MAPPED);
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_MAPPED);
|
||||||
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->hide (actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_unrealize (ClutterActor *actor)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
|
||||||
|
CLUTTER_MARK();
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->unrealize (actor);
|
||||||
|
|
||||||
|
if (stage_egl->egl_surface)
|
||||||
|
{
|
||||||
|
eglDestroySurface (clutter_egl_display (), stage_egl->egl_surface);
|
||||||
|
stage_egl->egl_surface = EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
clutter_stage_ensure_current (stage_egl->wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_realize (ClutterActor *actor)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
||||||
|
ClutterBackendEGL *backend_egl;
|
||||||
|
EGLConfig configs[2];
|
||||||
|
EGLint config_count;
|
||||||
|
EGLBoolean status;
|
||||||
|
gboolean is_offscreen;
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
||||||
|
|
||||||
|
g_object_get (stage_egl->wrapper, "offscreen", &is_offscreen, NULL);
|
||||||
|
|
||||||
|
backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ());
|
||||||
|
|
||||||
|
if (G_LIKELY (!is_offscreen))
|
||||||
|
{
|
||||||
|
EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE,
|
||||||
|
EGL_RED_SIZE, 5,
|
||||||
|
EGL_GREEN_SIZE, 6,
|
||||||
|
EGL_BLUE_SIZE, 5,
|
||||||
|
EGL_DEPTH_SIZE, 16,
|
||||||
|
EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
||||||
|
EGL_STENCIL_SIZE, 2,
|
||||||
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
EGL_NONE };
|
||||||
|
|
||||||
|
status = eglGetConfigs (backend_egl->edpy,
|
||||||
|
configs,
|
||||||
|
2,
|
||||||
|
&config_count);
|
||||||
|
|
||||||
|
if (status != EGL_TRUE)
|
||||||
|
g_warning ("eglGetConfigs failed");
|
||||||
|
|
||||||
|
status = eglChooseConfig (backend_egl->edpy,
|
||||||
|
cfg_attribs,
|
||||||
|
configs,
|
||||||
|
G_N_ELEMENTS (configs),
|
||||||
|
&config_count);
|
||||||
|
|
||||||
|
if (status != EGL_TRUE)
|
||||||
|
g_warning ("eglChooseConfig failed");
|
||||||
|
|
||||||
|
if (stage_egl->egl_surface != EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
|
||||||
|
stage_egl->egl_surface = EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backend_egl->egl_context)
|
||||||
|
{
|
||||||
|
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
|
||||||
|
backend_egl->egl_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_egl->egl_surface =
|
||||||
|
eglCreateWindowSurface (backend_egl->edpy,
|
||||||
|
configs[0],
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
g_critical ("Unable to create an EGL surface");
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eglQuerySurface (backend_egl->edpy,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
EGL_WIDTH,
|
||||||
|
&stage_egl->surface_width);
|
||||||
|
|
||||||
|
eglQuerySurface (backend_egl->edpy,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
EGL_HEIGHT,
|
||||||
|
&stage_egl->surface_height);
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i",
|
||||||
|
stage_egl->surface_width,
|
||||||
|
stage_egl->surface_height);
|
||||||
|
|
||||||
|
|
||||||
|
if (G_UNLIKELY (backend_egl->egl_context == NULL))
|
||||||
|
{
|
||||||
|
CLUTTER_NOTE (GL, "Creating EGL Context");
|
||||||
|
|
||||||
|
backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
|
||||||
|
configs[0],
|
||||||
|
EGL_NO_CONTEXT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (backend_egl->egl_context == EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
g_critical ("Unable to create a suitable EGL context");
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this will make sure to set the current context */
|
||||||
|
CLUTTER_NOTE (BACKEND, "Marking stage as realized and setting context");
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_REALIZED);
|
||||||
|
CLUTTER_ACTOR_SET_FLAGS (stage_egl, CLUTTER_ACTOR_REALIZED);
|
||||||
|
|
||||||
|
|
||||||
|
status = eglMakeCurrent (backend_egl->edpy,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
stage_egl->egl_surface,
|
||||||
|
backend_egl->egl_context);
|
||||||
|
|
||||||
|
if (status != EGL_TRUE)
|
||||||
|
g_warning ("eglMakeCurrent");
|
||||||
|
|
||||||
|
/*clutter_stage_ensure_current (stage_egl->wrapper);*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning("EGL Backend does not yet support offscreen rendering\n");
|
||||||
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CLUTTER_SET_PRIVATE_FLAGS (stage_egl->wrapper, CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_query_coords (ClutterActor *self,
|
||||||
|
ClutterActorBox *box)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self);
|
||||||
|
|
||||||
|
box->x1 = box->y1 = 0;
|
||||||
|
box->x2 = box->x1 + CLUTTER_UNITS_FROM_INT (stage_egl->surface_width);
|
||||||
|
box->y2 = box->y1 + CLUTTER_UNITS_FROM_INT (stage_egl->surface_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_request_coords (ClutterActor *self,
|
||||||
|
ClutterActorBox *box)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self);
|
||||||
|
|
||||||
|
/* framebuffer no resize */
|
||||||
|
box->x1 = 0;
|
||||||
|
box->y1 = 0;
|
||||||
|
box->x2 = CLUTTER_UNITS_FROM_INT (stage_egl->surface_width);
|
||||||
|
box->y2 = CLUTTER_UNITS_FROM_INT (stage_egl->surface_height);
|
||||||
|
|
||||||
|
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->request_coords (self,
|
||||||
|
box);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_dispose (GObject *gobject)
|
||||||
|
{
|
||||||
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (gobject);
|
||||||
|
|
||||||
|
clutter_actor_unrealize (CLUTTER_ACTOR (stage_egl));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->dispose = clutter_stage_egl_dispose;
|
||||||
|
|
||||||
|
actor_class->show = clutter_stage_egl_show;
|
||||||
|
actor_class->hide = clutter_stage_egl_hide;
|
||||||
|
actor_class->realize = clutter_stage_egl_realize;
|
||||||
|
actor_class->unrealize = clutter_stage_egl_unrealize;
|
||||||
|
actor_class->request_coords = clutter_stage_egl_request_coords;
|
||||||
|
actor_class->query_coords = clutter_stage_egl_query_coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_set_fullscreen (ClutterStageWindow *stage_window,
|
||||||
|
gboolean fullscreen)
|
||||||
|
{
|
||||||
|
g_warning ("Stage of type `%s' do not support ClutterStage::set_fullscreen",
|
||||||
|
G_OBJECT_TYPE_NAME (stage_window));
|
||||||
|
}
|
||||||
|
|
||||||
|
static ClutterActor *
|
||||||
|
clutter_stage_egl_get_wrapper (ClutterStageWindow *stage_window)
|
||||||
|
{
|
||||||
|
return CLUTTER_ACTOR (CLUTTER_STAGE_EGL (stage_window)->wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||||
|
{
|
||||||
|
iface->set_fullscreen = clutter_stage_egl_set_fullscreen;
|
||||||
|
iface->set_title = NULL;
|
||||||
|
iface->get_wrapper = clutter_stage_egl_get_wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_egl_init (ClutterStageEGL *stage)
|
||||||
|
{
|
||||||
|
}
|
48
clutter/fruity/clutter-stage-fruity.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef __CLUTTER_STAGE_EGL_H__
|
||||||
|
#define __CLUTTER_STAGE_EGL_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <clutter/clutter-stage.h>
|
||||||
|
|
||||||
|
#if HAVE_CLUTTER_FRUITY
|
||||||
|
/* extra include needed for the GLES header for arm-apple-darwin */
|
||||||
|
#include <CoreSurface/CoreSurface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <GLES/egl.h>
|
||||||
|
#include "clutter-backend-fruity.h"
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_STAGE_FRUITY (clutter_stage_egl_get_type ())
|
||||||
|
#define CLUTTER_STAGE_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_FRUITY, ClutterStageEGL))
|
||||||
|
#define CLUTTER_IS_STAGE_EGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STAGE_FRUITY))
|
||||||
|
#define CLUTTER_STAGE_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STAGE_FRUITY, ClutterStageEGLClass))
|
||||||
|
#define CLUTTER_IS_STAGE_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STAGE_FRUITY))
|
||||||
|
#define CLUTTER_STAGE_EGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STAGE_FRUITY, ClutterStageEGLClass))
|
||||||
|
|
||||||
|
typedef struct _ClutterStageEGL ClutterStageEGL;
|
||||||
|
typedef struct _ClutterStageEGLClass ClutterStageEGLClass;
|
||||||
|
|
||||||
|
struct _ClutterStageEGL
|
||||||
|
{
|
||||||
|
ClutterActor parent_instance;
|
||||||
|
|
||||||
|
/* from the backend */
|
||||||
|
gint surface_width;
|
||||||
|
gint surface_height;
|
||||||
|
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
/* the stage wrapper */
|
||||||
|
ClutterStage *wrapper;
|
||||||
|
ClutterBackendEGL *backend;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _ClutterStageEGLClass
|
||||||
|
{
|
||||||
|
ClutterActorClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType clutter_stage_egl_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
#endif /* __CLUTTER_STAGE_EGL_H__ */
|
@ -4,8 +4,8 @@ libclutterinclude_HEADERS = clutter-glx.h clutter-glx-texture-pixmap.h
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DG_LOG_DOMAIN=\"ClutterGLX\" \
|
-DG_LOG_DOMAIN=\"ClutterGLX\" \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
-I$(top_builddir)/clutter \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "../clutter-private.h"
|
#include "../clutter-private.h"
|
||||||
#include "../clutter-version.h"
|
#include "../clutter-version.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11);
|
G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
#include "../clutter-util.h"
|
#include "../clutter-util.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
typedef void (*BindTexImage) (Display *display,
|
typedef void (*BindTexImage) (Display *display,
|
||||||
GLXDrawable drawable,
|
GLXDrawable drawable,
|
||||||
@ -159,10 +159,11 @@ clutter_glx_texture_pixmap_init (ClutterGLXTexturePixmap *self)
|
|||||||
CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
|
CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
|
||||||
ClutterGLXTexturePixmapPrivate);
|
ClutterGLXTexturePixmapPrivate);
|
||||||
|
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api.
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
||||||
priv->target_type = CGL_TEXTURE_RECTANGLE_ARB;
|
priv->target_type = CGL_TEXTURE_RECTANGLE_ARB;
|
||||||
else
|
else
|
||||||
priv->target_type = CGL_TEXTURE_2D;
|
priv->target_type = CGL_TEXTURE_2D; */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -225,12 +226,13 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
|
|||||||
"pixmap-height", &height,
|
"pixmap-height", &height,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api
|
||||||
cogl_textures_create (1, &priv->texture_id);
|
cogl_textures_create (1, &priv->texture_id);
|
||||||
|
*/
|
||||||
clutter_glx_texture_pixmap_update_area (CLUTTER_X11_TEXTURE_PIXMAP (actor),
|
clutter_glx_texture_pixmap_update_area (CLUTTER_X11_TEXTURE_PIXMAP (actor),
|
||||||
0, 0,
|
0, 0,
|
||||||
width, height);
|
width, height);
|
||||||
|
/*
|
||||||
cogl_texture_set_alignment (priv->target_type, 4, width);
|
cogl_texture_set_alignment (priv->target_type, 4, width);
|
||||||
|
|
||||||
cogl_texture_set_filters (priv->target_type,
|
cogl_texture_set_filters (priv->target_type,
|
||||||
@ -240,7 +242,7 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
|
|||||||
cogl_texture_set_wrap (priv->target_type,
|
cogl_texture_set_wrap (priv->target_type,
|
||||||
repeat_x ? CGL_REPEAT : CGL_CLAMP_TO_EDGE,
|
repeat_x ? CGL_REPEAT : CGL_CLAMP_TO_EDGE,
|
||||||
repeat_y ? CGL_REPEAT : CGL_CLAMP_TO_EDGE);
|
repeat_y ? CGL_REPEAT : CGL_CLAMP_TO_EDGE);
|
||||||
|
*/
|
||||||
CLUTTER_ACTOR_SET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
CLUTTER_ACTOR_SET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,8 +277,9 @@ clutter_glx_texture_pixmap_unrealize (ClutterActor *actor)
|
|||||||
clutter_x11_untrap_x_errors ();
|
clutter_x11_untrap_x_errors ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api.
|
||||||
cogl_textures_destroy (1, &priv->texture_id);
|
cogl_textures_destroy (1, &priv->texture_id);
|
||||||
|
*/
|
||||||
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,6 +290,7 @@ texture_render_to_gl_quad (ClutterGLXTexturePixmap *texture,
|
|||||||
int x_2,
|
int x_2,
|
||||||
int y_2)
|
int y_2)
|
||||||
{
|
{
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api
|
||||||
ClutterGLXTexturePixmapPrivate *priv = texture->priv;
|
ClutterGLXTexturePixmapPrivate *priv = texture->priv;
|
||||||
|
|
||||||
int qx1 = 0, qx2 = 0, qy1 = 0, qy2 = 0;
|
int qx1 = 0, qx2 = 0, qy1 = 0, qy2 = 0;
|
||||||
@ -304,7 +308,7 @@ texture_render_to_gl_quad (ClutterGLXTexturePixmap *texture,
|
|||||||
|
|
||||||
cogl_texture_bind (priv->target_type, priv->texture_id);
|
cogl_texture_bind (priv->target_type, priv->texture_id);
|
||||||
|
|
||||||
if (priv->target_type == CGL_TEXTURE_2D) /* POT */
|
if (priv->target_type == CGL_TEXTURE_2D)
|
||||||
{
|
{
|
||||||
tx = (float) width / clutter_util_next_p2 (width);
|
tx = (float) width / clutter_util_next_p2 (width);
|
||||||
ty = (float) height / clutter_util_next_p2 (height);
|
ty = (float) height / clutter_util_next_p2 (height);
|
||||||
@ -323,7 +327,7 @@ texture_render_to_gl_quad (ClutterGLXTexturePixmap *texture,
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
CLUTTER_FLOAT_TO_FIXED (tx),
|
CLUTTER_FLOAT_TO_FIXED (tx),
|
||||||
CLUTTER_FLOAT_TO_FIXED (ty));
|
CLUTTER_FLOAT_TO_FIXED (ty)); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -347,6 +351,7 @@ clutter_glx_texture_pixmap_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
cogl_push_matrix ();
|
cogl_push_matrix ();
|
||||||
|
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api.
|
||||||
switch (priv->target_type)
|
switch (priv->target_type)
|
||||||
{
|
{
|
||||||
case CGL_TEXTURE_2D:
|
case CGL_TEXTURE_2D:
|
||||||
@ -357,7 +362,7 @@ clutter_glx_texture_pixmap_paint (ClutterActor *actor)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
} */
|
||||||
|
|
||||||
col.alpha = clutter_actor_get_opacity (actor);
|
col.alpha = clutter_actor_get_opacity (actor);
|
||||||
|
|
||||||
@ -527,10 +532,11 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
|
|||||||
|
|
||||||
attribs[i++] = GLX_TEXTURE_TARGET_EXT;
|
attribs[i++] = GLX_TEXTURE_TARGET_EXT;
|
||||||
|
|
||||||
|
/* FIXME: Obsolete. Move to new cogl api
|
||||||
if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB)
|
if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB)
|
||||||
attribs[i++] = GLX_TEXTURE_RECTANGLE_EXT;
|
attribs[i++] = GLX_TEXTURE_RECTANGLE_EXT;
|
||||||
else
|
else
|
||||||
attribs[i++] = GLX_TEXTURE_2D_EXT;
|
attribs[i++] = GLX_TEXTURE_2D_EXT; */
|
||||||
|
|
||||||
attribs[i++] = None;
|
attribs[i++] = None;
|
||||||
|
|
||||||
@ -553,7 +559,8 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
|
|||||||
CLUTTER_ACTOR_IS_REALIZED (texture) &&
|
CLUTTER_ACTOR_IS_REALIZED (texture) &&
|
||||||
priv->bound)
|
priv->bound)
|
||||||
{
|
{
|
||||||
cogl_texture_bind (priv->target_type, priv->texture_id);
|
/*
|
||||||
|
cogl_texture_bind (priv->target_type, priv->texture_id); */
|
||||||
|
|
||||||
clutter_x11_trap_x_errors ();
|
clutter_x11_trap_x_errors ();
|
||||||
|
|
||||||
@ -603,7 +610,8 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
|
|||||||
if (!CLUTTER_ACTOR_IS_REALIZED (texture))
|
if (!CLUTTER_ACTOR_IS_REALIZED (texture))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cogl_texture_bind (priv->target_type, priv->texture_id);
|
/* FIXME: Obsolete.
|
||||||
|
cogl_texture_bind (priv->target_type, priv->texture_id); */
|
||||||
|
|
||||||
if (_have_tex_from_pixmap_ext)
|
if (_have_tex_from_pixmap_ext)
|
||||||
{
|
{
|
||||||
|
@ -42,13 +42,11 @@
|
|||||||
#include "../clutter-stage.h"
|
#include "../clutter-stage.h"
|
||||||
#include "../clutter-stage-window.h"
|
#include "../clutter-stage-window.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
#include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
|
|
||||||
|
|
||||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageGLX,
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageGLX,
|
||||||
@ -313,85 +311,6 @@ fail:
|
|||||||
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
snapshot_pixbuf_free (guchar *pixels,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
g_free (pixels);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkPixbuf *
|
|
||||||
clutter_stage_glx_draw_to_pixbuf (ClutterStageWindow *stage_window,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint width,
|
|
||||||
gint height)
|
|
||||||
{
|
|
||||||
guchar *data;
|
|
||||||
GdkPixbuf *pixb;
|
|
||||||
ClutterActor *actor;
|
|
||||||
ClutterStageGLX *stage_glx;
|
|
||||||
ClutterStageX11 *stage_x11;
|
|
||||||
gboolean is_offscreen = FALSE;
|
|
||||||
|
|
||||||
stage_glx = CLUTTER_STAGE_GLX (stage_window);
|
|
||||||
stage_x11 = CLUTTER_STAGE_X11 (stage_window);
|
|
||||||
actor = CLUTTER_ACTOR (stage_window);
|
|
||||||
|
|
||||||
if (width < 0)
|
|
||||||
width = clutter_actor_get_width (actor);
|
|
||||||
|
|
||||||
if (height < 0)
|
|
||||||
height = clutter_actor_get_height (actor);
|
|
||||||
|
|
||||||
g_object_get (stage_x11->wrapper, "offscreen", &is_offscreen, NULL);
|
|
||||||
|
|
||||||
if (G_UNLIKELY (is_offscreen))
|
|
||||||
{
|
|
||||||
gdk_pixbuf_xlib_init (stage_x11->xdpy, stage_x11->xscreen);
|
|
||||||
|
|
||||||
pixb = gdk_pixbuf_xlib_get_from_drawable (NULL,
|
|
||||||
(Drawable) stage_x11->xpixmap,
|
|
||||||
DefaultColormap (stage_x11->xdpy,
|
|
||||||
stage_x11->xscreen),
|
|
||||||
stage_x11->xvisinfo->visual,
|
|
||||||
x, y,
|
|
||||||
0, 0,
|
|
||||||
width, height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GdkPixbuf *tmp = NULL, *tmp2 = NULL;
|
|
||||||
gint stride;
|
|
||||||
|
|
||||||
stride = ((width * 4 + 3) &~ 3);
|
|
||||||
|
|
||||||
data = g_malloc0 (sizeof (guchar) * stride * height);
|
|
||||||
|
|
||||||
glReadPixels (x,
|
|
||||||
clutter_actor_get_height (actor) - y - height,
|
|
||||||
width,
|
|
||||||
height, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
|
||||||
|
|
||||||
tmp = gdk_pixbuf_new_from_data (data,
|
|
||||||
GDK_COLORSPACE_RGB,
|
|
||||||
TRUE,
|
|
||||||
8,
|
|
||||||
width, height,
|
|
||||||
stride,
|
|
||||||
snapshot_pixbuf_free,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
tmp2 = gdk_pixbuf_flip (tmp, TRUE);
|
|
||||||
g_object_unref (tmp);
|
|
||||||
|
|
||||||
pixb = gdk_pixbuf_rotate_simple (tmp2, GDK_PIXBUF_ROTATE_UPSIDEDOWN);
|
|
||||||
g_object_unref (tmp2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pixb;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_glx_dispose (GObject *gobject)
|
clutter_stage_glx_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
@ -424,7 +343,5 @@ clutter_stage_glx_init (ClutterStageGLX *stage)
|
|||||||
static void
|
static void
|
||||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||||
{
|
{
|
||||||
iface->draw_to_pixbuf = clutter_stage_glx_draw_to_pixbuf;
|
|
||||||
|
|
||||||
/* the rest is inherited from ClutterStageX11 */
|
/* the rest is inherited from ClutterStageX11 */
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ libclutterinclude_HEADERS = clutter-osx.h
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DG_LOG_DOMAIN=\"ClutterOSX\" \
|
-DG_LOG_DOMAIN=\"ClutterOSX\" \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
-I$(top_builddir)/clutter \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS) \
|
$(GCC_FLAGS) \
|
||||||
|
@ -16,8 +16,8 @@ INCLUDES = \
|
|||||||
@GCC_FLAGS@ @CLUTTER_CFLAGS@ \
|
@GCC_FLAGS@ @CLUTTER_CFLAGS@ \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@
|
-I$(top_builddir)/clutter
|
||||||
|
|
||||||
pangoclutterheadersdir = $(includedir)/clutter-@CLUTTER_MAJORMINOR@/clutter
|
pangoclutterheadersdir = $(includedir)/clutter-@CLUTTER_MAJORMINOR@/clutter
|
||||||
pangoclutterheaders_HEADERS = $(source_h)
|
pangoclutterheaders_HEADERS = $(source_h)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "pangoclutter-private.h"
|
#include "pangoclutter-private.h"
|
||||||
#include "../clutter-debug.h"
|
#include "../clutter-debug.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Texture cache support code
|
* Texture cache support code
|
||||||
@ -43,18 +43,18 @@
|
|||||||
#define TC_ROUND 4
|
#define TC_ROUND 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
guint name;
|
CoglHandle cogl_tex;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
} tc_area;
|
} tc_area;
|
||||||
|
|
||||||
typedef struct tc_texture {
|
typedef struct tc_texture {
|
||||||
struct tc_texture *next;
|
struct tc_texture *next;
|
||||||
COGLuint name;
|
CoglHandle cogl_tex;
|
||||||
int avail;
|
int avail;
|
||||||
} tc_texture;
|
} tc_texture;
|
||||||
|
|
||||||
typedef struct tc_slice {
|
typedef struct tc_slice {
|
||||||
guint name;
|
CoglHandle cogl_tex;
|
||||||
int avail, y;
|
int avail, y;
|
||||||
} tc_slice;
|
} tc_slice;
|
||||||
|
|
||||||
@ -68,12 +68,12 @@ tc_clear ()
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = TC_HEIGHT / TC_ROUND; i--; )
|
for (i = TC_HEIGHT / TC_ROUND; i--; )
|
||||||
slices [i].name = 0;
|
slices [i].cogl_tex = COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
while (first_texture)
|
while (first_texture)
|
||||||
{
|
{
|
||||||
tc_texture *next = first_texture->next;
|
tc_texture *next = first_texture->next;
|
||||||
cogl_textures_destroy (1, &first_texture->name);
|
cogl_texture_unref (first_texture->cogl_tex);
|
||||||
g_slice_free (tc_texture, first_texture);
|
g_slice_free (tc_texture, first_texture);
|
||||||
first_texture = next;
|
first_texture = next;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ tc_get (tc_area *area, int width, int height)
|
|||||||
|
|
||||||
width = MIN (width, TC_WIDTH);
|
width = MIN (width, TC_WIDTH);
|
||||||
|
|
||||||
if (!slice->name || slice->avail < width)
|
if (slice->cogl_tex == COGL_INVALID_HANDLE || slice->avail < width)
|
||||||
{
|
{
|
||||||
/* try to find a texture with enough space */
|
/* try to find a texture with enough space */
|
||||||
tc_texture *tex, *match = 0;
|
tc_texture *tex, *match = 0;
|
||||||
@ -113,52 +113,35 @@ tc_get (tc_area *area, int width, int height)
|
|||||||
/* create a new texture if necessary */
|
/* create a new texture if necessary */
|
||||||
if (!match)
|
if (!match)
|
||||||
{
|
{
|
||||||
COGLenum texture_target_type = CGL_TEXTURE_2D;
|
|
||||||
|
|
||||||
CLUTTER_NOTE (PANGO, "creating new texture %i x %i",
|
CLUTTER_NOTE (PANGO, "creating new texture %i x %i",
|
||||||
TC_WIDTH, TC_HEIGHT);
|
TC_WIDTH, TC_HEIGHT);
|
||||||
|
|
||||||
/* Use NPOTS if available as it simply makes shaders easier to
|
|
||||||
* work with on text.
|
|
||||||
*/
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
texture_target_type = CGL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
|
|
||||||
match = g_slice_new (tc_texture);
|
match = g_slice_new (tc_texture);
|
||||||
match->next = first_texture;
|
match->next = first_texture;
|
||||||
first_texture = match;
|
first_texture = match;
|
||||||
match->avail = TC_HEIGHT;
|
match->avail = TC_HEIGHT;
|
||||||
|
|
||||||
cogl_textures_create (1, &match->name);
|
match->cogl_tex = cogl_texture_new_with_size (TC_WIDTH, TC_HEIGHT, 0,
|
||||||
|
COGL_PIXEL_FORMAT_A_8);
|
||||||
|
|
||||||
cogl_texture_bind (texture_target_type, match->name);
|
/* We might even want to use mipmapping instead of
|
||||||
|
* CGL_LINEAR here that should allow rerendering of glyphs
|
||||||
/* We might even want to use mipmapping instead of CGL_LINEAR here
|
* to look nice even at scales far below 50%.
|
||||||
* that should allow rerendering of glyphs to look nice even at scales
|
|
||||||
* far below 50%.
|
|
||||||
*/
|
*/
|
||||||
cogl_texture_set_filters (texture_target_type,
|
cogl_texture_set_filters (match->cogl_tex,
|
||||||
CGL_LINEAR, CGL_NEAREST);
|
CGL_LINEAR, CGL_NEAREST);
|
||||||
|
|
||||||
cogl_texture_image_2d (texture_target_type,
|
|
||||||
CGL_ALPHA,
|
|
||||||
TC_WIDTH,
|
|
||||||
TC_HEIGHT,
|
|
||||||
CGL_ALPHA,
|
|
||||||
CGL_UNSIGNED_BYTE,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match->avail -= slice_height;
|
match->avail -= slice_height;
|
||||||
|
|
||||||
slice->name = match->name;
|
slice->cogl_tex = match->cogl_tex;
|
||||||
slice->avail = TC_WIDTH;
|
slice->avail = TC_WIDTH;
|
||||||
slice->y = match->avail;
|
slice->y = match->avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
slice->avail -= width;
|
slice->avail -= width;
|
||||||
|
|
||||||
area->name = slice->name;
|
area->cogl_tex = slice->cogl_tex;
|
||||||
area->x = slice->avail;
|
area->x = slice->avail;
|
||||||
area->y = slice->y;
|
area->y = slice->y;
|
||||||
}
|
}
|
||||||
@ -194,8 +177,6 @@ struct _PangoClutterRenderer
|
|||||||
PangoRenderer parent_instance;
|
PangoRenderer parent_instance;
|
||||||
ClutterColor color;
|
ClutterColor color;
|
||||||
int flags;
|
int flags;
|
||||||
guint curtex; /* current texture */
|
|
||||||
COGLenum texture_target_type; /* 2D or Rect */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (PangoClutterRenderer, \
|
G_DEFINE_TYPE (PangoClutterRenderer, \
|
||||||
@ -330,9 +311,9 @@ draw_glyph (PangoRenderer *renderer_,
|
|||||||
double xd,
|
double xd,
|
||||||
double yd)
|
double yd)
|
||||||
{
|
{
|
||||||
PangoClutterRenderer *renderer = PANGO_CLUTTER_RENDERER (renderer_);
|
|
||||||
glyph_info *g;
|
glyph_info *g;
|
||||||
gint x = (gint)xd, y = (gint)yd;
|
gint x = (gint)xd, y = (gint)yd;
|
||||||
|
ClutterFixed fx, fy;
|
||||||
|
|
||||||
if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
|
if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
|
||||||
{
|
{
|
||||||
@ -384,100 +365,33 @@ draw_glyph (PangoRenderer *renderer_,
|
|||||||
|
|
||||||
CLUTTER_NOTE (PANGO, "cache fail; subimage2d %i", glyph);
|
CLUTTER_NOTE (PANGO, "cache fail; subimage2d %i", glyph);
|
||||||
|
|
||||||
cogl_texture_bind (renderer->texture_target_type, g->tex.name);
|
cogl_texture_set_region (g->tex.cogl_tex,
|
||||||
|
0, 0,
|
||||||
cogl_texture_set_alignment (renderer->texture_target_type,
|
g->tex.x, g->tex.y,
|
||||||
1, bm.stride);
|
bm.width, bm.height,
|
||||||
|
bm.width, bm.height,
|
||||||
cogl_texture_sub_image_2d (renderer->texture_target_type,
|
COGL_PIXEL_FORMAT_A_8,
|
||||||
g->tex.x,
|
bm.stride,
|
||||||
g->tex.y,
|
|
||||||
bm.width,
|
|
||||||
bm.height,
|
|
||||||
CGL_ALPHA,
|
|
||||||
CGL_UNSIGNED_BYTE,
|
|
||||||
bm.bitmap);
|
bm.bitmap);
|
||||||
|
|
||||||
glTexParameteri (renderer->texture_target_type,
|
|
||||||
GL_GENERATE_MIPMAP, FALSE);
|
|
||||||
|
|
||||||
renderer->curtex = g->tex.name;
|
|
||||||
}
|
}
|
||||||
else CLUTTER_NOTE (PANGO, "cache succsess %i\n", glyph);
|
else
|
||||||
|
CLUTTER_NOTE (PANGO, "cache success %i\n", glyph);
|
||||||
|
|
||||||
x += g->left;
|
x += g->left;
|
||||||
y -= g->top;
|
y -= g->top;
|
||||||
|
|
||||||
if (g->tex.name != renderer->curtex)
|
|
||||||
{
|
|
||||||
cogl_texture_bind (renderer->texture_target_type, g->tex.name);
|
|
||||||
renderer->curtex = g->tex.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
{
|
|
||||||
cogl_texture_quad (x,
|
|
||||||
x + g->tex.w,
|
|
||||||
y,
|
|
||||||
y + g->tex.h,
|
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.x),
|
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.y),
|
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.w + g->tex.x),
|
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.h + g->tex.y));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ClutterFixed fx, fy;
|
|
||||||
|
|
||||||
fx = CLUTTER_INT_TO_FIXED (g->tex.x) / TC_WIDTH;
|
fx = CLUTTER_INT_TO_FIXED (g->tex.x) / TC_WIDTH;
|
||||||
fy = CLUTTER_INT_TO_FIXED (g->tex.y) / TC_HEIGHT;
|
fy = CLUTTER_INT_TO_FIXED (g->tex.y) / TC_HEIGHT;
|
||||||
|
|
||||||
cogl_texture_quad (x,
|
cogl_texture_rectangle (g->tex.cogl_tex,
|
||||||
x + g->tex.w,
|
CLUTTER_INT_TO_FIXED (x),
|
||||||
y,
|
CLUTTER_INT_TO_FIXED (y),
|
||||||
y + g->tex.h,
|
CLUTTER_INT_TO_FIXED (x + g->tex.w),
|
||||||
fx,
|
CLUTTER_INT_TO_FIXED (y + g->tex.h),
|
||||||
fy,
|
fx, fy,
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.w) / TC_WIDTH + fx,
|
CLUTTER_INT_TO_FIXED (g->tex.w) / TC_WIDTH + fx,
|
||||||
CLUTTER_INT_TO_FIXED (g->tex.h) / TC_HEIGHT + fy);
|
CLUTTER_INT_TO_FIXED (g->tex.h) / TC_WIDTH + fy);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
draw_trapezoid (PangoRenderer *renderer_,
|
|
||||||
PangoRenderPart part,
|
|
||||||
double y01,
|
|
||||||
double x11,
|
|
||||||
double x21,
|
|
||||||
double y02,
|
|
||||||
double x12,
|
|
||||||
double x22)
|
|
||||||
{
|
|
||||||
PangoClutterRenderer *renderer = (PangoClutterRenderer *)renderer_;
|
|
||||||
|
|
||||||
if (renderer->curtex)
|
|
||||||
{
|
|
||||||
/* glEnd (); */
|
|
||||||
renderer->curtex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Turn texturing off */
|
|
||||||
cogl_enable (CGL_ENABLE_BLEND);
|
|
||||||
|
|
||||||
cogl_trapezoid ((gint) y01,
|
|
||||||
(gint) x11,
|
|
||||||
(gint) x21,
|
|
||||||
(gint) y02,
|
|
||||||
(gint) x12,
|
|
||||||
(gint) x22);
|
|
||||||
|
|
||||||
/* Turn it back on again */
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
|
|
||||||
else
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
pango_clutter_render_layout_subpixel (PangoLayout *layout,
|
pango_clutter_render_layout_subpixel (PangoLayout *layout,
|
||||||
@ -545,11 +459,6 @@ pango_clutter_render_clear_caches (void)
|
|||||||
static void
|
static void
|
||||||
pango_clutter_renderer_init (PangoClutterRenderer *renderer)
|
pango_clutter_renderer_init (PangoClutterRenderer *renderer)
|
||||||
{
|
{
|
||||||
renderer->texture_target_type = CGL_TEXTURE_2D;
|
|
||||||
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
renderer->texture_target_type = CGL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
|
|
||||||
memset (&renderer->color, 0xff, sizeof(ClutterColor));
|
memset (&renderer->color, 0xff, sizeof(ClutterColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,25 +523,11 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
|
|||||||
static void
|
static void
|
||||||
draw_begin (PangoRenderer *renderer_)
|
draw_begin (PangoRenderer *renderer_)
|
||||||
{
|
{
|
||||||
PangoClutterRenderer *renderer = (PangoClutterRenderer *)renderer_;
|
|
||||||
|
|
||||||
renderer->curtex = 0;
|
|
||||||
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
|
|
||||||
else
|
|
||||||
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_end (PangoRenderer *renderer_)
|
draw_end (PangoRenderer *renderer_)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
PangoClutterRenderer *renderer = (PangoClutterRenderer *)renderer_;
|
|
||||||
|
|
||||||
if (renderer->curtex)
|
|
||||||
glEnd ();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -641,7 +536,6 @@ pango_clutter_renderer_class_init (PangoClutterRendererClass *klass)
|
|||||||
PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);
|
PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);
|
||||||
|
|
||||||
renderer_class->draw_glyph = draw_glyph;
|
renderer_class->draw_glyph = draw_glyph;
|
||||||
renderer_class->draw_trapezoid = draw_trapezoid;
|
|
||||||
renderer_class->prepare_run = prepare_run;
|
renderer_class->prepare_run = prepare_run;
|
||||||
renderer_class->begin = draw_begin;
|
renderer_class->begin = draw_begin;
|
||||||
renderer_class->end = draw_end;
|
renderer_class->end = draw_end;
|
||||||
|
@ -4,8 +4,8 @@ libclutterinclude_HEADERS = clutter-sdl.h
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DG_LOG_DOMAIN=\"ClutterSDL\" \
|
-DG_LOG_DOMAIN=\"ClutterSDL\" \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter/ \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
-I$(top_builddir)/clutter/ \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "../clutter-units.h"
|
#include "../clutter-units.h"
|
||||||
#include "../clutter-stage-window.h"
|
#include "../clutter-stage-window.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ pkgconfigdir = $(libdir)/pkgconfig
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DG_LOG_DOMAIN=\"ClutterWin32\" \
|
-DG_LOG_DOMAIN=\"ClutterWin32\" \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
-I$(top_builddir)/clutter \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "../clutter-private.h"
|
#include "../clutter-private.h"
|
||||||
#include "../clutter-version.h"
|
#include "../clutter-version.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterBackendWin32, clutter_backend_win32,
|
G_DEFINE_TYPE (ClutterBackendWin32, clutter_backend_win32,
|
||||||
CLUTTER_TYPE_BACKEND);
|
CLUTTER_TYPE_BACKEND);
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "../clutter-shader.h"
|
#include "../clutter-shader.h"
|
||||||
#include "../clutter-stage.h"
|
#include "../clutter-stage.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ pkgconfigdir = $(libdir)/pkgconfig
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DG_LOG_DOMAIN=\"ClutterX11\" \
|
-DG_LOG_DOMAIN=\"ClutterX11\" \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
-I$(top_srcdir)/clutter \
|
||||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
-I$(top_builddir)/clutter \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
$(GCC_FLAGS)
|
$(GCC_FLAGS)
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "../clutter-debug.h"
|
#include "../clutter-debug.h"
|
||||||
#include "../clutter-private.h"
|
#include "../clutter-private.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND);
|
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND);
|
||||||
|
|
||||||
|
@ -38,14 +38,12 @@
|
|||||||
#include "../clutter-debug.h"
|
#include "../clutter-debug.h"
|
||||||
#include "../clutter-units.h"
|
#include "../clutter-units.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
#ifdef HAVE_XFIXES
|
#ifdef HAVE_XFIXES
|
||||||
#include <X11/extensions/Xfixes.h>
|
#include <X11/extensions/Xfixes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
|
|
||||||
|
|
||||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageX11,
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageX11,
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "clutter-x11.h"
|
#include "clutter-x11.h"
|
||||||
#include "clutter-backend-x11.h"
|
#include "clutter-backend-x11.h"
|
||||||
|
|
||||||
#include "cogl.h"
|
#include "cogl/cogl.h"
|
||||||
|
|
||||||
/* FIXME: Check exts exist in autogen */
|
/* FIXME: Check exts exist in autogen */
|
||||||
#include <X11/extensions/Xdamage.h>
|
#include <X11/extensions/Xdamage.h>
|
||||||
@ -454,6 +454,9 @@ clutter_x11_texture_pixmap_update_area_real (ClutterX11TexturePixmap *texture,
|
|||||||
priv = texture->priv;
|
priv = texture->priv;
|
||||||
dpy = clutter_x11_get_default_display();
|
dpy = clutter_x11_get_default_display();
|
||||||
|
|
||||||
|
if (!priv->pixmap)
|
||||||
|
return;
|
||||||
|
|
||||||
clutter_x11_trap_x_errors ();
|
clutter_x11_trap_x_errors ();
|
||||||
|
|
||||||
/* FIXME: Use XSHM here! */
|
/* FIXME: Use XSHM here! */
|
||||||
|
104
configure.ac
@ -56,6 +56,8 @@ dnl ========================================================================
|
|||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
#_AM_DEPENDENCIES([OBJC])
|
||||||
|
#AC_PROG_OBJC
|
||||||
AC_DISABLE_STATIC
|
AC_DISABLE_STATIC
|
||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
@ -76,6 +78,26 @@ AC_FUNC_MALLOC
|
|||||||
AC_FUNC_MMAP
|
AC_FUNC_MMAP
|
||||||
AC_CHECK_FUNCS([memset munmap strcasecmp strdup])
|
AC_CHECK_FUNCS([memset munmap strcasecmp strdup])
|
||||||
|
|
||||||
|
dnl ========================================================================
|
||||||
|
|
||||||
|
imagebackend="gdk-pixbuf"
|
||||||
|
AC_ARG_WITH([imagebackend],
|
||||||
|
AC_HELP_STRING([--with-imagebackend=@<:@gdk-pixbuf/internal@:>@],
|
||||||
|
[Select COGL image loading backend]),
|
||||||
|
imagebackend=$with_imagebackend)
|
||||||
|
|
||||||
|
case $imagebackend in
|
||||||
|
|
||||||
|
gdk-pixbuf)
|
||||||
|
AC_DEFINE([USE_GDKPIXBUF], 1, [Use GdkPixbuf for loading image files])
|
||||||
|
;;
|
||||||
|
|
||||||
|
internal)
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
dnl ========================================================================
|
dnl ========================================================================
|
||||||
|
|
||||||
@ -127,6 +149,8 @@ if test x$have_xcomposite = xyes; then
|
|||||||
X11_LIBS="$X11_LIBS -lXcomposite"
|
X11_LIBS="$X11_LIBS -lXcomposite"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
x11_tests=no
|
||||||
|
|
||||||
# Currently require all extentions, may not for actual release.
|
# Currently require all extentions, may not for actual release.
|
||||||
if test "x$clutterbackend" = "xglx" || test "x$clutterbackend" = "xeglx"
|
if test "x$clutterbackend" = "xglx" || test "x$clutterbackend" = "xeglx"
|
||||||
then
|
then
|
||||||
@ -134,8 +158,11 @@ then
|
|||||||
then
|
then
|
||||||
AC_MSG_ERROR([[Required backend X11 Libraries not found.]])
|
AC_MSG_ERROR([[Required backend X11 Libraries not found.]])
|
||||||
fi
|
fi
|
||||||
|
x11_tests=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AM_CONDITIONAL(X11_TESTS, test "x$x11_tests" != "xno")
|
||||||
|
|
||||||
clutter_gl_header=""
|
clutter_gl_header=""
|
||||||
|
|
||||||
case $clutterbackend in
|
case $clutterbackend in
|
||||||
@ -203,8 +230,10 @@ case $clutterbackend in
|
|||||||
AC_MSG_ERROR([GLX not found and GLX backend requested]);
|
AC_MSG_ERROR([GLX not found and GLX backend requested]);
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "x$imagebackend" = "xgdk-pixbuf"; then
|
||||||
# xlib pixbuf needed for exporting the stage
|
# xlib pixbuf needed for exporting the stage
|
||||||
BACKEND_PC_FILES="gdk-pixbuf-xlib-2.0"
|
BACKEND_PC_FILES="gdk-pixbuf-xlib-2.0"
|
||||||
|
fi
|
||||||
|
|
||||||
GLX_LIBS="$X11_LIBS -lGL"
|
GLX_LIBS="$X11_LIBS -lGL"
|
||||||
GLX_CFLAGS="$X11_CFLAGS"
|
GLX_CFLAGS="$X11_CFLAGS"
|
||||||
@ -286,6 +315,35 @@ case $clutterbackend in
|
|||||||
EGL_CFLAGS="$TSLIB_CFLAGS"
|
EGL_CFLAGS="$TSLIB_CFLAGS"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
fruity)
|
||||||
|
|
||||||
|
clutter_gl_header="GLES/gl.h"
|
||||||
|
|
||||||
|
|
||||||
|
CLUTTER_FLAVOUR="fruity"
|
||||||
|
CLUTTER_STAGE_TYPE="CLUTTER_TYPE_STAGE_FRUITY"
|
||||||
|
AC_DEFINE([HAVE_CLUTTER_FRUITY], 1, [We're building a fruity version of the eglnative backend])
|
||||||
|
|
||||||
|
# We currently assume having egl means also having gles..
|
||||||
|
CLUTTER_COGL="gles"
|
||||||
|
|
||||||
|
AC_DEFINE([HAVE_CLUTTER_EGL], 1, [Have the EGL backend])
|
||||||
|
|
||||||
|
# We currently assume having egl means also having gles..
|
||||||
|
CLUTTER_COGL="gles"
|
||||||
|
AC_DEFINE([HAVE_COGL_GLES], 1, [Have GL/ES for rendering])
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS([$clutter_gl_header],,
|
||||||
|
[AC_MSG_ERROR([Unable to locate require GL header])])
|
||||||
|
AC_CHECK_HEADERS([GLES/egl.h],,
|
||||||
|
[AC_MSG_ERROR([Unable to locate required GLES headers])])
|
||||||
|
|
||||||
|
backendextra=
|
||||||
|
|
||||||
|
EGL_LIBS="-ObjC -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreSurface -framework GraphicsServices -framework OpenGLES -framework LayerKit -framework UIKit"
|
||||||
|
EGL_CFLAGS=""
|
||||||
|
;;
|
||||||
|
|
||||||
osx)
|
osx)
|
||||||
|
|
||||||
clutter_gl_header="OpenGL/gl.h"
|
clutter_gl_header="OpenGL/gl.h"
|
||||||
@ -325,7 +383,7 @@ case $clutterbackend in
|
|||||||
CLUTTER_LT_LDFLAGS="$CLUTTER_LT_LDFLAGS -no-undefined"
|
CLUTTER_LT_LDFLAGS="$CLUTTER_LT_LDFLAGS -no-undefined"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*) AC_MSG_ERROR([Invalid backend for Clutter: use glx,sdl,osx,win32,eglx or eglnative])
|
*) AC_MSG_ERROR([Invalid backend for Clutter: use glx,sdl,osx,win32,eglx, eglnative or fruity])
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
@ -333,6 +391,7 @@ esac
|
|||||||
CLUTTER_GL_HEADER=$clutter_gl_header
|
CLUTTER_GL_HEADER=$clutter_gl_header
|
||||||
|
|
||||||
AC_SUBST([clutterbackend])
|
AC_SUBST([clutterbackend])
|
||||||
|
AC_SUBST([imagebackend])
|
||||||
AC_SUBST([backendextra])
|
AC_SUBST([backendextra])
|
||||||
AC_SUBST([backendextralib])
|
AC_SUBST([backendextralib])
|
||||||
AC_SUBST(CLUTTER_FLAVOUR)
|
AC_SUBST(CLUTTER_FLAVOUR)
|
||||||
@ -381,7 +440,12 @@ fi
|
|||||||
AC_SUBST(JSON_PREFIX)
|
AC_SUBST(JSON_PREFIX)
|
||||||
AM_CONDITIONAL(LOCAL_JSON_GLIB, test "x$have_json" = "xno")
|
AM_CONDITIONAL(LOCAL_JSON_GLIB, test "x$have_json" = "xno")
|
||||||
|
|
||||||
CLUTTER_REQUIRES="pangoft2 glib-2.0 >= 2.14 gobject-2.0 gthread-2.0 gdk-pixbuf-2.0 $BACKEND_PC_FILES $JSON_GLIB_PC"
|
CLUTTER_REQUIRES="pangoft2 glib-2.0 >= 2.14 gobject-2.0 gthread-2.0 gmodule-2.0 $BACKEND_PC_FILES $JSON_GLIB_PC"
|
||||||
|
|
||||||
|
if test "x$imagebackend" = "xgdk-pixbuf"; then
|
||||||
|
CLUTTER_REQUIRES="$CLUTTER_REQUIRES gdk-pixbuf-2.0"
|
||||||
|
fi
|
||||||
|
|
||||||
PKG_CHECK_MODULES(CLUTTER_DEPS, [$CLUTTER_REQUIRES])
|
PKG_CHECK_MODULES(CLUTTER_DEPS, [$CLUTTER_REQUIRES])
|
||||||
|
|
||||||
AC_SUBST(CLUTTER_REQUIRES)
|
AC_SUBST(CLUTTER_REQUIRES)
|
||||||
@ -485,20 +549,26 @@ AC_CONFIG_FILES([
|
|||||||
clutter/glx/Makefile
|
clutter/glx/Makefile
|
||||||
clutter/eglx/Makefile
|
clutter/eglx/Makefile
|
||||||
clutter/eglnative/Makefile
|
clutter/eglnative/Makefile
|
||||||
|
clutter/fruity/Makefile
|
||||||
clutter/osx/Makefile
|
clutter/osx/Makefile
|
||||||
clutter/win32/Makefile
|
clutter/win32/Makefile
|
||||||
clutter/win32/clutter-win32.pc
|
clutter/win32/clutter-win32.pc
|
||||||
clutter/sdl/Makefile
|
clutter/sdl/Makefile
|
||||||
clutter/cogl/Makefile
|
clutter/cogl/Makefile
|
||||||
|
clutter/cogl/common/Makefile
|
||||||
|
clutter/cogl/cogl.h
|
||||||
|
clutter/cogl/cogl-defines-gl.h:clutter/cogl/gl/cogl-defines.h.in
|
||||||
|
clutter/cogl/cogl-defines-gles.h:clutter/cogl/gles/cogl-defines.h.in
|
||||||
clutter/cogl/gl/Makefile
|
clutter/cogl/gl/Makefile
|
||||||
clutter/cogl/gl/cogl-defines.h
|
|
||||||
clutter/cogl/gles/Makefile
|
clutter/cogl/gles/Makefile
|
||||||
clutter/json/Makefile
|
clutter/json/Makefile
|
||||||
clutter/pango/Makefile
|
clutter/pango/Makefile
|
||||||
tests/Makefile
|
tests/Makefile
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
doc/reference/Makefile
|
doc/reference/Makefile
|
||||||
doc/reference/version.xml
|
doc/reference/clutter/Makefile
|
||||||
|
doc/reference/clutter/version.xml
|
||||||
|
doc/reference/cogl/Makefile
|
||||||
doc/manual/clutter-manual.xml
|
doc/manual/clutter-manual.xml
|
||||||
doc/manual/Makefile
|
doc/manual/Makefile
|
||||||
clutter.pc
|
clutter.pc
|
||||||
@ -522,3 +592,29 @@ echo " Compiler flags: ${CPPFLAGS}"
|
|||||||
echo " API Documentation: ${enable_gtk_doc}"
|
echo " API Documentation: ${enable_gtk_doc}"
|
||||||
echo " Manual Documentation: ${enable_manual}"
|
echo " Manual Documentation: ${enable_manual}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# you can add more configuration options or flags that will bring up the
|
||||||
|
# the experimental/unstable warning summary.
|
||||||
|
|
||||||
|
if test "x$imagebackend" = "xinternal"; then
|
||||||
|
experimental_stuff="$experimental_stuff\n imagebackend=$imagebackend"
|
||||||
|
fi
|
||||||
|
if test "x$clutterbackend" = "xfruity"; then
|
||||||
|
experimental_stuff="$experimental_stuff\n clutterbackend=$clutterbackend"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x$experimental_stuff" != "x"; then
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
echo ""
|
||||||
|
echo "Experimental features configured, stability of your build either uses"
|
||||||
|
echo "experimental backends or experimental and unsupported features:"
|
||||||
|
echo -e "$experimental_stuff"
|
||||||
|
echo ""
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,50 @@
|
|||||||
|
2008-04-22 Øyvind Kolås <pippin@o-hand.com>
|
||||||
|
|
||||||
|
* clutter/Makefile.am:
|
||||||
|
* cogl/Makefile.am: s/EXTRA_DIST +=/EXTRA_DIST =/ since newer automake
|
||||||
|
is more stringent and EXTRA_DIST has not been defined earlier.
|
||||||
|
|
||||||
|
2008-04-21 Neil Roberts <neil@o-hand.com>
|
||||||
|
|
||||||
|
* cogl/cogl-sections.txt: Added CoglTextureVertex,
|
||||||
|
cogl_texture_can_polygon and cogl_texture_polygon.
|
||||||
|
|
||||||
|
2008-04-18 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
* cogl/cogl-docs.sgml: Fill out and add an "about" section.
|
||||||
|
|
||||||
|
* cogl/cogl-sections.txt: Remove unused/redundant stuff,
|
||||||
|
divide into logical subsections and in general make the
|
||||||
|
documentation more structured.
|
||||||
|
|
||||||
|
* cogl/Makefile.am: Ignore some private header files.
|
||||||
|
|
||||||
|
2008-04-18 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
* cogl/: Add COGL documentation.
|
||||||
|
|
||||||
|
* Makefile.am: Add cogl/ to the list of SUBDIRS.
|
||||||
|
|
||||||
|
2008-04-18 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
* clutter/:
|
||||||
|
* *: Moved everything into the clutter/ subdirectory, to make
|
||||||
|
room for the COGL API reference.
|
||||||
|
|
||||||
|
2008-04-07 Neil Roberts <neil@o-hand.com>
|
||||||
|
|
||||||
|
* clutter-sections.txt: Removed clutter_texture_new_from_pixbuf
|
||||||
|
and clutter_texture_{get,set}_pixbuf. Added
|
||||||
|
clutter_texture_{set,new}_from_file.
|
||||||
|
|
||||||
|
2008-04-03 Neil Roberts <neil@o-hand.com>
|
||||||
|
|
||||||
|
* clutter-sections.txt: Removed ClutterTexture functions that are
|
||||||
|
no longer neccessary to implement ClutterCloneTexture because of
|
||||||
|
the new COGL texture API. Added
|
||||||
|
clutter_texture_{get,set}_filter_quality and
|
||||||
|
clutter_texture_get_cogl_texture.
|
||||||
|
|
||||||
2008-03-30 Neil Roberts <neil@o-hand.com>
|
2008-03-30 Neil Roberts <neil@o-hand.com>
|
||||||
|
|
||||||
* clutter-sections.txt: Added clutter_win32_get_stage_from_window
|
* clutter-sections.txt: Added clutter_win32_get_stage_from_window
|
||||||
|
@ -1,129 +1 @@
|
|||||||
## Process this file with automake to produce Makefile.in
|
SUBDIRS = clutter cogl
|
||||||
|
|
||||||
# We require automake 1.6 at least.
|
|
||||||
AUTOMAKE_OPTIONS = 1.6
|
|
||||||
|
|
||||||
# This is a blank Makefile.am for using gtk-doc.
|
|
||||||
# Copy this to your project's API docs directory and modify the variables to
|
|
||||||
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
|
|
||||||
# of using the various options.
|
|
||||||
|
|
||||||
# The name of the module, e.g. 'glib'.
|
|
||||||
DOC_MODULE=clutter
|
|
||||||
|
|
||||||
# The top-level SGML file. You can change this if you want to.
|
|
||||||
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
|
|
||||||
|
|
||||||
# The directory containing the source code. Relative to $(srcdir).
|
|
||||||
# gtk-doc will search all .c & .h files beneath here for inline comments
|
|
||||||
# documenting the functions and macros.
|
|
||||||
# e.g. DOC_SOURCE_DIR=../../../gtk
|
|
||||||
DOC_SOURCE_DIR=../../clutter
|
|
||||||
|
|
||||||
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
|
|
||||||
SCANGOBJ_OPTIONS=--type-init-func="clutter_base_init()"
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-scan.
|
|
||||||
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
|
||||||
SCAN_OPTIONS=--deprecated-guards="CLUTTER_DISABLE_DEPRECATED"
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-mkdb.
|
|
||||||
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
|
|
||||||
MKDB_OPTIONS=--sgml-mode --output-format=xml
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-mktmpl
|
|
||||||
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
|
|
||||||
MKTMPL_OPTIONS=
|
|
||||||
|
|
||||||
# Extra options to supply to gtkdoc-fixref. Not normally needed.
|
|
||||||
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
|
|
||||||
FIXXREF_OPTIONS=\
|
|
||||||
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject \
|
|
||||||
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
|
|
||||||
--extra-dir=$(PANGO_PREFIX)/share/gtk-doc/html/pango \
|
|
||||||
--extra-dir=$(GDPIXBUF_PREFIX)/share/gtk-doc/html/gdk-pixbuf
|
|
||||||
|
|
||||||
# Used for dependencies. The docs will be rebuilt if any of these change.
|
|
||||||
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
|
|
||||||
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
|
|
||||||
HFILE_GLOB=$(top_srcdir)/clutter/*.h \
|
|
||||||
$(top_srcdir)/clutter/x11/clutter-x11.h \
|
|
||||||
$(top_srcdir)/clutter/win32/clutter-win32.h
|
|
||||||
CFILE_GLOB=$(top_srcdir)/clutter/*.c
|
|
||||||
|
|
||||||
# Header files to ignore when scanning.
|
|
||||||
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
|
|
||||||
IGNORE_HFILES=\
|
|
||||||
clutter.h \
|
|
||||||
clutter-debug.h \
|
|
||||||
clutter-deprecated.h \
|
|
||||||
clutter-enum-types.h \
|
|
||||||
clutter-json.h \
|
|
||||||
clutter-keysyms.h \
|
|
||||||
clutter-keysyms-table.h \
|
|
||||||
clutter-marshal.h \
|
|
||||||
clutter-model-private.h \
|
|
||||||
clutter-private.h \
|
|
||||||
clutter-id-pool.h \
|
|
||||||
clutter-script-private.h \
|
|
||||||
stamp-clutter-enum-types.h \
|
|
||||||
stamp-clutter-marshal.h \
|
|
||||||
cogl \
|
|
||||||
eglnative \
|
|
||||||
eglx \
|
|
||||||
glx \
|
|
||||||
osx \
|
|
||||||
x11 \
|
|
||||||
json \
|
|
||||||
pango \
|
|
||||||
sdl \
|
|
||||||
win32
|
|
||||||
|
|
||||||
EXTRA_HFILES=\
|
|
||||||
../../clutter/x11/clutter-x11.h \
|
|
||||||
../../clutter/win32/clutter-win32.h
|
|
||||||
|
|
||||||
# Images to copy into HTML directory.
|
|
||||||
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
|
||||||
HTML_IMAGES=\
|
|
||||||
actor-box.png \
|
|
||||||
alpha-func.png \
|
|
||||||
event-flow.png \
|
|
||||||
path-alpha-func.png
|
|
||||||
|
|
||||||
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
|
|
||||||
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
|
|
||||||
content_files= \
|
|
||||||
subclassing-ClutterActor.sgml \
|
|
||||||
clutter-animation.sgml \
|
|
||||||
creating-your-own-behaviours.sgml \
|
|
||||||
version.xml
|
|
||||||
|
|
||||||
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
|
|
||||||
# These files must be listed here *and* in content_files
|
|
||||||
# e.g. expand_content_files=running.sgml
|
|
||||||
expand_content_files= \
|
|
||||||
subclassing-ClutterActor.sgml \
|
|
||||||
clutter-animation.sgml \
|
|
||||||
creating-your-own-behaviours.sgml
|
|
||||||
|
|
||||||
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
|
||||||
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
|
|
||||||
# signals and properties.
|
|
||||||
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
|
|
||||||
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
|
|
||||||
|
|
||||||
INCLUDES=-I$(top_srcdir) $(CLUTTER_CFLAGS)
|
|
||||||
GTKDOC_LIBS=$(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la $(CLUTTER_LIBS)
|
|
||||||
|
|
||||||
# This includes the standard gtk-doc make rules, copied by gtkdocize.
|
|
||||||
include $(top_srcdir)/gtk-doc.make
|
|
||||||
|
|
||||||
# Other files to distribute
|
|
||||||
# e.g. EXTRA_DIST += version.xml.in
|
|
||||||
EXTRA_DIST += \
|
|
||||||
version.xml.in \
|
|
||||||
actor-box.png \
|
|
||||||
alpha-func.png \
|
|
||||||
event-flow.png \
|
|
||||||
path-alpha-func.png
|
|
||||||
|
129
doc/reference/clutter/Makefile.am
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
# We require automake 1.6 at least.
|
||||||
|
AUTOMAKE_OPTIONS = 1.6
|
||||||
|
|
||||||
|
# This is a blank Makefile.am for using gtk-doc.
|
||||||
|
# Copy this to your project's API docs directory and modify the variables to
|
||||||
|
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
|
||||||
|
# of using the various options.
|
||||||
|
|
||||||
|
# The name of the module, e.g. 'glib'.
|
||||||
|
DOC_MODULE=clutter
|
||||||
|
|
||||||
|
# The top-level SGML file. You can change this if you want to.
|
||||||
|
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
|
||||||
|
|
||||||
|
# The directory containing the source code. Relative to $(srcdir).
|
||||||
|
# gtk-doc will search all .c & .h files beneath here for inline comments
|
||||||
|
# documenting the functions and macros.
|
||||||
|
# e.g. DOC_SOURCE_DIR=../../../gtk
|
||||||
|
DOC_SOURCE_DIR=../../../clutter
|
||||||
|
|
||||||
|
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
|
||||||
|
SCANGOBJ_OPTIONS=--type-init-func="clutter_base_init()"
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-scan.
|
||||||
|
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||||
|
SCAN_OPTIONS=--deprecated-guards="CLUTTER_DISABLE_DEPRECATED"
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-mkdb.
|
||||||
|
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||||
|
MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-mktmpl
|
||||||
|
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
|
||||||
|
MKTMPL_OPTIONS=
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-fixref. Not normally needed.
|
||||||
|
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
|
||||||
|
FIXXREF_OPTIONS=\
|
||||||
|
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject \
|
||||||
|
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
|
||||||
|
--extra-dir=$(PANGO_PREFIX)/share/gtk-doc/html/pango \
|
||||||
|
--extra-dir=$(GDPIXBUF_PREFIX)/share/gtk-doc/html/gdk-pixbuf
|
||||||
|
|
||||||
|
# Used for dependencies. The docs will be rebuilt if any of these change.
|
||||||
|
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
|
||||||
|
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
|
||||||
|
HFILE_GLOB=$(top_srcdir)/clutter/*.h \
|
||||||
|
$(top_srcdir)/clutter/x11/clutter-x11.h \
|
||||||
|
$(top_srcdir)/clutter/win32/clutter-win32.h
|
||||||
|
CFILE_GLOB=$(top_srcdir)/clutter/*.c
|
||||||
|
|
||||||
|
# Header files to ignore when scanning.
|
||||||
|
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
|
||||||
|
IGNORE_HFILES=\
|
||||||
|
clutter.h \
|
||||||
|
clutter-debug.h \
|
||||||
|
clutter-deprecated.h \
|
||||||
|
clutter-enum-types.h \
|
||||||
|
clutter-json.h \
|
||||||
|
clutter-keysyms.h \
|
||||||
|
clutter-keysyms-table.h \
|
||||||
|
clutter-marshal.h \
|
||||||
|
clutter-model-private.h \
|
||||||
|
clutter-private.h \
|
||||||
|
clutter-id-pool.h \
|
||||||
|
clutter-script-private.h \
|
||||||
|
stamp-clutter-enum-types.h \
|
||||||
|
stamp-clutter-marshal.h \
|
||||||
|
cogl \
|
||||||
|
eglnative \
|
||||||
|
eglx \
|
||||||
|
glx \
|
||||||
|
osx \
|
||||||
|
x11 \
|
||||||
|
json \
|
||||||
|
pango \
|
||||||
|
sdl \
|
||||||
|
win32
|
||||||
|
|
||||||
|
EXTRA_HFILES=\
|
||||||
|
../../../clutter/x11/clutter-x11.h \
|
||||||
|
../../../clutter/win32/clutter-win32.h
|
||||||
|
|
||||||
|
# Images to copy into HTML directory.
|
||||||
|
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
||||||
|
HTML_IMAGES=\
|
||||||
|
actor-box.png \
|
||||||
|
alpha-func.png \
|
||||||
|
event-flow.png \
|
||||||
|
path-alpha-func.png
|
||||||
|
|
||||||
|
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
|
||||||
|
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
|
||||||
|
content_files= \
|
||||||
|
subclassing-ClutterActor.sgml \
|
||||||
|
clutter-animation.sgml \
|
||||||
|
creating-your-own-behaviours.sgml \
|
||||||
|
version.xml
|
||||||
|
|
||||||
|
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
|
||||||
|
# These files must be listed here *and* in content_files
|
||||||
|
# e.g. expand_content_files=running.sgml
|
||||||
|
expand_content_files= \
|
||||||
|
subclassing-ClutterActor.sgml \
|
||||||
|
clutter-animation.sgml \
|
||||||
|
creating-your-own-behaviours.sgml
|
||||||
|
|
||||||
|
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
||||||
|
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
|
||||||
|
# signals and properties.
|
||||||
|
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
|
||||||
|
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
|
||||||
|
|
||||||
|
INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/clutter $(CLUTTER_CFLAGS)
|
||||||
|
GTKDOC_LIBS=$(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la $(CLUTTER_LIBS)
|
||||||
|
|
||||||
|
# This includes the standard gtk-doc make rules, copied by gtkdocize.
|
||||||
|
include $(top_srcdir)/gtk-doc.make
|
||||||
|
|
||||||
|
# Other files to distribute
|
||||||
|
# e.g. EXTRA_DIST += version.xml.in
|
||||||
|
EXTRA_DIST = \
|
||||||
|
version.xml.in \
|
||||||
|
actor-box.png \
|
||||||
|
alpha-func.png \
|
||||||
|
event-flow.png \
|
||||||
|
path-alpha-func.png
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
@ -28,15 +28,14 @@ clutter_media_get_type
|
|||||||
<FILE>clutter-units</FILE>
|
<FILE>clutter-units</FILE>
|
||||||
<TITLE>Unit conversion</TITLE>
|
<TITLE>Unit conversion</TITLE>
|
||||||
ClutterUnit
|
ClutterUnit
|
||||||
|
CLUTTER_UNITS_FROM_DEVICE
|
||||||
|
CLUTTER_UNITS_TO_DEVICE
|
||||||
CLUTTER_UNITS_FROM_FIXED
|
CLUTTER_UNITS_FROM_FIXED
|
||||||
CLUTTER_UNITS_TO_FIXED
|
CLUTTER_UNITS_TO_FIXED
|
||||||
CLUTTER_UNITS_FROM_FLOAT
|
CLUTTER_UNITS_FROM_FLOAT
|
||||||
CLUTTER_UNITS_TO_FLOAT
|
CLUTTER_UNITS_TO_FLOAT
|
||||||
CLUTTER_UNITS_FROM_INT
|
CLUTTER_UNITS_FROM_INT
|
||||||
CLUTTER_UNITS_TO_INT
|
CLUTTER_UNITS_TO_INT
|
||||||
<SUBSECTION>
|
|
||||||
CLUTTER_UNITS_FROM_DEVICE
|
|
||||||
CLUTTER_UNITS_TO_DEVICE
|
|
||||||
CLUTTER_UNITS_FROM_PANGO_UNIT
|
CLUTTER_UNITS_FROM_PANGO_UNIT
|
||||||
CLUTTER_UNITS_TO_PANGO_UNIT
|
CLUTTER_UNITS_TO_PANGO_UNIT
|
||||||
CLUTTER_UNITS_TMP_FROM_DEVICE
|
CLUTTER_UNITS_TMP_FROM_DEVICE
|
||||||
@ -49,23 +48,6 @@ CLUTTER_UNITS_FROM_MM
|
|||||||
CLUTTER_UNITS_FROM_MMX
|
CLUTTER_UNITS_FROM_MMX
|
||||||
CLUTTER_UNITS_FROM_POINTS
|
CLUTTER_UNITS_FROM_POINTS
|
||||||
CLUTTER_UNITS_FROM_POINTSX
|
CLUTTER_UNITS_FROM_POINTSX
|
||||||
<SUBSECTION>
|
|
||||||
CLUTTER_VALUE_HOLDS_UNIT
|
|
||||||
clutter_value_set_unit
|
|
||||||
clutter_value_get_unit
|
|
||||||
<SUBSECTION>
|
|
||||||
CLUTTER_MAXUNIT
|
|
||||||
CLUTTER_MINUNIT
|
|
||||||
ClutterParamSpecUnit
|
|
||||||
clutter_param_spec_unit
|
|
||||||
<SUBSECTION Standard>
|
|
||||||
CLUTTER_TYPE_UNIT
|
|
||||||
CLUTTER_TYPE_PARAM_UNIT
|
|
||||||
CLUTTER_PARAM_SPEC_UNIT
|
|
||||||
CLUTTER_IS_PARAM_SPEC_UNIT
|
|
||||||
<SUBSECTION Private>
|
|
||||||
clutter_unit_get_type
|
|
||||||
clutter_param_unit_get_type
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
@ -446,24 +428,21 @@ ClutterTexture
|
|||||||
ClutterTextureClass
|
ClutterTextureClass
|
||||||
ClutterTextureFlags
|
ClutterTextureFlags
|
||||||
clutter_texture_new
|
clutter_texture_new
|
||||||
clutter_texture_new_from_pixbuf
|
clutter_texture_new_from_file
|
||||||
clutter_texture_new_from_actor
|
clutter_texture_new_from_actor
|
||||||
CLUTTER_TEXTURE_ERROR
|
CLUTTER_TEXTURE_ERROR
|
||||||
ClutterTextureError
|
ClutterTextureError
|
||||||
|
clutter_texture_set_from_file
|
||||||
clutter_texture_set_from_rgb_data
|
clutter_texture_set_from_rgb_data
|
||||||
clutter_texture_set_from_yuv_data
|
clutter_texture_set_from_yuv_data
|
||||||
clutter_texture_set_area_from_rgb_data
|
clutter_texture_set_area_from_rgb_data
|
||||||
clutter_texture_set_pixbuf
|
|
||||||
clutter_texture_get_pixbuf
|
|
||||||
clutter_texture_get_base_size
|
clutter_texture_get_base_size
|
||||||
|
clutter_texture_get_filter_quality
|
||||||
<SUBSECTION>
|
clutter_texture_set_filter_quality
|
||||||
clutter_texture_bind_tile
|
clutter_texture_get_max_tile_waste
|
||||||
clutter_texture_get_n_tiles
|
clutter_texture_set_max_tile_waste
|
||||||
clutter_texture_get_x_tile_detail
|
clutter_texture_get_cogl_texture
|
||||||
clutter_texture_get_y_tile_detail
|
clutter_texture_set_cogl_texture
|
||||||
clutter_texture_has_generated_tiles
|
|
||||||
clutter_texture_is_tiled
|
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
CLUTTER_TEXTURE
|
CLUTTER_TEXTURE
|
||||||
@ -874,31 +853,12 @@ clutter_qmulx
|
|||||||
clutter_qdivx
|
clutter_qdivx
|
||||||
clutter_tani
|
clutter_tani
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
CLUTTER_VALUE_HOLDS_FIXED
|
|
||||||
clutter_value_set_fixed
|
|
||||||
clutter_value_get_fixed
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
CLUTTER_MAXFIXED
|
|
||||||
CLUTTER_MINFIXED
|
|
||||||
ClutterParamSpecFixed
|
|
||||||
clutter_param_spec_fixed
|
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
|
||||||
CLUTTER_PARAM_SPEC_FIXED
|
|
||||||
CLUTTER_IS_PARAM_SPEC_FIXED
|
|
||||||
|
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
CFX_DIV
|
CFX_DIV
|
||||||
CFX_INT
|
CFX_INT
|
||||||
CFX_MUL
|
CFX_MUL
|
||||||
CFX_QMUL
|
CFX_QMUL
|
||||||
CFX_QDIV
|
CFX_QDIV
|
||||||
CLUTTER_TYPE_FIXED
|
|
||||||
CLUTTER_TYPE_PARAM_FIXED
|
|
||||||
clutter_fixed_get_type
|
|
||||||
clutter_param_fixed_get_type
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
93
doc/reference/cogl/Makefile.am
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
# We require automake 1.6 at least.
|
||||||
|
AUTOMAKE_OPTIONS = 1.6
|
||||||
|
|
||||||
|
# This is a blank Makefile.am for using gtk-doc.
|
||||||
|
# Copy this to your project's API docs directory and modify the variables to
|
||||||
|
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
|
||||||
|
# of using the various options.
|
||||||
|
|
||||||
|
# The name of the module, e.g. 'glib'.
|
||||||
|
DOC_MODULE=cogl
|
||||||
|
|
||||||
|
# The top-level SGML file. You can change this if you want to.
|
||||||
|
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
|
||||||
|
|
||||||
|
# The directory containing the source code. Relative to $(srcdir).
|
||||||
|
# gtk-doc will search all .c & .h files beneath here for inline comments
|
||||||
|
# documenting the functions and macros.
|
||||||
|
# e.g. DOC_SOURCE_DIR=../../../gtk
|
||||||
|
DOC_SOURCE_DIR=../../../clutter/cogl
|
||||||
|
|
||||||
|
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
|
||||||
|
SCANGOBJ_OPTIONS=
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-scan.
|
||||||
|
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||||
|
SCAN_OPTIONS=--deprecated-guards="CLUTTER_DISABLE_DEPRECATED"
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-mkdb.
|
||||||
|
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||||
|
MKDB_OPTIONS=--sgml-mode --output-format=xml
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-mktmpl
|
||||||
|
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
|
||||||
|
MKTMPL_OPTIONS=
|
||||||
|
|
||||||
|
# Extra options to supply to gtkdoc-fixref. Not normally needed.
|
||||||
|
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
|
||||||
|
FIXXREF_OPTIONS=\
|
||||||
|
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
|
||||||
|
--extra-dir=$(GDPIXBUF_PREFIX)/share/gtk-doc/html/gdk-pixbuf \
|
||||||
|
--extra-dir=$(top_srcdir)/doc/reference/clutter/html
|
||||||
|
|
||||||
|
# Used for dependencies. The docs will be rebuilt if any of these change.
|
||||||
|
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
|
||||||
|
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
|
||||||
|
HFILE_GLOB=\
|
||||||
|
$(top_srcdir)/clutter/cogl/*.h \
|
||||||
|
$(top_srcdir)/clutter/cogl/common/*.h
|
||||||
|
CFILE_GLOB=\
|
||||||
|
$(top_srcdir)/clutter/cogl/common/*.c
|
||||||
|
|
||||||
|
# Header files to ignore when scanning.
|
||||||
|
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
|
||||||
|
IGNORE_HFILES=\
|
||||||
|
cogl-bitmap.h \
|
||||||
|
cogl-context.h \
|
||||||
|
cogl-defines.h \
|
||||||
|
cogl-internal.h \
|
||||||
|
cogl-primitives.h \
|
||||||
|
cogl-texture.h
|
||||||
|
|
||||||
|
EXTRA_HFILES=
|
||||||
|
|
||||||
|
# Images to copy into HTML directory.
|
||||||
|
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
||||||
|
HTML_IMAGES=
|
||||||
|
|
||||||
|
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
|
||||||
|
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
|
||||||
|
content_files=
|
||||||
|
|
||||||
|
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
|
||||||
|
# These files must be listed here *and* in content_files
|
||||||
|
# e.g. expand_content_files=running.sgml
|
||||||
|
expand_content_files=
|
||||||
|
|
||||||
|
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
||||||
|
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
|
||||||
|
# signals and properties.
|
||||||
|
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
|
||||||
|
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
|
||||||
|
|
||||||
|
INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/clutter $(CLUTTER_CFLAGS)
|
||||||
|
GTKDOC_LIBS=$(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la $(CLUTTER_LIBS)
|
||||||
|
|
||||||
|
# This includes the standard gtk-doc make rules, copied by gtkdocize.
|
||||||
|
include $(top_srcdir)/gtk-doc.make
|
||||||
|
|
||||||
|
# Other files to distribute
|
||||||
|
# e.g. EXTRA_DIST += version.xml.in
|
||||||
|
EXTRA_DIST =
|