2008-04-25 09:37:36 -04:00
|
|
|
/*
|
2009-04-27 10:48:12 -04:00
|
|
|
* Cogl
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
* Copyright (C) 2008,2009 Intel Corporation.
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-04-27 10:48:12 -04:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COGL_H__
|
|
|
|
#define __COGL_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
#define __COGL_H_INSIDE__
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include <cogl/cogl-defines-@CLUTTER_COGL@.h>
|
2008-10-30 13:25:00 -04: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
|
|
|
#include <cogl/cogl-vertex-buffer.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 <cogl/cogl-matrix.h>
|
2009-01-20 16:12:44 -05:00
|
|
|
#include <cogl/cogl-vertex-buffer.h>
|
2008-10-30 12:37:55 -04:00
|
|
|
#include <cogl/cogl-fixed.h>
|
2008-10-30 12:50:07 -04:00
|
|
|
#include <cogl/cogl-color.h>
|
2008-10-30 13:25:00 -04:00
|
|
|
#include <cogl/cogl-offscreen.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 <cogl/cogl-material.h>
|
2008-10-30 13:25:00 -04:00
|
|
|
#include <cogl/cogl-path.h>
|
|
|
|
#include <cogl/cogl-shader.h>
|
2009-04-30 13:00:22 -04:00
|
|
|
#include <cogl/cogl-bitmap.h>
|
2008-10-30 13:25:00 -04:00
|
|
|
#include <cogl/cogl-texture.h>
|
|
|
|
#include <cogl/cogl-types.h>
|
2009-02-23 07:47:02 -05:00
|
|
|
#include <cogl/cogl-debug.h>
|
2008-11-12 08:57:58 -05:00
|
|
|
#include <cogl/cogl-deprecated.h>
|
2009-05-29 07:31:47 -04:00
|
|
|
#include <cogl/cogl-enum-types.h>
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2008-06-12 13:21:16 -04:00
|
|
|
/**
|
|
|
|
* SECTION:cogl
|
|
|
|
* @short_description: General purpose API
|
|
|
|
*
|
|
|
|
* General utility functions for COGL.
|
|
|
|
*/
|
|
|
|
|
2009-02-23 07:47:02 -05:00
|
|
|
/**
|
|
|
|
* cogl_get_option_group:
|
|
|
|
*
|
|
|
|
* Retrieves the #GOptionGroup used by COGL to parse the command
|
|
|
|
* line options. Clutter uses this to handle the COGL command line
|
|
|
|
* options during its initialization process.
|
|
|
|
*
|
|
|
|
* Return value: a #GOptionGroup
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
GOptionGroup * cogl_get_option_group (void);
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Misc */
|
|
|
|
/**
|
|
|
|
* cogl_get_features:
|
|
|
|
*
|
|
|
|
* Returns all of the features supported by COGL.
|
|
|
|
*
|
|
|
|
* Return value: A logical OR of all the supported COGL features.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-10-30 12:52:56 -04:00
|
|
|
CoglFeatureFlags cogl_get_features (void);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_features_available:
|
|
|
|
* @features: A bitmask of features to check for
|
|
|
|
*
|
|
|
|
* Checks whether the given COGL features are available. Multiple
|
|
|
|
* features can be checked for by or-ing them together with the '|'
|
|
|
|
* operator. %TRUE is only returned if all of the requested features
|
|
|
|
* are available.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the features are available, %FALSE otherwise.
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
gboolean cogl_features_available (CoglFeatureFlags features);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_get_proc_address:
|
|
|
|
* @name: the name of the function.
|
|
|
|
*
|
|
|
|
* Gets a pointer to a given GL or GL ES extension function. This acts
|
|
|
|
* as a wrapper around glXGetProcAddress() or whatever is the
|
|
|
|
* appropriate function for the current backend.
|
|
|
|
*
|
|
|
|
* Return value: a pointer to the requested function or %NULL if the
|
|
|
|
* function is not available.
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
CoglFuncPtr cogl_get_proc_address (const gchar *name);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2008-04-28 10:00:46 -04:00
|
|
|
/**
|
|
|
|
* cogl_check_extension:
|
|
|
|
* @name: extension to check for
|
|
|
|
* @ext: list of extensions
|
|
|
|
*
|
|
|
|
* Check whether @name occurs in list of extensions in @ext.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the extension occurs in the list, %FALSE otherwize.
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
gboolean cogl_check_extension (const gchar *name,
|
|
|
|
const gchar *ext);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_get_bitmasks:
|
|
|
|
* @red: Return location for the number of red bits or %NULL
|
|
|
|
* @green: Return location for the number of green bits or %NULL
|
|
|
|
* @blue: Return location for the number of blue bits or %NULL
|
|
|
|
* @alpha: Return location for the number of alpha bits or %NULL
|
|
|
|
*
|
|
|
|
* Gets the number of bitplanes used for each of the color components
|
|
|
|
* in the color buffer. Pass %NULL for any of the arguments if the
|
|
|
|
* value is not required.
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
void cogl_get_bitmasks (gint *red,
|
|
|
|
gint *green,
|
|
|
|
gint *blue,
|
|
|
|
gint *alpha);
|
2008-04-28 10:00:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_perspective:
|
|
|
|
* @fovy: Vertical of view angle in degrees.
|
|
|
|
* @aspect: Aspect ratio of diesplay
|
2008-04-28 11:36:11 -04:00
|
|
|
* @z_near: Nearest visible point
|
|
|
|
* @z_far: Furthest visible point along the z-axis
|
2008-04-28 10:00:46 -04:00
|
|
|
*
|
2008-08-01 08:23:57 -04:00
|
|
|
* Replaces the current projection matrix with a perspective matrix
|
|
|
|
* based on the provided values.
|
2008-04-28 10:00:46 -04:00
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_perspective (float fovy,
|
|
|
|
float aspect,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2008-08-01 08:23:57 -04:00
|
|
|
/**
|
|
|
|
* cogl_frustum:
|
|
|
|
* @left: Left clipping plane
|
|
|
|
* @right: Right clipping plane
|
|
|
|
* @bottom: Bottom clipping plane
|
|
|
|
* @top: Top clipping plane
|
|
|
|
* @z_near: Nearest visible point
|
|
|
|
* @z_far: Furthest visible point along the z-axis
|
|
|
|
*
|
|
|
|
* Replaces the current projection matrix with a perspective matrix
|
|
|
|
* for the given viewing frustum.
|
|
|
|
*
|
|
|
|
* Since: 0.8.2
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_frustum (float left,
|
|
|
|
float right,
|
|
|
|
float bottom,
|
|
|
|
float top,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2008-08-01 08:23:57 -04:00
|
|
|
|
2009-05-26 06:33:54 -04:00
|
|
|
/**
|
|
|
|
* cogl_ortho:
|
|
|
|
* @left: The coordinate for the left clipping plane
|
|
|
|
* @right: The coordinate for the right clipping plane
|
|
|
|
* @bottom: The coordinate for the bottom clipping plane
|
|
|
|
* @top: The coordinate for the top clipping plane
|
|
|
|
* @near: The coordinate for the near clipping plane (may be negative if
|
|
|
|
* the plane is behind the viewer)
|
|
|
|
* @far: The coordinate for the far clipping plane (may be negative if
|
|
|
|
* the plane is behind the viewer)
|
|
|
|
*
|
|
|
|
* Replaces the current projection matrix with a parallel projection
|
|
|
|
* matrix.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_ortho (float left,
|
|
|
|
float right,
|
|
|
|
float bottom,
|
|
|
|
float top,
|
|
|
|
float near,
|
|
|
|
float far);
|
|
|
|
|
2009-05-28 08:03:19 -04:00
|
|
|
/*
|
|
|
|
* _cogl_setup_viewport:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @width: Width of the viewport
|
|
|
|
* @height: Height of the viewport
|
|
|
|
* @fovy: Field of view angle in degrees
|
|
|
|
* @aspect: Aspect ratio to determine the field of view along the x-axis
|
|
|
|
* @z_near: Nearest visible point along the z-axis
|
|
|
|
* @z_far: Furthest visible point along the z-axis
|
|
|
|
*
|
|
|
|
* Replaces the current viewport and projection matrix with the given
|
|
|
|
* values. The viewport is placed at the top left corner of the window
|
|
|
|
* with the given width and height. The projection matrix is replaced
|
|
|
|
* with one that has a viewing angle of @fovy along the y-axis and a
|
|
|
|
* view scaled according to @aspect along the x-axis. The view is
|
|
|
|
* clipped according to @z_near and @z_far on the z-axis.
|
2009-05-28 08:03:19 -04:00
|
|
|
*
|
|
|
|
* This function is used only by Clutter.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-05-28 08:03:19 -04:00
|
|
|
void _cogl_setup_viewport (guint width,
|
|
|
|
guint height,
|
2009-01-20 11:20:54 -05:00
|
|
|
float fovy,
|
|
|
|
float aspect,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2008-08-01 08:23:57 -04:00
|
|
|
/**
|
|
|
|
* cogl_viewport:
|
|
|
|
* @width: Width of the viewport
|
|
|
|
* @height: Height of the viewport
|
|
|
|
*
|
|
|
|
* Replace the current viewport with the given values.
|
|
|
|
*
|
|
|
|
* Since: 0.8.2
|
|
|
|
*/
|
|
|
|
void cogl_viewport (guint width,
|
|
|
|
guint height);
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/**
|
|
|
|
* cogl_push_matrix:
|
|
|
|
*
|
|
|
|
* Store the current model-view matrix on the matrix stack. The matrix
|
|
|
|
* can later be restored with cogl_pop_matrix().
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
void cogl_push_matrix (void);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_pop_matrix:
|
|
|
|
*
|
|
|
|
* Restore the current model-view matrix from the matrix stack.
|
|
|
|
*/
|
2008-04-28 11:36:11 -04:00
|
|
|
void cogl_pop_matrix (void);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_scale:
|
|
|
|
* @x: Amount to scale along the x-axis
|
|
|
|
* @y: Amount to scale along the y-axis
|
2009-01-26 17:52:38 -05:00
|
|
|
* @z: Amount to scale along the z-axis
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-01-26 17:52:38 -05:00
|
|
|
* Multiplies the current model-view matrix by one that scales the x,
|
|
|
|
* y and z axes by the given values.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_scale (float x,
|
2009-01-26 17:52:38 -05:00
|
|
|
float y,
|
|
|
|
float z);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
2009-01-20 11:20:54 -05:00
|
|
|
* cogl_translate:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @x: Distance to translate along the x-axis
|
|
|
|
* @y: Distance to translate along the y-axis
|
|
|
|
* @z: Distance to translate along the z-axis
|
|
|
|
*
|
|
|
|
* Multiplies the current model-view matrix by one that translates the
|
|
|
|
* model along all three axes according to the given values.
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_translate (float x,
|
|
|
|
float y,
|
|
|
|
float z);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
2009-01-20 11:20:54 -05:00
|
|
|
* cogl_rotate:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @angle: Angle in degrees to rotate.
|
|
|
|
* @x: X-component of vertex to rotate around.
|
|
|
|
* @y: Y-component of vertex to rotate around.
|
|
|
|
* @z: Z-component of vertex to rotate around.
|
|
|
|
*
|
|
|
|
* Multiplies the current model-view matrix by one that rotates the
|
|
|
|
* model around the vertex specified by @x, @y and @z. The rotation
|
|
|
|
* follows the right-hand thumb rule so for example rotating by 10
|
|
|
|
* degrees about the vertex (0, 0, 1) causes a small counter-clockwise
|
|
|
|
* rotation.
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_rotate (float angle,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float z);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_get_modelview_matrix:
|
2009-02-18 13:54:54 -05:00
|
|
|
* @matrix: pointer to a CoglMatrix to recieve the matrix
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-02-18 13:54:54 -05:00
|
|
|
* Stores the current model-view matrix in @matrix.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-02-18 13:54:54 -05:00
|
|
|
void cogl_get_modelview_matrix (CoglMatrix *matrix);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2009-05-26 06:33:54 -04:00
|
|
|
/**
|
|
|
|
* cogl_set_modelview_matrix:
|
|
|
|
* @matrix: pointer to a CoglMatrix to set as the new model-view matrix
|
|
|
|
*
|
|
|
|
* Loads matrix as the new model-view matrix.
|
|
|
|
*/
|
|
|
|
void cogl_set_modelview_matrix (CoglMatrix *matrix);
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/**
|
|
|
|
* cogl_get_projection_matrix:
|
2009-02-18 13:54:54 -05:00
|
|
|
* @matrix: pointer to a CoglMatrix to recieve the matrix
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-02-18 13:54:54 -05:00
|
|
|
* Stores the current projection matrix in @matrix.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-02-18 13:54:54 -05:00
|
|
|
void cogl_get_projection_matrix (CoglMatrix *matrix);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2009-05-26 06:33:54 -04:00
|
|
|
/**
|
|
|
|
* cogl_set_projection_matrix:
|
|
|
|
* @matrix: pointer to a CoglMatrix to set as the new projection matrix
|
|
|
|
*
|
|
|
|
* Loads matrix as the new projection matrix.
|
|
|
|
*/
|
|
|
|
void cogl_set_projection_matrix (CoglMatrix *matrix);
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/**
|
|
|
|
* cogl_get_viewport:
|
2009-01-20 11:20:54 -05:00
|
|
|
* @v: pointer to a 4 element array of #float<!-- -->s to
|
2008-04-25 09:37:36 -04:00
|
|
|
* receive the viewport dimensions.
|
|
|
|
*
|
|
|
|
* Stores the current viewport in @v. @v[0] and @v[1] get the x and y
|
|
|
|
* position of the viewport and @v[2] and @v[3] get the width and
|
|
|
|
* height.
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
void cogl_get_viewport (float v[4]);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
2009-06-10 07:50:45 -04:00
|
|
|
* cogl_set_depth_test_enabled:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @setting: %TRUE to enable depth testing or %FALSE to disable.
|
|
|
|
*
|
|
|
|
* Sets whether depth testing is enabled. If it is disabled then the
|
|
|
|
* order that actors are layered on the screen depends solely on the
|
|
|
|
* order specified using clutter_actor_raise() and
|
|
|
|
* clutter_actor_lower(), otherwise it will also take into account the
|
|
|
|
* actor's depth. Depth testing is disabled by default.
|
|
|
|
*/
|
2009-06-10 07:50:45 -04:00
|
|
|
void cogl_set_depth_test_enabled (gboolean setting);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2008-10-27 10:36:52 -04:00
|
|
|
/**
|
2009-05-26 11:55:11 -04:00
|
|
|
* cogl_get_depth_test_enable:
|
|
|
|
*
|
|
|
|
* Queries if depth testing has been enabled via cogl_set_depth_test_enable()
|
|
|
|
*
|
|
|
|
* Returns: TRUE if depth testing is enabled else FALSE
|
|
|
|
*/
|
2009-06-10 07:50:45 -04:00
|
|
|
gboolean cogl_get_depth_test_enabled (void);
|
2009-05-26 11:55:11 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_set_backface_culling_enabled:
|
2008-10-27 10:36:52 -04:00
|
|
|
* @setting: %TRUE to enable backface culling or %FALSE to disable.
|
|
|
|
*
|
|
|
|
* Sets whether textures positioned so that their backface is showing
|
|
|
|
* should be hidden. This can be used to efficiently draw two-sided
|
2009-05-21 09:56:38 -04:00
|
|
|
* textures or fully closed cubes without enabling depth testing. This
|
|
|
|
* only affects calls to the cogl_rectangle* family of functions and
|
|
|
|
* cogl_vertex_buffer_draw*. Backface culling is disabled by default.
|
2008-10-27 10:36:52 -04:00
|
|
|
*/
|
2009-05-26 11:55:11 -04:00
|
|
|
void cogl_set_backface_culling_enabled (gboolean setting);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_get_backface_culling_enabled:
|
|
|
|
*
|
|
|
|
* Queries if backface culling has been enabled via
|
|
|
|
* cogl_set_backface_culling_enabled()
|
|
|
|
*
|
|
|
|
* Returns: TRUE if backface culling is enabled else FALSE
|
|
|
|
*/
|
|
|
|
gboolean cogl_get_backface_culling_enabled (void);
|
2008-10-27 10:36:52 -04:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/**
|
2009-02-04 04:21:37 -05:00
|
|
|
* cogl_set_fog:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @fog_color: The color of the fog
|
2009-02-12 08:23:20 -05:00
|
|
|
* @mode: A CoglFogMode that determines the equation used to calculate the
|
|
|
|
* fogging blend factor.
|
|
|
|
* @density: Used by the EXPONENTIAL and EXPONENTIAL_SQUARED CoglFogMode
|
|
|
|
* equations.
|
2008-04-25 09:37:36 -04:00
|
|
|
* @z_near: Position along z-axis where no fogging should be applied
|
|
|
|
* @z_far: Position along z-axes where full fogging should be applied
|
|
|
|
*
|
2009-06-07 06:54:05 -04:00
|
|
|
* Enables fogging. Fogging causes vertices that are further away from the eye
|
|
|
|
* to be rendered with a different color. The color is determined according to
|
|
|
|
* the chosen fog mode; at it's simplest the color is linearly interpolated so
|
|
|
|
* that vertices at @z_near are drawn fully with their original color and
|
|
|
|
* vertices at @z_far are drawn fully with @fog_color. Fogging will remain
|
|
|
|
* enabled until you call cogl_disable_fog().
|
|
|
|
*
|
|
|
|
* Note: The fogging functions only work correctly when primitives use
|
|
|
|
* unmultiplied alpha colors. By default Cogl will premultiply textures
|
|
|
|
* and cogl_set_source_color will premultiply colors, so unless you
|
|
|
|
* explicitly load your textures requesting an unmultiplied
|
|
|
|
* internal_format and use cogl_material_set_color you can only use
|
|
|
|
* fogging with fully opaque primitives.
|
|
|
|
*
|
|
|
|
* We can look to improve this in the future when we can depend on
|
|
|
|
* fragment shaders.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-02-04 04:21:37 -05:00
|
|
|
void cogl_set_fog (const CoglColor *fog_color,
|
2009-02-12 08:23:20 -05:00
|
|
|
CoglFogMode mode,
|
2009-02-04 04:21:37 -05:00
|
|
|
float density,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
/**
|
2009-02-12 08:23:20 -05:00
|
|
|
* cogl_disable_fog:
|
|
|
|
*
|
|
|
|
* This function disables fogging, so primitives drawn afterwards will not be
|
|
|
|
* blended with any previously set fog color.
|
|
|
|
*/
|
|
|
|
void cogl_disable_fog (void);
|
|
|
|
|
2009-04-24 13:09:52 -04:00
|
|
|
/**
|
|
|
|
* CoglBufferBit:
|
|
|
|
* @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer
|
|
|
|
* @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer
|
|
|
|
* @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer
|
2009-05-28 12:18:13 -04:00
|
|
|
*
|
|
|
|
* Types of auxiliary buffers
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2009-04-24 13:09:52 -04:00
|
|
|
*/
|
2009-05-29 07:31:47 -04:00
|
|
|
typedef enum {
|
2009-04-24 13:09:52 -04:00
|
|
|
COGL_BUFFER_BIT_COLOR = 1L<<0,
|
|
|
|
COGL_BUFFER_BIT_DEPTH = 1L<<1,
|
|
|
|
COGL_BUFFER_BIT_STENCIL = 1L<<2
|
|
|
|
} CoglBufferBit;
|
|
|
|
|
2009-02-12 08:23:20 -05:00
|
|
|
/**
|
|
|
|
* cogl_clear:
|
2008-04-25 09:37:36 -04:00
|
|
|
* @color: Background color to clear to
|
2009-05-29 07:31:47 -04:00
|
|
|
* @buffers: A mask of #CoglBufferBit<!-- -->'s identifying which auxiliary
|
|
|
|
* buffers to clear
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-04-24 13:09:52 -04:00
|
|
|
* Clears all the auxiliary buffers identified in the @buffers mask, and if
|
|
|
|
* that includes the color buffer then the specified @color is used.
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
2009-05-29 07:31:47 -04:00
|
|
|
void cogl_clear (const CoglColor *color,
|
|
|
|
gulong buffers);
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2009-02-06 06:16:42 -05:00
|
|
|
/**
|
|
|
|
* cogl_set_source:
|
|
|
|
* @material: A CoglMaterial object
|
|
|
|
*
|
|
|
|
* This function sets the source material that will be used to fill subsequent
|
|
|
|
* geometry emitted via the cogl API.
|
|
|
|
*
|
|
|
|
* Note: in the future we may add the ability to set a front facing material,
|
|
|
|
* and a back facing material, in which case this function will set both to the
|
|
|
|
* same.
|
|
|
|
*
|
|
|
|
* Since 1.0
|
|
|
|
*/
|
|
|
|
void cogl_set_source (CoglHandle material);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_set_source_color:
|
|
|
|
* @color: a #CoglColor
|
|
|
|
*
|
2009-05-09 14:39:01 -04:00
|
|
|
* This is a convenience function for creating a solid fill source material
|
|
|
|
* from the given color. This color will be used for any subsequent drawing
|
|
|
|
* operation.
|
|
|
|
*
|
|
|
|
* The color will be premultiplied by Cogl, so the color should be
|
|
|
|
* non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for
|
|
|
|
* semi-transparent red.
|
2009-02-06 06:16:42 -05:00
|
|
|
*
|
|
|
|
* See also cogl_set_source_color4ub() and cogl_set_source_color4f()
|
|
|
|
* if you already have the color components.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_set_source_color (const CoglColor *color);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_set_source_color4ub:
|
|
|
|
* @red: value of the red channel, between 0 and 255
|
|
|
|
* @green: value of the green channel, between 0 and 255
|
|
|
|
* @blue: value of the blue channel, between 0 and 255
|
|
|
|
* @alpha: value of the alpha channel, between 0 and 255
|
|
|
|
*
|
|
|
|
* This is a convenience function for creating a solid fill source material
|
|
|
|
* from the given color using unsigned bytes for each component. This
|
|
|
|
* color will be used for any subsequent drawing operation.
|
|
|
|
*
|
|
|
|
* The value for each component is an unsigned byte in the range
|
|
|
|
* between 0 and 255.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_set_source_color4ub (guint8 red,
|
|
|
|
guint8 green,
|
|
|
|
guint8 blue,
|
|
|
|
guint8 alpha);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_set_source_color4f:
|
|
|
|
* @red: value of the red channel, between 0 and %1.0
|
|
|
|
* @green: value of the green channel, between 0 and %1.0
|
|
|
|
* @blue: value of the blue channel, between 0 and %1.0
|
|
|
|
* @alpha: value of the alpha channel, between 0 and %1.0
|
|
|
|
*
|
|
|
|
* This is a convenience function for creating a solid fill source material
|
|
|
|
* from the given color using normalized values for each component. This color
|
|
|
|
* will be used for any subsequent drawing operation.
|
|
|
|
*
|
|
|
|
* The value for each component is a fixed point number in the range
|
|
|
|
* between 0 and %1.0. If the values passed in are outside that
|
|
|
|
* range, they will be clamped.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_set_source_color4f (float red,
|
|
|
|
float green,
|
|
|
|
float blue,
|
|
|
|
float alpha);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_set_source_texture:
|
|
|
|
* @texture_handle: The Cogl texture you want as your source
|
|
|
|
*
|
|
|
|
* This is a convenience function for creating a material with the first
|
|
|
|
* layer set to #texture_handle and setting that material as the source with
|
|
|
|
* cogl_set_source.
|
|
|
|
*
|
|
|
|
* Note: There is no interaction between calls to cogl_set_source_color
|
|
|
|
* and cogl_set_source_texture. If you need to blend a texture with a color then
|
|
|
|
* you can create a simple material like this:
|
|
|
|
* <programlisting>
|
|
|
|
* material = cogl_material_new ();
|
|
|
|
* cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80);
|
|
|
|
* cogl_material_set_layer (material, 0, tex_handle);
|
|
|
|
* cogl_set_source (material);
|
|
|
|
* </programlisting>
|
|
|
|
*
|
|
|
|
* Since 1.0
|
|
|
|
*/
|
|
|
|
void cogl_set_source_texture (CoglHandle texture_handle);
|
|
|
|
|
2009-02-12 08:23:20 -05:00
|
|
|
/**
|
|
|
|
* SECTION:cogl-clipping
|
|
|
|
* @short_description: Fuctions for manipulating a stack of clipping regions
|
|
|
|
*
|
|
|
|
* To support clipping your geometry to rectangles or paths Cogl exposes a
|
|
|
|
* stack based API whereby each clip region you push onto the stack is
|
|
|
|
* intersected with the previous region.
|
|
|
|
*/
|
|
|
|
|
2009-05-08 11:32:01 -04:00
|
|
|
/**
|
|
|
|
* cogl_clip_push_window_rect:
|
|
|
|
* @x_offset: left edge of the clip rectangle in window coordinates
|
|
|
|
* @y_offset: top edge of the clip rectangle in window coordinates
|
|
|
|
* @width: width of the clip rectangle
|
|
|
|
* @height: height of the clip rectangle
|
|
|
|
*
|
|
|
|
* Specifies a rectangular clipping area for all subsequent drawing
|
|
|
|
* operations. Any drawing commands that extend outside the rectangle
|
|
|
|
* will be clipped so that only the portion inside the rectangle will
|
|
|
|
* be displayed. The rectangle dimensions are not transformed by the
|
|
|
|
* current model-view matrix.
|
|
|
|
*
|
|
|
|
* The rectangle is intersected with the current clip region. To undo
|
|
|
|
* the effect of this function, call cogl_clip_pop().
|
|
|
|
*/
|
|
|
|
void cogl_clip_push_window_rect (float x_offset,
|
|
|
|
float y_offset,
|
|
|
|
float width,
|
|
|
|
float height);
|
|
|
|
|
2009-02-12 08:23:20 -05:00
|
|
|
/**
|
|
|
|
* cogl_clip_push:
|
|
|
|
* @x_offset: left edge of the clip rectangle
|
|
|
|
* @y_offset: top edge of the clip rectangle
|
|
|
|
* @width: width of the clip rectangle
|
|
|
|
* @height: height of the clip rectangle
|
|
|
|
*
|
|
|
|
* Specifies a rectangular clipping area for all subsequent drawing
|
|
|
|
* operations. Any drawing commands that extend outside the rectangle
|
|
|
|
* will be clipped so that only the portion inside the rectangle will
|
|
|
|
* be displayed. The rectangle dimensions are transformed by the
|
|
|
|
* current model-view matrix.
|
|
|
|
*
|
|
|
|
* The rectangle is intersected with the current clip region. To undo
|
|
|
|
* the effect of this function, call cogl_clip_pop().
|
|
|
|
*/
|
|
|
|
void cogl_clip_push (float x_offset,
|
|
|
|
float y_offset,
|
|
|
|
float width,
|
|
|
|
float height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_push_from_path:
|
|
|
|
*
|
|
|
|
* Sets a new clipping area using the current path. The current path
|
|
|
|
* is then cleared. The clipping area is intersected with the previous
|
|
|
|
* clipping area. To restore the previous clipping area, call
|
|
|
|
* cogl_clip_pop().
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_clip_push_from_path (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_push_from_path_preserve:
|
|
|
|
*
|
|
|
|
* Sets a new clipping area using the current path. The current path
|
|
|
|
* is then cleared. The clipping area is intersected with the previous
|
|
|
|
* clipping area. To restore the previous clipping area, call
|
|
|
|
* cogl_clip_pop().
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_clip_push_from_path_preserve (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_pop:
|
|
|
|
*
|
|
|
|
* Reverts the clipping region to the state before the last call to
|
|
|
|
* cogl_clip_push().
|
|
|
|
*/
|
|
|
|
void cogl_clip_pop (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_ensure:
|
|
|
|
*
|
|
|
|
* Ensures that the current clipping region has been set in GL. This
|
|
|
|
* will automatically be called before any Cogl primitives but it
|
|
|
|
* maybe be neccessary to call if you are using raw GL calls with
|
|
|
|
* clipping.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_clip_ensure (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_stack_save:
|
|
|
|
*
|
|
|
|
* Save the entire state of the clipping stack and then clear all
|
|
|
|
* clipping. The previous state can be returned to with
|
|
|
|
* cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
|
|
|
|
* must be matched by a call to cogl_clip_pop() before calling
|
|
|
|
* cogl_clip_stack_restore().
|
|
|
|
*
|
|
|
|
* Since: 0.8.2
|
|
|
|
*/
|
|
|
|
void cogl_clip_stack_save (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_clip_stack_restore:
|
|
|
|
*
|
|
|
|
* Restore the state of the clipping stack that was previously saved
|
|
|
|
* by cogl_clip_stack_save().
|
|
|
|
*
|
|
|
|
* Since: 0.8.2
|
|
|
|
*/
|
|
|
|
void cogl_clip_stack_restore (void);
|
|
|
|
|
2009-04-30 17:19:43 -04:00
|
|
|
/**
|
|
|
|
* cogl_set_draw_buffer:
|
|
|
|
* @target: A #CoglBufferTarget that specifies what kind of draw buffer you
|
|
|
|
* are setting as the render target.
|
|
|
|
* @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER
|
|
|
|
* then this is a CoglHandle for the offscreen buffer.
|
|
|
|
*
|
|
|
|
* This redirects all subsequent drawing to the specified draw buffer. This
|
|
|
|
* can either be an offscreen buffer created with
|
|
|
|
* cogl_offscreen_new_to_texture () or you can revert to your original
|
|
|
|
* on screen window buffer.
|
|
|
|
*/
|
|
|
|
void cogl_set_draw_buffer (CoglBufferTarget target,
|
|
|
|
CoglHandle offscreen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_push_draw_buffer:
|
|
|
|
*
|
|
|
|
* Save cogl_set_draw_buffer() state.
|
|
|
|
*/
|
|
|
|
void cogl_push_draw_buffer (void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_pop_draw_buffer:
|
|
|
|
*
|
|
|
|
* Restore cogl_set_draw_buffer() state.
|
|
|
|
*/
|
|
|
|
void cogl_pop_draw_buffer (void);
|
|
|
|
|
2009-06-17 09:30:44 -04:00
|
|
|
/**
|
|
|
|
* CoglReadPixelsFlags:
|
|
|
|
* @COGL_READ_PIXELS_COLOR_BUFFER: Read from the color buffer
|
|
|
|
*/
|
|
|
|
typedef enum _CoglReadPixelsFlags
|
|
|
|
{
|
|
|
|
COGL_READ_PIXELS_COLOR_BUFFER = 1L<<0
|
|
|
|
} CoglReadPixelsFlags;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_read_pixels:
|
|
|
|
* @x: The window x position to start reading from
|
|
|
|
* @y: The window y position to start reading from
|
|
|
|
* @width: The width of the rectangle you want to read
|
|
|
|
* @height: The height of the rectangle you want to read
|
|
|
|
* @source: Identifies which auxillary buffer you want to read
|
|
|
|
* (only COGL_READ_PIXELS_COLOR_BUFFER supported currently)
|
|
|
|
* @format: The pixel format you want the result in
|
|
|
|
* (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently)
|
|
|
|
* @pixels: The location to write the pixel data.
|
|
|
|
*
|
|
|
|
* This reads a rectangle of pixels from the current draw buffer where
|
|
|
|
* position (0, 0) is the top left. The pixel at (x, y) is the first
|
|
|
|
* read, and the data is returned with a rowstride of (width * 4)
|
|
|
|
*/
|
|
|
|
void cogl_read_pixels (int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
CoglReadPixelsFlags source,
|
|
|
|
CoglPixelFormat format,
|
|
|
|
guint8 *pixels);
|
|
|
|
|
2009-05-26 10:41:53 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal API available only to Clutter.
|
|
|
|
*
|
|
|
|
* These are typically only to deal with the poor seperation of
|
|
|
|
* responsabilities that currently exists between Clutter and Cogl.
|
|
|
|
* Eventually a lot of the backend code currently in Clutter will
|
|
|
|
* move down into Cogl and these functions will be removed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void _cogl_destroy_context (void);
|
|
|
|
|
2009-05-23 12:52:18 -04:00
|
|
|
/* XXX: Removed before we release Clutter 1.0 since the implementation
|
|
|
|
* wasn't complete, and so we assume no one is using this yet. Util we
|
|
|
|
* have some one with a good usecase, we can't pretend to support breaking
|
|
|
|
* out into raw OpenGL. */
|
|
|
|
#if 0
|
|
|
|
/*
|
2009-02-24 13:51:25 -05:00
|
|
|
* cogl_flush_gl_state:
|
|
|
|
* @flags: flags controlling what is flushed; currently unused, pass in 0
|
|
|
|
*
|
|
|
|
* As an optimization, COGL functions may not immediately modify GL's
|
|
|
|
* state, instead batching up changes and applying them "just in
|
|
|
|
* time." Unapplied state could include glEnable() flags and the
|
|
|
|
* current transformation matrix among other examples. If you want to
|
|
|
|
* use GL directly, you need to flush any state COGL may have kept
|
|
|
|
* around. cogl_flush_gl_state() syncs all of COGL's state to GL.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void cogl_flush_gl_state (int flags);
|
2009-05-23 12:52:18 -04:00
|
|
|
#endif
|
2009-02-24 13:51:25 -05:00
|
|
|
|
|
|
|
/* private */
|
|
|
|
void _cogl_set_indirect_context (gboolean indirect);
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
G_END_DECLS
|
|
|
|
|
2008-10-30 13:04:34 -04:00
|
|
|
#undef __COGL_H_INSIDE__
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#endif /* __COGL_H__ */
|