Commit Graph

36 Commits

Author SHA1 Message Date
Zan Dobersek
d8c47e25f2 Remove inclusion of Xlib headers in Cogl headers
Xlib headers define many trivially named objects which can later cause
name collision problems when only cogl.h header is included in a program
or library. Xlib headers are now only included through including the
standalone header cogl-xlib.h.

https://bugzilla.gnome.org/show_bug.cgi?id=661174

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-01 15:55:53 +00:00
Robert Bragg
6253b09c69 texture-2d-sliced: make CoglTexture2DSliced public
This make the CoglTexture2DSliced type public and adds
cogl_texture_2d_sliced_new_with_size() as an experimental API that can
be used to construct a sliced texture without any initial data.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:02:59 +00:00
Adel Gadllah
671a4dfb34 winsys-glx: Fix synchronisation behaviour in _cogl_winsys_onscreen_swap_region
This patch basically restores the logic from 1.6.  There we assumed that
glXCopySubBuffer won't tear and thus only needs to be throttled to the
framerate, while glBlitFramebuffer needs to always wait to avoid
tearing.

With Nvidia drivers specifically we have seen that glBlitFramebuffer is
not synchronized. Eventually the plan is that Cogl will actually take
into consideration the underlying driver/hw vendor and driver version
and we may want to only mark glBlitFramebuffer un-synchronized on
Nvidia.

https://bugzilla.gnome.org/show_bug.cgi?id=659360

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Robert Bragg
8b34a39319 Adds ColorMask support to Cogl
This adds CoglPipeline and CoglFramebuffer support for setting a color
mask which is a bit mask defining which color channels should be written
to the current framebuffer.

The final color mask is the intersection of the framebuffer color mask
and the pipeline color mask. The framebuffer mask affects all rendering
to the framebuffer while the pipeline masks can be used to affect
individual primitives.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-07-19 19:27:09 +01:00
Robert Bragg
3b64a439f0 replace public native_event APIs with typesafe APIs
This adds Xlib and Win32 typesafe replacements for
cogl_renderer_handle_native_event, cogl_renderer_add_native_filter,
cogl_renderer_remove_native_filter. The old functions are kept as an
implementation detail so we can share code.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +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
Neil Roberts
4a7762d6d7 cogl-context: Store winsys features in an array of unsigned ints
Previously the mask of available winsys features was stored in a
CoglBitmask. That isn't the ideal type to use for this because it is
intended for a growable array of bits so it can allocate extra memory
if there are more than 31 flags set. For the winsys feature flags the
highest used bit is known at compile time so it makes sense to
allocate a fixed array instead. This is conceptually similar to the
CoglDebugFlags which are stored in an array of integers with macros to
test a bit in the array. This moves the macros used for CoglDebugFlags
to cogl-flags.h and makes them more generic so they can be shared with
CoglContext.
2011-04-20 18:20:10 +01:00
Neil Roberts
f6ae9decaa cogl-renderer: Move the XEvent filters to be generic for all renderers
Instead of having cogl_renderer_xlib_add_filter and friends there is
now cogl_renderer_add_native_filter which can be used regardless of
the backend. The callback function for the filter now just takes a
void pointer instead of an XEvent pointer which should be interpreted
differently depending on the backend. For example, on Xlib it would
still be an XEvent but on Windows it could be a MSG. This simplifies
the code somewhat because the _cogl_xlib_add_filter no longer needs to
have its own filter list when a stub renderer is used because there is
always a renderer available.

cogl_renderer_xlib_handle_event has also been renamed to
cogl_renderer_handle_native_event. This just forwards the event on to
all of the listeners. The backend renderer is expected to register its
own event filter if it wants to process the events in some way.
2011-04-20 18:17:06 +01:00
Robert Bragg
d40cdfa3e1 Moves all GLX code down from Clutter to Cogl
This migrates all the GLX window system code down from the Clutter
backend code into a Cogl winsys. Moving OpenGL window system binding
code down from Clutter into Cogl is the biggest blocker to having Cogl
become a standalone 3D graphics library, so this is an important step in
that direction.
2011-04-11 17:54:36 +01:00
Robert Bragg
9b0fd92527 cogl: rename CoglVertexAttribute CoglAttribute
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to reduce the verbosity
of using the API. Another reason is that CoglVertexArray is going to be
renamed CoglAttributeBuffer and we want to help emphasize the
relationship between CoglAttributes and CoglAttributeBuffers.
2011-01-21 16:24:14 +00:00
Neil Roberts
4f08e3cf6e cogl-buffer: Support mapping buffers for write on GLES
GLES has an extension called GL_OES_mapbuffer to support mapping
buffer objects but only for writing. Cogl now has two new feature
flags to advertise whether mapping for reading and writing is
supported. Under OpenGL, these features are always set if the VBO
extension is advertised and under GLES only the write flag is set if
the GL_OES_mapbuffer extension is advertised.
2011-01-13 16:36:45 +00:00
Emmanuele Bassi
aa4f63338c docs: Fixes for the Cogl API reference 2010-12-22 09:52:35 +00:00
Robert Bragg
f80cb197a9 cogl: rename CoglMaterial -> CoglPipeline
This applies an API naming change that's been deliberated over for a
while now which is to rename CoglMaterial to CoglPipeline.

