当前位置: 首页>>代码示例>>C++>>正文


C++ COGL_TEXTURE函数代码示例

本文整理汇总了C++中COGL_TEXTURE函数的典型用法代码示例。如果您正苦于以下问题:C++ COGL_TEXTURE函数的具体用法?C++ COGL_TEXTURE怎么用?C++ COGL_TEXTURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了COGL_TEXTURE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _cogl_texture_2d_gl_get_data

void
_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
                              CoglPixelFormat format,
                              int rowstride,
                              uint8_t *data)
{
  CoglContext *ctx = COGL_TEXTURE (tex_2d)->context;
  int bpp;
  int width = COGL_TEXTURE (tex_2d)->width;
  GLenum gl_format;
  GLenum gl_type;

  bpp = _cogl_pixel_format_get_bytes_per_pixel (format);

  ctx->driver_vtable->pixel_format_to_gl (ctx,
                                          format,
                                          NULL, /* internal format */
                                          &gl_format,
                                          &gl_type);

  ctx->texture_driver->prep_gl_for_pixels_download (ctx,
                                                    rowstride,
                                                    width,
                                                    bpp);

  _cogl_bind_gl_texture_transient (tex_2d->gl_target,
                                   tex_2d->gl_texture,
                                   tex_2d->is_foreign);

  ctx->texture_driver->gl_get_tex_image (ctx,
                                         tex_2d->gl_target,
                                         gl_format,
                                         gl_type,
                                         data);
}
开发者ID:endlessm,项目名称:mutter,代码行数:35,代码来源:cogl-texture-2d-gl.c

示例2: meta_texture_rectangle_new

CoglTexture *
meta_texture_rectangle_new (unsigned int width,
                            unsigned int height,
                            CoglPixelFormat format,
                            unsigned int rowstride,
                            const guint8 *data)
{
  ClutterBackend *backend =
    clutter_get_default_backend ();
  CoglContext *context =
    clutter_backend_get_cogl_context (backend);
  CoglTextureRectangle *tex_rect;

  tex_rect = cogl_texture_rectangle_new_with_size (context, width, height);
  if (tex_rect == NULL)
    return NULL;

  if (data)
    cogl_texture_set_region (COGL_TEXTURE (tex_rect),
                             0, 0, /* src_x/y */
                             0, 0, /* dst_x/y */
                             width, height, /* dst_width/height */
                             width, height, /* width/height */
                             format,
                             rowstride,
                             data);

  return COGL_TEXTURE (tex_rect);
}
开发者ID:RCcola310,项目名称:mutter,代码行数:29,代码来源:meta-texture-rectangle.c

示例3: cogl_texture_pixmap_x11_new_right

CoglTexturePixmapX11 *
cogl_texture_pixmap_x11_new_right (CoglTexturePixmapX11 *tfp_left)
{
  CoglTexture *texture_left = COGL_TEXTURE (tfp_left);
  CoglTexturePixmapX11 *tfp_right;
  CoglPixelFormat internal_format;

  g_return_val_if_fail (tfp_left->stereo_mode == COGL_TEXTURE_PIXMAP_LEFT, NULL);

  tfp_right = g_new0 (CoglTexturePixmapX11, 1);
  tfp_right->stereo_mode = COGL_TEXTURE_PIXMAP_RIGHT;
  tfp_right->left = cogl_object_ref (tfp_left);

  internal_format = (tfp_left->depth >= 32
		     ? COGL_PIXEL_FORMAT_RGBA_8888_PRE
		     : COGL_PIXEL_FORMAT_RGB_888);
  _cogl_texture_init (COGL_TEXTURE (tfp_right),
		      texture_left->context,
		      texture_left->width,
		      texture_left->height,
		      internal_format,
		      NULL, /* no loader */
		      &cogl_texture_pixmap_x11_vtable);

  _cogl_texture_set_allocated (COGL_TEXTURE (tfp_right), internal_format,
                               texture_left->width, texture_left->height);

  return _cogl_texture_pixmap_x11_object_new (tfp_right);
}
开发者ID:endlessm,项目名称:mutter,代码行数:29,代码来源:cogl-texture-pixmap-x11.c

示例4: _cogl_texture_2d_gl_generate_mipmap

void
_cogl_texture_2d_gl_generate_mipmap (CoglTexture2D *tex_2d)
{
  CoglContext *ctx = COGL_TEXTURE (tex_2d)->context;

  /* glGenerateMipmap is defined in the FBO extension. If it's not
     available we'll fallback to temporarily enabling
     GL_GENERATE_MIPMAP and reuploading the first pixel */
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
    _cogl_texture_gl_generate_mipmaps (COGL_TEXTURE (tex_2d));
#ifdef HAVE_COGL_GL
  else
    {
      _cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
                                       tex_2d->gl_texture,
                                       tex_2d->is_foreign);

      GE( ctx, glTexParameteri (GL_TEXTURE_2D,
                                GL_GENERATE_MIPMAP,
                                GL_TRUE) );
      GE( ctx, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 1, 1,
                                tex_2d->first_pixel.gl_format,
                                tex_2d->first_pixel.gl_type,
                                tex_2d->first_pixel.data) );
      GE( ctx, glTexParameteri (GL_TEXTURE_2D,
                                GL_GENERATE_MIPMAP,
                                GL_FALSE) );
    }
