2011-07-13 14:47:10 +00:00
|
|
|
/*
|
|
|
|
* texture rectangle
|
|
|
|
*
|
|
|
|
* A small utility function to help create a rectangle texture
|
|
|
|
*
|
|
|
|
* Authored By Neil Roberts <neil@linux.intel.com>
|
|
|
|
*
|
2012-03-23 18:51:25 +00:00
|
|
|
* Copyright (C) 2011, 2012 Intel Corporation
|
2011-07-13 14:47:10 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2011-07-13 14:47:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2012-03-23 18:51:25 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include "meta-texture-rectangle.h"
|
2011-07-13 14:47:10 +00:00
|
|
|
|
2012-03-23 18:51:25 +00:00
|
|
|
static void
|
|
|
|
texture_rectangle_check_cb (CoglTexture *sub_texture,
|
|
|
|
const float *sub_texture_coords,
|
|
|
|
const float *meta_coords,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
gboolean *result = user_data;
|
|
|
|
|
|
|
|
if (cogl_is_texture_rectangle (sub_texture))
|
|
|
|
*result = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determines if the given texture is using a rectangle texture as its
|
|
|
|
* primitive texture type. Eventually this function could be replaced
|
|
|
|
* with cogl_texture_get_type if Cogl makes that public.
|
|
|
|
*
|
|
|
|
* http://git.gnome.org/browse/cogl/commit/?h=8012eee31
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
meta_texture_rectangle_check (CoglTexture *texture)
|
|
|
|
{
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
|
|
|
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (texture),
|
|
|
|
0.0f, 0.0f, /* tx_1 / ty_1 */
|
|
|
|
1.0f, 1.0f, /* tx_2 / ty_2 */
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
texture_rectangle_check_cb,
|
|
|
|
&result);
|
2011-07-13 14:47:10 +00:00
|
|
|
|
2012-03-23 18:51:25 +00:00
|
|
|
return result;
|
2011-07-13 14:47:10 +00:00
|
|
|
}
|