Commit Graph

871 Commits

Author SHA1 Message Date
Damien Lespiau
e157971cd8 debug: Allow to compile a debug Cogl without cairo
For people still wanting the debugging code, but don't have or don't
want to compile cairo for their platform.
2011-05-17 15:24:54 +01:00
Damien Lespiau
f436582114 android: Add support for an EGL/Android winsys
The native window type of the EGL/Android winsys is ANativeWinow*. The
Android NDK gives you a pointer to this ANativeWindow and you just need
to configure that window using the EGLConfig you are choosing when
creating the context.

This means you have to know the ANativeWindow* window before creating
the context. This is solved here by just having a global variable you
can set with cogl_android_set_native_window() before creating the
context. This is a bit ugly though, and it conceptually belongs to the
OnScreen creation to know which ANativeWindow* to use. This would need a
"lazy context creation" mechanism, waiting for the user to create the
OnScreen to initialize the GL context.
2011-05-17 15:24:54 +01:00
Damien Lespiau
bde6979c06 framebuffer: Checks if glBindFramebuffer() exists when using GLES1
With GLES 1, frame buffers are a optional extensions. We need to make
sure the pointer exist before calling the function and do that by just
checkout the corresponding feature.
2011-05-17 15:24:54 +01:00
Damien Lespiau
d384466a58 winsys-egl: Use g_clear_error() between two context creation tries
When try_create_context() returns saying that it has to be run again to
try to create a context with an alternate configuration, it might not
have a GError set (and in fact it does not right now).
g_clear_error() handles that case where error is still NULL;
2011-05-17 15:24:54 +01:00
Damien Lespiau
051e6da887 misc: Add the single include guard to cogl-define.h
This is a generated file and maybe the reason why it was not included
the first time?
2011-05-17 15:24:54 +01:00
Damien Lespiau
dd5a1c888b gles1: Include GLES/egl.h or EGL/egl.h depending on the implementation
Early implementations provided only a GLES/egl.h while Khronos's
implementer guide now states EGL/egl.h is the One. Some implementations
keep a GLES/egl.h wrapper around EGL/egl.h for backward compatibility
while others provide EGL/egl.h only.

Also took the opportunity to factorize a bit this inclusion in
cogl-defines.h.
2011-05-17 15:24:54 +01:00
Robert Bragg
cb7433cce9 Adds missing cogl-depth-state-private.h
This file was accidentally missed in the last commit
2011-05-16 18:45:51 +01:00
Robert Bragg
07c0b9f89f Add CoglDepthState API
Instead of simply extending the cogl_pipeline_ namespace to add api for
controlling the depth testing state we now break the api out. This adds
a CoglDepthState type that can be stack allocated. The members of the
structure are private but we have the following API to setup the state:

    cogl_depth_state_init
    cogl_depth_state_set_test_enabled
    cogl_depth_state_get_test_enabled
    cogl_depth_state_set_test_function
    cogl_depth_state_get_test_function
    cogl_depth_state_set_writing_enabled
    cogl_depth_state_get_writing_enabled
    cogl_depth_state_set_range
    cogl_depth_state_get_range

This removes the following experimental API which is now superseded:

    cogl_material_set_depth_test_enabled
    cogl_material_get_depth_test_enabled
    cogl_material_set_depth_test_function
    cogl_material_get_depth_test_function
    cogl_material_set_depth_writing_enabled
    cogl_material_get_depth_writing_enabled
    cogl_material_set_depth_range
    cogl_material_get_depth_range

