summaryrefslogtreecommitdiff
path: root/src/glitz_texture.c
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2005-01-25 19:50:26 +0000
committerDavid Reveman <davidr@novell.com>2005-01-25 19:50:26 +0000
commitb05afb1f26e5084f4a4a8a77dbc0b35866f911c5 (patch)
tree5a7fb6415698e802e0b30aea3088a5b7b11ca9a8 /src/glitz_texture.c
parentcb451f425a67be0e8d4701f601bcce6b28b129ba (diff)
Add anti-aliased trapezoids, rectangular clipping, multiple geometry arrays, bitmap geometry, mask surface convolution filtering
Diffstat (limited to 'src/glitz_texture.c')
-rw-r--r--src/glitz_texture.c216
1 files changed, 134 insertions, 82 deletions
diff --git a/src/glitz_texture.c b/src/glitz_texture.c
index f4f25b2..de53ff5 100644
--- a/src/glitz_texture.c
+++ b/src/glitz_texture.c
@@ -1,11 +1,11 @@
/*
- * Copyright © 2004 David Reveman
+ * Copyright © 2004 David Reveman
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the names of
+ * appear in supporting documentation, and that the name of
* David Reveman not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* David Reveman makes no representations about the suitability of this
@@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * Author: David Reveman <c99drn@cs.umu.se>
+ * Author: David Reveman <davidr@novell.com>
*/
#ifdef HAVE_CONFIG_H
@@ -34,55 +34,69 @@ glitz_texture_init (glitz_texture_t *texture,
int width,
int height,
glitz_gl_int_t texture_format,
- unsigned long feature_mask)
+ unsigned long feature_mask,
+ glitz_bool_t unnormalized)
{
- texture->filter = 0;
- texture->wrap = 0;
- texture->format = texture_format;
- texture->name = 0;
+ texture->filter = 0;
+ texture->wrap = 0;
+ texture->format = texture_format;
+ texture->name = 0;
- if (feature_mask & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK) {
- texture->box.x1 = texture->box.y1 = 0;
- texture->box.x2 = texture->width = width;
- texture->box.y2 = texture->height = height;
- texture->flags = GLITZ_TEXTURE_FLAG_REPEATABLE_MASK |
- GLITZ_TEXTURE_FLAG_PADABLE_MASK;
- } else {
- texture->box.x1 = texture->box.y1 = 1;
- texture->box.x2 = width + 1;
- texture->box.y2 = height + 1;
- texture->width = width + 2;
- texture->height = height + 2;
- texture->flags = 0;
- }
+ if (feature_mask & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
+ {
+ texture->box.x1 = texture->box.y1 = 0;
+ texture->box.x2 = texture->width = width;
+ texture->box.y2 = texture->height = height;
+ texture->flags = GLITZ_TEXTURE_FLAG_REPEATABLE_MASK |
+ GLITZ_TEXTURE_FLAG_PADABLE_MASK;
+ }
+ else
+ {
+ texture->box.x1 = texture->box.y1 = 1;
+ texture->box.x2 = width + 1;
+ texture->box.y2 = height + 1;
+ texture->width = width + 2;
+ texture->height = height + 2;
+ texture->flags = 0;
+ }
- if ((feature_mask & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
- (POWER_OF_TWO (texture->width) && POWER_OF_TWO (texture->height))) {
- texture->target = GLITZ_GL_TEXTURE_2D;
- } else {
- texture->flags &= ~GLITZ_TEXTURE_FLAG_REPEATABLE_MASK;
-
- if (feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK) {
- texture->target = GLITZ_GL_TEXTURE_RECTANGLE;
- } else {
- texture->target = GLITZ_GL_TEXTURE_2D;
- texture->flags &= ~GLITZ_TEXTURE_FLAG_PADABLE_MASK;
-
- if (!POWER_OF_TWO (texture->width))
- texture->width = glitz_uint_to_power_of_two (texture->width);
+ if (!unnormalized &&
+ ((feature_mask & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
+ (POWER_OF_TWO (texture->width) && POWER_OF_TWO (texture->height))))
+ {
+ texture->target = GLITZ_GL_TEXTURE_2D;
+ }
+ else
+ {
+ texture->flags &= ~GLITZ_TEXTURE_FLAG_REPEATABLE_MASK;
- if (!POWER_OF_TWO (texture->height))
- texture->height = glitz_uint_to_power_of_two (texture->height);
+ if (feature_mask & GLITZ_FEATURE_TEXTURE_RECTANGLE_MASK)
+ {
+ texture->target = GLITZ_GL_TEXTURE_RECTANGLE;
+ }
+ else
+ {
+ texture->target = GLITZ_GL_TEXTURE_2D;
+ texture->flags &= ~GLITZ_TEXTURE_FLAG_PADABLE_MASK;
+
+ if (!POWER_OF_TWO (texture->width))
+ texture->width = glitz_uint_to_power_of_two (texture->width);
+
+ if (!POWER_OF_TWO (texture->height))
+ texture->height = glitz_uint_to_power_of_two (texture->height);
+ }
}
- }
- if (texture->target == GLITZ_GL_TEXTURE_2D) {
- texture->texcoord_width_unit = 1.0f / texture->width;
- texture->texcoord_height_unit = 1.0f / texture->height;
- } else {
- texture->texcoord_width_unit = 1.0f;
- texture->texcoord_height_unit = 1.0f;
- }
+ if (texture->target == GLITZ_GL_TEXTURE_2D)
+ {
+ texture->texcoord_width_unit = 1.0f / texture->width;
+ texture->texcoord_height_unit = 1.0f / texture->height;
+ }
+ else
+ {
+ texture->texcoord_width_unit = 1.0f;
+ texture->texcoord_height_unit = 1.0f;
+ }
}
void
@@ -240,47 +254,85 @@ glitz_texture_copy_drawable (glitz_gl_proc_address_list_t *gl,
void
glitz_texture_set_tex_gen (glitz_gl_proc_address_list_t *gl,
glitz_texture_t *texture,
+ glitz_geometry_t *geometry,
int x_src,
int y_src,
- unsigned long flags)
+ unsigned long flags,
+ glitz_int_coordinate_t *coord)
{
- glitz_vec4_t plane;
+ glitz_vec4_t plane;
- plane.v[1] = plane.v[2] = 0.0f;
-
- if (flags & GLITZ_SURFACE_FLAG_EYE_COORDS_MASK) {
- plane.v[0] = 1.0f;
- plane.v[3] = -x_src;
- } else {
- plane.v[0] = texture->texcoord_width_unit;
-
- if (flags & GLITZ_SURFACE_FLAG_TRANSFORM_MASK)
- plane.v[3] = -(x_src) * texture->texcoord_width_unit;
- else
- plane.v[3] = -(x_src - texture->box.x1) * texture->texcoord_width_unit;
- }
-
- gl->tex_gen_i (GLITZ_GL_S, GLITZ_GL_TEXTURE_GEN_MODE,
- GLITZ_GL_EYE_LINEAR);
- gl->tex_gen_fv (GLITZ_GL_S, GLITZ_GL_EYE_PLANE, plane.v);
- gl->enable (GLITZ_GL_TEXTURE_GEN_S);
+ if (flags & GLITZ_SURFACE_FLAG_GEN_S_COORDS_MASK)
+ {
+ plane.v[1] = plane.v[2] = 0.0f;
+
+ if (flags & GLITZ_SURFACE_FLAG_EYE_COORDS_MASK)
+ {
+ plane.v[0] = 1.0f;
+ plane.v[3] = -x_src;
+ }
+ else
+ {
+ plane.v[0] = texture->texcoord_width_unit;
+
+ if (flags & GLITZ_SURFACE_FLAG_TRANSFORM_MASK)
+ plane.v[3] = -(x_src) * texture->texcoord_width_unit;
+ else
+ plane.v[3] = -(x_src - texture->box.x1) *
+ texture->texcoord_width_unit;
+ }
+
+ gl->tex_gen_i (GLITZ_GL_S, GLITZ_GL_TEXTURE_GEN_MODE,
+ GLITZ_GL_EYE_LINEAR);
+ gl->tex_gen_fv (GLITZ_GL_S, GLITZ_GL_EYE_PLANE, plane.v);
- plane.v[0] = 0.0f;
- if (flags & GLITZ_SURFACE_FLAG_EYE_COORDS_MASK) {
- plane.v[1] = 1.0f;
- plane.v[3] = -y_src;
- } else {
- plane.v[1] = -texture->texcoord_height_unit;
-
- if (flags & GLITZ_SURFACE_FLAG_TRANSFORM_MASK)
- plane.v[3] = (y_src + texture->box.y2 - texture->box.y1) *
- texture->texcoord_height_unit;
+ gl->enable (GLITZ_GL_TEXTURE_GEN_S);
+ }
else
- plane.v[3] = (y_src + texture->box.y2) * texture->texcoord_height_unit;
- }
+ gl->disable (GLITZ_GL_TEXTURE_GEN_S);
+
+ if (flags & GLITZ_SURFACE_FLAG_GEN_T_COORDS_MASK)
+ {
+ plane.v[0] = 0.0f;
+ if (flags & GLITZ_SURFACE_FLAG_EYE_COORDS_MASK)
+ {
+ plane.v[1] = 1.0f;
+ plane.v[3] = -y_src;
+ }
+ else
+ {
+ plane.v[1] = -texture->texcoord_height_unit;
+
+ if (flags & GLITZ_SURFACE_FLAG_TRANSFORM_MASK)
+ plane.v[3] = (y_src + texture->box.y2 - texture->box.y1) *
+ texture->texcoord_height_unit;
+ else
+ plane.v[3] = (y_src + texture->box.y2) *
+ texture->texcoord_height_unit;
+ }
- gl->tex_gen_i (GLITZ_GL_T, GLITZ_GL_TEXTURE_GEN_MODE,
- GLITZ_GL_EYE_LINEAR);
- gl->tex_gen_fv (GLITZ_GL_T, GLITZ_GL_EYE_PLANE, plane.v);
- gl->enable (GLITZ_GL_TEXTURE_GEN_T);
+ gl->tex_gen_i (GLITZ_GL_T, GLITZ_GL_TEXTURE_GEN_MODE,
+ GLITZ_GL_EYE_LINEAR);
+ gl->tex_gen_fv (GLITZ_GL_T, GLITZ_GL_EYE_PLANE, plane.v);
+
+ gl->enable (GLITZ_GL_TEXTURE_GEN_T);
+ }
+ else
+ gl->disable (GLITZ_GL_TEXTURE_GEN_T);
+
+ if (!(flags & GLITZ_SURFACE_FLAG_GEN_S_COORDS_MASK))
+ {
+ unsigned char *ptr;
+
+ gl->enable_client_state (GLITZ_GL_TEXTURE_COORD_ARRAY);
+
+ ptr = glitz_buffer_bind (geometry->buffer, GLITZ_GL_ARRAY_BUFFER);
+ ptr += coord->offset;
+
+ gl->tex_coord_pointer (coord->size,
+ coord->type,
+ geometry->stride,
+ (void *) ptr);
+ } else
+ gl->disable_client_state (GLITZ_GL_TEXTURE_COORD_ARRAY);
}