The GLES 2 wrapper needs to set up some state before each
draw. Previously this was acheived by wrapping glDrawArrays. Since the
multiple-texture-rectangle branch merge, glDrawElements is used
instead so we also need a wrapper for that.
It was also directly calling glBindTexture. GLES 2 uses a wrapper for
this function so that it can cope with GL_ALPHA format textures. The
format of the current texture needs to be stored as well as the target
and object number for this to work.
For the asynchronous loading we need a function call that parses
a file, given its path, and retrieves the image width and height.
This commit adds cogl_bitmap_get_size_from_file() to the CoglBitmap
API.
* animatable-iface:
[docs] Add ClutterAnimatable to the API reference
Add license notice to ClutterAnimation files
[animation] Use ClutterAnimatable inside Animation
[animation] Add ClutterAnimatable
Bug 1289 - Draw multiple glyphs at once
The multiple-texture-rectangle branch adds a new Cogl texture function
called cogl_texture_multiple_rectangles which is used to draw multiple
rectangles out of a texture using a single GL call. This is
significantly faster than drawing the rectangles with individual calls
on some platforms. The Pango renderer now uses this to speed up
rendering.
The conflicts are just due to the whitespace fixes in cb569a5.
Conflicts:
clutter/cogl/gl/cogl-context.c
clutter/cogl/gl/cogl-context.h
clutter/cogl/gl/cogl-texture.c
Merge branch 'text-actor'
* text-actor: (108 commits)
Re-align ClutterText header file
[text] Fix cursor sizing
Comments and whitespace fixes to ClutterText
[docs] Add newly added :single-line-mode accessors
Update the ignore file
[tests] Add text field interactive test
[text] Add single-line-mode to ClutterText
[text] Fix the deletion actions
[text] Use cached length when possible
[tests] Add unit for the ClutterText:password-char property
[docs] Update the Text section
[text] Coalesce text visibility and password character
Allow localizations to change the text direction
Clean up the update_pango_context() function
Pass the PangoContext, not the MainContext
Revert the logic of the PangoContext check
Remove the binding pool entry from the list
Remove BindingPool::list_actions()
Add ClutterActor::create_pango_context()
Rename the PangoContext creation functions
...
The rest of Cogl expects the texture mode to be GL_MODULATE so it
needs to be restored after calling cogl_material_rectangle. Otherwise
cogl_texture_rectangle will fail to blend with the Cogl color properly
and all of the labels will be black.
* units-rework:
[texture] Do not mix fixed point and units values
[tests] Fix the actor detection
[units] Do not use fixed point and units interchangeably
The API has been changed to take an explicit length for the number of
texture coordinates passed, and it's now documented that if there are
more layers to the current material than the number of texture coords
passed, then default coordinates will be generated for the other
layers.
cogl_material_rectangle should now handle the case where a single
sliced texture is supplied as a material layer by falling back to
cogl_texture_rectangle. We are nearly at the point that
cogl_texture_rectangle could be deprecated. A few issues remain
though, such as not considering waste in cogl_material_rectangle.
The other colors of a material; such as the ambient and diffuse color are
only relevent when we can enable lighting. This adds a basic unlit
color property.
Later cogl_set_source_color can be integrated to either modify the color
of the current source material, or maintain a special singlton CoglMaterial
that is modified by calls to cogl_set_source_color and implicitly made
current.
This flattens the three functions: cogl_material_flush_gl_material_state,
.._flush_gl_alpha_func and .._flush_gl_blend_func into one:
cogl_flush_material_gl_state which doesn't takes a material handle. (the handle
is instead taken from the context.)
This has allows us to avoid re-submitting some state to OpenGL when the
material has not been replaced.
Note: Avoiding redundant state changes for material layers isn't dealt with
in this patch.
Removed trailing white space from the following files:
- clutter-clone-texture.c
- clutter-texture.c
- clutter-texture.h
- cogl/cogl-texture.h
- cogl/gl/cogl-context.c
- cogl/gl/cogl-texture.c
- cogl/gl/cogl-context.h
test-cogl-material now runs on GLES 1 using the PVR GLES1 SDK (though since
only 2 texture units are supported the third rotating light map doesn't show)
Note: It currently doesn't build for GLES 2.0
My previous work to provide muti-texturing support has been extended into
a CoglMaterial abstraction that adds control over the texture combine
functions (controlling how multiple texture layers are blended together),
the gl blend function (used for blending the final primitive with the
framebuffer), the alpha function (used to discard fragments based on
their alpha channel), describing attributes such as a diffuse, ambient and
specular color (for use with the standard OpenGL lighting model), and
per layer rotations. (utilizing the new CoglMatrix utility API)
For now the only way this abstraction is exposed is via a new
cogl_material_rectangle function, that is similar to cogl_texture_rectangle
but doesn't take a texture handle (the source material is pulled from
the context), and the array of texture coordinates is extended to be able
to supply coordinates for each layer.
Note: this function doesn't support sliced textures; supporting sliced
textures is a non trivial problem, considering the ability to rotate layers.
Note: cogl_material_rectangle, has quite a few workarounds, for a number of
other limitations within Cogl a.t.m.
Note: The GLES1/2 multi-texturing support has yet to be updated to use
the material abstraction.
Multitexturing allows blending multiple layers of texture data when texturing
some geometry. A common use is for pre-baked light maps which can give nice
lighting effects relativly cheaply. Another is for dot-3 bump mapping, and
another is applying alpha channel masks.
The dot-3 bump mapping would be really nice one day, but currently cogl doesn't
support lighting so that's not dealt with in this patch.
notable limitations:
- It can only texture rectangles a.t.m - and like cogl_texture_rectangle there
is no support for rotated texturing.
- Sliced textures are not supported. I think I've figured out how to handle
layers with different slice sizes at least for rectangular geometry, but I'm
not sure how complex it becomes once rotations are possible and texturing
arbitrary cogl_polygons.
- Except for this new API, cogl still doesn't know about more than one texture
unit, and so has no way of caching any enables related to other units. So that
things don't break it's currently necessary to disable anything to do with
additional units as soon as we are done with them which isn't ideal.
- No clutter API yet.
* cairo-texture:
[cairo-texture] Remove the construct only restriction on surface size
[cairo-texture] Silently discard 0x0 surfaces
Re-indent ClutterPath header
Add a test case for the new cairo path functions
Add clutter_path_to_cairo_path and clutter_path_add_cairo_path
Warn instead of returning in the IN_PAINT check
Small documentation fixes
Print a warning when creating a cairo_t while painting
Do not set the IN_PAINT flag inside the Stage paint
Set the IN_PAINT private flag
[docs] Add ClutterCairoTexture to the API reference
Add ClutterCairoTexture
Require Cairo as a Clutter dependency
Conflicts:
Fix merge conflict in clutter/clutter-path.h
* clutter/cogl/gl/cogl-defines.h.in:
* clutter/cogl/gl/cogl-context.h:
* clutter/cogl/common/cogl-mesh.c: Rename the glBufferDataSub
function to glBufferSubData. When calling glXGetProcAddress with
the former Mesa returns a stub dispatch function which will
segfault if you try to use it. With NVIDIA it returns NULL so
_cogl_features_init decides the card doesn't have VBO support.
There's no point in clearing the index array because it is always the
same sequence of indices regardless of the vertices. Instead it is
just added to when there are more vertices than ever before.
* clutter/cogl/gl/cogl-texture.c (cogl_texture_new_from_foreign,
(_cogl_texture_quad_hw, cogl_texture_polygon),
(_cogl_texture_quad_sw): Support GL_ARB_texture_rectangle textures
* clutter/glx/clutter-glx-texture-pixmap.c: Use rectangle textures
when NPOTs are not available or it is forced by the
CLUTTER_PIXMAP_TEXTURE_RECTANGLE environment variable.
* clutter/cogl/gl/cogl.c (cogl_enable): Allow enabling
GL_TEXTURE_RECTANGLE_ARB.
* clutter/cogl/cogl-path.h:
* clutter/cogl/common/cogl-primitives.c:
* clutter/cogl/common/cogl-primitives.h:
* clutter/cogl/gl/cogl-primitives.c:
* clutter/cogl/gles/cogl-primitives.c: Changed the semantics of
cogl_path_move_to. Previously this always started a new path but
now it instead starts a new disjoint sub path. The path isn't
cleared until you call either cogl_path_stroke, cogl_path_fill or
cogl_path_new. There are also cogl_path_stroke_preserve and
cogl_path_fill_preserve functions.
* clutter/cogl/gl/cogl-context.c:
* clutter/cogl/gl/cogl-context.h:
* clutter/cogl/gles/cogl-context.c:
* clutter/cogl/gles/cogl-context.h: Convert the path nodes array
to a GArray.
* clutter/cogl/gl/cogl-texture.c:
* clutter/cogl/gles/cogl-texture.c: Call cogl_clip_ensure
* clutter/cogl/common/cogl-clip-stack.c:
* clutter/cogl/common/cogl-clip-stack.h: Simplified the clip
stack code quite a bit to make it more maintainable. Previously
whenever you added a new clip it would go through a separate route
to immediately intersect with the current clip and when you
removed it again it would immediately rebuild the entire clip. Now
when you add or remove a clip it doesn't do anything immediately
but just sets a dirty flag instead.
* clutter/cogl/gl/cogl.c:
* clutter/cogl/gles/cogl.c: Taken away the code to intersect
stencil clips when there is exactly one stencil bit. It won't work
with path clips and I don't know of any platform that doesn't have
eight or zero stencil bits. It needs at least three bits to
intersect a path with an existing clip. cogl_features_init now
just decides you don't have a stencil buffer at all if you have
less than three bits.
* clutter/cogl/cogl.h.in: New functions and documentation.
* tests/interactive/test-clip.c: Replaced with a different test
that lets you add and remove clips. The three different mouse
buttons add clips in different shapes. This makes it easier to
test multiple levels of clipping.
* tests/interactive/test-cogl-primitives.c: Use
cogl_path_stroke_preserve when using the same path again.
* doc/reference/cogl/cogl-sections.txt: Document the new
functions.
border artifacts
* clutter/cogl/gl/cogl-texture.c: Set the wrap mode of a texture
on demand
Instead of setting the wrap mode once per texture at creation, it
is now changed whenever the texture is drawn. The previous value
is cached so that it isn't changed if the value is the same.
This is used in _cogl_texture_quad_hw to only enable GL_REPEAT
mode when the coordinates are not in the range [0,1]. Otherwise it
can pull in pixels from the other edge when the texture is
rendered off-pixel.
Most cards don't actually support GL_QUADS and they are deprecated in
GL 3.0 so there is a chance it will perform faster with GL_TRIANGLES
even though it has to submit two extra vertices.
This takes an array of sets of 8 floats to describe the rectangles. It
tries to send the geometry with a single glDrawArrays as far as
possible. cogl_texture_rectangle is now just a wrapper around
cogl_texture_multiple_rectangles.
cogl_texture_quad_hw and _sw now just add vertices to the vertex
array. The last texture used is stored and if a different texture is
encountered then flushes the vertices. cogl_texture_rectangle always
flushes the vertices after calling either of the functions.
the test for whether to use hardware tiling. Previously it assumed
that texture coordinates are in increasing order but this is not
the case since bug 1057 was fixed. The texture coordinates are now
sorted later. It also allowed negative coordinates which doesn't
make sense if the texture has waste.
`_glDrawRangeElements@24'
Resolve glDrawRangeElements with cogl_get_proc_address instead of
calling it directly because functions defined in GL > 1.1 are not
directly exported under Windows.
* clutter/cogl/common/cogl-mesh.c: Use the function pointer from
the context
* clutter/cogl/gl/cogl-context.c (cogl_create_context): Initialise
function pointer.
* clutter/cogl/gl/cogl-context.h (CoglContext): Add a function
pointer
* clutter/cogl/gl/cogl-defines.h.in: Add a typedef for the
function pointer.
* clutter/cogl/gl/cogl.c (_cogl_features_init): Resolve
glDrawRangeElements