1
0
Fork 0
Commit graph

44 commits

Author SHA1 Message Date
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
Robert Bragg
b85af722f4 Make the CoglContext structure a bit more maintainable
This moves most of cogl-context.{c.h} to cogl/common with some driver
specific members now living in a CoglContextDriver struct.  Driver specific
context initialization and typedefs now live in
cogl/{gl,gles}/cogl-context-driver.{c,h}

Driver specific members can be found under ctx->drv.stuff
2009-10-16 18:58:49 +01:00
Robert Bragg
9a55b0c3ff [cogl-material] Fix some brackets in _layer_flush_gl_sampler_state
The wrong part of an expression was bracketed in the test to determine
when a new texture matrix needed to be loaded which resulted in the
first pass through _cogl_material_layer_flush_gl_sampler_state
not uploading any user matrix.
2009-08-18 16:57:38 +01:00
Haakon Sporsheim
584eca5eee Reposition variable declarations to avoid C99. 2009-07-28 12:13:42 +01:00
Robert Bragg
af49769b33 [cogl] Fix more brokeness with _cogl_material_equal
commit e2c4a2a9f8 fixed one thing but broke many others things :-/
hopfully this fixes that.

It turned out that the journal was mistakenly setting the OVERRIDE_LAYER0
flush option for all entries, but some other logic errors were also
uncovered in _cogl_material_equal.
2009-07-10 19:00:16 +01:00
Robert Bragg
a8e93e8588 [cogl] Fix drawing with sliced textures using material layer0 overrides
To help us handle sliced textures; When flushing materials there is an
override option that can be given to replace the texture name for layer0
so we may iterate the slices without needing to modify the material
in use.

Since improving the journal's ability to batch state changes we added a
_cogl_material_equals function that is used by the journal to compare
materials and identify when a state change is required, but this wasn't
correctly considering the layer0 override resulting in false positives that
meant the journal wouldn't update the GL state and the first texture name
was used for all slices.
2009-07-07 10:34:37 +01:00
Robert Bragg
fdc048ddd0 [cogl] Ensure well defined semantics for COGL_INVALID_HANDLE material layers
Fixes and adds a unit test for creating and drawing using materials with
COGL_INVALID_HANDLE texture layers.

This may be valid if for example the user has set a texture combine string
that only references a constant color.

_cogl_material_flush_layers_gl_state will bind the fallback texture for any
COGL_INVALID_HANDLE layer, later though we could explicitly check when the
current blend mode does't actually reference a texture source in which case
binding the fallback texture is redundant.

This tests drawing using cogl_rectangle, cogl_polygon and
cogl_vertex_buffer_draw.
2009-06-30 17:35:07 +01:00
Robert Bragg
cf621948a7 [cogl-material] Be more carefull about flushing in cogl_material_remove_layer
Previously we would call _cogl_material_pre_change_notify unconditionally, but
now we wait until we really know we are removing a layer before notifying the
change, which will require a journal flush.

Since the convenience functions cogl_set_source_color4ub and
cogl_set_source_texture share a single material, cogl_set_source_color4ub
always calls cogl_material_remove_layer.  Often this is a NOP though and
shouldn't require a journal flush.

This gets performance back to where it was before reverting the per-actor
material commits.
2009-06-30 17:13:38 +01:00
Robert Bragg
ac4f7f0bfe [material] _cogl_material_equal: catch the simplest case of matching handles
We were missing the simplest test of all: are the two CoglHandles equal and
are the flush option flags for each material equal?  This should improve
batching for some common cases.
2009-06-30 17:13:36 +01:00
Robert Bragg
3369c5138b [material] avoid flushing the journal when just changing the color
Whenever we modify a material we call _cogl_material_pre_change_notify which
checks to see if the material is referenced by the journal and if so flushes
if before we modify the material.

Since the journal logs material colors directly into a vertex array (to
avoid us repeatedly calling glColor) then we know we never need to flush
the journal when material colors change.
2009-06-30 17:13:36 +01:00
Robert Bragg
827798233a [cogl material] optimize logging of material colors in the journal
We now put the color of materials into the vertex array used by the journal
instead of calling glColor() but the number of requests for the material
color were quite expensive so we have changed the material color to
internally be byte components instead of floats to avoid repeat conversions
and added _cogl_material_get_colorubv as a fast-path for the journal to
copy data into the vertex array.
2009-06-30 17:13:35 +01:00
Robert Bragg
2b9478a665 [cogl] Improving Cogl journal to minimize driver overheads + GPU state changes
Previously the journal was always flushed at the end of
_cogl_rectangles_with_multitexture_coords, (i.e.  the end of any
cogl_rectangle* calls) but now we have broadened the potential for batching
geometry.  In ideal circumstances we will only flush once per scene.

