e007bc5358
Previously, Cogl's texture coordinate system was effectively always GL_REPEAT so that if an application specifies coordinates outside the range 0→1 it would get repeated copies of the texture. It would however change the mode to GL_CLAMP_TO_EDGE if all of the coordinates are in the range 0→1 so that in the common case that the whole texture is being drawn with linear filtering it will not blend in edge pixels from the opposite sides. This patch adds the option for applications to change the wrap mode per layer. There are now three wrap modes: 'repeat', 'clamp-to-edge' and 'automatic'. The automatic map mode is the default and it implements the previous behaviour. The wrap mode can be changed for the s and t coordinates independently. I've tried to make the internals support setting the r coordinate but as we don't support 3D textures yet I haven't exposed any public API for it. The texture backends still have a set_wrap_mode virtual but this value is intended to be transitory and it will be changed whenever the material is flushed (although the backends are expected to cache it so that it won't use too many GL calls). In my understanding this value was always meant to be transitory and all primitives were meant to set the value before drawing. However there were comments suggesting that this is not the expected behaviour. In particular the vertex buffer drawing code never set a wrap mode so it would end up with whatever the texture was previously used for. These issues are now fixed because the material will always set the wrap modes. There is code to manually implement clamp-to-edge for textures that can't be hardware repeated. However this doesn't fully work because it relies on being able to draw the stretched parts using quads with the same values for tx1 and tx2. The texture iteration code doesn't support this so it breaks. This is a separate bug and it isn't trivially solved. When flushing a material there are now extra options to set wrap mode overrides. The overrides are an array of values for each layer that specifies an override for the s, t or r coordinates. The primitives use this to implement the automatic wrap mode. cogl_polygon also uses it to set GL_CLAMP_TO_BORDER mode for its trick to render sliced textures. Although this code has been added it looks like the sliced trick has been broken for a while and I haven't attempted to fix it here. I've added a constant to represent the maximum number of layers that a material supports so that I can size the overrides array. I've set it to 32 because as far as I can tell we have that limit imposed anyway because the other flush options use a guint32 to store a flag about each layer. The overrides array ends up adding 32 bytes to each flush options struct which may be a concern. http://bugzilla.openedhand.com/show_bug.cgi?id=2063 |
||
---|---|---|
.. | ||
driver | ||
winsys | ||
cogl-atlas-texture-private.h | ||
cogl-atlas-texture.c | ||
cogl-atlas.c | ||
cogl-atlas.h | ||
cogl-bitmap-fallback.c | ||
cogl-bitmap-pixbuf.c | ||
cogl-bitmap-private.h | ||
cogl-bitmap.c | ||
cogl-bitmap.h | ||
cogl-blend-string.c | ||
cogl-blend-string.h | ||
cogl-buffer-private.h | ||
cogl-buffer.c | ||
cogl-buffer.h | ||
cogl-clip-stack.c | ||
cogl-clip-stack.h | ||
cogl-color.c | ||
cogl-color.h | ||
cogl-context.c | ||
cogl-context.h | ||
cogl-debug.c | ||
cogl-debug.h | ||
cogl-deprecated.h | ||
cogl-enum-types.c.in | ||
cogl-enum-types.h.in | ||
cogl-feature-private.c | ||
cogl-feature-private.h | ||
cogl-fixed.c | ||
cogl-fixed.h | ||
cogl-framebuffer-private.h | ||
cogl-framebuffer.c | ||
cogl-handle.h | ||
cogl-internal.h | ||
cogl-journal-private.h | ||
cogl-journal.c | ||
cogl-material-private.h | ||
cogl-material.c | ||
cogl-material.h | ||
cogl-matrix-mesa.c | ||
cogl-matrix-mesa.h | ||
cogl-matrix-private.h | ||
cogl-matrix-stack.c | ||
cogl-matrix-stack.h | ||
cogl-matrix.c | ||
cogl-matrix.h | ||
cogl-offscreen.h | ||
cogl-path-private.h | ||
cogl-path.c | ||
cogl-path.h | ||
cogl-pixel-buffer-private.h | ||
cogl-pixel-buffer.c | ||
cogl-pixel-buffer.h | ||
cogl-primitives.c | ||
cogl-primitives.h | ||
cogl-profile.c | ||
cogl-profile.h | ||
cogl-shader.h | ||
cogl-spans.c | ||
cogl-spans.h | ||
cogl-sub-texture-private.h | ||
cogl-sub-texture.c | ||
cogl-texture-2d-private.h | ||
cogl-texture-2d-sliced-private.h | ||
cogl-texture-2d-sliced.c | ||
cogl-texture-2d.c | ||
cogl-texture-driver.h | ||
cogl-texture-private.h | ||
cogl-texture.c | ||
cogl-texture.h | ||
cogl-types.h | ||
cogl-util.c | ||
cogl-util.h | ||
cogl-vertex-buffer-private.h | ||
cogl-vertex-buffer.c | ||
cogl-vertex-buffer.h | ||
cogl.c | ||
cogl.h | ||
cogl.pc.in | ||
Makefile.am | ||
stb_image.c |