2009-04-27 10:48:12 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008,2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
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-11 15:11:30 -05:00
|
|
|
#ifndef __COGL_MATERIAL_PRIVATE_H
|
|
|
|
#define __COGL_MATERIAL_PRIVATE_H
|
|
|
|
|
|
|
|
#include "cogl-material.h"
|
|
|
|
#include "cogl-matrix.h"
|
2009-04-01 12:16:44 -04:00
|
|
|
#include "cogl-handle.h"
|
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-11 15:11:30 -05:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
typedef struct _CoglMaterial CoglMaterial;
|
|
|
|
typedef struct _CoglMaterialLayer CoglMaterialLayer;
|
|
|
|
|
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-23 11:15:40 -05:00
|
|
|
/* XXX: I don't think gtk-doc supports having private enums so these aren't
|
|
|
|
* bundled in with CoglMaterialLayerFlags */
|
|
|
|
typedef enum _CoglMaterialLayerPrivFlags
|
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-11 15:11:30 -05:00
|
|
|
{
|
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-23 11:15:40 -05:00
|
|
|
/* Ref: CoglMaterialLayerFlags
|
|
|
|
COGL_MATERIAL_LAYER_FLAG_HAS_USER_MATRIX = 1L<<0
|
|
|
|
*/
|
|
|
|
COGL_MATERIAL_LAYER_FLAG_DIRTY = 1L<<1,
|
|
|
|
COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE = 1L<<2
|
|
|
|
} CoglMaterialLayerPrivFlags;
|
|
|
|
|
|
|
|
/* For tracking the state of a layer that's been flushed to OpenGL */
|
|
|
|
typedef struct _CoglLayerInfo
|
|
|
|
{
|
|
|
|
CoglHandle handle;
|
|
|
|
gulong flags;
|
|
|
|
GLenum gl_target;
|
|
|
|
GLuint gl_texture;
|
|
|
|
gboolean fallback;
|
|
|
|
gboolean disabled;
|
|
|
|
gboolean layer0_overridden;
|
|
|
|
} CoglLayerInfo;
|
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-11 15:11:30 -05:00
|
|
|
|
|
|
|
struct _CoglMaterialLayer
|
|
|
|
{
|
2009-04-01 12:16:44 -04:00
|
|
|
CoglHandleObject _parent;
|
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-11 15:11:30 -05:00
|
|
|
guint index; /*!< lowest index is blended first then others
|
|
|
|
on top */
|
|
|
|
gulong flags;
|
|
|
|
CoglHandle texture; /*!< The texture for this layer, or COGL_INVALID_HANDLE
|
|
|
|
for an empty layer */
|
2008-12-23 18:50:02 -05:00
|
|
|
|
|
|
|
/* Determines how the color of individual texture fragments
|
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-11 15:11:30 -05:00
|
|
|
* are calculated. */
|
2009-05-23 11:23:00 -04:00
|
|
|
GLint texture_combine_rgb_func;
|
|
|
|
GLint texture_combine_rgb_src[3];
|
|
|
|
GLint texture_combine_rgb_op[3];
|
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-11 15:11:30 -05:00
|
|
|
|
2009-05-23 11:23:00 -04:00
|
|
|
GLint texture_combine_alpha_func;
|
|
|
|
GLint texture_combine_alpha_src[3];
|
|
|
|
GLint texture_combine_alpha_op[3];
|
2008-12-23 18:50:02 -05:00
|
|
|
|
2009-05-10 19:40:41 -04:00
|
|
|
GLfloat texture_combine_constant[4];
|
|
|
|
|
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-11 15:11:30 -05:00
|
|
|
/* TODO: Support purely GLSL based material layers */
|
|
|
|
|
|
|
|
CoglMatrix matrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum _CoglMaterialFlags
|
|
|
|
{
|
|
|
|
COGL_MATERIAL_FLAG_ENABLE_BLEND = 1L<<0,
|
2008-12-23 18:50:02 -05:00
|
|
|
COGL_MATERIAL_FLAG_SHOWN_SAMPLER_WARNING = 1L<<1,
|
2009-02-19 04:01:18 -05:00
|
|
|
COGL_MATERIAL_FLAG_DEFAULT_COLOR = 1L<<2,
|
|
|
|
COGL_MATERIAL_FLAG_DEFAULT_GL_MATERIAL = 1L<<3,
|
|
|
|
COGL_MATERIAL_FLAG_DEFAULT_ALPHA_FUNC = 1L<<4,
|
|
|
|
COGL_MATERIAL_FLAG_DEFAULT_BLEND_FUNC = 1L<<5
|
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-11 15:11:30 -05:00
|
|
|
} CoglMaterialFlags;
|
|
|
|
|
|
|
|
struct _CoglMaterial
|
|
|
|
{
|
2009-04-01 12:16:44 -04:00
|
|
|
CoglHandleObject _parent;
|
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-11 15:11:30 -05:00
|
|
|
|
|
|
|
gulong flags;
|
|
|
|
|
2008-12-23 18:50:02 -05:00
|
|
|
/* If no lighting is enabled; this is the basic material color */
|
|
|
|
GLfloat unlit[4];
|
|
|
|
|
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-11 15:11:30 -05:00
|
|
|
/* Standard OpenGL lighting model attributes */
|
|
|
|
GLfloat ambient[4];
|
|
|
|
GLfloat diffuse[4];
|
|
|
|
GLfloat specular[4];
|
|
|
|
GLfloat emission[4];
|
|
|
|
GLfloat shininess;
|
2008-12-23 18:50:02 -05:00
|
|
|
|
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-11 15:11:30 -05:00
|
|
|
/* Determines what fragments are discarded based on their alpha */
|
|
|
|
CoglMaterialAlphaFunc alpha_func;
|
|
|
|
GLfloat alpha_func_reference;
|
|
|
|
|
|
|
|
/* Determines how this material is blended with other primitives */
|
2009-05-10 19:40:41 -04:00
|
|
|
#ifndef HAVE_COGL_GLES
|
|
|
|
GLenum blend_equation_rgb;
|
|
|
|
GLenum blend_equation_alpha;
|
2009-05-23 11:23:00 -04:00
|
|
|
GLint blend_src_factor_alpha;
|
|
|
|
GLint blend_dst_factor_alpha;
|
2009-05-10 19:40:41 -04:00
|
|
|
GLfloat blend_constant[4];
|
|
|
|
#endif
|
2009-05-23 11:23:00 -04:00
|
|
|
GLint blend_src_factor_rgb;
|
|
|
|
GLint blend_dst_factor_rgb;
|
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-11 15:11:30 -05:00
|
|
|
|
|
|
|
GList *layers;
|
|
|
|
};
|
|
|
|
|
2009-05-23 12:42:10 -04:00
|
|
|
/*
|
|
|
|
* SECTION:cogl-material-internals
|
|
|
|
* @short_description: Functions for creating custom primitives that make use
|
|
|
|
* of Cogl materials for filling.
|
|
|
|
*
|
|
|
|
* Normally you shouldn't need to use this API directly, but if you need to
|
|
|
|
* developing a custom/specialised primitive - probably using raw OpenGL - then
|
|
|
|
* this API aims to expose enough of the material internals to support being
|
|
|
|
* able to fill your geometry according to a given Cogl material.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cogl_material_get_cogl_enable_flags:
|
|
|
|
* @material: A CoglMaterial object
|
|
|
|
*
|
|
|
|
* This determines what flags need to be passed to cogl_enable before this
|
|
|
|
* material can be used. Normally you shouldn't need to use this function
|
|
|
|
* directly since Cogl will do this internally, but if you are developing
|
|
|
|
* custom primitives directly with OpenGL you may want to use this.
|
|
|
|
*
|
|
|
|
* Note: This API is hopfully just a stop-gap solution. Ideally cogl_enable
|
|
|
|
* will be replaced.
|
|
|
|
*/
|
|
|
|
/* TODO: find a nicer solution! */
|
|
|
|
gulong _cogl_material_get_cogl_enable_flags (CoglHandle handle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CoglMaterialLayerFlags:
|
|
|
|
* @COGL_MATERIAL_LAYER_FLAG_USER_MATRIX: Means the user has supplied a
|
|
|
|
* custom texture matrix.
|
|
|
|
*/
|
|
|
|
typedef enum _CoglMaterialLayerFlags
|
|
|
|
{
|
|
|
|
COGL_MATERIAL_LAYER_FLAG_HAS_USER_MATRIX = 1L<<0
|
|
|
|
} CoglMaterialLayerFlags;
|
|
|
|
/* XXX: NB: if you add flags here you will need to update
|
|
|
|
* CoglMaterialLayerPrivFlags!!! */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cogl_material_layer_get_flags:
|
|
|
|
* @layer_handle: A CoglMaterialLayer layer handle
|
|
|
|
*
|
|
|
|
* This lets you get a number of flag attributes about the layer. Normally
|
|
|
|
* you shouldn't need to use this function directly since Cogl will do this
|
|
|
|
* internally, but if you are developing custom primitives directly with
|
|
|
|
* OpenGL you may need this.
|
|
|
|
*/
|
|
|
|
gulong _cogl_material_layer_get_flags (CoglHandle layer_handle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CoglMaterialFlushOption:
|
|
|
|
* @COGL_MATERIAL_FLUSH_FALLBACK_MASK: Follow this by a guin32 mask
|
|
|
|
* of the layers that can't be supported with the user supplied texture
|
|
|
|
* and need to be replaced with fallback textures. (1 = fallback, and the
|
|
|
|
* least significant bit = layer 0)
|
|
|
|
* @COGL_MATERIAL_FLUSH_DISABLE_MASK: Follow this by a guint32 mask
|
|
|
|
* of the layers that you want to completly disable texturing for
|
|
|
|
* (1 = fallback, and the least significant bit = layer 0)
|
|
|
|
* @COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE: Follow this by a GLuint OpenGL texture
|
|
|
|
* name to override the texture used for layer 0 of the material. This is
|
|
|
|
* intended for dealing with sliced textures where you will need to point
|
|
|
|
* to each of the texture slices in turn when drawing your geometry.
|
|
|
|
* Passing a value of 0 is the same as not passing the option at all.
|
|
|
|
*/
|
|
|
|
typedef enum _CoglMaterialFlushOption
|
|
|
|
{
|
|
|
|
COGL_MATERIAL_FLUSH_FALLBACK_MASK = 1,
|
|
|
|
COGL_MATERIAL_FLUSH_DISABLE_MASK,
|
|
|
|
COGL_MATERIAL_FLUSH_LAYER0_OVERRIDE,
|
|
|
|
} CoglMaterialFlushOption;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cogl_material_flush_gl_state:
|
|
|
|
* @material: A CoglMaterial object
|
|
|
|
* @...: A NULL terminated list of (CoglMaterialFlushOption, data) pairs
|
|
|
|
*
|
|
|
|
* This function commits the state of the specified CoglMaterial - including
|
|
|
|
* the texture state for all the layers - to the OpenGL[ES] driver.
|
|
|
|
*
|
|
|
|
* Since 1.0
|
|
|
|
*/
|
|
|
|
void _cogl_material_flush_gl_state (CoglHandle material,
|
|
|
|
...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
|
|
|
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-11 15:11:30 -05:00
|
|
|
#endif /* __COGL_MATERIAL_PRIVATE_H */
|
|
|
|
|