Once a CoglDepthState structure is setup it can be set on a pipeline
using cogl_pipeline_set_depth_state().
2011-05-16 18:36:44 +01:00
Neil Roberts
eb109e6cc0 cogl-primitive: Fix some broken changes for removal of NULL terminator
Commit 3c1e83c7 changed uses of arrays of CoglAttributes to take a
length instead of being NULL terminated. In cogl_primitive_new it was
still adding the NULL terminator to the array it passes to
cogl_primitive_new_with_attributes but then it was also including this
terminator in the count so it would just segfault when it tries to ref
the NULL pointer. Also _cogl_primitive_new_with_attributes_unref was
still trying to detect the NULL terminator so it would also crash.
2011-05-16 18:34:22 +01:00
Robert Bragg
47da69cc3e doc: fix the name of the cogl_quaternion_equal args 2011-05-16 17:08:30 +01:00
Neil Roberts
a466dc272b Don't include cogl-pango.h when scanning introspection data
cogl/cogl-pango.h can't be included unless the include directory for
Pango is given in the compiler flags. In an application, it is
expected that if they are using this header then they would pull in
cogl-pango-1.0.pc which would provide this. However when building Cogl
itself we might be building without Pango support so the Makefile
can't rely on PANGO_CFLAGS. This was breaking building the
introspection data because cogl-pango.h was listed as one of the files
to scan but it can't be included.
2011-05-16 15:41:25 +01:00
Robert Bragg
3c1e83c7f5 Don't pass around NULL terminated CoglAttribute arrays
For the first iteration of the CoglAttribute API several of the new
functions accepted a pointer to a NULL terminated list of CoglAttribute
pointers - probably as a way to reduce the number of arguments required.
This style isn't consistent with existing Cogl APIs though and so we now
explicitly pass n_attributes arguments and don't require the NULL
termination.
2011-05-16 14:32:37 +01:00
Robert Bragg
bf7653ac93 Rename CoglIndexArray to CoglIndexBuffer
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to strongly imply a relationship between
CoglBuffers and CoglIndexBuffers and be consistent with the
CoglAttributeBuffer and CoglPixelBuffer APIs.
2011-05-16 14:31:31 +01:00
Robert Bragg
c328e0608f Rename CoglPixelArray to CoglPixelBuffer
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to strongly imply a relationship between
CoglBuffers and CoglPixelBuffers and be consistent with the
CoglAttributeBuffer and CoglIndexBuffer APIs.
2011-05-16 14:31:31 +01:00
Robert Bragg
ce7c06dc03 Rename CoglVertexArray to CoglAttributeBuffer
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to have a strongly implied relationship
between CoglAttributes and CoglAttributeBuffers.
2011-05-16 14:31:31 +01:00
Robert Bragg
2da24ab863 Add compile time checks for size of public structs
To help catch accidental changes to the size of public structs that can
be allocated on the stack this patch adds compile time checks that our
struct sizes haven't changed.
2011-05-16 14:12:49 +01:00
Robert Bragg
df1915d957 math: Adds an experimental euler API
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
2011-05-16 14:12:42 +01:00
Robert Bragg
d1434d1c33 math: Adds an experimental quaternion API
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.
2011-05-16 14:11:47 +01:00
Robert Bragg
b316241612 deprecate #include <cogl/cogl-pango.h>
cogl-pango is conceptually a separate library so it doesn't seem
appropriate to bundle the headers with all the other cogl headers. Also
in-tree the headers live in a cogl-pango directory so if we want
examples that can include cogl-pango consistently when built in or out
of tree using the convention #include <cogl-pango/cogl-pango.h> makes
that easy.

This adds a compatibility cogl/cogl-pango.h header that's will redirect
to cogl-pango/cogl-pango.h with a warning, or result in an error if
COGL_ENABLE_EXPERIMENTAL_2_0_API is defined.
2011-05-16 13:28:17 +01:00
Robert Bragg
89e46a472f framebuffer: check we have a draw/read_buffer before freeing
When freeing a framebuffer stack it's possible to have entries with NULL
draw or read buffers so we should check that before calling
cogl_onscreen/offscreen_free. This fixes a crash with the wayland
backend when running conformance tests such as cogl-test-object which
never push a framebuffer.
2011-05-11 16:46:56 +01:00
Robert Bragg
2282455f27 wayland: Allow setting foreign display/compositor
To support toolkits targeting wayland and using Cogl we allow toolkits
to be responsible for connecting to a wayland display and asking Cogl to
use the toolkit owned display and compositor object. Note: eventually
the plan is that wayland will allow retrospective querying of objects so
we won't need the foreign compositor API when Cogl can simply query it
from the foreign display.
2011-05-11 16:46:52 +01:00
Robert Bragg
653d59af04 Explicitly set EGL_PLATFORM=wayland for wayland winsys
The EGL API doesn't provide for a way to explicitly select a platform
when the driver can support multiple. Mesa allows selection using an
EGL_PLATFORM environment variable though so we set that to "wayland"
when we know that's what we want.
2011-05-11 16:44:08 +01:00
Neil Roberts
442d4586b7 win32: Use the right macro name for COGL_HAS_WIN32_SUPPORT
Some places were using COGL_HAS_WIN32 but the only macro defined is
COGL_HAS_WIN32_SUPPORT. The similar macros such as COGL_HAS_XLIB are
only defined for compatibility with existing code but COGL_HAS_WIN32
was never defined so there's no need to support it.