In summary the journal works like this:

When you use any of the cogl_rectangle* APIs then nothing is emitted to the
GPU at this point, we just log one or more quads into the journal.  A
journal entry consists of the quad coordinates, an associated material
reference, and a modelview matrix.  Ideally the journal only gets flushed
once at the end of a scene, but in fact there are things to consider that
may cause unwanted flushing, including:

- modifying materials mid-scene
    This is because each quad in the journal has an associated material
    reference (i.e. not copy), so if you try and modify a material that is
    already referenced in the journal we force a flush first)

    NOTE: For now this means you should avoid using cogl_set_source_color()
	      since that currently uses a single shared material. Later we
	  should change it to use a pool of materials that is recycled
	  when the journal is flushed.

- modifying any state that isn't currently logged, such as depth, fog and
  backface culling enables.

The first thing that happens when flushing, is to upload all the vertex data
associated with the journal into a single VBO.

We then go through a process of splitting up the journal into batches that
have compatible state so they can be emitted to the GPU together.  This is
currently broken up into 3 levels so we can stagger the state changes:

1) we break the journal up according to changes in the number of material layers
   associated with logged quads. The number of layers in a material determines
   the stride of the associated vertices, so we have to update our vertex
   array offsets at this level. (i.e. calling gl{Vertex,Color},Pointer etc)
2) we further split batches up according to material compatability. (e.g.
   materials with different textures) We flush material state at this level.
3) Finally we split batches up according to modelview changes. At this level
   we update the modelview matrix and actually emit the actual draw command.

This commit is largely about putting the initial design in-place; this will be
followed by other changes that take advantage of the extended batching.
2009-06-30 17:13:34 +01:00
Robert Bragg
14cef57480 [cogl] Don't allow calling cogl_set_source_texture with an INVALID_HANDLE
Although the underlying materials should allow layers with INVALID_HANDLES
it shouldn't be necissary to expose that via cogl_set_source_texture() and
it's easier to resolve a warning/crash here than odd artefacts/crashes later
in the pipeline.
2009-06-11 16:28:01 +01:00
Owen W. Taylor
f0de41331a Default to a blend function that expects premultiplied colors
Many operations, like mixing two textures together or alpha-blending
onto a destination with alpha, are done most logically if texture data
is in premultiplied form. We also have many sources of premultiplied
texture data, like X pixmaps, FBOs, cairo surfaces. Rather than trying
to work with two different types of texture data, simplify things by
always premultiplying texture data before uploading to GL.

Because the default blend function is changed to accommodate this,
uses of pure-color CoglMaterial need to be adapted to add
premultiplication.

gl/cogl-texture.c gles/cogl-texture.c: Always premultiply
  non-premultiplied texture data before uploading to GL.

cogl-material.c cogl-material.h: Switch the default blend functions
  to ONE, ONE_MINUS_SRC_ALPHA so they work correctly with premultiplied
  data.

cogl.c: Make cogl_set_source_color() premultiply the color.

cogl.h.in color-material.h: Add some documentation about
  premultiplication and its interaction with color values.

cogl-pango-render.c clutter-texture.c tests/interactive/test-cogl-offscreen.c:
  Use premultiplied colors.

http://bugzilla.openedhand.com/show_bug.cgi?id=1406

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:52 +01:00
Owen W. Taylor
a5b5691082 On bad blend strings, print the error if not returning it
It's very common that there's no reasonable fallback to do if the
blend or combine string you set isn't supported. So, rather than
requiring everybody to pass in a GError purely to catch syntax erorrs,
automatically g_warning() if a parse error is encountered and @error
is NULL.

