Commit Graph

883 Commits

Author SHA1 Message Date
Robert Bragg
ee7cc9e788 Make CoglTexture2D public as experimental API
This exposes a CoglTexture2D typedef and adds the following experimental
API:
    cogl_is_texture_2d
    cogl_texture_2d_new_with_size
    cogl_texture_2d_new_from_data
    cogl_texture_2d_new_from_foreign

Since this is experimental API you need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h.

Note: With these new entrypoints we now expect a CoglContext pointer to
be passed in, instead of assuming there is a default context. The aim is
that for Cogl 2.0 we won't have a default context so this is a step in
that direction.
2011-06-01 20:44:41 +01:00
Robert Bragg
1e3f4f62e0 framebuffer: validate width/height in _set_viewport
This validates that the viewport width and height arguments are positive
values in _cogl_framebuffer_set_viewport. In addition, just before
calling glViewport we also assert that something else hasn't gone amiss
and that the internal viewport width/height values we track are still
positive before passing to glViewport which generates an error for
negative values.
2011-06-01 20:21:59 +01:00
Robert Bragg
5a9b92a4a5 Revert "Initial build of a Quartz winsys stub"
This reverts commit b2e41f1bfa.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Robert Bragg
891a9c33c5 Revert "quartz: Remove X11 ifdefs"
This reverts commit eb81ec945c.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Neil Roberts
efadc439a4 cogl-journal: Use a pool of vertex arrays
Previously whenever the journal is flushed a new vertex array would be
created to contain the vertices. To avoid the overhead of reallocating
a buffer every time, this patch makes it use a pool of 8 buffers which
are cycled in turn. The buffers are never destroyed but instead the
data is replaced. The journal should only ever be using one buffer at
a time but we cache more than one buffer anyway in case the GL driver
is internally using the buffer in which case mapping the buffer may
cause it to create a new buffer anyway.
2011-06-01 14:41:59 +01:00
Neil Roberts
54f94a0ed0 cogl-pipeline-fragend-fixed: Fix enabling texture targets
When flushing a pipeline that has more layers than the previous
pipeline, the fixed function fragend is supposed to detect that the
texture unit previously had no texture target enabled and then enable
it. However the logic for checking whether the unit was enabled was
broken due to a typing failure when unit->enabled and
unit->current_gl_target were combined into one value in commit
6b7139b0. This was breaking some of the conformance tests when the
fixed function fragend is used.

https://bugzilla.gnome.org/show_bug.cgi?id=650979
2011-05-27 11:59:17 +01:00
Neil Roberts
d8df30cb9c cogl-pipeline-opengl: Don't use number of tex units on fixed-function
The CoglPipeline code uses a combination of GL_MAX_TEXTURE_COORDS,
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS and GL_MAX_TEXTURE_UNITS to
determine the maximum number of layers to allow in a pipeline. However
on fixed function hardware that doesn't advertise either GLSL or ARBfp
it was still using the first two enums which will probably just return
0 and set a GLerror. This meant that we effectively didn't support
using any layers on purely fixed function hardware. This patch changes
it to only use those two enums if the appropriate extensions are
advertised and to always use GL_MAX_TEXTURE_UNITS except on GLES2
where there is no fixed function.

https://bugzilla.gnome.org/show_bug.cgi?id=650966
2011-05-27 11:59:17 +01:00
Emmanuele Bassi
19e1dcff23 framebuffer: Bail out if the viewport has negative size 2011-05-25 16:49:09 +01:00
Emmanuele Bassi
eb81ec945c quartz: Remove X11 ifdefs 2011-05-25 16:47:38 +01:00
Emmanuele Bassi
b2e41f1bfa Initial build of a Quartz winsys stub 2011-05-24 23:08:59 +01:00
Emmanuele Bassi
57db73873e pipeline: Fix argument checking in set_depth_state() 2011-05-18 11:50:56 +01:00
Damien Lespiau
8680e3bfeb android: Expose the only android specific symbol as experimental 2011-05-17 15:24:55 +01:00
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