diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c index 7db23a161..949519655 100644 --- a/cogl/cogl-atlas-texture.c +++ b/cogl/cogl-atlas-texture.c @@ -234,7 +234,7 @@ static void _cogl_atlas_texture_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); @@ -242,7 +242,7 @@ _cogl_atlas_texture_set_wrap_mode_parameters (CoglTexture *tex, _cogl_texture_set_wrap_mode_parameters (atlas_tex->sub_texture, wrap_mode_s, wrap_mode_t, - wrap_mode_r); + wrap_mode_p); } static void diff --git a/cogl/cogl-material-private.h b/cogl/cogl-material-private.h index 279ad5a7b..9a52aaaa9 100644 --- a/cogl/cogl-material-private.h +++ b/cogl/cogl-material-private.h @@ -337,7 +337,7 @@ struct _CoglMaterialLayer CoglMaterialWrapMode wrap_mode_s; CoglMaterialWrapMode wrap_mode_t; - CoglMaterialWrapMode wrap_mode_r; + CoglMaterialWrapMode wrap_mode_p; /* Infrequent differences aren't currently tracked in * a separate, dynamically allocated structure as they are @@ -756,7 +756,7 @@ typedef struct _CoglMaterialWrapModeOverrides { CoglMaterialWrapModeOverride s; CoglMaterialWrapModeOverride t; - CoglMaterialWrapModeOverride r; + CoglMaterialWrapModeOverride p; } values[COGL_MATERIAL_MAX_LAYERS]; } CoglMaterialWrapModeOverrides; @@ -817,12 +817,12 @@ _cogl_material_journal_unref (CoglMaterial *material); /* TODO: These should be made public once we add support for 3D textures in Cogl */ void -_cogl_material_set_layer_wrap_mode_r (CoglMaterial *material, +_cogl_material_set_layer_wrap_mode_p (CoglMaterial *material, int layer_index, CoglMaterialWrapMode mode); CoglMaterialWrapMode -_cogl_material_layer_get_wrap_mode_r (CoglMaterialLayer *layer); +_cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer); void _cogl_material_set_user_program (CoglMaterial *material, diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index f9e6e74ed..82b50e314 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -1544,7 +1544,7 @@ _cogl_material_layer_initialize_state (CoglMaterialLayer *dest, { dest->wrap_mode_s = src->wrap_mode_s; dest->wrap_mode_t = src->wrap_mode_t; - dest->wrap_mode_r = src->wrap_mode_r; + dest->wrap_mode_p = src->wrap_mode_p; } if (differences & COGL_MATERIAL_LAYER_STATE_NEEDS_BIG_STATE) @@ -2223,14 +2223,14 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, CoglMaterialLayer *authority, CoglMaterialWrapModeInternal wrap_mode_s, CoglMaterialWrapModeInternal wrap_mode_t, - CoglMaterialWrapModeInternal wrap_mode_r) + CoglMaterialWrapModeInternal wrap_mode_p) { CoglMaterialLayer *new; CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; if (authority->wrap_mode_s == wrap_mode_s && authority->wrap_mode_t == wrap_mode_t && - authority->wrap_mode_r == wrap_mode_r) + authority->wrap_mode_p == wrap_mode_p) return; new = _cogl_material_layer_pre_change_notify (material, layer, change); @@ -2251,7 +2251,7 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, if (old_authority->wrap_mode_s == wrap_mode_s && old_authority->wrap_mode_t == wrap_mode_t && - old_authority->wrap_mode_r == wrap_mode_r) + old_authority->wrap_mode_p == wrap_mode_p) { layer->differences &= ~change; @@ -2266,7 +2266,7 @@ _cogl_material_set_layer_wrap_modes (CoglMaterial *material, layer->wrap_mode_s = wrap_mode_s; layer->wrap_mode_t = wrap_mode_t; - layer->wrap_mode_r = wrap_mode_r; + layer->wrap_mode_p = wrap_mode_p; /* If we weren't previously the authority on this state then we need * to extended our differences mask and so it's possible that some @@ -2322,7 +2322,7 @@ cogl_material_set_layer_wrap_mode_s (CoglMaterial *material, _cogl_material_set_layer_wrap_modes (material, layer, authority, internal_mode, authority->wrap_mode_t, - authority->wrap_mode_r); + authority->wrap_mode_p); } void @@ -2353,13 +2353,25 @@ cogl_material_set_layer_wrap_mode_t (CoglMaterial *material, _cogl_material_set_layer_wrap_modes (material, layer, authority, authority->wrap_mode_s, internal_mode, - authority->wrap_mode_r); + authority->wrap_mode_p); } /* TODO: this should be made public once we add support for 3D textures in Cogl */ +/* The rationale for naming the third texture coordinate 'p' instead + of OpenGL's usual 'r' is that 'r' conflicts with the usual naming + of the 'red' component when treating a vector as a color. Under + GLSL this is awkward because the texture swizzling for a vector + uses a single letter for each component and the names for colors, + textures and positions are synonymous. GLSL works around this by + naming the components of the texture s, t, p and q. Cogl already + effectively already exposes this naming because it exposes GLSL so + it makes sense to use that naming consistently. Another alternative + could be u, v and w. This is what Blender and Direct3D use. However + the w component conflicts with the w component of a position + vertex. */ void -_cogl_material_set_layer_wrap_mode_r (CoglMaterial *material, +_cogl_material_set_layer_wrap_mode_p (CoglMaterial *material, int layer_index, CoglMaterialWrapMode mode) { @@ -2493,18 +2505,18 @@ cogl_material_get_layer_wrap_mode_t (CoglMaterial *material, int layer_index) } CoglMaterialWrapMode -_cogl_material_layer_get_wrap_mode_r (CoglMaterialLayer *layer) +_cogl_material_layer_get_wrap_mode_p (CoglMaterialLayer *layer) { CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; CoglMaterialLayer *authority = _cogl_material_layer_get_authority (layer, change); - return internal_to_public_wrap_mode (authority->wrap_mode_r); + return internal_to_public_wrap_mode (authority->wrap_mode_p); } /* TODO: make this public when we expose 3D textures. */ CoglMaterialWrapMode -_cogl_material_get_layer_wrap_mode_r (CoglMaterial *material, int layer_index) +_cogl_material_get_layer_wrap_mode_p (CoglMaterial *material, int layer_index) { CoglMaterialLayer *layer; @@ -2518,14 +2530,14 @@ _cogl_material_get_layer_wrap_mode_r (CoglMaterial *material, int layer_index) * material. */ layer = _cogl_material_get_layer (material, layer_index); - return _cogl_material_layer_get_wrap_mode_r (layer); + return _cogl_material_layer_get_wrap_mode_p (layer); } static void _cogl_material_layer_get_wrap_modes (CoglMaterialLayer *layer, CoglMaterialWrapModeInternal *wrap_mode_s, CoglMaterialWrapModeInternal *wrap_mode_t, - CoglMaterialWrapModeInternal *wrap_mode_r) + CoglMaterialWrapModeInternal *wrap_mode_p) { CoglMaterialLayer *authority = _cogl_material_layer_get_authority (layer, @@ -2533,7 +2545,7 @@ _cogl_material_layer_get_wrap_modes (CoglMaterialLayer *layer, *wrap_mode_s = authority->wrap_mode_s; *wrap_mode_t = authority->wrap_mode_t; - *wrap_mode_r = authority->wrap_mode_r; + *wrap_mode_p = authority->wrap_mode_p; } gboolean @@ -2673,7 +2685,7 @@ apply_wrap_mode_overrides_cb (CoglMaterialLayer *layer, COGL_MATERIAL_LAYER_STATE_WRAP_MODES); CoglMaterialWrapModeInternal wrap_mode_s; CoglMaterialWrapModeInternal wrap_mode_t; - CoglMaterialWrapModeInternal wrap_mode_r; + CoglMaterialWrapModeInternal wrap_mode_p; g_return_val_if_fail (state->i < 32, FALSE); @@ -2683,16 +2695,16 @@ apply_wrap_mode_overrides_cb (CoglMaterialLayer *layer, wrap_mode_t = state->wrap_mode_overrides->values[state->i].t; if (wrap_mode_t == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) wrap_mode_t = (CoglMaterialWrapModeInternal)authority->wrap_mode_t; - wrap_mode_r = state->wrap_mode_overrides->values[state->i].r; - if (wrap_mode_r == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) - wrap_mode_r = (CoglMaterialWrapModeInternal)authority->wrap_mode_r; + wrap_mode_p = state->wrap_mode_overrides->values[state->i].p; + if (wrap_mode_p == COGL_MATERIAL_WRAP_MODE_OVERRIDE_NONE) + wrap_mode_p = (CoglMaterialWrapModeInternal)authority->wrap_mode_p; _cogl_material_set_layer_wrap_modes (state->material, layer, authority, wrap_mode_s, wrap_mode_t, - wrap_mode_r); + wrap_mode_p); state->i++; @@ -2973,7 +2985,7 @@ _cogl_material_layer_wrap_modes_equal (CoglMaterialLayer *authority0, { if (authority0->wrap_mode_s != authority1->wrap_mode_s || authority0->wrap_mode_t != authority1->wrap_mode_t || - authority0->wrap_mode_r != authority1->wrap_mode_r) + authority0->wrap_mode_p != authority1->wrap_mode_p) return FALSE; return TRUE; @@ -4515,7 +4527,7 @@ _cogl_material_init_default_layers (void) layer->wrap_mode_s = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; layer->wrap_mode_t = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; - layer->wrap_mode_r = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; + layer->wrap_mode_p = COGL_MATERIAL_WRAP_MODE_AUTOMATIC; layer->big_state = big_state; layer->has_big_state = TRUE; @@ -5828,8 +5840,8 @@ static void _cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, CoglHandle texture) { - CoglMaterialWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_r; - GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_r; + CoglMaterialWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p; + GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_p; if (texture == COGL_INVALID_HANDLE) return; @@ -5837,7 +5849,7 @@ _cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, _cogl_material_layer_get_wrap_modes (layer, &wrap_mode_s, &wrap_mode_t, - &wrap_mode_r); + &wrap_mode_p); /* Update the wrap mode on the texture object. The texture backend should cache the value so that it will be a no-op if the object @@ -5860,15 +5872,15 @@ _cogl_material_layer_forward_wrap_modes (CoglMaterialLayer *layer, else gl_wrap_mode_t = wrap_mode_t; - if (wrap_mode_r == COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC) - gl_wrap_mode_r = GL_CLAMP_TO_EDGE; + if (wrap_mode_p == COGL_MATERIAL_WRAP_MODE_INTERNAL_AUTOMATIC) + gl_wrap_mode_p = GL_CLAMP_TO_EDGE; else - gl_wrap_mode_r = wrap_mode_r; + gl_wrap_mode_p = wrap_mode_p; _cogl_texture_set_wrap_mode_parameters (texture, gl_wrap_mode_s, gl_wrap_mode_t, - gl_wrap_mode_r); + gl_wrap_mode_p); } /* OpenGL associates the min/mag filters and repeat modes with the diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c index 00db68b94..56aaa863b 100644 --- a/cogl/cogl-sub-texture.c +++ b/cogl/cogl-sub-texture.c @@ -227,14 +227,14 @@ static void _cogl_sub_texture_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); _cogl_texture_set_wrap_mode_parameters (sub_tex->full_texture, wrap_mode_s, wrap_mode_t, - wrap_mode_r); + wrap_mode_p); } static void diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c index 5f3855573..5178a68ee 100644 --- a/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl-texture-2d-sliced.c @@ -667,7 +667,7 @@ static void _cogl_texture_2d_sliced_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex); diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index bfec5df43..b5e4ed7ec 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -128,7 +128,7 @@ static void _cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); diff --git a/cogl/cogl-texture-3d-private.h b/cogl/cogl-texture-3d-private.h index cab49609e..b3bbb26b0 100644 --- a/cogl/cogl-texture-3d-private.h +++ b/cogl/cogl-texture-3d-private.h @@ -51,7 +51,7 @@ struct _CoglTexture3D GLenum mag_filter; GLint wrap_mode_s; GLint wrap_mode_t; - GLint wrap_mode_r; + GLint wrap_mode_p; gboolean auto_mipmap; gboolean mipmaps_dirty; }; diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c index 9c2d5e6f4..f58e3a51b 100644 --- a/cogl/cogl-texture-3d.c +++ b/cogl/cogl-texture-3d.c @@ -137,7 +137,7 @@ static void _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex); @@ -145,18 +145,18 @@ _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex, to avoid too many GL calls. */ if (tex_3d->wrap_mode_s != wrap_mode_s || tex_3d->wrap_mode_t != wrap_mode_t || - tex_3d->wrap_mode_r != wrap_mode_r) + tex_3d->wrap_mode_p != wrap_mode_p) { _cogl_bind_gl_texture_transient (GL_TEXTURE_3D, tex_3d->gl_texture, FALSE); GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, wrap_mode_s) ); GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, wrap_mode_t) ); - GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, wrap_mode_r) ); + GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, wrap_mode_p) ); tex_3d->wrap_mode_s = wrap_mode_s; tex_3d->wrap_mode_t = wrap_mode_t; - tex_3d->wrap_mode_r = wrap_mode_r; + tex_3d->wrap_mode_p = wrap_mode_p; } } @@ -194,7 +194,7 @@ _cogl_texture_3d_create_base (unsigned int width, /* Wrap mode not yet set */ tex_3d->wrap_mode_s = GL_FALSE; tex_3d->wrap_mode_t = GL_FALSE; - tex_3d->wrap_mode_r = GL_FALSE; + tex_3d->wrap_mode_p = GL_FALSE; tex_3d->format = internal_format; diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h index 5737e8de0..592ea06f0 100644 --- a/cogl/cogl-texture-private.h +++ b/cogl/cogl-texture-private.h @@ -124,7 +124,7 @@ struct _CoglTextureVtable void (* set_wrap_mode_parameters) (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r); + GLenum wrap_mode_p); CoglPixelFormat (* get_format) (CoglTexture *tex); GLenum (* get_gl_format) (CoglTexture *tex); @@ -198,7 +198,7 @@ void _cogl_texture_set_wrap_mode_parameters (CoglHandle handle, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r); + GLenum wrap_mode_p); void diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c index 1e35df6b5..447182bc7 100644 --- a/cogl/cogl-texture-rectangle.c +++ b/cogl/cogl-texture-rectangle.c @@ -151,7 +151,7 @@ static void _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex); diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 7e8087933..519c29d24 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -267,14 +267,14 @@ void _cogl_texture_set_wrap_mode_parameters (CoglHandle handle, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTexture *tex = COGL_TEXTURE (handle); tex->vtable->set_wrap_mode_parameters (tex, wrap_mode_s, wrap_mode_t, - wrap_mode_r); + wrap_mode_p); } /* This is like CoglSpanIter except it deals with floats and it diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c index ea7399d3b..bea72883a 100644 --- a/cogl/cogl-vertex-buffer.c +++ b/cogl/cogl-vertex-buffer.c @@ -1682,10 +1682,10 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; } - if (_cogl_material_layer_get_wrap_mode_r (layer) == + if (_cogl_material_layer_get_wrap_mode_p (layer) == COGL_MATERIAL_WRAP_MODE_AUTOMATIC) { - options.wrap_mode_overrides.values[i].r = + options.wrap_mode_overrides.values[i].p = COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; } diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c index 4af893c7b..70a42a957 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/winsys/cogl-texture-pixmap-x11.c @@ -1286,7 +1286,7 @@ static void _cogl_texture_pixmap_x11_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_s, GLenum wrap_mode_t, - GLenum wrap_mode_r) + GLenum wrap_mode_p) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); CoglHandle child_tex; @@ -1297,7 +1297,7 @@ _cogl_texture_pixmap_x11_set_wrap_mode_parameters (CoglTexture *tex, _cogl_texture_set_wrap_mode_parameters (child_tex, wrap_mode_s, wrap_mode_t, - wrap_mode_r); + wrap_mode_p); } static CoglPixelFormat