One of the places was including the non-existant cogl-win32.h. This
has been removed because the file only temporarily existed during
development of the backend.
2011-05-11 15:20:59 +01:00
Neil Roberts
a075f4498b cogl-pipeline-fragend-arbfp: Fix the comparison for dot3 arguments
There was a typo in fragend_arbfp_args_equal so that it wasn't
comparing the constants correctly.

Thomas Wood found this bug with static analysis.
2011-05-11 13:50:32 +01:00
Neil Roberts
cdfad9cdbe cogl-vertex-buffer: Fix the size of the array of attribute pointers
In update_primitive_attributes it tries to fill in an array of
pointers with a NULL terminator. However it was only allocating enough
space for a pointer for each of the attributes plus one byte instead
of plus enough bytes for another pointer.

Thomas Wood found this bug with static analysis.
2011-05-11 13:43:02 +01:00
Neil Roberts
463603f1a0 cogl-winsys: Fix freeing a CoglOnscreen
All of the winsys backends didn't handle cleaning up the CoglOnscreen
properly so that they would assert in cogl_onscreen_free because the
winsys pointer is never freed. They also didn't cope if deinit is
called before init (which will be the case if an onscreen is created
and freed without being allocated).
2011-05-10 20:23:39 +01:00
Neil Roberts
6654533e40 cogl-winsys-wgl: Plug leak on error from SetPixelFormat
When SetPixelFormat fails, the DC would get released but none of the
other resources would be freed. This patch makes it call
_cogl_winsys_onscreen_deinit on failure to clean up all of the
resources. The patch looks big because it moves the onscreen_deinit
and onscreen_bind functions.
2011-05-10 19:53:00 +01:00
Neil Roberts
6788c80342 Add a WGL winsys
This adds a full winsys to handle WGL and Win32.
2011-05-10 17:58:41 +01:00
Neil Roberts
14d1303259 cogl-winsys: Explicitly comment which vfuncs are optional
Some of the virtual functions in CoglWinsysVtable only need to be
implemented for specific backends or when a specific feature is
advertised. This splits the vtable struct into two commented sections
marking which are optional and which are required. Wherever an
optional function is used there is now a g_return_if_fail to ensure
there is an implementation.
2011-05-10 17:15:22 +01:00
Neil Roberts
614efb190b cogl-winsys: Remove the get_vsync_counter virtual
This function is only used internally within the GLX winsys so there
doesn't seem to be much point in it being a virtual winsys backend
function.
2011-05-10 17:13:23 +01:00
Neil Roberts
f2a37b27f9 CoglWinsysVtable: Remove 'has_feature'
This virtual function is no longer used or defined anywhere since the
function was moved to the common backend code in 16bfa27d43.
2011-05-10 17:13:23 +01:00
Robert Bragg
e8b83f2880 Adds wayland support to the cogl EGL winsys
Wayland now supports integration via standard eglSurfaces which makes it
possible to share more code with other EGL platforms. (though at some
point cogl-winsys-egl.c really needs to gain a more formal
CoglEGLPlatform abstraction so we can rein back on the amount of #ifdefs
we have.)
2011-05-10 16:36:40 +01:00
Robert Bragg
4b6169267c winsys-egl: fix typo in _cogl_winsys_onscreen_init
We were trying to set attr.event_mask instead of xattr.event mask which
was causing a compilation error.
2011-05-10 16:36:40 +01:00
Damien Lespiau
62b7ea5972 build: Fix make distcheck
Some header files were split but never included in the list of source
files and thus not distributed.
2011-05-06 17:13:42 +01:00
Emmanuele Bassi
48c9157e97 build: Compile the introspection data
The compilation step for the introspection data was missing.
2011-05-06 16:53:43 +01:00
Robert Bragg
8b4ee0964b Remove all the options for building cogl standalone
This removes all the remnants from being able to build Cogl standalone
while it was part of the Clutter repository. Now that Cogl has been
split out then standalone builds are the only option.
2011-05-06 12:36:39 +01:00
Robert Bragg
6f2193545e consistently refer to cogl-pango as "cogl-pango"
This renames the pango directory to cogl-pango and it renames the
installed library to libcogl-pango instead of libcoglpango.
2011-05-06 12:12:08 +01:00
Robert Bragg
fbda52d21b Give cogl-pango it's own pkg-config file
We now install cogl-pango-1.0 and cogl-pango-2.0 pkg-config files that
applications should optionally depend on if they want to use the
cogl_pango API.
2011-05-06 12:12:08 +01:00
Robert Bragg
680c173947 framebuffer: in onscreen_x11_get_xid return foreign xids
If a foreign xid has been set on a CoglOnscreen then
cogl_onscreen_x11_get_window_xid doesn't need to defer to the winsys to
get the underlying window xid. This also means it's possible to read
back the xid before the framebuffer is allocated which fixes a crash in
the x11-foreign example app.
2011-05-05 20:41:01 +01:00
Robert Bragg
3a4d0a735b Export some private symbols from libcogl for coglpango
Ideally we wouldn't have any private symbols exported, but for now there
are some APIs that coglpango needs access to that aren't public so we
have ensure they are exported. The aim is to get rid of this need at
some point.
2011-05-05 20:34:54 +01:00
Neil Roberts
14ed963b05 cogl-debug: Add an option to disable atlasing sharing
If COGL_DEBUG contains disable-shared-atlas Cogl will not try to share
the atlas between glyphs and images.
2011-05-05 17:32:31 +01:00
Neil Roberts
184527580e cogl_pipeline_equal: Handle COGL_WRAP_MODE_AUTOMATIC better
When comparing the wrap modes of two pipeline layers it now considers
COGL_WRAP_MODE_AUTOMATIC to be equivalent to CLAMP_TO_EDGE. By the
time the pipeline is in the journal, the upper primitive code is
expected to have overridden this wrap mode with something else if it
wants any other behaviour. This is important for getting text to batch
together with textures because the text explicitly sets the wrap mode
to CLAMP_TO_EDGE on its pipeline.
2011-05-05 17:32:30 +01:00
Neil Roberts
a7aad27212 cogl-bitmap-private.h: Include cogl-bitmap.h
There was a header dependency problem which meant that
cogl-texture-private.h couldn't be included without first including
cogl-bitmap.h
2011-05-05 17:32:29 +01:00
Neil Roberts
239614a375 cogl-atlas-texture: Add a callback for when any atlas reorganizes
This adds cogl_atlas_texture_* functions to register a callback that
will get invoked whenever any of the CoglAtlas's the textures use get
reorganized. The callback is global and is not tied to any particular
atlas texture.
2011-05-05 17:32:28 +01:00
Neil Roberts
c76a4f8e24 cogl-atlas-texture: Split out new_from_bitmap to new_with_size
This adds a new function called _cogl_atlas_texture_new_with_size. The
old new_from_bitmap function now just calls this and updates the
texture with the data.
2011-05-05 17:32:27 +01:00
Robert Bragg
6c23f27801 Adds a way for Cogl to control event_mask of foreign wins
This extends cogl_onscreen_x11_set_foreign_xid to take a callback to a
function that details the event mask the Cogl requires the application
to select on foreign windows. This is required because Cogl, for
example, needs to track size changes of a window and may also in the
future want other notifications such as map/unmap.