#endif
}
开发者ID:endlessm,项目名称:mutter,代码行数:30,代码来源:cogl-texture-2d-gl.c

示例5: _cogl_atlas_create_texture

static CoglTexture2D *
_cogl_atlas_create_texture (CoglAtlas *atlas,
                            int width,
                            int height)
{
  CoglTexture2D *tex;
  CoglError *ignore_error = NULL;

  _COGL_GET_CONTEXT (ctx, NULL);

  if ((atlas->flags & COGL_ATLAS_CLEAR_TEXTURE))
    {
      uint8_t *clear_data;
      CoglBitmap *clear_bmp;
      int bpp = _cogl_pixel_format_get_bytes_per_pixel (atlas->texture_format);

      /* Create a buffer of zeroes to initially clear the texture */
      clear_data = g_malloc0 (width * height * bpp);
      clear_bmp = cogl_bitmap_new_for_data (ctx,
                                            width,
                                            height,
                                            atlas->texture_format,
                                            width * bpp,
                                            clear_data);

      tex = cogl_texture_2d_new_from_bitmap (clear_bmp);

      _cogl_texture_set_internal_format (COGL_TEXTURE (tex),
                                         atlas->texture_format);

      if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
        {
          cogl_error_free (ignore_error);
          cogl_object_unref (tex);
          tex = NULL;
        }

      cogl_object_unref (clear_bmp);

      g_free (clear_data);
    }
  else
    {
      tex = cogl_texture_2d_new_with_size (ctx, width, height);

      _cogl_texture_set_internal_format (COGL_TEXTURE (tex),
                                         atlas->texture_format);

      if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
        {
          cogl_error_free (ignore_error);
          cogl_object_unref (tex);
          tex = NULL;
        }
    }

  return tex;
}
开发者ID:collinss,项目名称:muffin,代码行数:58,代码来源:cogl-atlas.c

示例6: _cogl_texture_2d_free

static void
_cogl_texture_2d_free (CoglTexture2D *tex_2d)
{
    CoglContext *ctx = COGL_TEXTURE (tex_2d)->context;

    ctx->driver_vtable->texture_2d_free (tex_2d);

    /* Chain up */
    _cogl_texture_free (COGL_TEXTURE (tex_2d));
}
开发者ID:rib,项目名称:cogl,代码行数:10,代码来源:cogl-texture-2d.c

示例7: cogl_texture_new_with_size

CoglTexture *
cogl_texture_new_with_size (CoglContext *ctx,
                            int width,
			    int height,
                            CoglTextureFlags flags,
			    CoglPixelFormat internal_format)
{
  CoglTexture *tex;
  CoglError *skip_error = NULL;

  if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
    {
      /* First try creating a fast-path non-sliced texture */
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
                                                         width, height,
                                                         internal_format));

      /* TODO: instead of allocating storage here it would be better
       * if we had some api that let us just check that the size is
       * supported by the hardware so storage could be allocated
       * lazily when uploading data. */
      if (!cogl_texture_allocate (tex, &skip_error))
        {
          cogl_error_free (skip_error);
          cogl_object_unref (tex);
          tex = NULL;
        }
    }
  else
    tex = NULL;

  if (tex)
    {
      CoglBool auto_mipmap = !(flags & COGL_TEXTURE_NO_AUTO_MIPMAP);
      cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex),
                                              auto_mipmap);
    }
  else
    {
      /* If it fails resort to sliced textures */
      int max_waste = flags & COGL_TEXTURE_NO_SLICING ? -1 : COGL_TEXTURE_MAX_WASTE;
      cogl_error_free (skip_error);
      tex = COGL_TEXTURE (cogl_texture_2d_sliced_new_with_size (ctx,
                                                                width,
                                                                height,
                                                                max_waste,
                                                                internal_format));
    }

  return tex;
}
开发者ID:djdeath,项目名称:cogl-android,代码行数:53,代码来源:cogl-auto-texture.c

示例8: video_texture_new_from_data

/* This first tries to upload the texture to a CoglTexture2D, but
 * if that's not possible it falls back to a CoglTexture2DSliced.
 *
 * Auto-mipmapping of any uploaded texture is disabled
 */