http://bugzilla.openedhand.com/show_bug.cgi?id=1642

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-08 23:51:08 +01:00
Johan Bilien
8a31263274 Fix the leak of the GList of layers in CoglMaterial
http://bugzilla.openedhand.com/show_bug.cgi?id=1624

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-06 12:59:31 +01:00
Robert Bragg
fdb66d1076 [cogl] cogl_material_set_layer does nothing if resetting the same texture
This avoids dirtying the layer, and should avoid some uneeded state changes
2009-06-05 17:18:32 +01:00
Neil Roberts
e7e8978029 [cogl] Move the texture filters to be a property of the material layer
The texture filters are now a property of the material layer rather
than the texture object. Whenever a texture is painted with a material
it sets the filters on all of the GL textures in the Cogl texture. The
filter is cached so that it won't be changed unnecessarily.

The automatic mipmap generation has changed so that the mipmaps are
only generated when the texture is painted instead of every time the
data changes. Changing the texture sets a flag to mark that the
mipmaps are dirty. This works better if the FBO extension is available
because we can use glGenerateMipmap. If the extension is not available
it will temporarily enable automatic mipmap generation and reupload
the first pixel of each slice. This requires tracking the data for the
first pixel.

The COGL_TEXTURE_AUTO_MIPMAP flag has been replaced with
COGL_TEXTURE_NO_AUTO_MIPMAP so that it will default to
auto-mipmapping. The mipmap generation is now effectively free if you
are not using a mipmap filter mode so you would only want to disable
it if you had some special reason to generate your own mipmaps.

ClutterTexture no longer has to store its own copy of the filter
mode. Instead it stores it in the material and the property is
directly set and read from that. This fixes problems with the filters
getting out of sync when a cogl handle is set on the texture
directly. It also avoids the mess of having to rerealize the texture
if the filter quality changes to HIGH because Cogl will take of
generating the mipmaps if needed.
2009-06-04 19:03:40 +01:00
Neil Roberts
b7c8f8111e [cogl-material] Allow setting a layer with an invalid texture handle
It was previously possible to create a material layer with no texture
by setting some property on it such as the matrix. However it was not
possible to get back to that state without removing the layer and
recreating it. It is useful to be able to remove the texture to free
resources without forgetting the state of the layer so we can put a
different texture in later.
2009-06-04 14:04:32 +01:00
Neil Roberts
00ac53042e Load glBlendEquation and glBlendColor using cogl_get_proc_address
These are defined since OpenGL 1.2 and since Windows doesn't export
any functions defined after 1.1 we need to load them dynamically.
2009-06-04 11:50:06 +01:00
Robert Bragg
492f0e5d14 [material] Reduce the material API in preperation for releasing Clutter 1.0
There were a number of functions intended to support creating of new
primitives using materials, but at this point they aren't used outside of
Cogl so until someone has a usecase and we can get feedback on this
API, it's being removed before we release Clutter 1.0.
2009-05-28 02:43:34 +01:00
Robert Bragg
2dc882f685 [cogl-material] Removes all the API made redundant by the blend strings API
This removes the following API:
  cogl_material_set_blend_factors
  cogl_material_set_layer_combine_function
  cogl_material_set_layer_combine_arg_src
  cogl_material_set_layer_combine_arg_op

These were rather awkward to use, so since it's expected very few people are
using them at this point and it should be straight forward to switch over
to blend strings, the API is being removed before we release Clutter 1.0.
2009-05-28 02:43:34 +01:00
Robert Bragg
bc8a18ebc3 [cogl-material] Support string based blending and layer combine descriptions
Setting up layer combine functions and blend modes is very awkward to do
programatically.  This adds a parser for string based descriptions which are
more consise and readable.

E.g. a material layer combine function could now be given as:
  "RGBA = ADD (TEXTURE[A], PREVIOUS[RGB])"
or
  "RGB = REPLACE (PREVIOUS)"
  "A = MODULATE (PREVIOUS, TEXTURE)"

The simple syntax and grammar are only designed to expose standard fixed
function hardware, more advanced combining must be done with shaders.

This includes standalone documentation of blend strings covering the aspects
that are common to blending and texture combining, and adds documentation
with examples specific to the new cogl_material_set_blend() and
cogl_material_layer_set_combine() functions.