Most applications wont need to use the foreign xwindow apis, but those
that do are required to pass a valid callback and update the event mask
of their window according to Cogl's requirements.
2011-05-05 15:05:42 +01:00
Robert Bragg
97243ad9ac Adds cogl_onscreen_show/hide functions
This adds Cogl API to show and hide onscreen framebuffers. We don't want
to go too far down the road of abstracting window system APIs with Cogl
since that would be out of its scope but the previous idea that we would
automatically map framebuffers on allocation except for those made from
foreign windows wasn't good enough. The problem is that we don't want to
make Clutter always create stages from foreign windows but with the
automatic map semantics then Clutter doesn't get an opportunity to
select for all the events it requires before mapping. This meant that we
wouldn't be delivered a mouse enter event for windows mapped underneath
the cursor which would break Clutters handling of button press events.
2011-05-05 15:05:42 +01:00
Robert Bragg
2a150003ad add missing name mangle for cogl_onscreen_set_swap_throttled
We weren't mangling cogl_onscreen_set_swap_throttled to give it an _EXP
postfix to clarify that it is an experimental symbol.
2011-05-05 15:05:42 +01:00
Robert Bragg
ad56c00f7a Add missing _cogl_winsys_has_feature prototype
This adds a private prototype for _cogl_winsys_has_feature in
cogl-winsys-private.h to avoid compilation warnings.
2011-05-05 15:05:42 +01:00
Robert Bragg
195cfa7814 cogl/Makefile.am: pass EXTRA_LDFLAGS for linking
When building on windows for example we need to ensure we pass
-no-undefined to the linker. Although we were substituting a
COGL_EXTRA_LDFLAGS variable from our configure.ac we forgot to
reference that when linking cogl.
2011-05-05 15:05:41 +01:00