For now the new pipeline API is marked as experimental and public
headers continue to talk about materials not pipelines. The CoglMaterial
API is now maintained in terms of the cogl_pipeline API internally.
Currently this API is targeting Cogl 2.0 so we will have time to
integrate it properly with other upcoming Cogl 2.0 work.

The basic reasons for the rename are:
- That the term "material" implies to many people that they are
  constrained to fragment processing; perhaps as some kind of high-level
  texture abstraction.
    - In Clutter they get exposed by ClutterTexture actors which may be
      re-inforcing this misconception.
- When comparing how other frameworks use the term material, a material
  sometimes describes a multi-pass fragment processing technique which
  isn't the case in Cogl.
- In code, "CoglPipeline" will hopefully be a much more self documenting
  summary of what these objects represent; a full GPU pipeline
  configuration including, for example, vertex processing, fragment
  processing and blending.
- When considering the API documentation story, at some point we need a
  document introducing developers to how the "GPU pipeline" works so it
  should become intuitive that CoglPipeline maps back to that
  description of the GPU pipeline.
- This is consistent in terminology and concept to OpenGL 4's new
  pipeline object which is a container for program objects.

Note: The cogl-material.[ch] files have been renamed to
cogl-material-compat.[ch] because otherwise git doesn't seem to treat
the change as a moving the old cogl-material.c->cogl-pipeline.c and so
we loose all our git-blame history.
2010-11-03 18:09:23 +00:00
Robert Bragg
812dd1d83d Move IndicesType and VerticesMode typedefs to cogl-types.h
This moves the CoglIndicesType and CoglVerticesMode typedefs from
cogl-vertex-buffer.h to cogl-types.h so they can be shared with the
anticipated cogl vertex attribute API.
2010-10-26 17:25:33 +01:00
Murray Cumming
6a48065761 Remove trailin enum commas, avoiding C++ warnings.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2314
2010-09-13 15:45:55 +01:00
Emmanuele Bassi
6b5934a18e Add some more introspection annotations 2010-09-06 16:11:46 +01:00
Robert Bragg
11045c724c cogl: Adds a COGL_FEATURE_SHADERS_ARBFP feature flag
This adds a public feature flag for ARBfp so developers can determine if
the cogl API supports ARBfp or not.
2010-08-09 17:27:02 +01:00
Neil Roberts
5288f6d88d Add a Cogl texture 3D backend
This adds a publicly exposed experimental API for a 3D texture
backend. There is a feature flag which can be checked for whether 3D
textures are supported. Although we require OpenGL 1.2 which has 3D
textures in core, GLES only provides them through an extension so the
feature can be used to detect that.

The textures can be created with one of two new API functions :-

cogl_texture_3d_new_with_size

 and

cogl_texture_3d_new_from_data

There is also internally a new_from_bitmap function. new_from_data is
implemented in terms of this function.

The two constructors are effectively the only way to upload data to a
3D texture. It does not work to call glTexImage2D with the
GL_TEXTURE_3D target so the virtual for cogl_texture_set_region does
nothing. It would be possible to make cogl_texture_get_data do
something sensible like returning all of the images as a single long
image but this is not currently implemented and instead the virtual
just always fails. We may want to add API specific to the 3D texture
backend to get and set a sub region of the texture.

All of those three functions can throw a GError. This will happen if
the GPU does not support 3D textures or it does not support NPOTs and
an NPOT size is requested. It will also fail if the FBO extension is
not supported and the COGL_TEXTURE_NO_AUTO_MIPMAP flag is not
given. This could be avoided by copying the code for the
GL_GENERATE_MIPMAP TexParameter fallback, but in the interests of
keeping the code simple this is not yet done.

