Split the wrap mode of _cogl_texture_set_wrap_mode into three
GL supports setting different wrap modes for the s, t and r coordinates so we should design the backend interface to support that also. The r coordinate is not currently used by any of the backends but we might as well have it to make life easier if we ever add support for 3D textures. http://bugzilla.openedhand.com/show_bug.cgi?id=2063
This commit is contained in:
parent
908be0480c
commit
fb7f1a7fd6
@ -229,13 +229,18 @@ _cogl_atlas_texture_foreach_sub_texture_in_region (
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_atlas_texture_set_wrap_mode_parameter (CoglTexture *tex,
|
||||
GLenum wrap_mode)
|
||||
_cogl_atlas_texture_set_wrap_mode_parameters (CoglTexture *tex,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r)
|
||||
{
|
||||
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
||||
|
||||
/* Forward on to the sub texture */
|
||||
_cogl_texture_set_wrap_mode_parameter (atlas_tex->sub_texture, wrap_mode);
|
||||
_cogl_texture_set_wrap_mode_parameters (atlas_tex->sub_texture,
|
||||
wrap_mode_s,
|
||||
wrap_mode_t,
|
||||
wrap_mode_r);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1068,7 +1073,7 @@ cogl_atlas_texture_vtable =
|
||||
_cogl_atlas_texture_set_filters,
|
||||
_cogl_atlas_texture_ensure_mipmaps,
|
||||
_cogl_atlas_texture_ensure_non_quad_rendering,
|
||||
_cogl_atlas_texture_set_wrap_mode_parameter,
|
||||
_cogl_atlas_texture_set_wrap_mode_parameters,
|
||||
_cogl_atlas_texture_get_format,
|
||||
_cogl_atlas_texture_get_gl_format,
|
||||
_cogl_atlas_texture_get_width,
|
||||
|
@ -157,7 +157,10 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
||||
/* We can't use hardware repeat so we need to set clamp to edge
|
||||
otherwise it might pull in edge pixels from the other side */
|
||||
/* FIXME: wrap modes should be part of the material! */
|
||||
_cogl_texture_set_wrap_mode_parameter (tex_handle, GL_CLAMP_TO_EDGE);
|
||||
_cogl_texture_set_wrap_mode_parameters (tex_handle,
|
||||
GL_CLAMP_TO_EDGE,
|
||||
GL_CLAMP_TO_EDGE,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
|
||||
state.material = material;
|
||||
|
||||
@ -329,7 +332,10 @@ _cogl_multitexture_quad_single_primitive (const float *position,
|
||||
else
|
||||
wrap_mode = GL_CLAMP_TO_EDGE;
|
||||
|
||||
_cogl_texture_set_wrap_mode_parameter (tex_handle, wrap_mode);
|
||||
_cogl_texture_set_wrap_mode_parameters (tex_handle,
|
||||
wrap_mode,
|
||||
wrap_mode,
|
||||
wrap_mode);
|
||||
}
|
||||
|
||||
_cogl_journal_log_quad (position,
|
||||
@ -920,7 +926,9 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
||||
* a transparent border
|
||||
* XXX: it's doesn't look like we save/restore this, like
|
||||
* the comment implies? */
|
||||
_cogl_texture_set_wrap_mode_parameter (tex_handle,
|
||||
_cogl_texture_set_wrap_mode_parameters (tex_handle,
|
||||
GL_CLAMP_TO_BORDER,
|
||||
GL_CLAMP_TO_BORDER,
|
||||
GL_CLAMP_TO_BORDER);
|
||||
}
|
||||
#endif
|
||||
|
@ -224,12 +224,17 @@ _cogl_sub_texture_foreach_sub_texture_in_region (
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_sub_texture_set_wrap_mode_parameter (CoglTexture *tex,
|
||||
GLenum wrap_mode)
|
||||
_cogl_sub_texture_set_wrap_mode_parameters (CoglTexture *tex,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r)
|
||||
{
|
||||
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
|
||||
|
||||
_cogl_texture_set_wrap_mode_parameter (sub_tex->full_texture, wrap_mode);
|
||||
_cogl_texture_set_wrap_mode_parameters (sub_tex->full_texture,
|
||||
wrap_mode_s,
|
||||
wrap_mode_t,
|
||||
wrap_mode_r);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -547,7 +552,7 @@ cogl_sub_texture_vtable =
|
||||
_cogl_sub_texture_set_filters,
|
||||
_cogl_sub_texture_ensure_mipmaps,
|
||||
_cogl_sub_texture_ensure_non_quad_rendering,
|
||||
_cogl_sub_texture_set_wrap_mode_parameter,
|
||||
_cogl_sub_texture_set_wrap_mode_parameters,
|
||||
_cogl_sub_texture_get_format,
|
||||
_cogl_sub_texture_get_gl_format,
|
||||
_cogl_sub_texture_get_width,
|
||||
|
@ -47,7 +47,8 @@ struct _CoglTexture2D
|
||||
int height;
|
||||
GLenum min_filter;
|
||||
GLenum mag_filter;
|
||||
GLint wrap_mode;
|
||||
GLint wrap_mode_s;
|
||||
GLint wrap_mode_t;
|
||||
gboolean auto_mipmap;
|
||||
gboolean mipmaps_dirty;
|
||||
};
|
||||
|
@ -65,7 +65,8 @@ struct _CoglTexture2DSliced
|
||||
GLenum min_filter;
|
||||
GLenum mag_filter;
|
||||
gboolean is_foreign;
|
||||
GLint wrap_mode;
|
||||
GLenum wrap_mode_s;
|
||||
GLenum wrap_mode_t;
|
||||
gboolean auto_mipmap;
|
||||
gboolean mipmaps_dirty;
|
||||
|
||||
|
@ -661,14 +661,18 @@ _cogl_pot_slices_for_size (int size_to_fill,
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_texture_2d_sliced_set_wrap_mode_parameter (CoglTexture *tex,
|
||||
GLenum wrap_mode)
|
||||
_cogl_texture_2d_sliced_set_wrap_mode_parameters (CoglTexture *tex,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r)
|
||||
{
|
||||
CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex);
|
||||
|
||||
/* Only set the wrap mode if it's different from the current
|
||||
value to avoid too many GL calls */
|
||||
if (tex_2ds->wrap_mode != wrap_mode)
|
||||
/* Only set the wrap mode if it's different from the current value
|
||||
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
||||
coordinate so we can ignore its wrap mode */
|
||||
if (tex_2ds->wrap_mode_s != wrap_mode_s ||
|
||||
tex_2ds->wrap_mode_t != wrap_mode_t)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -681,11 +685,14 @@ _cogl_texture_2d_sliced_set_wrap_mode_parameter (CoglTexture *tex,
|
||||
GLuint texnum = g_array_index (tex_2ds->slice_gl_handles, GLuint, i);
|
||||
|
||||
GE( glBindTexture (tex_2ds->gl_target, texnum) );
|
||||
GE( glTexParameteri (tex_2ds->gl_target, GL_TEXTURE_WRAP_S, wrap_mode) );
|
||||
GE( glTexParameteri (tex_2ds->gl_target, GL_TEXTURE_WRAP_T, wrap_mode) );
|
||||
GE( glTexParameteri (tex_2ds->gl_target,
|
||||
GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
||||
GE( glTexParameteri (tex_2ds->gl_target,
|
||||
GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
||||
}
|
||||
|
||||
tex_2ds->wrap_mode = wrap_mode;
|
||||
tex_2ds->wrap_mode_s = wrap_mode_s;
|
||||
tex_2ds->wrap_mode_t = wrap_mode_t;
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,7 +834,8 @@ _cogl_texture_2d_sliced_slices_create (CoglTexture2DSliced *tex_2ds,
|
||||
tex_2ds->first_pixels = g_new (CoglTexturePixel, n_slices);
|
||||
|
||||
/* Wrap mode not yet set */
|
||||
tex_2ds->wrap_mode = GL_FALSE;
|
||||
tex_2ds->wrap_mode_s = GL_FALSE;
|
||||
tex_2ds->wrap_mode_t = GL_FALSE;
|
||||
|
||||
/* Generate a "working set" of GL texture objects
|
||||
* (some implementations might supported faster
|
||||
@ -1188,7 +1196,8 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle,
|
||||
tex_2ds->max_waste = 0;
|
||||
|
||||
/* Wrap mode not yet set */
|
||||
tex_2ds->wrap_mode = GL_FALSE;
|
||||
tex_2ds->wrap_mode_s = GL_FALSE;
|
||||
tex_2ds->wrap_mode_t = GL_FALSE;
|
||||
|
||||
/* Create slice arrays */
|
||||
tex_2ds->slice_x_spans =
|
||||
@ -1728,7 +1737,7 @@ cogl_texture_2d_sliced_vtable =
|
||||
_cogl_texture_2d_sliced_set_filters,
|
||||
_cogl_texture_2d_sliced_ensure_mipmaps,
|
||||
_cogl_texture_2d_sliced_ensure_non_quad_rendering,
|
||||
_cogl_texture_2d_sliced_set_wrap_mode_parameter,
|
||||
_cogl_texture_2d_sliced_set_wrap_mode_parameters,
|
||||
_cogl_texture_2d_sliced_get_format,
|
||||
_cogl_texture_2d_sliced_get_gl_format,
|
||||
_cogl_texture_2d_sliced_get_width,
|
||||
|
@ -124,24 +124,29 @@ _cogl_texture_2d_foreach_sub_texture_in_region (
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_texture_2d_set_wrap_mode_parameter (CoglTexture *tex,
|
||||
GLenum wrap_mode)
|
||||
_cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r)
|
||||
{
|
||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||
|
||||
/* Only set the wrap mode if it's different from the current
|
||||
value to avoid too many GL calls */
|
||||
if (tex_2d->wrap_mode != wrap_mode)
|
||||
/* Only set the wrap mode if it's different from the current value
|
||||
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
||||
coordinate so we can ignore its wrap mode */
|
||||
if (tex_2d->wrap_mode_s != wrap_mode_s ||
|
||||
tex_2d->wrap_mode_t != wrap_mode_t)
|
||||
{
|
||||
/* Any queued texture rectangles may be depending on the
|
||||
* previous wrap mode... */
|
||||
_cogl_journal_flush ();
|
||||
|
||||
GE( glBindTexture (GL_TEXTURE_2D, tex_2d->gl_texture) );
|
||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode) );
|
||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode) );
|
||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
||||
|
||||
tex_2d->wrap_mode = wrap_mode;
|
||||
tex_2d->wrap_mode_s = wrap_mode_s;
|
||||
tex_2d->wrap_mode_t = wrap_mode_t;
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +236,8 @@ _cogl_texture_2d_create_base (unsigned int width,
|
||||
tex_2d->mag_filter = GL_LINEAR;
|
||||
|
||||
/* Wrap mode not yet set */
|
||||
tex_2d->wrap_mode = GL_FALSE;
|
||||
tex_2d->wrap_mode_s = GL_FALSE;
|
||||
tex_2d->wrap_mode_t = GL_FALSE;
|
||||
|
||||
tex_2d->format = internal_format;
|
||||
|
||||
@ -643,7 +649,7 @@ cogl_texture_2d_vtable =
|
||||
_cogl_texture_2d_set_filters,
|
||||
_cogl_texture_2d_ensure_mipmaps,
|
||||
_cogl_texture_2d_ensure_non_quad_rendering,
|
||||
_cogl_texture_2d_set_wrap_mode_parameter,
|
||||
_cogl_texture_2d_set_wrap_mode_parameters,
|
||||
_cogl_texture_2d_get_format,
|
||||
_cogl_texture_2d_get_gl_format,
|
||||
_cogl_texture_2d_get_width,
|
||||
|
@ -109,8 +109,10 @@ struct _CoglTextureVtable
|
||||
void (* ensure_mipmaps) (CoglTexture *tex);
|
||||
void (* ensure_non_quad_rendering) (CoglTexture *tex);
|
||||
|
||||
void (* set_wrap_mode_parameter) (CoglTexture *tex,
|
||||
GLenum wrap_mode);
|
||||
void (* set_wrap_mode_parameters) (CoglTexture *tex,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r);
|
||||
|
||||
CoglPixelFormat (* get_format) (CoglTexture *tex);
|
||||
GLenum (* get_gl_format) (CoglTexture *tex);
|
||||
@ -148,8 +150,11 @@ GLenum
|
||||
_cogl_texture_get_gl_format (CoglHandle handle);
|
||||
|
||||
void
|
||||
_cogl_texture_set_wrap_mode_parameter (CoglHandle handle,
|
||||
GLenum wrap_mode);
|
||||
_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r);
|
||||
|
||||
|
||||
void
|
||||
_cogl_texture_set_filters (CoglHandle handle,
|
||||
|
@ -212,12 +212,17 @@ _cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
|
||||
|
||||
/* FIXME: wrap modes should be set on materials not textures */
|
||||
void
|
||||
_cogl_texture_set_wrap_mode_parameter (CoglHandle handle,
|
||||
GLenum wrap_mode)
|
||||
_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
|
||||
GLenum wrap_mode_s,
|
||||
GLenum wrap_mode_t,
|
||||
GLenum wrap_mode_r)
|
||||
{
|
||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
||||
|
||||
tex->vtable->set_wrap_mode_parameter (tex, wrap_mode);
|
||||
tex->vtable->set_wrap_mode_parameters (tex,
|
||||
wrap_mode_s,
|
||||
wrap_mode_t,
|
||||
wrap_mode_r);
|
||||
}
|
||||
|
||||
/* This is like CoglSpanIter except it deals with floats and it
|
||||
|
Loading…
Reference in New Issue
Block a user