#include "cogl/cogl.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
#include "clutter-actor-private.h"
const char *label,
const CoglColor *color)
{
- static CoglMaterial *outline = NULL;
+ static CoglPipeline *outline = NULL;
CoglPrimitive *prim;
ClutterVertex line_ends[12 * 2];
int n_vertices;
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ /* XXX: at some point we'll query this from the stage but we can't
+ * do that until the osx backend uses Cogl natively. */
+ CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
if (outline == NULL)
- outline = cogl_material_new ();
+ outline = cogl_pipeline_new ();
_clutter_paint_volume_complete (pv);
line_ends[22] = pv->vertices[3]; line_ends[23] = pv->vertices[7];
}
- prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_LINES, n_vertices,
+ prim = cogl_primitive_new_p3 (ctx, COGL_VERTICES_MODE_LINES, n_vertices,
(CoglVertexP3 *)line_ends);
- cogl_material_set_color (outline, color);
- cogl_set_source (outline);
- cogl_primitive_draw (prim);
+ cogl_pipeline_set_color (outline, color);
+ cogl_framebuffer_draw_primitive (fb, outline, prim);
+ cogl_object_unref (outline);
cogl_object_unref (prim);
if (label)
#include "config.h"
#endif
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
#include "clutter-deform-effect.h"
#include <cogl/cogl.h>
CoglHandle material;
CoglPipeline *pipeline;
CoglDepthState depth_state;
+ CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
if (priv->is_dirty)
{
/* draw the front */
if (material != COGL_INVALID_HANDLE)
- {
- cogl_push_source (pipeline);
- cogl_primitive_draw (priv->primitive);
- cogl_pop_source ();
- }
+ cogl_framebuffer_draw_primitive (fb, pipeline, priv->primitive);
/* draw the back */
if (priv->back_material != COGL_INVALID_HANDLE)
cogl_pipeline_set_cull_face_mode (pipeline,
COGL_PIPELINE_CULL_FACE_MODE_FRONT);
- cogl_push_source (back_pipeline);
- cogl_primitive_draw (priv->primitive);
- cogl_pop_source ();
+ cogl_framebuffer_draw_primitive (fb, back_pipeline, priv->primitive);
cogl_object_unref (back_pipeline);
}
if (G_UNLIKELY (priv->lines_primitive != NULL))
{
- cogl_set_source_color4f (1.0, 0, 0, 1.0);
- cogl_primitive_draw (priv->lines_primitive);
+ CoglPipeline *lines_pipeline = cogl_pipeline_new ();
+ cogl_pipeline_set_color4f (lines_pipeline, 1.0, 0, 0, 1.0);
+ cogl_framebuffer_draw_primitive (fb, lines_pipeline,
+ priv->lines_primitive);
+ cogl_object_unref (lines_pipeline);
}
}
gint x, y, direction, n_indices;
CoglAttribute *attributes[3];
guint16 *static_indices;
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
CoglIndices *indices;
guint16 *idx;
int i;
#undef MESH_INDEX
- indices = cogl_indices_new (COGL_INDICES_TYPE_UNSIGNED_SHORT,
+ indices = cogl_indices_new (ctx,
+ COGL_INDICES_TYPE_UNSIGNED_SHORT,
static_indices,
n_indices);
priv->n_vertices = (priv->x_tiles + 1) * (priv->y_tiles + 1);
priv->buffer =
- cogl_attribute_buffer_new (sizeof (CoglVertexP3T2C4) *
+ cogl_attribute_buffer_new (ctx,
+ sizeof (CoglVertexP3T2C4) *
priv->n_vertices,
NULL);
+#define COGL_ENABLE_EXPERIMENTAL_2_0_API
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
#include <clutter/clutter.h>
#include <string.h>
static const ClutterColor prim_color = { 0xff, 0x00, 0xff, 0xff };
static const ClutterColor tex_color = { 0x00, 0x00, 0xff, 0xff };
-typedef CoglPrimitive * (* TestPrimFunc) (ClutterColor *expected_color);
+typedef CoglPrimitive * (* TestPrimFunc) (CoglContext *ctx,
+ ClutterColor *expected_color);
static CoglPrimitive *
-test_prim_p2 (ClutterColor *expected_color)
+test_prim_p2 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP2 verts[] =
{ { 0, 0 }, { 0, 10 }, { 10, 0 } };
- return cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p2 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p3 (ClutterColor *expected_color)
+test_prim_p3 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP3 verts[] =
{ { 0, 0, 0 }, { 0, 10, 0 }, { 10, 0, 0 } };
- return cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p3 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p2c4 (ClutterColor *expected_color)
+test_prim_p2c4 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP2C4 verts[] =
{ { 0, 0, 255, 255, 0, 255 },
expected_color->green = 255;
expected_color->blue = 0;
- return cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p2c4 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p3c4 (ClutterColor *expected_color)
+test_prim_p3c4 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP3C4 verts[] =
{ { 0, 0, 0, 255, 255, 0, 255 },
expected_color->green = 255;
expected_color->blue = 0;
- return cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p3c4 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p2t2 (ClutterColor *expected_color)
+test_prim_p2t2 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP2T2 verts[] =
{ { 0, 0, 1, 0 },
*expected_color = tex_color;
- return cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p2t2 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p3t2 (ClutterColor *expected_color)
+test_prim_p3t2 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP3T2 verts[] =
{ { 0, 0, 0, 1, 0 },
*expected_color = tex_color;
- return cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p3t2 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p2t2c4 (ClutterColor *expected_color)
+test_prim_p2t2c4 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP2T2C4 verts[] =
{ { 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
*expected_color = tex_color;
expected_color->blue = 0xf0;
- return cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p2t2c4 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static CoglPrimitive *
-test_prim_p3t2c4 (ClutterColor *expected_color)
+test_prim_p3t2c4 (CoglContext *ctx, ClutterColor *expected_color)
{
static const CoglVertexP3T2C4 verts[] =
{ { 0, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
*expected_color = tex_color;
expected_color->blue = 0xf0;
- return cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLES,
+ return cogl_primitive_new_p3t2c4 (ctx,
+ COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
verts);
}
static void
paint_cb (void)
{
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
CoglPipeline *pipeline;
- CoglHandle tex;
+ CoglTexture *tex;
guint8 tex_data[6];
int i;
prim_color.blue,
prim_color.alpha);
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
- cogl_handle_unref (tex);
- cogl_set_source (pipeline);
- cogl_object_unref (pipeline);
+ cogl_object_unref (tex);
for (i = 0; i < G_N_ELEMENTS (test_prim_funcs); i++)
{
ClutterColor expected_color = prim_color;
guint8 pixel[4];
- prim = test_prim_funcs[i] (&expected_color);
+ prim = test_prim_funcs[i] (ctx, &expected_color);
cogl_push_matrix ();
cogl_translate (i * 10, 0, 0);
- cogl_primitive_draw (prim);
+ cogl_framebuffer_draw_primitive (fb, pipeline, prim);
cogl_pop_matrix ();
cogl_read_pixels (i * 10 + 2, 2, 1, 1,
cogl_object_unref (prim);
}
+ cogl_object_unref (pipeline);
+
/* Comment this out to see what the test paints */
clutter_main_quit ();
}