Argument names and @$arg suffered from various little mismatches, fix
them in a batch commit.
(cherry picked from commit d2ac3c5a88d980e7519c98bd261111b93cf73a6e)
When multiplying two quaternions, we now implicitly copy the components
of the 'a' argument so that the result can be reliably written back to
the 'a' argument quaternion without conflicting with the multiplication
itself. This is consistent with the cogl_matrix_multiply() api which
allows the 'result' and 'a' arguments to point to the same matrix. In
debug builds Cogl will assert that the 'b' and 'result' arguments don't
point to the same quaternion.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 207527313a8957789390069e84189254cf41e88f)
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
This option to GCC makes it give a warning whenever a global function
is defined without a declaration. This should catch cases were we've
defined a function but forgot to put it in a header. In that case it
is either only used within one file so we should make it static or we
should declare it in a header.
The following changes where made to fix problems:
• Some functions were made static
• cogl-path.h (the one containing the 1.0 API) was split into two
files, one defining the functions and one defining the enums so that
cogl-path.c can include the enum and function declarations from the
2.0 API as well as the function declarations from the 1.0 API.
• cogl2-clip-state has been removed. This only had one experimental
function called cogl_clip_push_from_path but as this is unstable we
might as well remove it favour of the equivalent cogl_framebuffer_*
API.
• The GLX, SDL and WGL winsys's now have a private header to define
their get_vtable function instead of directly declaring in the C
file where it is called.
• All places that were calling COGL_OBJECT_DEFINE need to have the
cogl_is_whatever function declared so these have been added either
as a public function or in a private header.
• Some files that were not including the header containing their
function declarations have been fixed to do so.
• Any unused error quark functions have been removed. If we later want
them we should add them back one by one and add a declaration for
them in a header.
• _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and
made a public function with a declaration in cogl-framebuffer.h
• Similarly for CoglOnscreen.
• cogl_vdraw_indexed_attributes is called
cogl_framebuffer_vdraw_indexed_attributes in the header. The
definition has been changed to match the header.
• cogl_index_buffer_allocate has been removed. This had no declaration
and I'm not sure what it's supposed to do.
• CoglJournal has been changed to use the internal CoglObject macro so
that it won't define an exported cogl_is_journal symbol.
• The _cogl_blah_pointer_from_handle functions have been removed.
CoglHandle isn't used much anymore anyway and in the few places
where it is used I think it's safe to just use the implicit cast
from void* to the right type.
• The test-utils.h header for the conformance tests explicitly
disables the -Wmissing-declaration option using a pragma because all
of the tests declare their main function without a header. Any
mistakes relating to missing declarations aren't really important
for the tests.
• cogl_quaternion_init_from_quaternion and init_from_matrix have been
given declarations in cogl-quaternion.h
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The cogl.h header is meant to be the public header for including the 1.x
api used by Clutter so we should stop using that as a convenient way to
include all likely prototypes and typedefs. Actually we already do a
good job of listing the specific headers we depend on in each of the .c
files we have so mostly this patch just strip out the redundant
includes for cogl.h with a few fixups where that broke the build.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
So we can get to the point where cogl.h is merely an aggregation of
header includes for the 1.x api this moves all the function prototypes
and type definitions into a cogl-context.h and a new cogl1-context.h.
Ideally no code internally should ever need to include cogl.h as it just
represents the public facing header for accessing the 1.x api which
should only be used by Clutter.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
It proved to be inconvenient that we had a special CoglVector3 typedef
for vectors instead of just accepting pointers to float arrays because
you'd so often end up having to make awkward casts from another vector
type into a CoglVector3 and then cast back again. We're hoping that
taking float pointers instead will lead to less unnecessary casting.
Since we've had several developers from admirable projects say they
would like to use Cogl but would really prefer not to pull in
gobject,gmodule and glib as extra dependencies we are investigating if
we can get to the point where glib is only an optional dependency.
Actually we feel like we only make minimal use of glib anyway, so it may
well be quite straightforward to achieve this.
This adds a --disable-glib configure option that can be used to disable
features that depend on glib.
Actually --disable-glib doesn't strictly disable glib at this point
because it's more helpful if cogl continues to build as we make
incremental progress towards this.
The first use of glib that this patch tackles is the use of
g_return_val_if_fail and g_return_if_fail which have been replaced with
equivalent _COGL_RETURN_VAL_IF_FAIL and _COGL_RETURN_IF_FAIL macros.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
In cogl_quaternion_init_from_array we were passing the address of the x
component as the destination for memcpy, but that was wrong at least
because w is actually the first member in the structure. Another
concern raised was whether it was safe to assume that there was no
padding within the CoglQuaternion struct with some compilers so we also
switch to explicitly indexing each element of the array we want to copy.
In practice I think it's pretty safe to assume that padding will only be
introduced to ensure members are naturally aligned, but being explicit
is readable and it can't hurt to be extra cautious.
Another good catch in bug #655228 was that in
cogl_quaternion_get_rotation_axis we had a copy and paste error at the
end where we finally extract the axis and we were repeatedly calculating
just the x component. Now we calculate the y and z components too.
Thanks to Bug #655228 for identifying these issues.
https://bugzilla.gnome.org/show_bug.cgi?id=655228
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds an experimental CoglEuler data type and the following new
functions:
cogl_euler_init
cogl_euler_init_from_matrix
cogl_euler_init_from_quaternion
cogl_euler_equal
cogl_euler_copy
cogl_euler_free
cogl_quaternion_init_from_euler
Since this is experimental API you need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h
This adds an experimental quaternion utility API. It's not yet fully
documented but it's complete enough that people can start to experiment
with using it. It adds the following functions:
cogl_quaternion_init_identity
cogl_quaternion_init
cogl_quaternion_init_from_angle_vector
cogl_quaternion_init_from_array
cogl_quaternion_init_from_x_rotation
cogl_quaternion_init_from_y_rotation
cogl_quaternion_init_from_z_rotation
cogl_quaternion_equal
cogl_quaternion_copy
cogl_quaternion_free
cogl_quaternion_get_rotation_angle
cogl_quaternion_get_rotation_axis
cogl_quaternion_normalize
cogl_quaternion_dot_product
cogl_quaternion_invert
cogl_quaternion_multiply
cogl_quaternion_pow
cogl_quaternion_slerp
cogl_quaternion_nlerp
cogl_quaternion_squad
cogl_get_static_identity_quaternion
cogl_get_static_zero_quaternion
Since it's experimental API you'll need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h.