This adds a couple of functions to cogl-texture-driver for uploading
3D data and querying the 3D proxy
texture. prep_gl_for_pixels_upload_full now also takes sets the
GL_UNPACK_IMAGE_HEIGHT parameter so that 3D textures can have padding
between the images. Whenever 3D texture is uploading, both the height
of the images and the height of all of the data is specified (either
explicitly or implicilty from the CoglBitmap) so that the image height
can be deduced by dividing by the depth.
2010-07-13 14:28:52 +01:00
Neil Roberts
396ef40d43 Rename COGL_ERROR_MISSING_FEATURE to COGL_ERROR_UNSUPPORTED
We can use this error in more unsupported situations than just when we
have a Cogl feature flag for the error. For example if a non-sliced
texture is created with dimensions that are too large then we could
throw this error. Therefore it seems good to rename to something more
general.
2010-07-13 14:28:36 +01:00
Neil Roberts
da3be3df6b cogl-material: Add support for point sprites
This adds a new API call to enable point sprite coordinate generation
for a material layer:

void
cogl_material_set_layer_point_sprite_coords_enabled (CoglHandle material,
                                                     int layer_index,
                                                     gboolean enable);

There is also a corresponding get function.

Enabling point sprite coords simply sets the GL_COORD_REPLACE of the
GL_POINT_SPRITE glTexEnv when flusing the material. There is no
separate application control for glEnable(GL_POINT_SPRITE). Instead it
is left permanently enabled under the assumption that it has no affect
unless GL_COORD_REPLACE is enabled for a texture unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
7571cc1923 cogl: expose the semantic differences of gl/gles2 npot textures
This adds three new feature flags COGL_FEATURE_TEXTURE_NPOT_BASIC,
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
that can tell you if your hardware supports non power of two textures,
npot textures + mipmaps and npot textures + wrap modes other than
CLAMP_TO_EDGE.

The pre-existing COGL_FEATURE_TEXTURE_NPOT feature implies all of the
above.

By default GLES 2 core supports npot textures but mipmaps and repeat
modes can only be used with power of two textures. This patch also makes
GLES check for the GL_OES_texture_npot extension to determine if mipmaps
and repeating are supported with npot textures.
2010-07-07 13:26:41 +01:00
Robert Bragg
dab4ddc718 material: Make CoglMaterial responsible for depth state
This redirects the legacy depth testing APIs through CoglMaterial and
adds a new experimental cogl_material_ API for handling the depth
testing state.

This adds the following new functions:
cogl_material_set_depth_test_enabled
cogl_material_get_depth_test_enabled
cogl_material_set_depth_writing_enabled
cogl_material_get_depth_writing_enabled
cogl_material_set_depth_test_function
cogl_material_get_depth_test_function
cogl_material_set_depth_range
cogl_material_get_depth_range

As with other experimental Cogl API you need to define
COGL_ENABLE_EXPERIMENTAL_API to access them and their stability isn't
yet guaranteed.
2010-06-15 15:26:28 +01:00
Damien Lespiau
2e52c5f67b doc: Some fixes for the Cogl documentation
• 3 general fixes (typos, copy/paste),
 • ignore cogl-object-private.h,
 • cogl_fixed_atani() was in reality cogl_fixed_atan(), fixed in commit
   43564f05.
 • Fix the cogl-vector section: sections must have a </SECTION> tag at
   the end. Also the cogl-vector section was added in the middle of the
   cogl-buffer one. Let's shiffle it out and add that </SECTION> tag.
2010-06-07 14:32:32 +01:00
Robert Bragg
7bcea1c64e Start eradicating the CoglHandle typedef
CoglHandle is a common source of complaints and confusion because people
expect a "handle" to be some form of integer type with some indirection
to lookup the corresponding objects as opposed to a direct pointer.

This patch starts by renaming CoglHandle to CoglObject * and creating
corresponding cogl_object_ APIs to replace the cogl_handle ones.

The next step though is to remove all use of CoglHandle in the Cogl APIs
and replace with strongly typed pointer types such as CoglMaterial * or
CoglTexture * etc also all occurrences of COGL_INVALID_HANDLE can just
use NULL instead.

After this we will consider switching to GTypeInstance internally so we
can have inheritance for our types and hopefully improve how we handle
bindings.

Note all these changes will be done in a way that maintains the API and
ABI.
2010-05-28 18:39:22 +01:00
Neil Roberts
908be0480c cogl: Make private members really hard to accidentally use
CoglColor and CoglMatrix have public declarations with private members
so that we are free to change the implementation but the structures
could still be allocated on the stack in applications. However it's
quite easy not to realise the members are private and then access them
directly. This patch wraps the members in a macro which redefines the
symbol name when including the header outside of the clutter source.

