本文整理汇总了C++中cogl_object_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ cogl_object_unref函数的具体用法?C++ cogl_object_unref怎么用?C++ cogl_object_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cogl_object_unref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: clutter_image_set_area
/**
* clutter_image_set_area:
* @image: a #ClutterImage
* @data: (array): the image data, as an array of bytes
* @pixel_format: the Cogl pixel format of the image data
* @rect: a rectangle indicating the area that should be set
* @row_stride: the length of each row inside @data
* @error: return location for a #GError, or %NULL
*
* Sets the image data to be display by @image, using @rect to indicate
* the position and size of the image data to be set.
*
* If the @image does not have any image data set when this function is
* called, a new texture will be created with the size of the width and
* height of the rectangle, i.e. calling this function on a newly created
* #ClutterImage will be the equivalent of calling clutter_image_set_data().
*
* If the image data was successfully loaded, the @image will be invalidated.
*
* In case of error, the @error value will be set, and this function will
* return %FALSE.
*
* The image data is copied in texture memory.
*
* Return value: %TRUE if the image data was successfully loaded,
* and %FALSE otherwise.
*
* Since: 1.10
*/
gboolean
clutter_image_set_area (ClutterImage *image,
const guint8 *data,
CoglPixelFormat pixel_format,
const cairo_rectangle_int_t *area,
guint row_stride,
GError **error)
{
ClutterImagePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (area != NULL, FALSE);
priv = image->priv;
if (priv->texture == NULL)
{
CoglTextureFlags flags = COGL_TEXTURE_NONE;
if (area->width >= 512 && area->height >= 512)
flags |= COGL_TEXTURE_NO_ATLAS;
priv->texture = cogl_texture_new_from_data (area->width,
area->height,
flags,
pixel_format,
COGL_PIXEL_FORMAT_ANY,
row_stride,
data);
}
else
{
gboolean res;
res = cogl_texture_set_region (priv->texture,
0, 0,
area->x, area->y,
area->width, area->height,
area->width, area->height,
pixel_format,
row_stride,
data);
if (!res)
{
cogl_object_unref (priv->texture);
priv->texture = NULL;
}
}
if (priv->texture == NULL)
{
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
CLUTTER_IMAGE_ERROR_INVALID_DATA,
_("Unable to load image data"));
return FALSE;
}
clutter_content_invalidate (CLUTTER_CONTENT (image));
return TRUE;
}
开发者ID:ebassi,项目名称:clutter,代码行数:92,代码来源:clutter-image.c
示例2: _cogl_texture_driver_upload_to_gl_3d
void
_cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
GLuint gl_handle,
gboolean is_foreign,
GLint height,
GLint depth,
CoglBitmap *source_bmp,
GLint internal_gl_format,
GLuint source_gl_format,
GLuint source_gl_type)
{
int bpp = _cogl_get_format_bpp (_cogl_bitmap_get_format (source_bmp));
int rowstride = _cogl_bitmap_get_rowstride (source_bmp);
int bmp_width = _cogl_bitmap_get_width (source_bmp);
int bmp_height = _cogl_bitmap_get_height (source_bmp);
guint8 *data;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
/* If the rowstride or image height can't be specified with just
GL_ALIGNMENT alone then we need to copy the bitmap because there
is no GL_ROW_LENGTH */
if (rowstride / bpp != bmp_width ||
height != bmp_height / depth)
{
CoglBitmap *bmp;
int image_height = bmp_height / depth;
int i;
_cogl_texture_driver_prep_gl_for_pixels_upload (bmp_width * bpp, bpp);
/* Initialize the texture with empty data and then upload each
image with a sub-region update */
GE( glTexImage3D (gl_target,
0, /* level */
internal_gl_format,
bmp_width,
height,
depth,
0,
source_gl_format,
source_gl_type,
NULL) );
bmp = _cogl_bitmap_new_from_data (g_malloc (bpp * bmp_width * height),
_cogl_bitmap_get_format (source_bmp),
bmp_width,
height,
bpp * bmp_width,
(CoglBitmapDestroyNotify) g_free,
NULL);
for (i = 0; i < depth; i++)
{
_cogl_bitmap_copy_subregion (source_bmp,
bmp,
0, image_height * i,
0, 0,
bmp_width,
height);
data = _cogl_bitmap_bind (bmp,
COGL_BUFFER_ACCESS_READ, 0);
GE( glTexSubImage3D (gl_target,
0, /* level */
0, /* xoffset */
0, /* yoffset */
i, /* zoffset */
bmp_width, /* width */
height, /* height */
1, /* depth */
source_gl_format,
source_gl_type,
data) );
_cogl_bitmap_unbind (bmp);
}
cogl_object_unref (bmp);
}
else
{
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
GE( glTexImage3D (gl_target,
0, /* level */
internal_gl_format,
bmp_width,
height,
depth,
0,
source_gl_format,
source_gl_type,
data) );
//.........这里部分代码省略.........
开发者ID:nobled,项目名称:clutter,代码行数:101,代码来源:cogl-texture-driver-gles.c
示例3: cogl_context_new
/* For reference: There was some deliberation over whether to have a
* constructor that could throw an exception but looking at standard
* practices with several high level OO languages including python, C++,
* C# Java and Ruby they all support exceptions in constructors and the
* general consensus appears to be that throwing an exception is neater
* than successfully constructing with an internal error status that
* would then have to be explicitly checked via some form of ::is_ok()
* method.
*/
CoglContext *
cogl_context_new (CoglDisplay *display,
GError **error)
{
CoglContext *context;
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
CoglBitmap *default_texture_bitmap;
const CoglWinsysVtable *winsys;
int i;
_cogl_init ();
#ifdef COGL_ENABLE_PROFILE
/* We need to be absolutely sure that uprof has been initialized
* before calling _cogl_uprof_init. uprof_init (NULL, NULL)
* will be a NOP if it has been initialized but it will also
* mean subsequent parsing of the UProf GOptionGroup will have no
* affect.
*
* Sadly GOptionGroup based library initialization is extremely
* fragile by design because GOptionGroups have no notion of
* dependencies and so the order things are initialized isn't
* currently under tight control.
*/
uprof_init (NULL, NULL);
_cogl_uprof_init ();
#endif
/* Allocate context memory */
context = g_malloc0 (sizeof (CoglContext));
/* Convert the context into an object immediately in case any of the
code below wants to verify that the context pointer is a valid
object */
_cogl_context_object_new (context);
/* XXX: Gross hack!
* Currently everything in Cogl just assumes there is a default
* context which it can access via _COGL_GET_CONTEXT() including
* code used to construct a CoglContext. Until all of that code
* has been updated to take an explicit context argument we have
* to immediately make our pointer the default context.
*/
_context = context;
/* Init default values */
memset (context->features, 0, sizeof (context->features));
context->feature_flags = 0;
context->private_feature_flags = 0;
context->texture_types = NULL;
context->buffer_types = NULL;
context->rectangle_state = COGL_WINSYS_RECTANGLE_STATE_UNKNOWN;
memset (context->winsys_features, 0, sizeof (context->winsys_features));
if (!display)
{
CoglRenderer *renderer = cogl_renderer_new ();
if (!cogl_renderer_connect (renderer, error))
{
g_free (context);
return NULL;
}
display = cogl_display_new (renderer, NULL);
}
else
cogl_object_ref (display);
if (!cogl_display_setup (display, error))
{
cogl_object_unref (display);
g_free (context);
return NULL;
}
context->display = display;
/* This is duplicated data, but it's much more convenient to have
the driver attached to the context and the value is accessed a
lot throughout Cogl */
context->driver = display->renderer->driver;
switch (context->driver)
{
#ifdef HAVE_COGL_GL
case COGL_DRIVER_GL:
context->driver_vtable = &_cogl_driver_gl;
context->texture_driver = &_cogl_texture_driver_gl;
//.........这里部分代码省略.........
开发者ID:ChrisCummins,项目名称:cogl,代码行数:101,代码来源:cogl-context.c
示例4: paint_test_backface_culling
static void
paint_test_backface_culling (TestState *state,
CoglFramebuffer *framebuffer)
{
int draw_num;
CoglPipeline *base_pipeline = cogl_pipeline_new (test_ctx);
cogl_framebuffer_orthographic (framebuffer,
0, 0,
state->width,
state->height,
-1,
100);
cogl_framebuffer_clear4f (framebuffer,
COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_STENCIL,
0, 0, 0, 1);
cogl_pipeline_set_layer_texture (base_pipeline, 0, state->texture);
cogl_pipeline_set_layer_filters (base_pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
/* Render the scene eight times to test all of the combinations of
cull face mode and winding orders */
for (draw_num = 0; draw_num < 8; draw_num++)
{
float x1 = 0, x2, y1 = 0, y2 = (float)(TEXTURE_RENDER_SIZE);
CoglTextureVertex verts[4];
CoglPipeline *pipeline;
cogl_framebuffer_push_matrix (framebuffer);
cogl_framebuffer_translate (framebuffer,
0, TEXTURE_RENDER_SIZE * draw_num, 0);
pipeline = cogl_pipeline_copy (base_pipeline);
cogl_pipeline_set_front_face_winding (pipeline, FRONT_WINDING (draw_num));
cogl_pipeline_set_cull_face_mode (pipeline, CULL_FACE_MODE (draw_num));
memset (verts, 0, sizeof (verts));
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a front-facing texture */
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, x1, y1, x2, y2);
x1 = x2;
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a front-facing texture with flipped texcoords */
cogl_framebuffer_draw_textured_rectangle (framebuffer,
pipeline,
x1, y1, x2, y2,
1.0, 0.0, 0.0, 1.0);
x1 = x2;
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a back-facing texture */
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, x2, y1, x1, y2);
cogl_framebuffer_pop_matrix (framebuffer);
cogl_object_unref (pipeline);
}
cogl_object_unref (base_pipeline);
}
开发者ID:ChrisCummins,项目名称:cogl,代码行数:70,代码来源:test-backface-culling.c
示例5: ensure_xfixes_cursor
static void
ensure_xfixes_cursor (MetaCursorTracker *tracker)
{
MetaDisplay *display = meta_get_display ();
XFixesCursorImage *cursor_image;
CoglTexture2D *sprite;
guint8 *cursor_data;
gboolean free_cursor_data;
CoglContext *ctx;
CoglError *error = NULL;
if (tracker->xfixes_cursor)
return;
cursor_image = XFixesGetCursorImage (display->xdisplay);
if (!cursor_image)
return;
/* Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit
* quantities as arrays of long; we need to convert on 64 bit */
if (sizeof(long) == 4)
{
cursor_data = (guint8 *)cursor_image->pixels;
free_cursor_data = FALSE;
}
else
{
int i, j;
guint32 *cursor_words;
gulong *p;
guint32 *q;
cursor_words = g_new (guint32, cursor_image->width * cursor_image->height);
cursor_data = (guint8 *)cursor_words;
p = cursor_image->pixels;
q = cursor_words;
for (j = 0; j < cursor_image->height; j++)
for (i = 0; i < cursor_image->width; i++)
*(q++) = *(p++);
free_cursor_data = TRUE;
}
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
sprite = cogl_texture_2d_new_from_data (ctx,
cursor_image->width,
cursor_image->height,
CLUTTER_CAIRO_FORMAT_ARGB32,
cursor_image->width * 4, /* stride */
cursor_data,
&error);
if (free_cursor_data)
g_free (cursor_data);
if (error != NULL)
{
meta_warning ("Failed to allocate cursor sprite texture: %s\n", error->message);
cogl_error_free (error);
}
if (sprite != NULL)
{
MetaCursorSprite *cursor_sprite = meta_cursor_sprite_new ();
meta_cursor_sprite_set_texture (cursor_sprite,
sprite,
cursor_image->xhot,
cursor_image->yhot);
cogl_object_unref (sprite);
tracker->xfixes_cursor = cursor_sprite;
}
XFree (cursor_image);
}
开发者ID:MaximeMorel,项目名称:mutter,代码行数:74,代码来源:meta-cursor-tracker.c
示例6: main
int
main (int argc, char *argv[])
{
CoglTexture *tex;
CoglOnscreen *onscreen;
GSource *cogl_source;
GMainLoop *loop;
Data data;
int i;
data.context = cogl_context_new (NULL, NULL);
create_primitive (&data);
data.pipeline = cogl_pipeline_new (data.context);
data.last_spark_time = g_timer_new ();
data.next_spark_num = 0;
cogl_pipeline_set_point_size (data.pipeline, TEXTURE_SIZE);
tex = generate_round_texture (data.context);
cogl_pipeline_set_layer_texture (data.pipeline, 0, tex);
cogl_object_unref (tex);
cogl_pipeline_set_layer_point_sprite_coords_enabled (data.pipeline,
0, /* layer */
TRUE,
NULL /* error */);
for (i = 0; i < N_FIREWORKS; i++)
{
data.fireworks[i].x = -FLT_MAX;
data.fireworks[i].y = FLT_MAX;
data.fireworks[i].size = 0.0f;
data.fireworks[i].timer = g_timer_new ();
}
for (i = 0; i < N_SPARKS; i++)
{
data.sparks[i].x = 2.0f;
data.sparks[i].y = 2.0f;
}
onscreen = cogl_onscreen_new (data.context, 800, 600);
cogl_onscreen_show (onscreen);
data.fb = onscreen;
cogl_source = cogl_glib_source_new (data.context, G_PRIORITY_DEFAULT);
g_source_attach (cogl_source, NULL);
cogl_onscreen_add_frame_callback (onscreen,
frame_event_cb,
&data,
NULL /* destroy notify */);
loop = g_main_loop_new (NULL, TRUE);
paint (&data);
g_main_loop_run (loop);
g_main_loop_unref (loop);
g_source_destroy (cogl_source);
cogl_object_unref (data.pipeline);
cogl_object_unref (data.attribute_buffer);
cogl_object_unref (data.primitive);
cogl_object_unref (onscreen);
cogl_object_unref (data.context);
g_timer_destroy (data.last_spark_time);
for (i = 0; i < N_FIREWORKS; i++)
g_timer_destroy (data.fireworks[i].timer);
return 0;
}
开发者ID:3v1n0,项目名称:cogl,代码行数:78,代码来源:cogl-point-sprites.c
示例7: test_byte_verts
static void
test_byte_verts (TestState *state, int offset_x, int offset_y)
{
CoglAttribute *attributes[2];
CoglAttributeBuffer *buffer, *unnorm_buffer;
CoglPrimitive *primitive;
static const ByteVert norm_verts[] =
{
{ 0, 10, /**/ 255, 0, 0, 255 },
{ 10, 10, /**/ 255, 0, 0, 255 },
{ 5, 0, /**/ 255, 0, 0, 255 },
{ 10, 10, /**/ 0, 255, 0, 255 },
{ 20, 10, /**/ 0, 255, 0, 255 },
{ 15, 0, /**/ 0, 255, 0, 255 }
};
static const ByteVert unnorm_verts[] =
{
{ 0, 0, /**/ 0, 0, 1, 1 },
{ 0, 0, /**/ 0, 0, 1, 1 },
{ 0, 0, /**/ 0, 0, 1, 1 },
};
buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (norm_verts), norm_verts);
attributes[0] = cogl_attribute_new (buffer,
"cogl_position_in",
sizeof (ByteVert),
G_STRUCT_OFFSET (ByteVert, x),
2, /* n_components */
COGL_ATTRIBUTE_TYPE_SHORT);
attributes[1] = cogl_attribute_new (buffer,
"color",
sizeof (ByteVert),
G_STRUCT_OFFSET (ByteVert, r),
4, /* n_components */
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
cogl_attribute_set_normalized (attributes[1], TRUE);
cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb, offset_x, offset_y, 0.0f);
primitive = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES,
6, /* n_vertices */
attributes,
2); /* n_attributes */
cogl_primitive_draw (primitive, test_fb, state->pipeline);
cogl_object_unref (primitive);
cogl_object_unref (attributes[1]);
/* Test again with unnormalized attributes */
unnorm_buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (unnorm_verts),
unnorm_verts);
attributes[1] = cogl_attribute_new (unnorm_buffer,
"color",
sizeof (ByteVert),
G_STRUCT_OFFSET (ByteVert, r),
4, /* n_components */
COGL_ATTRIBUTE_TYPE_BYTE);
cogl_framebuffer_translate (test_fb, 20, 0, 0);
primitive = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES,
3, /* n_vertices */
attributes,
2); /* n_attributes */
cogl_primitive_draw (primitive, test_fb, state->pipeline);
cogl_object_unref (primitive);
cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (attributes[0]);
cogl_object_unref (attributes[1]);
cogl_object_unref (buffer);
cogl_object_unref (unnorm_buffer);
test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
test_utils_check_pixel (test_fb, offset_x + 25, offset_y + 5, 0x0000ffff);
}
开发者ID:3v1n0,项目名称:cogl,代码行数:84,代码来源:test-custom-attributes.c
示例8: cogl_handle_unref
void
cogl_handle_unref (CoglHandle handle)
{
cogl_object_unref (handle);
}
开发者ID:collects,项目名称:cogl,代码行数:5,代码来源:cogl-object.c
示例9: clutter_stage_glx_redraw
//.........这里部分代码省略.........
float y_2 = clip->y + clip->height;
float quad[8] = {
x_1, y_1,
x_2, y_1,
x_2, y_2,
x_1, y_2
};
CoglMatrix modelview;
if (outline == NULL)
{
outline = cogl_material_new ();
cogl_material_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff);
}
vbo = cogl_vertex_buffer_new (4);
cogl_vertex_buffer_add (vbo,
"gl_Vertex",
2, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
quad);
cogl_vertex_buffer_submit (vbo);
cogl_push_matrix ();
cogl_matrix_init_identity (&modelview);
_clutter_actor_apply_modelview_transform (actor, &modelview);
cogl_set_modelview_matrix (&modelview);
cogl_set_source (outline);
cogl_vertex_buffer_draw (vbo, COGL_VERTICES_MODE_LINE_LOOP,
0 , 4);
cogl_pop_matrix ();
cogl_object_unref (vbo);
}
cogl_flush ();
CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer);
drawable = stage_glx->glxwin
? stage_glx->glxwin
: stage_x11->xwin;
/* If we might ever use _clutter_backend_glx_blit_sub_buffer then we
* always need to keep track of the video_sync_count so that we can
* throttle blits.
*
* Note: we get the count *before* we issue any glXCopySubBuffer or
* blit_sub_buffer request in case the count would go up before
* returning control to us.
*/
if (backend_glx->can_blit_sub_buffer && backend_glx->get_video_sync)
backend_glx->get_video_sync (&video_sync_count);
/* push on the screen */
if (use_clipped_redraw)
{
ClutterGeometry *clip = &stage_glx->bounding_redraw_clip;
ClutterGeometry copy_area;
ClutterActor *actor;
CLUTTER_NOTE (BACKEND,
"_glx_blit_sub_buffer (window: 0x%lx, "
"x: %d, y: %d, "
"width: %d, height: %d)",
(unsigned long) drawable,
开发者ID:rib,项目名称:clutter,代码行数:67,代码来源:clutter-stage-glx.c
示例10: _st_create_shadow_pipeline_from_actor
CoglPipeline *
_st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
ClutterActor *actor)
{
CoglPipeline *shadow_pipeline = NULL;
if (CLUTTER_IS_TEXTURE (actor))
{
CoglTexture *texture;
texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor));
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec, texture);
}
else
{
CoglTexture *buffer;
CoglOffscreen *offscreen;
CoglFramebuffer *fb;
ClutterActorBox box;
CoglColor clear_color;
float width, height;
CoglError *catch_error = NULL;
clutter_actor_get_allocation_box (actor, &box);
clutter_actor_box_get_size (&box, &width, &height);
if (width == 0 || height == 0)
return NULL;
buffer = cogl_texture_new_with_size (width,
height,
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY);
if (buffer == NULL)
return NULL;
offscreen = cogl_offscreen_new_with_texture (buffer);
fb = COGL_FRAMEBUFFER (offscreen);
if (!cogl_framebuffer_allocate (fb, &catch_error))
{
cogl_error_free (catch_error);
cogl_object_unref (buffer);
return NULL;
}
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
/* XXX: There's no way to render a ClutterActor to an offscreen
* as it uses the implicit API. */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
cogl_push_framebuffer (fb);
G_GNUC_END_IGNORE_DEPRECATIONS;
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
cogl_framebuffer_translate (fb, -box.x1, -box.y1, 0);
cogl_framebuffer_orthographic (fb, 0, 0, width, height, 0, 1.0);
clutter_actor_set_opacity_override (actor, 255);
clutter_actor_paint (actor);
clutter_actor_set_opacity_override (actor, -1);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
cogl_pop_framebuffer ();
G_GNUC_END_IGNORE_DEPRECATIONS;
cogl_object_unref (fb);
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec, buffer);
cogl_object_unref (buffer);
}
return shadow_pipeline;
}
开发者ID:aNeutrino,项目名称:gnome-shell,代码行数:76,代码来源:st-private.c
示例11: draw_rectangle
static CoglBool
draw_rectangle (TestState *state,
int x,
int y,
TestDepthState *rect_state,
CoglBool legacy_mode)
{
uint8_t Cr = MASK_RED (rect_state->color);
uint8_t Cg = MASK_GREEN (rect_state->color);
uint8_t Cb = MASK_BLUE (rect_state->color);
uint8_t Ca = MASK_ALPHA (rect_state->color);
CoglPipeline *pipeline;
CoglDepthState depth_state;
cogl_depth_state_init (&depth_state);
cogl_depth_state_set_test_enabled (&depth_state, rect_state->test_enable);
cogl_depth_state_set_test_function (&depth_state, rect_state->test_function);
cogl_depth_state_set_write_enabled (&depth_state, rect_state->write_enable);
cogl_depth_state_set_range (&depth_state,
rect_state->range_near,
rect_state->range_far);
pipeline = cogl_pipeline_new (test_ctx);
if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL))
{
cogl_object_unref (pipeline);
return FALSE;
}
if (!legacy_mode)
{
cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
cogl_framebuffer_set_depth_write_enabled (test_fb,
rect_state->fb_write_enable);
cogl_framebuffer_push_matrix (test_fb);
cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
x * QUAD_WIDTH,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_framebuffer_pop_matrix (test_fb);
}
else
{
cogl_push_framebuffer (test_fb);
cogl_push_matrix ();
cogl_set_source_color4ub (Cr, Cg, Cb, Ca);
cogl_translate (0, 0, rect_state->depth);
cogl_rectangle (x * QUAD_WIDTH,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_pop_matrix ();
cogl_pop_framebuffer ();
}
cogl_object_unref (pipeline);
return TRUE;
}
开发者ID:MaximeMorel,项目名称:mutter,代码行数:63,代码来源:test-depth-test.c
示例12: _cogl_matrix_stack_destroy_cache
void
_cogl_matrix_stack_destroy_cache (CoglMatrixStackCache *cache)
{
if (cache->stack)
cogl_object_unref (cache->stack);
}
开发者ID:collects,项目名称:cogl,代码行数:6,代码来源:cogl-matrix-stack.c
示例13: _cogl_atlas_reserve_space
//.........这里部分代码省略.........
_cogl_atlas_compare_size_cb);
/* Try to create a new atlas that can contain all of the textures */
if (atlas->map)
{
map_width = _cogl_rectangle_map_get_width (atlas->map);
map_height = _cogl_rectangle_map_get_height (atlas->map);
/* If there is enough space in for the new rectangle in the
existing atlas with at least 6% waste we'll start with the
same size, otherwise we'll immediately double it */
if ((map_width * map_height -
_cogl_rectangle_map_get_remaining_space (atlas->map) +
width * height) * 53 / 50 >
map_width * map_height)
_cogl_atlas_get_next_size (&map_width, &map_height);
}
else
_cogl_atlas_get_initial_size (atlas->texture_format,
&map_width, &map_height);
new_map = _cogl_atlas_create_map (atlas->texture_format,
map_width, map_height,
data.n_textures, data.textures);
/* If we can't create a map with the texture then give up */
if (new_map == NULL)
{
COGL_NOTE (ATLAS, "%p: Could not fit texture in the atlas", atlas);
ret = FALSE;
}
/* We need to migrate the existing textures into a new texture */
else if ((new_tex = _cogl_atlas_create_texture
(atlas,
_cogl_rectangle_map_get_width (new_map),
_cogl_rectangle_map_get_height (new_map))) == NULL)
{
COGL_NOTE (ATLAS, "%p: Could not create a CoglTexture2D", atlas);
_cogl_rectangle_map_free (new_map);
ret = FALSE;
}
else
{
int waste;
COGL_NOTE (ATLAS,
"%p: Atlas %s with size %ix%i",
atlas,
atlas->map == NULL ||
_cogl_rectangle_map_get_width (atlas->map) !=
_cogl_rectangle_map_get_width (new_map) ||
_cogl_rectangle_map_get_height (atlas->map) !=
_cogl_rectangle_map_get_height (new_map) ?
"resized" : "reorganized",
_cogl_rectangle_map_get_width (new_map),
_cogl_rectangle_map_get_height (new_map));
if (atlas->map)
{
/* Move all the textures to the right position in the new
texture. This will also update the texture's rectangle */
_cogl_atlas_migrate (atlas,
data.n_textures,
data.textures,
atlas->texture,
COGL_TEXTURE (new_tex),
user_data);
_cogl_rectangle_map_free (atlas->map);
cogl_object_unref (atlas->texture);
}
else
/* We know there's only one texture so we can just directly
update the rectangle from its new position */
atlas->update_position_cb (data.textures[0].user_data,
COGL_TEXTURE (new_tex),
&data.textures[0].new_position);
atlas->map = new_map;
atlas->texture = COGL_TEXTURE (new_tex);
waste = (_cogl_rectangle_map_get_remaining_space (atlas->map) *
100 / (_cogl_rectangle_map_get_width (atlas->map) *
_cogl_rectangle_map_get_height (atlas->map)));
COGL_NOTE (ATLAS, "%p: Atlas is %ix%i, has %i textures and is %i%% waste",
atlas,
_cogl_rectangle_map_get_width (atlas->map),
_cogl_rectangle_map_get_height (atlas->map),
_cogl_rectangle_map_get_n_rectangles (atlas->map),
waste);
ret = TRUE;
}
g_free (data.textures);
_cogl_atlas_notify_post_reorganize (atlas);
return ret;
}
开发者ID:collinss,项目名称:muffin,代码行数:101,代码来源:cogl-atlas.c
示例14: primitive_new_p2t2t2
static CoglPrimitive *
primitive_new_p2t2t2 (CoglContext *ctx,
CoglVerticesMode mode,
int n_vertices,
const VertexP2T2T2 *data)
{
CoglAttributeBuffer *attribute_buffer =
cogl_attribute_buffer_new (ctx, n_vertices * sizeof (VertexP2T2T2), data);
int n_attributes = 7;
CoglAttribute *attributes[n_attributes];
CoglPrimitive *primitive;
#ifndef MESA_CONST_ATTRIB_BUG_WORKAROUND
const float normal[3] = { 0, 0, 1 };
const float tangent[3] = { 1, 0, 0 };
#endif
int i;
attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, x),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
/* coords for circle mask, for rounded corners */
attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, s0),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
/* coords for primary texture */
attributes[2] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord1_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, s1),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
/* coords for alpha mask texture */
attributes[3] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord4_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, s1),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
/* coords for normal map */
attributes[4] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord7_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, s1),
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
#ifdef MESA_CONST_ATTRIB_BUG_WORKAROUND
attributes[5] = cogl_attribute_new (attribute_buffer,
"cogl_normal_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, Nx),
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[6] = cogl_attribute_new (attribute_buffer,
"tangent_in",
sizeof (VertexP2T2T2),
offsetof (VertexP2T2T2, Tx),
3,
COGL_ATTRIBUTE_TYPE_FLOAT);
#else
attributes[5] = cogl_attribute_new_const_3fv (ctx,
"cogl_normal_in",
normal);
attributes[6] = cogl_attribute_new_const_3fv (ctx,
"tangent_in",
tangent);
#endif
cogl_object_unref (attribute_buffer);
primitive = cogl_primitive_new_with_attributes (mode,
n_vertices,
attributes,
n_attributes);
for (i = 0; i < n_attributes; i++)
cogl_object_unref (attributes[i]);
return primitive;
}
开发者ID:ChrisCummins,项目名称:rig,代码行数:89,代码来源:rut-diamond.c
示例15: _cogl_texture_new_from_bitmap
static CoglTexture *
_cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
CoglTextureFlags flags,
CoglPixelFormat internal_format,
CoglBool can_convert_in_place,
CoglError **error)
{
CoglContext *ctx = _cogl_bitmap_get_context (bitmap);
CoglTexture *tex;
CoglError *internal_error = NULL;
if (!flags &&
!COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ATLAS))
{
/* First try putting the texture in the atlas */
CoglAtlasTexture *atlas_tex =
_cogl_atlas_texture_new_from_bitmap (bitmap,
can_convert_in_place);
_cogl_texture_set_internal_format (COGL_TEXTURE (atlas_tex),
internal_format);
if (cogl_texture_allocate (COGL_TEXTURE (atlas_tex), &internal_error))
return COGL_TEXTURE (atlas_tex);
cogl_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (atlas_tex);
}
/* If that doesn't work try a fast path 2D texture */
if ((_cogl_util_is_pot (bitmap->width) &&
_cogl_util_is_pot (bitmap->height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
{
tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &internal_error))
{
cogl_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
}
else
tex = NULL;
if (!tex)
{
/* Otherwise create a sliced texture */
int max_waste = flags & COGL_TEXTURE_NO_SLICING ? -1 : COGL_TEXTURE_MAX_WASTE;
tex = COGL_TEXTURE (_cogl_texture_2d_sliced_new_from_bitmap (bitmap,
max_waste,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, error))
{
cogl_object_unref (tex);
tex = NULL;
}
}
if (tex &&
flags & COGL_TEXTURE_NO_AUTO_MIPMAP)
{
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
0, 0, 1, 1,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
set_auto_mipmap_cb,
NULL);
}
return tex;
}
开发者ID:MaximeMorel,项目名称:mutter,代码行数:82,代码来源:cogl-auto-texture.c
示例16: _cogl_gl_flush_attributes_state
//.........这里部分代码省略.........
{
/* If we haven't already created a derived pipeline... */
if (!copy)
{
copy = cogl_pipeline_copy (pipeline);
pipeline = copy;
}
_cogl_pipeline_apply_overrides (pipeline, &layers_state->options);
/* TODO:
* overrides = cogl_pipeline_get_data (pipeline,
* last_overrides_key);
* if (overrides)
* {
* age = cogl_pipeline_get_age (pipeline);
* XXX: actually we also need to check for legacy_state
* and blending overrides for use of glColorPointer...
* if (overrides->ags != age ||
* memcmp (&overrides->options, &options,
* sizeof (options) != 0)
* {
* cogl_object_unref (overrides->weak_pipeline);
* g_slice_free (Overrides, overrides);
* overrides = NULL;
* }
* }
* if (!overrides)
* {
* overrides = g_slice_new (Overrides);
* overrides->weak_pipeline =
* cogl_pipeline_weak_copy (pipeline);
* _cogl_pipeline_apply_overrides (overrides->weak_pipeline,
* &options);
*
* cogl_pipeline_set_data (pipeline, last_overrides_key,
* weak_overrides,
* free_overrides_cb,
* NULL);
* }
* pipeline = overrides->weak_pipeline;
*/
}
_cogl_pipeline_flush_gl_state (ctx,
pipeline,
framebuffer,
with_color_attrib,
unknown_color_alpha);
_cogl_bitmask_clear_all (&ctx->enable_builtin_attributes_tmp);
_cogl_bitmask_clear_all (&ctx->enable_texcoord_attributes_tmp);
_cogl_bitmask_clear_all (&ctx->enable_custom_attributes_tmp);
/* Bind the attribute pointers. We need to do this after the
* pipeline is flushed because when using GLSL that is the only
* point when we can determine the attribute locations */
for (i = 0; i < n_attributes; i++)
{
CoglAttribute *attribute = attributes[i];
CoglAttributeBuffer *attribute_buffer;
CoglBuffer *buffer;
uint8_t *base;
if (attribute->is_buffered)
{
attribute_buffer = cogl_attribute_get_buffer (attribute);
buffer = COGL_BUFFER (attribute_buffer);
/* Note: we don't try and catch errors with binding buffers
* here since OOM errors at this point indicate that nothing
* has yet been uploaded to attribute
|
请发表评论