Note: The hope is to remove the now redundant bits of the material API
before 1.0
2009-05-28 02:43:28 +01:00
Robert Bragg
93c5769722 [cogl-material] Adds a cogl_material_set_color4f convenience function
This is simply a wrapper around cogl_color_set_from_4f and
cogl_material_set_color. We already had a prototype for this, it was
an oversight that it wasn't already implemented.
2009-05-02 04:12:26 +01:00
Robert Bragg
66cb117056 [cogl-material] make _cogl_material_layer_free check for an invalid texture handle
It is valid in some situations to have a material layer with an invalid texture
handle (e.g. if you setup a texture combine mode before setting the texture)
and so _cogl_material_layer_free needs to check for a valid handle before
attempting to unref it.
2009-05-02 04:12:25 +01:00
Robert Bragg
7e9685294e [cogl] Updates all file headers and removes lots of trailing white space
Adds missing notices, and ensures all the notices are consistent. The Cogl
blurb also now reads:

 * Cogl
 *
 * An object oriented GL/GLES Abstraction/Utility Layer
2009-05-02 04:12:25 +01:00
Robert Bragg
ed272213f0 [cogl-handle] Optimize how we define cogl handles
The cogl_is_* functions were showing up quite high on profiles due to
iterating through arrays of cogl handles.

This does away with all the handle arrays and implements a simple struct
inheritance scheme. All cogl objects now add a CoglHandleObject _parent;
member to their main structures. The base object includes 2 members a.t.m; a
ref_count, and a klass pointer. The klass in turn gives you a type and
virtual function for freeing objects of that type.

Each handle type has a _cogl_##handle_type##_get_type () function
automatically defined which returns a GQuark of the handle type, so now
implementing the cogl_is_* funcs is just a case of comparing with
obj->klass->type.

Another outcome of the re-work is that cogl_handle_{ref,unref} are also much
more efficient, and no longer need extending for each handle type added to
cogl. The cogl_##handle_type##_{ref,unref} functions are now deprecated and
are no longer used internally to Clutter or Cogl. Potentially we can remove
them completely before 1.0.
2009-04-02 11:58:43 +01:00
Robert Bragg
4b484d6496 [cogl] handle_automatic_blend_enable(): consider layers with invalid textures
A layer object may be instantiated when setting a combine mode, but before a
texture is associated. (e.g. this is done by the pango renderer) if this is the
case we shouldn't call cogl_texture_get_format() with an invalid cogl handle.

This patch skips over layers without a texture handle when determining if any
textures have an alpha channel.
2009-04-02 11:50:44 +01:00
Havoc Pennington
11349b6c74 Virtualize GL matrix operations and use a client-side matrix when GL is indirect
This is useful because sometimes we need to get the current matrix, which
is too expensive when indirect rendering.

In addition, this virtualization makes it easier to clean up the API in
the future.
2009-03-12 18:32:45 +00:00
Robert Bragg
114385b2cf [cogl-material] Always glBindTexture when flushing material state
Bug #1457 - Creating a new texture messes up the cogl material state
            cache; reported by Neil Roberts

We still don't have caching of bound texture state so we always have to
re-bind the texture when flushing the GL state of any material layers.
2009-02-23 10:49:35 +00:00
Robert Bragg
25fc1b85ab [Cogl] Fixes automatic handling of the GL blend enable state.
Bug #1460 - Handling of flags in cogl_material_set_color

Cogl automatically enables/disables blending based on whether the source color
has an alhpa < 1.0, or if any textures with an alpha component are in use, but
it wasn't doing it quite right.

At the same time I removed some of the dirty flags which on second thought
are nothing more than micro-optimsations that only helped clutter the code.

thanks to Owen Taylor for reporting the bug
2009-02-23 10:49:35 +00:00
Neil Roberts
43a5fef73d Call glActiveTexture and glClientActiveTexture through cogl_get_proc_address
All GL functions that are defined in a version later than 1.1 need to
be called through cogl_get_proc_address because the Windows GL DLL
does not export them to directly link against.
2009-02-16 12:46:36 +00:00
Robert Bragg
9059367dcc [cogl-material] Fixes some dirty flag checks
Flushing material layers wasn't clearing the right dirty flag and
some of the tests used to avoid re-submitting GL state weren't
complete.
2009-02-09 14:15:06 +00:00
Neil Roberts
c50935edca Fix building GLES 2 after the material branch merge
- In cogl-material.h it directly sets the values of the
  CoglMaterialLayerCombineFunc to some GL_* constants. However these
  aren't defined in GLES 2 beacuse it has no fixed function texture
  combining. Instead the CGL_* versions are now used. cogl-defines.h
  now sets these to either the GL_* version if it is available,
  otherwise it directly uses the number.

- Under GLES 2 cogl-material.c needs to access the CoglTexture struct
  so it needs to include cogl-texture-private.h

