CoglTexture * cogl_texture_new_from_sub_texture (CoglTexture *full_texture, int sub_x, int sub_y, int sub_width, int sub_height) { _COGL_GET_CONTEXT (ctx, NULL); return COGL_TEXTURE (cogl_sub_texture_new (ctx, full_texture, sub_x, sub_y, sub_width, sub_height)); }
static CoglSubTexture * _cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, const CoglRectangleMapEntry *rectangle) { CoglContext *ctx = full_texture->context; /* Create a subtexture for the given rectangle not including the 1-pixel border */ return cogl_sub_texture_new (ctx, full_texture, rectangle->x + 1, rectangle->y + 1, rectangle->width - 2, rectangle->height - 2); }
CoglTexture * 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_GET_CONTEXT (ctx, NULL); #ifdef HAVE_COGL_GL if (gl_target == GL_TEXTURE_RECTANGLE_ARB) { CoglTextureRectangle *texture_rectangle; CoglSubTexture *sub_texture; if (x_pot_waste != 0 || y_pot_waste != 0) { /* It shouldn't be necessary to have waste in this case since * the texture isn't limited to power of two sizes. */ g_warning ("You can't create a foreign GL_TEXTURE_RECTANGLE cogl " "texture with waste\n"); return NULL; } texture_rectangle = cogl_texture_rectangle_new_from_foreign (ctx, gl_handle, width, height, format); _cogl_texture_set_internal_format (COGL_TEXTURE (texture_rectangle), format); /* CoglTextureRectangle textures work with non-normalized * coordinates, but the semantics for this function that people * depend on are that all returned texture works with normalized * coordinates so we wrap with a CoglSubTexture... */ sub_texture = cogl_sub_texture_new (ctx, COGL_TEXTURE (texture_rectangle), 0, 0, width, height); return COGL_TEXTURE (sub_texture); } #endif if (x_pot_waste != 0 || y_pot_waste != 0) { CoglTexture *tex = COGL_TEXTURE (_cogl_texture_2d_sliced_new_from_foreign (ctx, gl_handle, gl_target, width, height, x_pot_waste, y_pot_waste, format)); _cogl_texture_set_internal_format (tex, format); cogl_texture_allocate (tex, NULL); return tex; } else { CoglTexture *tex = COGL_TEXTURE (cogl_texture_2d_gl_new_from_foreign (ctx, gl_handle, width, height, format)); _cogl_texture_set_internal_format (tex, format); cogl_texture_allocate (tex, NULL); return tex; } }
CoglTexture * cogl_texture_gl_new_from_foreign (CoglContext *ctx, unsigned int gl_handle, unsigned int gl_target, int width, int height, int x_pot_waste, int y_pot_waste, CoglPixelFormat format, CoglError **error) { #ifdef HAVE_COGL_GL if (gl_target == GL_TEXTURE_RECTANGLE_ARB) { CoglTextureRectangle *texture_rectangle; CoglSubTexture *sub_texture; if (x_pot_waste != 0 || y_pot_waste != 0) { /* It shouldn't be necessary to have waste in this case since * the texture isn't limited to power of two sizes. */ g_warning ("You can't create a foreign GL_TEXTURE_RECTANGLE cogl " "texture with waste\n"); return NULL; } texture_rectangle = cogl_texture_rectangle_new_from_foreign (ctx, gl_handle, width, height, format, error); if (!texture_rectangle) return NULL; /* CoglTextureRectangle textures work with non-normalized * coordinates, but the semantics for this function that people * depend on are that all returned textures work with normalized * coordinates so we wrap with a CoglSubTexture... */ sub_texture = cogl_sub_texture_new (ctx, COGL_TEXTURE (texture_rectangle), 0, 0, width, height); return COGL_TEXTURE (sub_texture); } #endif if (x_pot_waste != 0 || y_pot_waste != 0) return COGL_TEXTURE (_cogl_texture_2d_sliced_new_from_foreign (ctx, gl_handle, gl_target, width, height, x_pot_waste, y_pot_waste, format, error)); else { return COGL_TEXTURE (cogl_texture_2d_gl_new_from_foreign (ctx, gl_handle, width, height, format, error)); } }