http://bugzilla.openedhand.com/show_bug.cgi?id=2065
2010-04-12 15:38:58 +01:00
Emmanuele Bassi
72f4ddf532 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Neil Roberts
82fd07c54a cogl-vertex-buffer: Add support for unsigned int indices
This adds a COGL_INDICES_TYPE_UNSIGNED_INT enum value so that unsigned
ints can be used with cogl_vertex_buffer_indices_new.  Unsigned ints
are not supported in core on GLES so a feature flag has also been
added to advertise this. GLES only sets the feature if the
GL_OES_element_index_uint extension is available. It is an error to
call indices_new() with unsigned ints unless the feature is
advertised.

http://bugzilla.openedhand.com/show_bug.cgi?id=1998
2010-02-26 10:56:35 +00:00
Robert Bragg
0f5f4e8645 cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.

There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.

The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:

 return_type
 cogl_function_name (CoglType arg0,
                     CoglType arg1);

Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.

The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.

The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.

The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-12 14:05:00 +00:00
Emmanuele Bassi
2674a1ead2 docs: Fixes for Cogl API reference
98% symbol docs coverage.
  335 symbols documented.
  0 symbols incomplete.
  8 not documented.

Not bad, if I may say so.
2010-02-09 14:41:37 +00:00
Damien Lespiau
ca80e8802b cogl-pixel-buffer: Add a fallback path
First, let's add a new public feature called, surprisingly,
COGL_FEATURE_PBOS to check the availability of PBOs and provide a
fallback path when running on older GL implementations or on OpenGL ES

In case the underlying OpenGL implementation does not provide PBOs, we
need a fallback path (a malloc'ed buffer). The CoglPixelBufer
constructors will instanciate a subclass of CoglBuffer that handles
map/unmap and set_data() with a malloc'ed buffer.

The public feature is useful to check before using set_data() on a
buffer as it will mean doing a memcpy() when not supporting PBOs (in
that case, it's better to create the texture directly instead of using a
CoglBuffer).
2010-02-08 17:14:49 +00:00
Neil Roberts
efcbd20320 Merge remote branch 'master' into texture-debugging
Conflicts:
	clutter/cogl/cogl/cogl-context.h
2010-02-01 13:37:19 +00:00
Neil Roberts
548ed1cdf2 docs: Add some notes about the CoglPixelFormat enums
The pixel format enums didn't explain what order in memory the
components should be so it was difficult to use them.
2010-01-27 12:07:38 +00:00
Neil Roberts
bec2600087 cogl: Add an atlased texture backend
This adds a CoglAtlas type which is a data structure that keeps track
of unused sub rectangles of a larger rectangle. There is a new atlased
texture backend which uses this to put multiple textures into a single
larger texture.

Currently the atlas is always sized 256x256 and the textures are never
moved once they are put in. Eventually it needs to be able to
reorganise the atlas and grow it if necessary. It also needs to
migrate the textures out of the atlas if mipmaps are required.
2009-12-04 20:26:39 +00:00
Robert Bragg
0bce7eac53 Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.

Currently this is the structure I'm aiming for:
cogl/
    cogl/
	<put common source here>
	winsys/
	   cogl-glx.c
	   cogl-wgl.c
	driver/
	    gl/
	    gles/
	os/ ?
    utils/
	cogl-fixed
	cogl-matrix-stack?
        cogl-journal?
        cogl-primitives?
    pango/

The new winsys component is a starting point for migrating window system
code (i.e.  x11,glx,wgl,osx,egl etc) from Clutter to Cogl.

The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.

Overview of the planned structure:

* The winsys/ API is the API that binds OpenGL to a specific window system,
  be that X11 or win32 etc.  Example are glx, wgl and egl. Much of the logic
  under clutter/{glx,osx,win32 etc} should migrate here.

* Note there is also the idea of a winsys-base that may represent a window
  system for which there are multiple winsys APIs.  An example of this is
  x11, since glx and egl may both be used with x11.  (currently only Clutter
  has the idea of a winsys-base)

* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
  representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
  GLES 1.1 (fixed funciton) and 2.0 (fully shader based)

* Everything under cogl/ should fundamentally be supporting access to the
  GPU.  Essentially Cogl's most basic requirement is to provide a nice GPU
  Graphics API and drawing a line between this and the utility functionality
  we add to support Clutter should help keep this lean and maintainable.

* Code under utils/ as suggested builds on cogl/ adding more convenient
  APIs or mechanism to optimize special cases. Broadly speaking you can
  compare cogl/ to OpenGL and utils/ to GLU.

* clutter/pango will be moved to clutter/cogl/pango

How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"

Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps

As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-10-16 18:58:50 +01:00