- There are now #define's in cogl-gles2-wrapper.h to remap the GL
  function names to the wrapper names. These are disabled in
  cogl-gles2-wrapper.c by defining COGL_GLES2_WRAPPER_NO_REMAP.

- Added missing wrappers for glLoadMatrixf and glMaterialfv.

- Renamed the TexEnvf wrapper to TexEnvi because the latter is used
  instead from the material API.
2009-02-02 21:57:41 +00:00
Neil Roberts
a54d13368f [cogl-material] Always bind the new texture handle
Cogl previously tried to cache the currently bound texture when
drawing through the material API to avoid excessive GL calls. However,
a few other places in Cogl and Clutter rebind the texture as well so
this can cause problems.

This was causing shaped windows to fail in Mutter because
ClutterGLXTexturePixmap was binding a different texture to update it
while the second texture unit was still active which meant the mask
texture would not be selected when the shaped window was drawn
subsequent times.

Ideally we would fix this by providing a wrapper around glBindTexture
which would affect the cached value. The cache would also have to be
cleared if a selected texture was deleted.
2009-02-02 14:53:23 +00:00
Emmanuele Bassi
670b35ddf0 Remove gtk-doc annotation
The _cogl_material_flush_layers_gl_state() function is static,
so it should not have a gtk-doc annotation.
2009-01-28 11:57:49 +00:00
Emmanuele Bassi
31e4ca5733 Fallout from cogl-material merge
When enabling the maintainer CFLAGS the compiler got very angry
at the code that has been merged.
2009-01-27 16:02:04 +00:00
Robert Bragg
9abf44eac3 Updates GLES1 support for CoglMaterial
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.
2009-01-27 14:26:50 +00:00
Robert Bragg
94077997a7 Removes cogl_blend_func and cogl_alpha_func
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.
2009-01-27 14:26:49 +00:00
Robert Bragg
2503f7b321 Fully integrates CoglMaterial throughout the rest of Cogl
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.
2009-01-27 14:26:39 +00:00
Robert Bragg
98bd85afaa [cogl-material] Adds a cogl_material_set_color function
The other colors of a material; such as the ambient and diffuse color are
only relevent when we can enable lighting. This adds a basic unlit
color property.

Later cogl_set_source_color can be integrated to either modify the color
of the current source material, or maintain a special singlton CoglMaterial
that is modified by calls to cogl_set_source_color and implicitly made
current.
2008-12-24 01:35:02 +00:00
Robert Bragg
e4548bcdc5 [cogl-material] Some improvements for how we sync CoglMaterial state with OpenGL
This flattens the three functions: cogl_material_flush_gl_material_state,
.._flush_gl_alpha_func and .._flush_gl_blend_func into one:
cogl_flush_material_gl_state which doesn't takes a material handle. (the handle
is instead taken from the context.)

This has allows us to avoid re-submitting some state to OpenGL when the
material has not been replaced.

Note: Avoiding redundant state changes for material layers isn't dealt with
in this patch.
2008-12-24 01:33:23 +00:00
Robert Bragg
5b61106684 [doc] Hooks up cogl-material reference documentation
Adds some more gtk-doc comments to cogl-material.h, and adds a new section to
cogl-sections.txt
2008-12-22 16:35:52 +00:00
Robert Bragg
61b8cc1874 Adds a CoglMaterial abstraction, which includes support for multi-texturing
My previous work to provide muti-texturing support has been extended into
a CoglMaterial abstraction that adds control over the texture combine
functions (controlling how multiple texture layers are blended together),
the gl blend function (used for blending the final primitive with the
framebuffer), the alpha function (used to discard fragments based on
their alpha channel), describing attributes such as a diffuse, ambient and
specular color (for use with the standard OpenGL lighting model), and
per layer rotations. (utilizing the new CoglMatrix utility API)

For now the only way this abstraction is exposed is via a new
cogl_material_rectangle function, that is similar to cogl_texture_rectangle
but doesn't take a texture handle (the source material is pulled from
the context), and the array of texture coordinates is extended to be able
to supply coordinates for each layer.

Note: this function doesn't support sliced textures; supporting sliced
textures is a non trivial problem, considering the ability to rotate layers.
Note: cogl_material_rectangle, has quite a few workarounds, for a number of
other limitations within Cogl a.t.m.
Note: The GLES1/2 multi-texturing support has yet to be updated to use
the material abstraction.
2008-12-22 16:35:52 +00:00