This updates cogl/gles in line with the integration of CoglMaterial throughout
Cogl that has been done for cogl/gl.
Note: This is still buggy, but at least it builds again and test-actors works.
Some GLES2 specific changes were made, but these haven't been tested yet.
This changes all GLES code to use the OpenGL function names instead of
the cogl_wrap_* names. For GLES2 we now define the OpenGL name to point
to the wrapper, as opposed to defining the wrapper to point to the
OpenGL name for GLES1.
I've also done a quick pass through gl/cogl.c and gles/cogl.c to make
them more easily comparable. (most of the code is now identical)
The GL blend function and alpha function are now controlled by the material
code, and even internally Cogl should now be using the material API when
it needs control of these.
This glues CoglMaterial in as the fundamental way that Cogl describes how to
fill in geometry.
It adds cogl_set_source (), which is used to set the material which will be
used by all subsequent drawing functions
It adds cogl_set_source_texture as a convenience for setting up a default
material with a single texture layer, and cogl_set_source_color is now also
a convenience for setting up a material with a solid fill.
"drawing functions" include, cogl_rectangle, cogl_texture_rectangle,
cogl_texture_multiple_rectangles, cogl_texture_polygon (though the
cogl_texture_* funcs have been renamed; see below for details),
cogl_path_fill/stroke and cogl_vertex_buffer_draw*.
cogl_texture_rectangle, cogl_texture_multiple_rectangles and
cogl_texture_polygon no longer take a texture handle; instead the current
source material is referenced. The functions have also been renamed to:
cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords
and cogl_polygon respectivly.
Most code that previously did:
cogl_texture_rectangle (tex_handle, x, y,...);
needs to be changed to now do:
cogl_set_source_texture (tex_handle);
cogl_rectangle_with_texture_coords (x, y,....);
In the less likely case where you were blending your source texture with a color
like:
cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */
cogl_texture_rectangle (tex_handle, x, y,...);
you will need your own material to do that:
mat = cogl_material_new ();
cogl_material_set_color4ub (r,g,b,a);
cogl_material_set_layer (mat, 0, tex_handle));
cogl_set_source_material (mat);
Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use
cog_rectangle_with_texure_coords since these are the coordinates that
cogl_rectangle will use.
For cogl_texture_polygon; as well as dropping the texture handle, the
n_vertices and vertices arguments were transposed for consistency. So
code previously written as:
cogl_texture_polygon (tex_handle, 3, verts, TRUE);
need to be written as:
cogl_set_source_texture (tex_handle);
cogl_polygon (verts, 3, TRUE);
All of the unit tests have been updated to now use the material API and
test-cogl-material has been renamed to test-cogl-multitexture since any
textured quad is now technically a test of CoglMaterial but this test
specifically creates a material with multiple texture layers.
Note: The GLES backend has not been updated yet; that will be done in a
following commit.
Step two: rename the object and its methods.
While we're at it, adhere more strictly to the coding style
practises; rename :clone-source to :source; add a setter method
for the :source property; take a reference on the source actor
to avoid it disappearing while we're still accessing it.
Like clutter_timeline_advance(), calling advance_to_marker() will
not emit ::new-frame for the frame where the marker is set on; it
will also not emit ::marker-reached for the marker we are advancing
the timeline to.
When calling clutter_timeline_advance(), a timeline will not emit
the ::new-frame signal for the frame we are advancing to, as this
would break the invariants of the timeline behaviour.
The documentation should make this clear.
The clutter_timeline_new() constructor is not checking the full
range of the passed :fps property. The ParamSpec of the property
and the setter method perform this check, so the ctor should as
well.
The "is-timeline-complete" condition is pretty long, spanning
four lines and four logical sub-conditions. It is possible to
neatly move it into an is_complete() function and make the
code more readable.
The long description of the ClutterTimeline class is very C
developer-oriented. Since many language bindings will refer to
the C API reference we should probably be more verbose and
language agnostic -- at least in the class description.
The methods documentation also requires a little pass to increase
the consistency of the terminology, the grammar and the syntax.
Finally, comments never killed anyone.
Since not every timeline will have markers it's unfair to make
all of them crete two empty hash tables (with a preallocated
fixed size).
This commit moves the responsibility of creating the hash tables
to the marker API itself, and adds the relative checks.
Since we are using milliseconds granularity to integrate timelines
with the GLib main loop, we cannot allow values of the :fps
property bigger than 1000. This means validating the fps value both
in the GParamSpec and the clutter_timeline_set_speed() accessor
function.
This should also fix floating point exceptions when trying to
perform "n_frames = milliseconds / (1000 / fps)".
See bug 1354:
http://bugzilla.openedhand.com/show_bug.cgi?id=1354
If a ClutterTexture does not sync size, it should be possible to
change the texture size without causing a relayout.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
There is some GL work and a repaint anytime the clip is set
or unset, so avoid that if it isn't really changed.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
The stage will usually be painted before the first ConfigureNotify
arrives so we need to set the SYNC_MATRICES flag to ensure that the
viewport will be correct for that paint. Unfortunately this means that
the viewport will be set again once the ConfigureNotify is received
but compared to rendering an initial invalid scene I think it is the
lesser of two evils.
When calling clutter_behaviour_apply() the new actor is prepended
to the list of actors to which a behaviour is applied; this breaks
the rest of methods working on the actors list, e.g.:
# adding actors
apply(actor_0);
apply(actor_1);
apply(actor_2);
# expected: [ actor_0, actor_1, actor_2 ]
[ actor_2, actor_1, actor_0 ] = get_actors();
# expected: actor_2
actor_0 = get_nth_actor(2);
This commit fixes the inconsistency in the returned values.
The Cogl primitives broke for GLES 1.1 and 2 after the cogl-float
branch merge.
CoglPathNode was still being declared as GLfixed for the GLES backend
but it was being filled with float values so they were all ending up
as numbers < 1.
glDrawArrays was being called with GL_FIXED so this has been changed
to GL_FLOAT.
The scanline rasterizer had a leftover hardcoded ClutterFixed constant
to add a small amount to the height of each line.
struct _CoglFloatVec2 has been removed because it is no longer used
anywhere.
This removes a lot of code from test-cogl-primitives to make it easier
to follow. The TestCoglBox custom actor has gone and instead a blank
ClutterGroup is created with a paint signal handler.
Instead of rendering constantly and updating when a GTimer elapses a
second, a ClutterTimeline is used with 1 fps and a new redraw is
queued every frame.
The custom main loop is replaced with a regular call to clutter_main.
This fixes the close button of the stage window so you can quit
without having to press Ctrl+C.
The special check to invert the progress when the timeline direction
is backwards is not necessary because the actual frame number will be
decreasing in that case. Inverting just makes it progress forwards
again.
This is more apparent since the float-alpha-value branch merge because
the clutter_linear function directly returns the value from
get_progress. For example in test-depth, the animations loop instead
of oscillating back and forth.
The documentation has been updated to reflect the fact that the anchor
point will move when the actor changes size if it was specified using
a gravity value. The new functions for setting the scale center and z
rotation gravity are also documented.
The rotation centers are now tested in a similar way to the anchor
point and scale centers.
The notification handling code has been simplified a bit to handle the
increased amount of properties.
Currently only the Z axis rotation center can be set using a gravity
but the other rotations also store their center as an AnchorCoord for
consistency. Specifying the center as a gravity makes less sense for
the other axes because the actors have no size along the Z axis.
The rotation angles are now stored as gdoubles and the fixed point *x
entry points have been removed.
The Z rotation can now be set with a gravity center using the
following new function:
void clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
gdouble angle,
ClutterGravity gravity);
This sets the center point from which the scaling will occur. This can
be used insetad of the anchor point to avoid moving the actor. Like
the anchor point, it can be specified as either a coordinate in units
or a gravity enum.
To set the center you can use two new variants of set_scale:
clutter_actor_set_scale_full (ClutterActor *self,
gdouble scale_x,
gdouble scale_y,
int center_x,
int center_y);
or
clutter_actor_set_scale_with_gravity (ClutterActor *self,
gdouble scale_x,
gdouble scale_y,
ClutterGravity gravity);
The ClutterFixed variants of the set_scale functions have been removed
and the scale value is now always stored as a double.
This makes it so when the anchor point is set using a gravity enum
then the anchor point moves when the actor changes size. A new
property is added for the anchor point gravity. If the anchor point is
set from gravity then the position in units can also be retreived with
the regular API.
A new union type is used to store the anchor point with helper
accessor functions. The hope is these can be reused for the scale and
rotation center points.
The clutter_stage_get_resolution() and fixed-point API are just
shorthands for:
clutter_backend_get_resolution (default_backend);
And as such do not fit at all in the ClutterStage class. The only
reason for their existence was the ClutterUnit conversion macros,
which have now been fixed to use the default backend through a
function call instead.
Thus, we can safely remove the stage entry points.
Since we override the clean-generic target in order to remove
the shell scripts we create for each conformance test unit, we
cannot use CLEANFILES to remove the test reports.
The maintainer compiler flags we use trigger warnings and errors
in the autogenerated code that gtk-doc creates to scan the header
and source files. Since we cannot control that, and we must run
a distcheck with both --enable-gtk-doc and --enable-maintainer-flags
turned on, we need to use less-strict compiler flags when inside
the doc/reference subdirectories.
The way to do this is to split the maintainer compiler flags into
their own Makefile variable, called MAINTAINER_CFLAGS. The we
can use $(MAINTAINER_CFLAGS) in the INCLUDES or _CFLAGS sections
of each part of the source directories we wish to check with the
anal retentiveness suited for maintainers.
* float-alpha-value:
[script] Parse easing modes by name
[docs] Update the easing modes documentation
[animation] Implement new easing functions
[animation] Move the alpha value to floating point
Since we allow overriding the paint() implementation through the
::paint signal to change the way an actor is being painted, we
should also allow overriding the pick() implementation using a
::pick signal.
The script converted calls to COGL_FIXED_MUL(x,y) to (x*y). However
this fails for cases like this:
COGL_FIXED_MUL(a + b, c)
which become
(a + b * c)
The meaning of this is of course different because multiplication has
a higher precedence than addition.
This was causing breakages in cogl_texture_quad_sw when the vertex
coordinates are not in increasing order. This was the case in
test-backface-culling when NPOTs are not available.
Improve clutter_sinx() by replacing the low precision CFX_SIN_STEP
with a multiply/divide pair. This reduces the maximum error from
1.8e-04 to 2.4e-05.
http://bugzilla.openedhand.com/show_bug.cgi?id=1314
Based on a patch by Owen W. Taylor <otaylor@fishsoup.net>
Since a pick is really a paint operation, we can safely get
the allocation box, instead of using get_width() and get_height().
This should help cutting down the function calls. If we were
feeling adventurous, we could even use the allocation directly
from the private data structure.
Based on a patch by Gwenole Beauchesne <gbeauchesne@splitted-desktop.org>
Compute the value of the camera distance as exactly half the xx
component of the projection matrix. The heuristically derived
value for 60 degrees was off by about 0.016%, causing noticeable
blurring, and other field of view angles which didn't have the
heuristic adjustment off by much more.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
If an actor is not set as visible, or if it is in a section of
the scenegraph that it's set as not visible (e.g. one of the
parents is not visible) then we should not queue a redraw for
it.
Patch based on code from Michael Boccara <michael@graphtech.co.il>
The intention behind ::queue-redraw is to be able to block the
default handler by attaching a callback and calling one of the
g_signal_stop_emission variants.
However this doesn't work, because ::queue-redraw has the
G_SIGNAL_RUN_FIRST flag instead of G_SIGNAL_RUN_LAST.