2008-06-06 Matthew Allum <mallum@openedhand.com>
Bug #948 - Remove texture rectangle support * clutter/clutter-feature.c: * clutter/clutter-feature.h: * clutter/clutter-texture.c: * clutter/cogl/gl/cogl.c: * clutter/glx/clutter-glx-texture-pixmap.c: Remove support for GL_TEXTURE_RECTANGLE_ARB (now using just regular 2D textures, with optional npots extension). Simplifys code, + makes mipmap & shader support much more sane.
This commit is contained in:
parent
1ee75faaa4
commit
04845aa9c9
@ -539,20 +539,7 @@ _cogl_texture_size_supported (GLenum gl_target,
|
|||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
if (gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
if (gl_target == GL_TEXTURE_2D)
|
||||||
{
|
|
||||||
/* There is no proxy rectangle texture target so best we can
|
|
||||||
* do is to check against the safest value (although depending
|
|
||||||
* on our specific format and type the size could be supported
|
|
||||||
* when it seems it is not) */
|
|
||||||
|
|
||||||
GLint max_size = 0;
|
|
||||||
|
|
||||||
GE( glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_size) );
|
|
||||||
|
|
||||||
return (max_size && width <= max_size && height <= max_size);
|
|
||||||
}
|
|
||||||
else if (gl_target == GL_TEXTURE_2D)
|
|
||||||
{
|
{
|
||||||
/* Proxy texture allows for a quick check for supported size */
|
/* Proxy texture allows for a quick check for supported size */
|
||||||
|
|
||||||
@ -601,13 +588,6 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
|||||||
tex->gl_target = GL_TEXTURE_2D;
|
tex->gl_target = GL_TEXTURE_2D;
|
||||||
slices_for_size = _cogl_rect_slices_for_size;
|
slices_for_size = _cogl_rect_slices_for_size;
|
||||||
}
|
}
|
||||||
else if (cogl_features_available (COGL_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
{
|
|
||||||
max_width = tex->bitmap.width;
|
|
||||||
max_height = tex->bitmap.height;
|
|
||||||
tex->gl_target = GL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
slices_for_size = _cogl_rect_slices_for_size;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max_width = cogl_util_next_p2 (tex->bitmap.width);
|
max_width = cogl_util_next_p2 (tex->bitmap.width);
|
||||||
@ -1230,8 +1210,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
CoglTexSliceSpan y_span;
|
CoglTexSliceSpan y_span;
|
||||||
|
|
||||||
/* Allow 2-dimensional textures only */
|
/* Allow 2-dimensional textures only */
|
||||||
if (gl_target != GL_TEXTURE_2D &&
|
if (gl_target != GL_TEXTURE_2D)
|
||||||
gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
@ -1747,9 +1726,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
gulong enable_flags = 0;
|
gulong enable_flags = 0;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
if (ctx->color_alpha < 255
|
||||||
@ -1806,11 +1782,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
/* Normalize texture coordinates to current slice
|
/* Normalize texture coordinates to current slice
|
||||||
(rectangle texture targets take denormalized) */
|
(rectangle texture targets take denormalized) */
|
||||||
if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
slice_ty1 /= iter_y.span->size;
|
slice_ty1 /= iter_y.span->size;
|
||||||
slice_ty2 /= iter_y.span->size;
|
slice_ty2 /= iter_y.span->size;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Iterate until whole quad width covered */
|
/* Iterate until whole quad width covered */
|
||||||
@ -1835,11 +1808,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
/* Normalize texture coordinates to current slice
|
/* Normalize texture coordinates to current slice
|
||||||
(rectangle texture targets take denormalized) */
|
(rectangle texture targets take denormalized) */
|
||||||
if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
slice_tx1 /= iter_x.span->size;
|
slice_tx1 /= iter_x.span->size;
|
||||||
slice_tx2 /= iter_x.span->size;
|
slice_tx2 /= iter_x.span->size;
|
||||||
}
|
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
||||||
@ -1908,9 +1878,6 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
gulong enable_flags = 0;
|
gulong enable_flags = 0;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
if (ctx->color_alpha < 255
|
||||||
@ -1934,15 +1901,6 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
|
|
||||||
/* Denormalize texture coordinates for rectangle textures */
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
tx1 *= x_span->size;
|
|
||||||
tx2 *= x_span->size;
|
|
||||||
ty1 *= y_span->size;
|
|
||||||
ty2 *= y_span->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
|
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
|
||||||
|
|
||||||
/* Draw textured quad */
|
/* Draw textured quad */
|
||||||
@ -2088,9 +2046,6 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
tex = _cogl_texture_pointer_from_handle (handle);
|
tex = _cogl_texture_pointer_from_handle (handle);
|
||||||
|
|
||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
cogl_enable (COGL_ENABLE_TEXTURE_RECT | COGL_ENABLE_BLEND);
|
|
||||||
else
|
|
||||||
cogl_enable (COGL_ENABLE_TEXTURE_2D | COGL_ENABLE_BLEND);
|
cogl_enable (COGL_ENABLE_TEXTURE_2D | COGL_ENABLE_BLEND);
|
||||||
|
|
||||||
/* Temporarily change the wrapping mode on all of the slices to use
|
/* Temporarily change the wrapping mode on all of the slices to use
|
||||||
@ -2140,12 +2095,6 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
- y_span->start / (GLfloat) tex->bitmap.height)
|
- y_span->start / (GLfloat) tex->bitmap.height)
|
||||||
* tex->bitmap.height / y_span->size;
|
* tex->bitmap.height / y_span->size;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
tx *= x_span->size;
|
|
||||||
ty *= y_span->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
glTexCoord2f (tx, ty);
|
glTexCoord2f (tx, ty);
|
||||||
|
|
||||||
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
|
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
|
||||||
|
13
gl/cogl.c
13
gl/cogl.c
@ -323,11 +323,6 @@ cogl_enable (gulong flags)
|
|||||||
COGL_ENABLE_TEXCOORD_ARRAY,
|
COGL_ENABLE_TEXCOORD_ARRAY,
|
||||||
GL_TEXTURE_COORD_ARRAY);
|
GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
|
||||||
cogl_toggle_flag (ctx, flags,
|
|
||||||
COGL_ENABLE_TEXTURE_RECT,
|
|
||||||
GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gulong
|
gulong
|
||||||
@ -673,14 +668,6 @@ _cogl_features_init ()
|
|||||||
|
|
||||||
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
#if defined(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB) && defined(GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
if (cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions) ||
|
|
||||||
cogl_check_extension ("GL_EXT_texture_rectangle", gl_extensions))
|
|
||||||
{
|
|
||||||
flags |= COGL_FEATURE_TEXTURE_RECTANGLE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
|
if (cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
|
||||||
{
|
{
|
||||||
flags |= COGL_FEATURE_TEXTURE_NPOT;
|
flags |= COGL_FEATURE_TEXTURE_NPOT;
|
||||||
|
Loading…
Reference in New Issue
Block a user