static CoglTexture *
video_texture_new_from_data (CoglContext *ctx,
                             int width,
                             int height,
                             CoglPixelFormat format,
                             CoglPixelFormat internal_format,
                             int rowstride,
                             const uint8_t *data,
                             CoglError **error)
{
  CoglBitmap *bitmap;
  CoglTexture *tex;
  CoglError *internal_error = NULL;

  bitmap = cogl_bitmap_new_for_data (ctx,
                                     width, height,
                                     format,
                                     rowstride,
                                     (uint8_t *) data);

  if ((is_pot (cogl_bitmap_get_width (bitmap)) &&
       is_pot (cogl_bitmap_get_height (bitmap))) ||
      cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC))
    {
      tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap,
                                                           internal_format,
                                                           &internal_error));
      if (!tex)
        {
          cogl_error_free (internal_error);
          internal_error = NULL;
        }
    }
  else
    tex = NULL;

  if (!tex)
    {
      /* Otherwise create a sliced texture */
      CoglTexture2DSliced *tex_2ds =
        cogl_texture_2d_sliced_new_from_bitmap (bitmap,
                                                -1, /* no maximum waste */
                                                internal_format,
                                                error);
      tex = COGL_TEXTURE (tex_2ds);
    }

  cogl_object_unref (bitmap);

  return tex;
}
开发者ID:gcampax,项目名称:cogl,代码行数:56,代码来源:cogl-gst-video-sink.c

示例9: create_migration_texture

static CoglTexture *
create_migration_texture (CoglContext *ctx,
                          int width,
                          int height,
                          CoglPixelFormat internal_format)
{
  CoglTexture *tex;
  CoglError *skip_error = NULL;

  if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
    {
      /* First try creating a fast-path non-sliced texture */
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
                                                         width, height));

      _cogl_texture_set_internal_format (tex, internal_format);

      /* TODO: instead of allocating storage here it would be better
       * if we had some api that let us just check that the size is
       * supported by the hardware so storage could be allocated
       * lazily when uploading data. */
      if (!cogl_texture_allocate (tex, &skip_error))
        {
          cogl_error_free (skip_error);
          cogl_object_unref (tex);
          tex = NULL;
        }
    }
  else
    tex = NULL;

  if (!tex)
    {
      CoglTexture2DSliced *tex_2ds =
        cogl_texture_2d_sliced_new_with_size (ctx,
                                              width,
                                              height,
                                              COGL_TEXTURE_MAX_WASTE);

      _cogl_texture_set_internal_format (COGL_TEXTURE (tex_2ds),
                                         internal_format);

      tex = COGL_TEXTURE (tex_2ds);
    }

  return tex;
}
开发者ID:collinss,项目名称:muffin,代码行数:49,代码来源:cogl-atlas.c

示例10: cogl_pango_glyph_cache_add_to_global_atlas

static gboolean
cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
                                            PangoFont *font,
                                            PangoGlyph glyph,
                                            CoglPangoGlyphCacheValue *value)
{
  CoglAtlasTexture *texture;
  CoglError *ignore_error = NULL;

  if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
    return FALSE;

  /* If the cache is using mipmapping then we can't use the global
     atlas because it would just get migrated back out */
  if (cache->use_mipmapping)
    return FALSE;

  texture = cogl_atlas_texture_new_with_size (cache->ctx,
                                              value->draw_width,
                                              value->draw_height);
  if (!cogl_texture_allocate (COGL_TEXTURE (texture), &ignore_error))
    {
      cogl_error_free (ignore_error);
      return FALSE;
    }

  value->texture = COGL_TEXTURE (texture);
  value->tx1 = 0;
  value->ty1 = 0;
  value->tx2 = 1;
  value->ty2 = 1;
  value->tx_pixel = 0;
  value->ty_pixel = 0;

  /* The first time we store a texture in the global atlas we'll
     register for notifications when the global atlas is reorganized
     so we can forward the notification on as a glyph
     reorganization */
  if (!cache->using_global_atlas)
    {
      _cogl_atlas_texture_add_reorganize_callback
        (cache->ctx,
         cogl_pango_glyph_cache_reorganize_cb, cache);
      cache->using_global_atlas = TRUE;
    }

  return TRUE;
}
开发者ID:GNOME,项目名称:mutter,代码行数:48,代码来源:cogl-pango-glyph-cache.c

示例11: _cogl_texture_pixmap_x11_free

static void
_cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
{
  set_damage_object_internal (tex_pixmap, 0, 0);

  if (tex_pixmap->image)
    XDestroyImage (tex_pixmap->image);

  if (tex_pixmap->shm_info.shmid != -1)
    {
      XShmDetach (_cogl_xlib_get_display (), &tex_pixmap->shm_info);
      shmdt (tex_pixmap->shm_info.shmaddr);
      shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0);
    }

  if (tex_pixmap->tex)
    cogl_handle_unref (tex_pixmap->tex);

#ifdef COGL_HAS_GLX_SUPPORT
  _cogl_texture_pixmap_x11_free_glx_pixmap (tex_pixmap);

  if (tex_pixmap->glx_tex)
    cogl_handle_unref (tex_pixmap->glx_tex);
#endif

  /* Chain up */
  _cogl_texture_free (COGL_TEXTURE (tex_pixmap));
}
开发者ID:nobled,项目名称:clutter,代码行数:28,代码来源:cogl-texture-pixmap-x11.c

示例12: _cogl_texture_2d_copy_from_framebuffer

void
_cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d,
                                        int src_x,
                                        int src_y,
                                        int width,
                                        int height,
                                        CoglFramebuffer *src_fb,
                                        int dst_x,
                                        int dst_y,
                                        int level)
{
    CoglTexture *tex = COGL_TEXTURE (tex_2d);
    CoglContext *ctx = tex->context;

    /* Assert that the storage for this texture has been allocated */
    cogl_texture_allocate (tex, NULL); /* (abort on error) */

    ctx->driver_vtable->texture_2d_copy_from_framebuffer (tex_2d,
            src_x,
            src_y,
            width,
            height,
            src_fb,
            dst_x,
            dst_y,
            level);

    tex_2d->mipmaps_dirty = TRUE;
}
开发者ID:rib,项目名称:cogl,代码行数:29,代码来源:cogl-texture-2d.c

示例13: cogl_wayland_texture_set_region_from_shm_buffer

CoglBool
cogl_wayland_texture_set_region_from_shm_buffer (CoglTexture *texture,
        int src_x,
        int src_y,
        int width,
        int height,
        struct wl_shm_buffer *
        shm_buffer,
        int dst_x,
        int dst_y,
        int level,
        CoglError **error)
{
    const uint8_t *data = wl_shm_buffer_get_data (shm_buffer);
    int32_t stride = wl_shm_buffer_get_stride (shm_buffer);
    CoglPixelFormat format;
    int bpp;

    shm_buffer_get_cogl_pixel_format (shm_buffer, &format, NULL);
    bpp = _cogl_pixel_format_get_bytes_per_pixel (format);

    return cogl_texture_set_region (COGL_TEXTURE (texture),
                                    width, height,
                                    format,
                                    stride,
                                    data + src_x * bpp + src_y * stride,
                                    dst_x, dst_y,
                                    level,
                                    error);
}
开发者ID:rib,项目名称:cogl,代码行数:30,代码来源:cogl-texture-2d.c

示例14: _cogl_texture_2d_create_base

static CoglTexture2D *
_cogl_texture_2d_create_base (unsigned int     width,
                              unsigned int     height,
                              CoglTextureFlags flags,
                              CoglPixelFormat  internal_format)
{
  CoglTexture2D *tex_2d = g_new (CoglTexture2D, 1);
  CoglTexture *tex = COGL_TEXTURE (tex_2d);

  tex->vtable = &cogl_texture_2d_vtable;

  tex_2d->width = width;
  tex_2d->height = height;
  tex_2d->mipmaps_dirty = TRUE;
  tex_2d->auto_mipmap = (flags & COGL_TEXTURE_NO_AUTO_MIPMAP) == 0;

  /* We default to GL_LINEAR for both filters */
  tex_2d->min_filter = GL_LINEAR;
  tex_2d->mag_filter = GL_LINEAR;

  /* Wrap mode not yet set */
  tex_2d->wrap_mode = GL_FALSE;

  tex_2d->format = internal_format;

  return tex_2d;
}
开发者ID:gramozeka,项目名称:GSB-NEW,代码行数:27,代码来源:cogl-texture-2d.c

示例15: COGL_TEXTURE

CoglTexture *
st_cogl_texture_new_from_file_wrapper         (const char *filename,
                                         CoglTextureFlags  flags,
                                          CoglPixelFormat  internal_format)
{
    CoglTexture *texture = NULL;
    CoglError *error = NULL;

    if (hardware_supports_npot_sizes ())
      {
        texture = COGL_TEXTURE (cogl_texture_2d_new_from_file (cogl_context,
                                                               filename,
#if COGL_VERSION < COGL_VERSION_ENCODE (1, 18, 0)
                                                               COGL_PIXEL_FORMAT_ANY,
#endif
                                                               &error));
      }
    else
      {
        texture = cogl_texture_new_from_file (filename,
                                              flags,
                                              internal_format,
                                              &error);
      }

    if (error)
      {
        g_debug ("cogl_texture_(2d)_new_from_file failed: %s\n", error->message);
        cogl_error_free (error);
      }

    return texture;
}
开发者ID:AlbertJP,项目名称:Cinnamon,代码行数:33,代码来源:st-cogl-wrapper.c


注:本文中的COGL_TEXTURE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。