From 90f4b1d4926d9474374b4adebdda50f3427bda00 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 30 Oct 2008 17:25:00 +0000 Subject: [PATCH] 2008-10-30 Emmanuele Bassi Bug 1219 - Clean up cogl.h * clutter/cogl/cogl.h.in: * clutter/cogl/cogl-offscreen.h: * clutter/cogl/cogl-path.h: * clutter/cogl/cogl-shader.h: * clutter/cogl/cogl-texture.h: * clutter/cogl/cogl-types.h: Split up the massive cogl.h file into sub-header for each section of the API. * clutter/cogl/gl/*: * clutter/cogl/gles/*: Update the GL and GLES implementations of COGL to cope with the new header structure. * doc/reference/cogl/Makefile.am: Fix symbol retrieval. --- ChangeLog | 18 + clutter/cogl/cogl-color.h | 24 +- clutter/cogl/cogl-fixed.h | 23 +- clutter/cogl/cogl-offscreen.h | 110 ++ clutter/cogl/cogl-path.h | 315 +++++ clutter/cogl/cogl-shader.h | 210 +++ clutter/cogl/cogl-texture.h | 371 ++++++ clutter/cogl/cogl-types.h | 240 ++++ clutter/cogl/cogl.h.in | 1167 +---------------- clutter/cogl/common/cogl-color.c | 1 + clutter/cogl/gl/Makefile.am | 17 +- clutter/cogl/gl/cogl-fbo.c | 2 +- clutter/cogl/gl/cogl-program.c | 2 +- .../{cogl-shader.h => cogl-shader-private.h} | 0 clutter/cogl/gl/cogl-shader.c | 2 +- ...{cogl-texture.h => cogl-texture-private.h} | 0 clutter/cogl/gl/cogl-texture.c | 2 +- clutter/cogl/gles/Makefile.am | 16 +- clutter/cogl/gles/cogl-fbo.c | 2 +- clutter/cogl/gles/cogl-gles2-wrapper.c | 2 +- clutter/cogl/gles/cogl-program.c | 2 +- .../{cogl-shader.h => cogl-shader-private.h} | 0 clutter/cogl/gles/cogl-shader.c | 2 +- ...{cogl-texture.h => cogl-texture-private.h} | 0 clutter/cogl/gles/cogl-texture.c | 2 +- doc/reference/cogl/Makefile.am | 9 +- 26 files changed, 1313 insertions(+), 1226 deletions(-) create mode 100644 clutter/cogl/cogl-offscreen.h create mode 100644 clutter/cogl/cogl-path.h create mode 100644 clutter/cogl/cogl-shader.h create mode 100644 clutter/cogl/cogl-texture.h create mode 100644 clutter/cogl/cogl-types.h rename clutter/cogl/gl/{cogl-shader.h => cogl-shader-private.h} (100%) rename clutter/cogl/gl/{cogl-texture.h => cogl-texture-private.h} (100%) rename clutter/cogl/gles/{cogl-shader.h => cogl-shader-private.h} (100%) rename clutter/cogl/gles/{cogl-texture.h => cogl-texture-private.h} (100%) diff --git a/ChangeLog b/ChangeLog index eec71811d..b29529f0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-10-30 Emmanuele Bassi + + Bug 1219 - Clean up cogl.h + + * clutter/cogl/cogl.h.in: + * clutter/cogl/cogl-offscreen.h: + * clutter/cogl/cogl-path.h: + * clutter/cogl/cogl-shader.h: + * clutter/cogl/cogl-texture.h: + * clutter/cogl/cogl-types.h: Split up the massive cogl.h file + into sub-header for each section of the API. + + * clutter/cogl/gl/*: + * clutter/cogl/gles/*: Update the GL and GLES implementations + of COGL to cope with the new header structure. + + * doc/reference/cogl/Makefile.am: Fix symbol retrieval. + 2008-10-30 Emmanuele Bassi Bug 1215 - Move the Pango renderer to the public API diff --git a/clutter/cogl/cogl-color.h b/clutter/cogl/cogl-color.h index 56f75a86b..d957ff26a 100644 --- a/clutter/cogl/cogl-color.h +++ b/clutter/cogl/cogl-color.h @@ -5,32 +5,10 @@ #ifndef __COGL_COLOR_H__ #define __COGL_COLOR_H__ -#include -#include +#include G_BEGIN_DECLS -typedef struct _CoglColor CoglColor; - -/** - * CoglColor: - * - * A structure for holding a color definition. The contents of - * the CoglColor structure are private and should never by accessed - * directly. - * - * Since: 1.0 - */ -struct _CoglColor -{ - /*< private >*/ - CoglFixed red; - CoglFixed green; - CoglFixed blue; - - CoglFixed alpha; -}; - /** * cogl_color_set_from_4ub: * @dest: return location for a #CoglColor diff --git a/clutter/cogl/cogl-fixed.h b/clutter/cogl/cogl-fixed.h index 1e2709572..dc8a66024 100644 --- a/clutter/cogl/cogl-fixed.h +++ b/clutter/cogl/cogl-fixed.h @@ -5,7 +5,7 @@ #ifndef __COGL_FIXED_H__ #define __COGL_FIXED_H__ -#include +#include /** * SECTION:cogl-fixed @@ -45,17 +45,6 @@ G_BEGIN_DECLS -/** - * CoglFixed: - * - * Fixed point number using a (16.16) notation. - */ -typedef gint32 CoglFixed; - -/* - * some commonly used constants - */ - /** * COGL_FIXED_BITS: * @@ -614,16 +603,6 @@ guint cogl_fixed_pow (guint x, */ gint cogl_sqrti (gint x); -/** - * CoglAngle: - * - * Integer representation of an angle such that 1024 corresponds to - * full circle (i.e., 2 * pi). - * - * Since: 1.0 - */ -typedef gint32 CoglAngle; - /** * COGL_ANGLE_FROM_DEG: * @x: an angle in degrees in floating point notation diff --git a/clutter/cogl/cogl-offscreen.h b/clutter/cogl/cogl-offscreen.h new file mode 100644 index 000000000..a621ce36a --- /dev/null +++ b/clutter/cogl/cogl-offscreen.h @@ -0,0 +1,110 @@ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_OFFSCREEN_H__ +#define __COGL_OFFSCREEN_H__ + +#include + +G_BEGIN_DECLS + +/** + * SECTION:cogl-offscreen + * @short_description: Fuctions for creating and manipulating offscreen + * frame buffer objects + * + * COGL allows creating and operating on FBOs (Framebuffer Objects). + */ + +/* Offscreen api */ + +/** + * cogl_offscreen_new_to_texture: + * @texhandle: + * + * Returns: + */ +CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle); + +/** + * cogl_offscreen_new_multisample: + * + * + * Returns: + */ +CoglHandle cogl_offscreen_new_multisample (void); + +/** + * cogl_offscreen_ref: + * @handle: + * + * Returns: + */ +CoglHandle cogl_offscreen_ref (CoglHandle handle); + +/** + * cogl_is_offscreen: + * @handle: A CoglHandle + * + * Gets whether the given handle references an existing offscreen + * buffer object. + * + * Returns: %TRUE if the handle references an offscreen buffer, + * %FALSE otherwise + */ +gboolean cogl_is_offscreen (CoglHandle handle); + +/** + * cogl_offscreen_unref: + * @handle: + * + */ +void cogl_offscreen_unref (CoglHandle handle); + +/** + * cogl_offscreen_blit: + * @src_buffer: + * @dst_buffer: + * + */ +void cogl_offscreen_blit (CoglHandle src_buffer, + CoglHandle dst_buffer); + +/** + * cogl_offscreen_blit_region: + * @src_buffer: + * @dst_buffer: + * @src_x: + * @src_y: + * @src_w: + * @src_h: + * @dst_x: + * @dst_y: + * @dst_w: + * @dst_h: + * + */ +void cogl_offscreen_blit_region (CoglHandle src_buffer, + CoglHandle dst_buffer, + gint src_x, + gint src_y, + gint src_w, + gint src_h, + gint dst_x, + gint dst_y, + gint dst_w, + gint dst_h); + +/** + * cogl_draw_buffer: + * @target: + * @offscreen: + * + */ +void cogl_draw_buffer (CoglBufferTarget target, + CoglHandle offscreen); + +G_END_DECLS + +#endif /* __COGL_OFFSCREEN_H__ */ diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h new file mode 100644 index 000000000..6e499076e --- /dev/null +++ b/clutter/cogl/cogl-path.h @@ -0,0 +1,315 @@ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_PATH_H__ +#define __COGL_PATH_H__ + +#include + +G_BEGIN_DECLS + +/** + * SECTION:cogl-primitives + * @short_description: Functions that draw various primitive shapes and + * allow for construction of more complex paths. + * + * There are three levels on which drawing with cogl can be used. The + * highest level functions construct various simple primitive shapes + * to be either filled or stroked. Using a lower-level set of functions + * more complex and arbitrary paths can be constructed by concatenating + * straight line, bezier curve and arc segments. Additionally there + * are utility functions that draw the most common primitives - rectangles + * and trapezoids - in a maximaly optimized fashion. + * + * When constructing arbitrary paths, the current pen location is + * initialized using the move_to command. The subsequent path segments + * implicitly use the last pen location as their first vertex and move + * the pen location to the last vertex they produce at the end. Also + * there are special versions of functions that allow specifying the + * vertices of the path segments relative to the last pen location + * rather then in the absolute coordinates. + */ + +/** + * cogl_color: + * @color: new current @CoglColor. + * + * Changes the color of cogl's current paint, which is used for filling and stroking + * primitives. + */ +void cogl_color (const CoglColor *color); + + +/** + * cogl_rectangle: + * @x: X coordinate of the top-left corner + * @y: Y coordinate of the top-left corner + * @width: Width of the rectangle + * @height: Height of the rectangle + * + * Fills a rectangle at the given coordinates with the current + * drawing color in a highly optimizied fashion. + **/ +void cogl_rectangle (gint x, + gint y, + guint width, + guint height); + +/** + * cogl_rectanglex: + * @x: X coordinate of the top-left corner + * @y: Y coordinate of the top-left corner + * @width: Width of the rectangle + * @height: Height of the rectangle + * + * A fixed-point version of cogl_fast_fill_rectangle. + **/ +void cogl_rectanglex (CoglFixed x, + CoglFixed y, + CoglFixed width, + CoglFixed height); + +/** + * cogl_path_fill: + * + * Fills the constructed shape using the current drawing color. + **/ +void cogl_path_fill (void); + +/** + * cogl_path_stroke: + * + * Strokes the constructed shape using the current drawing color + * and a width of 1 pixel (regardless of the current transformation + * matrix). + **/ +void cogl_path_stroke (void); + + +/** + * cogl_path_move_to: + * @x: X coordinate of the pen location to move to. + * @y: Y coordinate of the pen location to move to. + * + * Clears the previously constructed shape and begins a new path + * contour by moving the pen to the given coordinates. + **/ +void cogl_path_move_to (CoglFixed x, + CoglFixed y); + + +/** + * cogl_path_rel_move_to: + * @x: X offset from the current pen location to move the pen to. + * @y: Y offset from the current pen location to move the pen to. + * + * Clears the previously constructed shape and begins a new path + * contour by moving the pen to the given coordinates relative + * to the current pen location. + **/ +void cogl_path_rel_move_to (CoglFixed x, + CoglFixed y); + +/** + * cogl_path_line_to: + * @x: X coordinate of the end line vertex + * @y: Y coordinate of the end line vertex + * + * Adds a straight line segment to the current path that ends at the + * given coordinates. + **/ +void cogl_path_line_to (CoglFixed x, + CoglFixed y); + +/** + * cogl_path_rel_line_to: + * @x: X offset from the current pen location of the end line vertex + * @y: Y offset from the current pen location of the end line vertex + * + * Adds a straight line segment to the current path that ends at the + * given coordinates relative to the current pen location. + **/ +void cogl_path_rel_line_to (CoglFixed x, + CoglFixed y); + + +/** + * cogl_path_arc: + * @center_x: X coordinate of the elliptical arc center + * @center_y: Y coordinate of the elliptical arc center + * @radius_x: X radius of the elliptical arc + * @radius_y: Y radious of the elliptical arc + * @angle_1: Angle in the unit-circle at which the arc begin + * @angle_2: Angle in the unit-circle at which the arc ends + * + * Adds an elliptical arc segment to the current path. A straight line + * segment will link the current pen location with the first vertex + * of the arc. If you perform a move_to to the arcs start just before + * drawing it you create a free standing arc. + **/ +void cogl_path_arc (CoglFixed center_x, + CoglFixed center_y, + CoglFixed radius_x, + CoglFixed radius_y, + CoglAngle angle_1, + CoglAngle angle_2); + + + +/** + * cogl_path_curve_to: + * @x1: X coordinate of the second bezier control point + * @y1: Y coordinate of the second bezier control point + * @x2: X coordinate of the third bezier control point + * @y2: Y coordinate of the third bezier control point + * @x3: X coordinate of the fourth bezier control point + * @y3: Y coordinate of the fourth bezier control point + * + * Adds a cubic bezier curve segment to the current path with the given + * second, third and fourth control points and using current pen location + * as the first control point. + **/ +void cogl_path_curve_to (CoglFixed x1, + CoglFixed y1, + CoglFixed x2, + CoglFixed y2, + CoglFixed x3, + CoglFixed y3); + +/** + * cogl_path_rel_curve_to: + * @x1: X coordinate of the second bezier control point + * @y1: Y coordinate of the second bezier control point + * @x2: X coordinate of the third bezier control point + * @y2: Y coordinate of the third bezier control point + * @x3: X coordinate of the fourth bezier control point + * @y3: Y coordinate of the fourth bezier control point + * + * Adds a cubic bezier curve segment to the current path with the given + * second, third and fourth control points and using current pen location + * as the first control point. The given coordinates are relative to the + * current pen location. + */ +void cogl_path_rel_curve_to (CoglFixed x1, + CoglFixed y1, + CoglFixed x2, + CoglFixed y2, + CoglFixed x3, + CoglFixed y3); + +/** + * cogl_path_close: + * + * Closes the path being constructed by adding a straight line segment + * to it that ends at the first vertex of the path. + **/ +void cogl_path_close (void); + +/** + * cogl_path_line: + * @x1: X coordinate of the start line vertex + * @y1: Y coordinate of the start line vertex + * @x2: X coordinate of the end line vertex + * @y2: Y coordinate of the end line vertex + * + * Clears the previously constructed shape and constructs a straight + * line shape start and ending at the given coordinates. + **/ +void cogl_path_line (CoglFixed x1, + CoglFixed y1, + CoglFixed x2, + CoglFixed y2); + +/** + * cogl_path_polyline: + * @coords: A pointer to the first element of an array of fixed-point + * values that specify the vertex coordinates. + * @num_points: The total number of vertices. + * + * Clears the previously constructed shape and constructs a series of straight + * line segments, starting from the first given vertex coordinate. Each + * subsequent segment stars where the previous one ended and ends at the next + * given vertex coordinate. + * + * The coords array must contain 2 * num_points values. The first value + * represents the X coordinate of the first vertex, the second value + * represents the Y coordinate of the first vertex, continuing in the same + * fashion for the rest of the vertices. (num_points - 1) segments will + * be constructed. + **/ +void cogl_path_polyline (CoglFixed *coords, + gint num_points); + + +/** + * cogl_path_polygon: + * @coords: A pointer to the first element of an array of fixed-point + * values that specify the vertex coordinates. + * @num_points: The total number of vertices. + * + * Clears the previously constructed shape and constructs a polygonal + * shape of the given number of vertices. + * + * The coords array must contain 2 * num_points values. The first value + * represents the X coordinate of the first vertex, the second value + * represents the Y coordinate of the first vertex, continuing in the same + * fashion for the rest of the vertices. + **/ +void cogl_path_polygon (CoglFixed *coords, + gint num_points); + + +/** + * cogl_path_rectangle: + * @x: X coordinate of the top-left corner. + * @y: Y coordinate of the top-left corner. + * @width: Rectangle width. + * @height: Rectangle height. + * + * Clears the previously constructed shape and constructs a rectangular + * shape at the given coordinates. + **/ +void cogl_path_rectangle (CoglFixed x, + CoglFixed y, + CoglFixed width, + CoglFixed height); + +/** + * cogl_path_ellipse: + * @center_x: X coordinate of the ellipse center + * @center_y: Y coordinate of the ellipse center + * @radius_x: X radius of the ellipse + * @radius_y: Y radius of the ellipse + * + * Clears the previously constructed shape and constructs an ellipse + * shape. + **/ +void cogl_path_ellipse (CoglFixed center_x, + CoglFixed center_y, + CoglFixed radius_x, + CoglFixed radius_y); + +/** + * cogl_path_round_rectangle: + * @x: X coordinate of the top-left corner + * @y: Y coordinate of the top-left corner + * @width: Width of the rectangle + * @height: Height of the rectangle + * @radius: Radius of the corner arcs. + * @arc_step: Angle increment resolution for subdivision of + * the corner arcs. + * + * Clears the previously constructed shape and constructs a rectangular + * shape with rounded corners. + **/ +void cogl_path_round_rectangle (CoglFixed x, + CoglFixed y, + CoglFixed width, + CoglFixed height, + CoglFixed radius, + CoglAngle arc_step); + +G_END_DECLS + +#endif /* __COGL_PATH_H__ */ diff --git a/clutter/cogl/cogl-shader.h b/clutter/cogl/cogl-shader.h new file mode 100644 index 000000000..8d91dea13 --- /dev/null +++ b/clutter/cogl/cogl-shader.h @@ -0,0 +1,210 @@ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_SHADER_H__ +#define __COGL_SHADER_H__ + +#include + +G_BEGIN_DECLS + +/** + * SECTION:cogl-shaders + * @short_description: Fuctions for accessing the programmable GL pipeline + * + * COGL allows accessing the GL programmable pipeline in order to create + * vertex and fragment shaders. + * + * The only supported format is GLSL shaders. + */ + +/** + * cogl_create_shader: + * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. + * + * Create a new shader handle, use #cogl_shader_source to set the source code + * to be used on it. + * + * Returns: a new shader handle. + */ +CoglHandle cogl_create_shader (COGLenum shader_type); + +/** + * cogl_shader_ref: + * @handle: A #CoglHandle to a shader. + * + * Add an extra reference to a shader. + * + * Returns: @handle + */ +CoglHandle cogl_shader_ref (CoglHandle handle); + +/** + * cogl_shader_unref: + * @handle: A #CoglHandle to a shader. + * + * Removes a reference to a shader. If it was the last reference the + * shader object will be destroyed. + */ +void cogl_shader_unref (CoglHandle handle); + +/** + * cogl_is_shader: + * @handle: A CoglHandle + * + * Gets whether the given handle references an existing shader object. + * + * Returns: %TRUE if the handle references a shader, + * %FALSE otherwise + */ +gboolean cogl_is_shader (CoglHandle handle); + +/** + * cogl_shader_source: + * @shader: #CoglHandle for a shader. + * @source: GLSL shader source. + * + * Replaces the current GLSL source associated with a shader with a new + * one. + */ +void cogl_shader_source (CoglHandle shader, + const gchar *source); +/** + * cogl_shader_compile: + * @handle: #CoglHandle for a shader. + * + * Compiles the shader, no return value, but the shader is now ready for + * linking into a program. + */ +void cogl_shader_compile (CoglHandle handle); + +/** + * cogl_shader_get_info_log: + * @handle: #CoglHandle for a shader. + * @size: maximum number of bytes to retrieve. + * @buffer: location for info log. + * + * Retrieves the information log for a coglobject, can be used in conjunction + * with #cogl_shader_get_parameteriv to retrieve the compiler warnings/error + * messages that caused a shader to not compile correctly, mainly useful for + * debugging purposes. + */ +void cogl_shader_get_info_log (CoglHandle handle, + guint size, + gchar *buffer); + +/** + * cogl_shader_get_parameteriv: + * @handle: #CoglHandle for a shader. + * @pname: the named COGL parameter to retrieve. + * @dest: storage location for COGLint return value. + * + * Retrieve a named parameter from a shader can be used to query to compile + * satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. + */ +void cogl_shader_get_parameteriv (CoglHandle handle, + COGLenum pname, + COGLint *dest); + +/** + * cogl_create_program: + * + * Create a new cogl program object that can be used to replace parts of the GL + * rendering pipeline with custom code. + * + * Returns: a new cogl program. + */ +CoglHandle cogl_create_program (void); + +/** + * cogl_program_ref: + * @handle: A #CoglHandle to a program. + * + * Add an extra reference to a program. + * + * Returns: @handle + */ +CoglHandle cogl_program_ref (CoglHandle handle); + +/** + * cogl_program_unref: + * @handle: A #CoglHandle to a program. + * + * Removes a reference to a program. If it was the last reference the + * program object will be destroyed. + */ +void cogl_program_unref (CoglHandle handle); + +/** + * cogl_is_program: + * @handle: A CoglHandle + * + * Gets whether the given handle references an existing program object. + * + * Returns: %TRUE if the handle references a program, + * %FALSE otherwise + */ +gboolean cogl_is_program (CoglHandle handle); + +/** + * cogl_program_attach_shader: + * @program_handle: a #CoglHandle for a shdaer program. + * @shader_handle: a #CoglHandle for a vertex of fragment shader. + * + * Attaches a shader to a program object, a program can have one vertex shader + * and one fragment shader attached. + */ +void cogl_program_attach_shader (CoglHandle program_handle, + CoglHandle shader_handle); + + +/** + * cogl_program_link: + * @handle: a #CoglHandle for a shader program. + * + * Links a program making it ready for use. + */ +void cogl_program_link (CoglHandle handle); + +/** + * cogl_program_use: + * @handle: a #CoglHandle for a shader program or COGL_INVALID_HANDLE. + * + * Activate a specific shader program replacing that part of the GL + * rendering pipeline, if passed in COGL_INVALID_HANDLE the default + * behavior of GL is reinstated. + */ +void cogl_program_use (CoglHandle handle); + +/** + * cogl_program_get_uniform_location: + * @handle: a #CoglHandle for a shader program. + * @uniform_name: the name of a uniform. + * + * Retrieve the location (offset) of a uniform variable in a shader program, a + * uniform is a variable that is constant for all vertices/fragments for a + * shader object and is possible to modify as an external parameter. + * + * Returns: the offset of a uniform in a specified program, this uniform can be + * set using #cogl_program_uniform_1f when the program is in use. + */ +COGLint cogl_program_get_uniform_location + (CoglHandle handle, + const gchar *uniform_name); + + +/** + * cogl_program_uniform_1f: + * @uniform_no: the unform to set. + * @value: the new value of the uniform. + * + * Changes the value of a uniform in the currently used (see #cogl_program_use) + * shader program. + */ +void cogl_program_uniform_1f (COGLint uniform_no, + gfloat value); + +G_END_DECLS + +#endif /* __COGL_SHADER_H__ */ diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h new file mode 100644 index 000000000..c9d9ff84c --- /dev/null +++ b/clutter/cogl/cogl-texture.h @@ -0,0 +1,371 @@ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_TEXTURE_H__ +#define __COGL_TEXTURE_H__ + +G_BEGIN_DECLS + +#include + +/** + * SECTION:cogl-texture + * @short_description: Fuctions for creating and manipulating textures + * + * COGL allows creating and manipulating GL textures using a uniform + * API that tries to hide all the various complexities of creating, + * loading and manipulating textures. + */ + +/** + * cogl_texture_new_with_size: + * @width: width of texture in pixels. + * @height: height of texture in pixels. + * @max_waste: maximum extra horizontal and|or vertical margin pixels to make + * texture fit GPU limitations. + * @auto_mipmap: enable or disable automatic generation of mipmap pyramid + * from the base level image whenever it is updated. + * @internal_format: the #CoglPixelFormat to use for the GPU storage of the + * texture. + * + * Create a new texture with specified dimensions and pixel format. + * + * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE + * if texture creation failed. + */ +CoglHandle cogl_texture_new_with_size (guint width, + guint height, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format); + +/** + * cogl_texture_new_from_file: + * @filename: the file to load + * @max_waste: maximum extra horizontal and|or vertical margin pixels to make + * texture fit GPU limitations. + * @auto_mipmap: enable or disable automatic generation of mipmap pyramid + * from the base level image whenever it is updated. + * @internal_format: the #CoglPixelFormat to use for the GPU storage of the + * texture. + * @error: a #GError or NULL. + * + * Load an image file from disk. + * + * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE + * if creating the texture failed. + */ +CoglHandle cogl_texture_new_from_file (const gchar *filename, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat internal_format, + GError **error); + +/** + * cogl_texture_new_from_data: + * @width: width of texture in pixels. + * @height: height of texture in pixels. + * @max_waste: maximum extra horizontal and|or vertical margin pixels to make + * @auto_mipmap: enable or disable automatic generation of mipmap pyramid + * from the base level image whenever it is updated. + * @format: the #CoglPixelFormat the buffer is stored in in RAM + * @internal_format: the #CoglPixelFormat that will be used for storing the + * buffer on the GPU. + * @rowstride: the memory offset in bytes between the starts of scanlines in + * @data. + * @data: pointer the memory region where the source buffer resides. + * + * Create a new cogl texture based on data residing in memory. + * + * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE + * if creating the texture failed. + */ +CoglHandle cogl_texture_new_from_data (guint width, + guint height, + gint max_waste, + gboolean auto_mipmap, + CoglPixelFormat format, + CoglPixelFormat internal_format, + guint rowstride, + const guchar *data); + +/** + * cogl_texture_new_from_foreign: + * @gl_handle: opengl target type of foreign texture + * @gl_target: opengl handle of foreign texture. + * @width: width of foreign texture + * @height: height of foreign texture. + * @x_pot_waste: maximum horizontal waste. + * @y_pot_waste: maximum vertical waste. + * @format: format of the foreign texture. + * + * Create a cogl texture based on an existing OpenGL texture, the width, height + * and format are passed along since it is not possible to query this from a + * handle with GLES 1.0. + * + * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE + * if creating the texture failed. + */ +CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, + GLenum gl_target, + GLuint width, + GLuint height, + GLuint x_pot_waste, + GLuint y_pot_waste, + CoglPixelFormat format); + +/** + * cogl_is_texture: + * @handle: A CoglHandle + * + * Gets whether the given handle references an existing texture object. + * + * Returns: %TRUE if the handle references a texture, + * %FALSE otherwise + */ +gboolean cogl_is_texture (CoglHandle handle); + +/** + * cogl_texture_get_width: + * @handle: a #CoglHandle for a texture. + * + * Query the width of a cogl texture. + * + * Returns: the width of the GPU side texture in pixels: + */ +guint cogl_texture_get_width (CoglHandle handle); + +/** + * cogl_texture_get_height: + * @handle: a #CoglHandle for a texture. + * + * Query the height of a cogl texture. + * + * Returns: the height of the GPU side texture in pixels: + */ +guint cogl_texture_get_height (CoglHandle handle); + +/** + * cogl_texture_get_format: + * @handle: a #CoglHandle for a texture. + * + * Query the #CoglPixelFormat of a cogl texture. + * + * Returns: the #CoglPixelFormat of the GPU side texture. + */ +CoglPixelFormat cogl_texture_get_format (CoglHandle handle); + + +/** + * cogl_texture_get_rowstride: + * @handle: a #CoglHandle for a texture. + * + * Query the rowstride of a cogl texture. + * + * Returns: the offset in bytes between each consequetive row of pixels. + */ +guint cogl_texture_get_rowstride (CoglHandle handle); + +/** + * cogl_texture_get_max_waste: + * @handle: a #CoglHandle for a texture. + * + * Query the maximum wasted (unused) pixels in one dimension of a GPU side + * texture. + * + * Returns: the maximum waste. + */ +gint cogl_texture_get_max_waste (CoglHandle handle); + +/** + * cogl_texture_get_min_filter: + * @handle: a #CoglHandle for a texture. + * + * Query the currently set downscaling filter for a cogl texture. + * + * Returns: the current downscaling filter for a cogl texture. + */ +COGLenum cogl_texture_get_min_filter (CoglHandle handle); + +/** + * cogl_texture_get_mag_filter: + * @handle: a #CoglHandle for a texture. + * + * Query the currently set downscaling filter for a cogl texture. + * + * Returns: the current downscaling filter for a cogl texture. + */ +COGLenum cogl_texture_get_mag_filter (CoglHandle handle); + +/** + * cogl_texture_is_sliced: + * @handle: a #CoglHandle for a texture. + * + * Query if a texture is sliced (stored as multiple GPU side tecture + * objects). + * + * Returns: %TRUE if the texture is sliced, %FALSE if the texture + * is stored as a single GPU texture. + */ +gboolean cogl_texture_is_sliced (CoglHandle handle); + +/** + * cogl_texture_get_gl_texture: + * @handle: a #CoglHandle for a texture. + * @out_gl_handle: pointer to return location for the textures GL handle, or + * NULL. + * @out_gl_target: pointer to return location for the GL target type, or NULL. + * + * Query the GL handles for a GPU side texture through it's #CoglHandle, + * if the texture is spliced the data for the first sub texture will be + * queried. + * + * Returns: %TRUE if the handle was successfully retrieved %FALSE + * if the handle was invalid. + */ +gboolean cogl_texture_get_gl_texture (CoglHandle handle, + GLuint *out_gl_handle, + GLenum *out_gl_target); + +/** + * cogl_texture_get_data: + * @handle: a #CoglHandle for a texture. + * @format: the #CoglPixelFormat to store the texture as. + * @rowstride: the rowstride of @data or retrieved from texture if none is + * specified. + * @data: memory location to write contents of buffer, or %NULL if we're + * only querying the data size through the return value. + * + * Copy the pixel data from a cogl texture to system memory. + * + * Returns: the size of the texture data in bytes (or 0 if the texture + * is not valid.) + */ +gint cogl_texture_get_data (CoglHandle handle, + CoglPixelFormat format, + guint rowstride, + guchar *data); + +/** + * cogl_texture_set_filters: + * @handle: a #CoglHandle. + * @min_filter: the filter used when scaling the texture down. + * @mag_filter: the filter used when magnifying the texture. + * + * Changes the decimation and interpolation filters used when the texture is + * drawn at other scales than 100%. + */ +void cogl_texture_set_filters (CoglHandle handle, + COGLenum min_filter, + COGLenum mag_filter); + + +/** + * cogl_texture_set_region: + * @handle: a #CoglHandle. + * @src_x: upper left coordinate to use from source data. + * @src_y: upper left coordinate to use from source data. + * @dst_x: upper left destination horizontal coordinate. + * @dst_y: upper left destination vertical coordinate. + * @dst_width: width of destination region to write. + * @dst_height: height of destination region to write. + * @width: width of source data buffer. + * @height: height of source data buffer. + * @format: the #CoglPixelFormat used in the source buffer. + * @rowstride: rowstride of source buffer (computed from width if none + * specified) + * @data: the actual pixel data. + * + * Sets the pixels in a rectangular subregion of @handle from an in-memory + * buffer containing pixel data. + * + * Returns: %TRUE if the subregion upload was successful, otherwise %FALSE. + */ +gboolean cogl_texture_set_region (CoglHandle handle, + gint src_x, + gint src_y, + gint dst_x, + gint dst_y, + guint dst_width, + guint dst_height, + gint width, + gint height, + CoglPixelFormat format, + guint rowstride, + const guchar *data); + +/** + * cogl_texture_ref: + * @handle: a @CoglHandle. + * + * Increment the reference count for a cogl texture. + * + * Returns: the @handle. + */ +CoglHandle cogl_texture_ref (CoglHandle handle); + +/** + * cogl_texture_unref: + * @handle: a @CoglHandle. + * + * Deccrement the reference count for a cogl texture. + */ +void cogl_texture_unref (CoglHandle handle); + +/** + * cogl_texture_rectangle: + * @handle: a @CoglHandle. + * @x1: x coordinate upper left on screen. + * @y1: y coordinate upper left on screen. + * @x2: x coordinate lower right on screen. + * @y2: y coordinate lower right on screen. + * @tx1: x part of texture coordinate to use for upper left pixel + * @ty1: y part of texture coordinate to use for upper left pixel + * @tx2: x part of texture coordinate to use for lower right pixel + * @ty2: y part of texture coordinate to use for left pixel + * + * Draw a rectangle from a texture to the display, to draw the entire + * texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0. + */ +void cogl_texture_rectangle (CoglHandle handle, + CoglFixed x1, + CoglFixed y1, + CoglFixed x2, + CoglFixed y2, + CoglFixed tx1, + CoglFixed ty1, + CoglFixed tx2, + CoglFixed ty2); + +/** + * cogl_texture_polygon: + * @handle: A CoglHandle for a texture + * @n_vertices: The length of the vertices array + * @vertices: An array of #CoglTextureVertex structs + * @use_color: %TRUE if the color member of #CoglTextureVertex should be used + * + * Draws a polygon from a texture with the given model and texture + * coordinates. This can be used to draw arbitrary shapes textured + * with a COGL texture. If @use_color is %TRUE then the current COGL + * color will be changed for each vertex using the value specified in + * the color member of #CoglTextureVertex. This can be used for + * example to make the texture fade out by setting the alpha value of + * the color. + * + * All of the texture coordinates must be in the range [0,1] and + * repeating the texture is not supported. + * + * Because of the way this function is implemented it will currently + * only work if either the texture is not sliced or the backend is not + * OpenGL ES and the minifying and magnifying functions are both set + * to CGL_NEAREST. + */ +void cogl_texture_polygon (CoglHandle handle, + guint n_vertices, + CoglTextureVertex *vertices, + gboolean use_color); + +G_END_DECLS + +#endif /* __COGL_TEXTURE_H__ */ diff --git a/clutter/cogl/cogl-types.h b/clutter/cogl/cogl-types.h new file mode 100644 index 000000000..b2f3dcc17 --- /dev/null +++ b/clutter/cogl/cogl-types.h @@ -0,0 +1,240 @@ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_TYPES_H__ +#define __COGL_TYPES_H__ + +#include + +G_BEGIN_DECLS + +/** + * CoglHandle: + * + * Type used for storing references to cogl objects, the CoglHandle is + * a fully opaque type without any public data members. + */ +typedef gpointer CoglHandle; + +/** + * COGL_INVALID_HANDLE: + * + * A COGL handle that is not valid, used for unitialized handles as well as + * error conditions. + */ +#define COGL_INVALID_HANDLE NULL + +/** + * CoglFuncPtr: + * + * The type used by cogl for function pointers, note that this type + * is used as a generic catch-all cast for function pointers and the + * actual arguments and return type may be different. + */ +typedef void (* CoglFuncPtr) (void); + +/** + * CoglFixed: + * + * Fixed point number using a (16.16) notation. + */ +typedef gint32 CoglFixed; + +/** + * CoglAngle: + * + * Integer representation of an angle such that 1024 corresponds to + * full circle (i.e., 2 * pi). + * + * Since: 1.0 + */ +typedef gint32 CoglAngle; + +typedef struct _CoglColor CoglColor; +typedef struct _CoglTextureVertex CoglTextureVertex; + +/* Enum declarations */ + +#define COGL_PIXEL_FORMAT_24 2 +#define COGL_PIXEL_FORMAT_32 3 +#define COGL_A_BIT (1 << 4) +#define COGL_BGR_BIT (1 << 5) +#define COGL_AFIRST_BIT (1 << 6) +#define COGL_PREMULT_BIT (1 << 7) +#define COGL_UNORDERED_MASK 0x0F +#define COGL_UNPREMULT_MASK 0x7F + +/** + * CoglPixelFormat: + * @COGL_PIXEL_FORMAT_ANY: + * @COGL_PIXEL_FORMAT_A_8: + * @COGL_PIXEL_FORMAT_RGB_888: + * @COGL_PIXEL_FORMAT_BGR_888: + * @COGL_PIXEL_FORMAT_RGBA_8888: + * @COGL_PIXEL_FORMAT_BGRA_8888: + * @COGL_PIXEL_FORMAT_ARGB_8888: + * @COGL_PIXEL_FORMAT_ABGR_8888: + * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: + * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: + * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: + * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: + * @COGL_PIXEL_FORMAT_RGB_565: + * @COGL_PIXEL_FORMAT_RGBA_4444: + * @COGL_PIXEL_FORMAT_RGBA_5551: + * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: + * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: + * @COGL_PIXEL_FORMAT_YUV: + * @COGL_PIXEL_FORMAT_G_8: + * + * Pixel formats used by COGL. + */ +typedef enum +{ + COGL_PIXEL_FORMAT_ANY = 0, + COGL_PIXEL_FORMAT_A_8 = 1 | COGL_A_BIT, + + COGL_PIXEL_FORMAT_RGB_565 = 4, + COGL_PIXEL_FORMAT_RGBA_4444 = 5 | COGL_A_BIT, + COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT, + COGL_PIXEL_FORMAT_YUV = 7, + COGL_PIXEL_FORMAT_G_8 = 8, + + COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24, + + COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 | + COGL_BGR_BIT), + + COGL_PIXEL_FORMAT_RGBA_8888 = COGL_PIXEL_FORMAT_32 | + COGL_A_BIT, + + COGL_PIXEL_FORMAT_BGRA_8888 = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_BGR_BIT), + + COGL_PIXEL_FORMAT_ARGB_8888 = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_AFIRST_BIT), + + COGL_PIXEL_FORMAT_ABGR_8888 = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_BGR_BIT | + COGL_AFIRST_BIT), + + COGL_PIXEL_FORMAT_RGBA_8888_PRE = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_PREMULT_BIT), + + COGL_PIXEL_FORMAT_BGRA_8888_PRE = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_PREMULT_BIT | + COGL_BGR_BIT), + + COGL_PIXEL_FORMAT_ARGB_8888_PRE = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_PREMULT_BIT | + COGL_AFIRST_BIT), + + COGL_PIXEL_FORMAT_ABGR_8888_PRE = (COGL_PIXEL_FORMAT_32 | + COGL_A_BIT | + COGL_PREMULT_BIT | + COGL_BGR_BIT | + COGL_AFIRST_BIT), + + COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | + COGL_A_BIT | + COGL_PREMULT_BIT), + + COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | + COGL_A_BIT | + COGL_PREMULT_BIT), + + +} CoglPixelFormat; + +/** + * CoglFeatureFlags: + * @COGL_FEATURE_TEXTURE_RECTANGLE: + * @COGL_FEATURE_TEXTURE_NPOT: + * @COGL_FEATURE_TEXTURE_YUV: + * @COGL_FEATURE_TEXTURE_READ_PIXELS: + * @COGL_FEATURE_SHADERS_GLSL: + * @COGL_FEATURE_OFFSCREEN: + * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: + * @COGL_FEATURE_OFFSCREEN_BLIT: + * @COGL_FEATURE_FOUR_CLIP_PLANES: + * @COGL_FEATURE_STENCIL_BUFFER: + * + * Flags for the supported features. + */ +typedef enum +{ + COGL_FEATURE_TEXTURE_RECTANGLE = (1 << 1), + COGL_FEATURE_TEXTURE_NPOT = (1 << 2), + COGL_FEATURE_TEXTURE_YUV = (1 << 3), + COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4), + COGL_FEATURE_SHADERS_GLSL = (1 << 5), + COGL_FEATURE_OFFSCREEN = (1 << 6), + COGL_FEATURE_OFFSCREEN_MULTISAMPLE = (1 << 7), + COGL_FEATURE_OFFSCREEN_BLIT = (1 << 8), + COGL_FEATURE_FOUR_CLIP_PLANES = (1 << 9), + COGL_FEATURE_STENCIL_BUFFER = (1 << 10) +} CoglFeatureFlags; + +/** + * CoglBufferTarget: + * @COGL_WINDOW_BUFFER: + * @COGL_MASK_BUFFER: + * @COGL_OFFSCREEN_BUFFER: + * + * + */ +typedef enum +{ + COGL_WINDOW_BUFFER = (1 << 1), + COGL_MASK_BUFFER = (1 << 2), + COGL_OFFSCREEN_BUFFER = (1 << 3) + +} CoglBufferTarget; + +/** + * CoglColor: + * + * A structure for holding a color definition. The contents of + * the CoglColor structure are private and should never by accessed + * directly. + * + * Since: 1.0 + */ +struct _CoglColor +{ + /*< private >*/ + CoglFixed red; + CoglFixed green; + CoglFixed blue; + + CoglFixed alpha; +}; + +/** + * CoglTextureVertex: + * @x: Model x-coordinate + * @y: Model y-coordinate + * @z: Model z-coordinate + * @tx: Texture x-coordinate + * @ty: Texture y-coordinate + * @color: The color to use at this vertex. This is ignored if + * @use_color is %FALSE when calling cogl_texture_polygon(). + * + * Used to specify vertex information when calling cogl_texture_polygon(). + */ +struct _CoglTextureVertex +{ + CoglFixed x, y, z; + CoglFixed tx, ty; + CoglColor color; +}; + +G_END_DECLS + +#endif /* __COGL_TYPES_H__ */ diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 5b57a7e8f..b65069783 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -23,22 +23,6 @@ * Boston, MA 02111-1307, USA. */ -/* - * COGL - * ==== - * - * 'cogl' is a very simple abstraction layer which wraps GL and GLES. - * - * - * !!!! DO NOT USE THIS API YET OUTSIDE OF CLUTTER CORE !!!! - * THE API WILL FLUCTUATE WILDLY - * - * TODO: - * - Use ClutterReal for fixed/float params. - * - Add Perspective/viewport setup - * - Add Features.. - */ - #ifndef __COGL_H__ #define __COGL_H__ @@ -47,175 +31,17 @@ #include #include + #include #include +#include +#include +#include +#include +#include G_BEGIN_DECLS -/* Enum declarations */ - -#define COGL_PIXEL_FORMAT_24 2 -#define COGL_PIXEL_FORMAT_32 3 -#define COGL_A_BIT (1 << 4) -#define COGL_BGR_BIT (1 << 5) -#define COGL_AFIRST_BIT (1 << 6) -#define COGL_PREMULT_BIT (1 << 7) -#define COGL_UNORDERED_MASK 0x0F -#define COGL_UNPREMULT_MASK 0x7F - -/** - * CoglPixelFormat: - * @COGL_PIXEL_FORMAT_ANY: - * @COGL_PIXEL_FORMAT_A_8: - * @COGL_PIXEL_FORMAT_RGB_888: - * @COGL_PIXEL_FORMAT_BGR_888: - * @COGL_PIXEL_FORMAT_RGBA_8888: - * @COGL_PIXEL_FORMAT_BGRA_8888: - * @COGL_PIXEL_FORMAT_ARGB_8888: - * @COGL_PIXEL_FORMAT_ABGR_8888: - * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: - * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: - * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: - * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: - * @COGL_PIXEL_FORMAT_RGB_565: - * @COGL_PIXEL_FORMAT_RGBA_4444: - * @COGL_PIXEL_FORMAT_RGBA_5551: - * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: - * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: - * @COGL_PIXEL_FORMAT_YUV: - * @COGL_PIXEL_FORMAT_G_8: - * - * Pixel formats used by COGL. - */ -typedef enum -{ - COGL_PIXEL_FORMAT_ANY = 0, - COGL_PIXEL_FORMAT_A_8 = 1 | COGL_A_BIT, - - COGL_PIXEL_FORMAT_RGB_565 = 4, - COGL_PIXEL_FORMAT_RGBA_4444 = 5 | COGL_A_BIT, - COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT, - COGL_PIXEL_FORMAT_YUV = 7, - COGL_PIXEL_FORMAT_G_8 = 8, - - COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24, - - COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 | - COGL_BGR_BIT), - - COGL_PIXEL_FORMAT_RGBA_8888 = COGL_PIXEL_FORMAT_32 | - COGL_A_BIT, - - COGL_PIXEL_FORMAT_BGRA_8888 = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_BGR_BIT), - - COGL_PIXEL_FORMAT_ARGB_8888 = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_AFIRST_BIT), - - COGL_PIXEL_FORMAT_ABGR_8888 = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_BGR_BIT | - COGL_AFIRST_BIT), - - COGL_PIXEL_FORMAT_RGBA_8888_PRE = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_PREMULT_BIT), - - COGL_PIXEL_FORMAT_BGRA_8888_PRE = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_PREMULT_BIT | - COGL_BGR_BIT), - - COGL_PIXEL_FORMAT_ARGB_8888_PRE = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_PREMULT_BIT | - COGL_AFIRST_BIT), - - COGL_PIXEL_FORMAT_ABGR_8888_PRE = (COGL_PIXEL_FORMAT_32 | - COGL_A_BIT | - COGL_PREMULT_BIT | - COGL_BGR_BIT | - COGL_AFIRST_BIT), - - COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | - COGL_A_BIT | - COGL_PREMULT_BIT), - - COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | - COGL_A_BIT | - COGL_PREMULT_BIT), - - -} CoglPixelFormat; - -/** - * CoglFeatureFlags: - * @COGL_FEATURE_TEXTURE_RECTANGLE: - * @COGL_FEATURE_TEXTURE_NPOT: - * @COGL_FEATURE_TEXTURE_YUV: - * @COGL_FEATURE_TEXTURE_READ_PIXELS: - * @COGL_FEATURE_SHADERS_GLSL: - * @COGL_FEATURE_OFFSCREEN: - * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: - * @COGL_FEATURE_OFFSCREEN_BLIT: - * @COGL_FEATURE_FOUR_CLIP_PLANES: - * @COGL_FEATURE_STENCIL_BUFFER: - * - * Flags for the supported features. - */ -typedef enum -{ - COGL_FEATURE_TEXTURE_RECTANGLE = (1 << 1), - COGL_FEATURE_TEXTURE_NPOT = (1 << 2), - COGL_FEATURE_TEXTURE_YUV = (1 << 3), - COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4), - COGL_FEATURE_SHADERS_GLSL = (1 << 5), - COGL_FEATURE_OFFSCREEN = (1 << 6), - COGL_FEATURE_OFFSCREEN_MULTISAMPLE = (1 << 7), - COGL_FEATURE_OFFSCREEN_BLIT = (1 << 8), - COGL_FEATURE_FOUR_CLIP_PLANES = (1 << 9), - COGL_FEATURE_STENCIL_BUFFER = (1 << 10) -} CoglFeatureFlags; - -/** - * CoglBufferTarget: - * @COGL_WINDOW_BUFFER: - * @COGL_MASK_BUFFER: - * @COGL_OFFSCREEN_BUFFER: - * - * - */ -typedef enum -{ - COGL_WINDOW_BUFFER = (1 << 1), - COGL_MASK_BUFFER = (1 << 2), - COGL_OFFSCREEN_BUFFER = (1 << 3) - -} CoglBufferTarget; - -/** - * CoglTextureVertex: - * @x: Model x-coordinate - * @y: Model y-coordinate - * @z: Model z-coordinate - * @tx: Texture x-coordinate - * @ty: Texture y-coordinate - * @color: The color to use at this vertex. This is ignored if - * @use_color is %FALSE when calling cogl_texture_polygon(). - * - * Used to specify vertex information when calling cogl_texture_polygon(). - */ -struct _CoglTextureVertex -{ - CoglFixed x, y, z; - CoglFixed tx, ty; - CoglColor color; -}; - -typedef struct _CoglTextureVertex CoglTextureVertex; - /** * SECTION:cogl * @short_description: General purpose API @@ -240,31 +66,6 @@ gboolean cogl_create_context (void); void cogl_destroy_context (void); /* Misc */ -/** - * COGL_INVALID_HANDLE: - * - * A COGL handle that is not valid, used for unitialized handles as well as - * error conditions. - */ -#define COGL_INVALID_HANDLE NULL - -/** - * CoglHandle: - * - * Type used for storing references to cogl objects, the CoglHandle is - * a fully opaque type without any public data members. - */ -typedef gpointer CoglHandle; - -/** - * CoglFuncPtr: - * - * The type used by cogl for function pointers, note that this type - * is used as a generic catch-all cast for function pointers and the - * actual arguments and return type may be different. - */ -typedef void (* CoglFuncPtr) (void); - /** * cogl_get_features: * @@ -631,962 +432,6 @@ void cogl_fog_set (const CoglColor *fog_color, */ void cogl_paint_init (const CoglColor *color); -/** - * SECTION:cogl-texture - * @short_description: Fuctions for creating and manipulating textures - * - * COGL allows creating and manipulating GL textures using a uniform - * API that tries to hide all the various complexities of creating, - * loading and manipulating textures. - */ - -/* Textures api */ - -/** - * cogl_texture_new_with_size: - * @width: width of texture in pixels. - * @height: height of texture in pixels. - * @max_waste: maximum extra horizontal and|or vertical margin pixels to make - * texture fit GPU limitations. - * @auto_mipmap: enable or disable automatic generation of mipmap pyramid - * from the base level image whenever it is updated. - * @internal_format: the #CoglPixelFormat to use for the GPU storage of the - * texture. - * - * Create a new texture with specified dimensions and pixel format. - * - * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE - * if texture creation failed. - */ -CoglHandle cogl_texture_new_with_size (guint width, - guint height, - gint max_waste, - gboolean auto_mipmap, - CoglPixelFormat internal_format); - -/** - * cogl_texture_new_from_file: - * @filename: the file to load - * @max_waste: maximum extra horizontal and|or vertical margin pixels to make - * texture fit GPU limitations. - * @auto_mipmap: enable or disable automatic generation of mipmap pyramid - * from the base level image whenever it is updated. - * @internal_format: the #CoglPixelFormat to use for the GPU storage of the - * texture. - * @error: a #GError or NULL. - * - * Load an image file from disk. - * - * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE - * if creating the texture failed. - */ -CoglHandle cogl_texture_new_from_file (const gchar *filename, - gint max_waste, - gboolean auto_mipmap, - CoglPixelFormat internal_format, - GError **error); - -/** - * cogl_texture_new_from_data: - * @width: width of texture in pixels. - * @height: height of texture in pixels. - * @max_waste: maximum extra horizontal and|or vertical margin pixels to make - * @auto_mipmap: enable or disable automatic generation of mipmap pyramid - * from the base level image whenever it is updated. - * @format: the #CoglPixelFormat the buffer is stored in in RAM - * @internal_format: the #CoglPixelFormat that will be used for storing the - * buffer on the GPU. - * @rowstride: the memory offset in bytes between the starts of scanlines in - * @data. - * @data: pointer the memory region where the source buffer resides. - * - * Create a new cogl texture based on data residing in memory. - * - * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE - * if creating the texture failed. - */ -CoglHandle cogl_texture_new_from_data (guint width, - guint height, - gint max_waste, - gboolean auto_mipmap, - CoglPixelFormat format, - CoglPixelFormat internal_format, - guint rowstride, - const guchar *data); - -/** - * cogl_texture_new_from_foreign: - * @gl_handle: opengl target type of foreign texture - * @gl_target: opengl handle of foreign texture. - * @width: width of foreign texture - * @height: height of foreign texture. - * @x_pot_waste: maximum horizontal waste. - * @y_pot_waste: maximum vertical waste. - * @format: format of the foreign texture. - * - * Create a cogl texture based on an existing OpenGL texture, the width, height - * and format are passed along since it is not possible to query this from a - * handle with GLES 1.0. - * - * Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE - * if creating the texture failed. - */ -CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, - GLenum gl_target, - GLuint width, - GLuint height, - GLuint x_pot_waste, - GLuint y_pot_waste, - CoglPixelFormat format); - -/** - * cogl_is_texture: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing texture object. - * - * Returns: %TRUE if the handle references a texture, - * %FALSE otherwise - */ -gboolean cogl_is_texture (CoglHandle handle); - -/** - * cogl_texture_get_width: - * @handle: a #CoglHandle for a texture. - * - * Query the width of a cogl texture. - * - * Returns: the width of the GPU side texture in pixels: - */ -guint cogl_texture_get_width (CoglHandle handle); - -/** - * cogl_texture_get_height: - * @handle: a #CoglHandle for a texture. - * - * Query the height of a cogl texture. - * - * Returns: the height of the GPU side texture in pixels: - */ -guint cogl_texture_get_height (CoglHandle handle); - -/** - * cogl_texture_get_format: - * @handle: a #CoglHandle for a texture. - * - * Query the #CoglPixelFormat of a cogl texture. - * - * Returns: the #CoglPixelFormat of the GPU side texture. - */ -CoglPixelFormat cogl_texture_get_format (CoglHandle handle); - - -/** - * cogl_texture_get_rowstride: - * @handle: a #CoglHandle for a texture. - * - * Query the rowstride of a cogl texture. - * - * Returns: the offset in bytes between each consequetive row of pixels. - */ -guint cogl_texture_get_rowstride (CoglHandle handle); - -/** - * cogl_texture_get_max_waste: - * @handle: a #CoglHandle for a texture. - * - * Query the maximum wasted (unused) pixels in one dimension of a GPU side - * texture. - * - * Returns: the maximum waste. - */ -gint cogl_texture_get_max_waste (CoglHandle handle); - -/** - * cogl_texture_get_min_filter: - * @handle: a #CoglHandle for a texture. - * - * Query the currently set downscaling filter for a cogl texture. - * - * Returns: the current downscaling filter for a cogl texture. - */ -COGLenum cogl_texture_get_min_filter (CoglHandle handle); - -/** - * cogl_texture_get_mag_filter: - * @handle: a #CoglHandle for a texture. - * - * Query the currently set downscaling filter for a cogl texture. - * - * Returns: the current downscaling filter for a cogl texture. - */ -COGLenum cogl_texture_get_mag_filter (CoglHandle handle); - -/** - * cogl_texture_is_sliced: - * @handle: a #CoglHandle for a texture. - * - * Query if a texture is sliced (stored as multiple GPU side tecture - * objects). - * - * Returns: %TRUE if the texture is sliced, %FALSE if the texture - * is stored as a single GPU texture. - */ -gboolean cogl_texture_is_sliced (CoglHandle handle); - -/** - * cogl_texture_get_gl_texture: - * @handle: a #CoglHandle for a texture. - * @out_gl_handle: pointer to return location for the textures GL handle, or - * NULL. - * @out_gl_target: pointer to return location for the GL target type, or NULL. - * - * Query the GL handles for a GPU side texture through it's #CoglHandle, - * if the texture is spliced the data for the first sub texture will be - * queried. - * - * Returns: %TRUE if the handle was successfully retrieved %FALSE - * if the handle was invalid. - */ -gboolean cogl_texture_get_gl_texture (CoglHandle handle, - GLuint *out_gl_handle, - GLenum *out_gl_target); - -/** - * cogl_texture_get_data: - * @handle: a #CoglHandle for a texture. - * @format: the #CoglPixelFormat to store the texture as. - * @rowstride: the rowstride of @data or retrieved from texture if none is - * specified. - * @data: memory location to write contents of buffer, or %NULL if we're - * only querying the data size through the return value. - * - * Copy the pixel data from a cogl texture to system memory. - * - * Returns: the size of the texture data in bytes (or 0 if the texture - * is not valid.) - */ -gint cogl_texture_get_data (CoglHandle handle, - CoglPixelFormat format, - guint rowstride, - guchar *data); - -/** - * cogl_texture_set_filters: - * @handle: a #CoglHandle. - * @min_filter: the filter used when scaling the texture down. - * @mag_filter: the filter used when magnifying the texture. - * - * Changes the decimation and interpolation filters used when the texture is - * drawn at other scales than 100%. - */ -void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter); - - -/** - * cogl_texture_set_region: - * @handle: a #CoglHandle. - * @src_x: upper left coordinate to use from source data. - * @src_y: upper left coordinate to use from source data. - * @dst_x: upper left destination horizontal coordinate. - * @dst_y: upper left destination vertical coordinate. - * @dst_width: width of destination region to write. - * @dst_height: height of destination region to write. - * @width: width of source data buffer. - * @height: height of source data buffer. - * @format: the #CoglPixelFormat used in the source buffer. - * @rowstride: rowstride of source buffer (computed from width if none - * specified) - * @data: the actual pixel data. - * - * Sets the pixels in a rectangular subregion of @handle from an in-memory - * buffer containing pixel data. - * - * Returns: %TRUE if the subregion upload was successful, otherwise %FALSE. - */ -gboolean cogl_texture_set_region (CoglHandle handle, - gint src_x, - gint src_y, - gint dst_x, - gint dst_y, - guint dst_width, - guint dst_height, - gint width, - gint height, - CoglPixelFormat format, - guint rowstride, - const guchar *data); - -/** - * cogl_texture_ref: - * @handle: a @CoglHandle. - * - * Increment the reference count for a cogl texture. - * - * Returns: the @handle. - */ -CoglHandle cogl_texture_ref (CoglHandle handle); - -/** - * cogl_texture_unref: - * @handle: a @CoglHandle. - * - * Deccrement the reference count for a cogl texture. - */ -void cogl_texture_unref (CoglHandle handle); - -/** - * cogl_texture_rectangle: - * @handle: a @CoglHandle. - * @x1: x coordinate upper left on screen. - * @y1: y coordinate upper left on screen. - * @x2: x coordinate lower right on screen. - * @y2: y coordinate lower right on screen. - * @tx1: x part of texture coordinate to use for upper left pixel - * @ty1: y part of texture coordinate to use for upper left pixel - * @tx2: x part of texture coordinate to use for lower right pixel - * @ty2: y part of texture coordinate to use for left pixel - * - * Draw a rectangle from a texture to the display, to draw the entire - * texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0. - */ -void cogl_texture_rectangle (CoglHandle handle, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2); - -/** - * cogl_texture_polygon: - * @handle: A CoglHandle for a texture - * @n_vertices: The length of the vertices array - * @vertices: An array of #CoglTextureVertex structs - * @use_color: %TRUE if the color member of #CoglTextureVertex should be used - * - * Draws a polygon from a texture with the given model and texture - * coordinates. This can be used to draw arbitrary shapes textured - * with a COGL texture. If @use_color is %TRUE then the current COGL - * color will be changed for each vertex using the value specified in - * the color member of #CoglTextureVertex. This can be used for - * example to make the texture fade out by setting the alpha value of - * the color. - * - * All of the texture coordinates must be in the range [0,1] and - * repeating the texture is not supported. - * - * Because of the way this function is implemented it will currently - * only work if either the texture is not sliced or the backend is not - * OpenGL ES and the minifying and magnifying functions are both set - * to CGL_NEAREST. - */ -void cogl_texture_polygon (CoglHandle handle, - guint n_vertices, - CoglTextureVertex *vertices, - gboolean use_color); - -/* Primitives API */ - -/** - * SECTION:cogl-primitives - * @short_description: Functions that draw various primitive shapes and - * allow for construction of more complex paths. - * - * There are three levels on which drawing with cogl can be used. The - * highest level functions construct various simple primitive shapes - * to be either filled or stroked. Using a lower-level set of functions - * more complex and arbitrary paths can be constructed by concatenating - * straight line, bezier curve and arc segments. Additionally there - * are utility functions that draw the most common primitives - rectangles - * and trapezoids - in a maximaly optimized fashion. - * - * When constructing arbitrary paths, the current pen location is - * initialized using the move_to command. The subsequent path segments - * implicitly use the last pen location as their first vertex and move - * the pen location to the last vertex they produce at the end. Also - * there are special versions of functions that allow specifying the - * vertices of the path segments relative to the last pen location - * rather then in the absolute coordinates. - */ - - - -/** - * cogl_color: - * @color: new current @CoglColor. - * - * Changes the color of cogl's current paint, which is used for filling and stroking - * primitives. - */ -void cogl_color (const CoglColor *color); - - -/** - * cogl_rectangle: - * @x: X coordinate of the top-left corner - * @y: Y coordinate of the top-left corner - * @width: Width of the rectangle - * @height: Height of the rectangle - * - * Fills a rectangle at the given coordinates with the current - * drawing color in a highly optimizied fashion. - **/ -void cogl_rectangle (gint x, - gint y, - guint width, - guint height); - -/** - * cogl_rectanglex: - * @x: X coordinate of the top-left corner - * @y: Y coordinate of the top-left corner - * @width: Width of the rectangle - * @height: Height of the rectangle - * - * A fixed-point version of cogl_fast_fill_rectangle. - **/ -void cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); - -/** - * cogl_path_fill: - * - * Fills the constructed shape using the current drawing color. - **/ -void cogl_path_fill (void); - -/** - * cogl_path_stroke: - * - * Strokes the constructed shape using the current drawing color - * and a width of 1 pixel (regardless of the current transformation - * matrix). - **/ -void cogl_path_stroke (void); - - -/** - * cogl_path_move_to: - * @x: X coordinate of the pen location to move to. - * @y: Y coordinate of the pen location to move to. - * - * Clears the previously constructed shape and begins a new path - * contour by moving the pen to the given coordinates. - **/ -void cogl_path_move_to (CoglFixed x, - CoglFixed y); - - -/** - * cogl_path_rel_move_to: - * @x: X offset from the current pen location to move the pen to. - * @y: Y offset from the current pen location to move the pen to. - * - * Clears the previously constructed shape and begins a new path - * contour by moving the pen to the given coordinates relative - * to the current pen location. - **/ -void cogl_path_rel_move_to (CoglFixed x, - CoglFixed y); - -/** - * cogl_path_line_to: - * @x: X coordinate of the end line vertex - * @y: Y coordinate of the end line vertex - * - * Adds a straight line segment to the current path that ends at the - * given coordinates. - **/ -void cogl_path_line_to (CoglFixed x, - CoglFixed y); - -/** - * cogl_path_rel_line_to: - * @x: X offset from the current pen location of the end line vertex - * @y: Y offset from the current pen location of the end line vertex - * - * Adds a straight line segment to the current path that ends at the - * given coordinates relative to the current pen location. - **/ -void cogl_path_rel_line_to (CoglFixed x, - CoglFixed y); - - -/** - * cogl_path_arc: - * @center_x: X coordinate of the elliptical arc center - * @center_y: Y coordinate of the elliptical arc center - * @radius_x: X radius of the elliptical arc - * @radius_y: Y radious of the elliptical arc - * @angle_1: Angle in the unit-circle at which the arc begin - * @angle_2: Angle in the unit-circle at which the arc ends - * - * Adds an elliptical arc segment to the current path. A straight line - * segment will link the current pen location with the first vertex - * of the arc. If you perform a move_to to the arcs start just before - * drawing it you create a free standing arc. - **/ -void cogl_path_arc (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y, - CoglAngle angle_1, - CoglAngle angle_2); - - - -/** - * cogl_path_curve_to: - * @x1: X coordinate of the second bezier control point - * @y1: Y coordinate of the second bezier control point - * @x2: X coordinate of the third bezier control point - * @y2: Y coordinate of the third bezier control point - * @x3: X coordinate of the fourth bezier control point - * @y3: Y coordinate of the fourth bezier control point - * - * Adds a cubic bezier curve segment to the current path with the given - * second, third and fourth control points and using current pen location - * as the first control point. - **/ -void cogl_path_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3); - -/** - * cogl_path_rel_curve_to: - * @x1: X coordinate of the second bezier control point - * @y1: Y coordinate of the second bezier control point - * @x2: X coordinate of the third bezier control point - * @y2: Y coordinate of the third bezier control point - * @x3: X coordinate of the fourth bezier control point - * @y3: Y coordinate of the fourth bezier control point - * - * Adds a cubic bezier curve segment to the current path with the given - * second, third and fourth control points and using current pen location - * as the first control point. The given coordinates are relative to the - * current pen location. - */ -void cogl_path_rel_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3); - -/** - * cogl_path_close: - * - * Closes the path being constructed by adding a straight line segment - * to it that ends at the first vertex of the path. - **/ -void cogl_path_close (void); - -/** - * cogl_path_line: - * @x1: X coordinate of the start line vertex - * @y1: Y coordinate of the start line vertex - * @x2: X coordinate of the end line vertex - * @y2: Y coordinate of the end line vertex - * - * Clears the previously constructed shape and constructs a straight - * line shape start and ending at the given coordinates. - **/ -void cogl_path_line (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2); - -/** - * cogl_path_polyline: - * @coords: A pointer to the first element of an array of fixed-point - * values that specify the vertex coordinates. - * @num_points: The total number of vertices. - * - * Clears the previously constructed shape and constructs a series of straight - * line segments, starting from the first given vertex coordinate. Each - * subsequent segment stars where the previous one ended and ends at the next - * given vertex coordinate. - * - * The coords array must contain 2 * num_points values. The first value - * represents the X coordinate of the first vertex, the second value - * represents the Y coordinate of the first vertex, continuing in the same - * fashion for the rest of the vertices. (num_points - 1) segments will - * be constructed. - **/ -void cogl_path_polyline (CoglFixed *coords, - gint num_points); - - -/** - * cogl_path_polygon: - * @coords: A pointer to the first element of an array of fixed-point - * values that specify the vertex coordinates. - * @num_points: The total number of vertices. - * - * Clears the previously constructed shape and constructs a polygonal - * shape of the given number of vertices. - * - * The coords array must contain 2 * num_points values. The first value - * represents the X coordinate of the first vertex, the second value - * represents the Y coordinate of the first vertex, continuing in the same - * fashion for the rest of the vertices. - **/ -void cogl_path_polygon (CoglFixed *coords, - gint num_points); - - -/** - * cogl_path_rectangle: - * @x: X coordinate of the top-left corner. - * @y: Y coordinate of the top-left corner. - * @width: Rectangle width. - * @height: Rectangle height. - * - * Clears the previously constructed shape and constructs a rectangular - * shape at the given coordinates. - **/ -void cogl_path_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); - -/** - * cogl_path_ellipse: - * @center_x: X coordinate of the ellipse center - * @center_y: Y coordinate of the ellipse center - * @radius_x: X radius of the ellipse - * @radius_y: Y radius of the ellipse - * - * Clears the previously constructed shape and constructs an ellipse - * shape. - **/ -void cogl_path_ellipse (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y); - -/** - * cogl_path_round_rectangle: - * @x: X coordinate of the top-left corner - * @y: Y coordinate of the top-left corner - * @width: Width of the rectangle - * @height: Height of the rectangle - * @radius: Radius of the corner arcs. - * @arc_step: Angle increment resolution for subdivision of - * the corner arcs. - * - * Clears the previously constructed shape and constructs a rectangular - * shape with rounded corners. - **/ -void cogl_path_round_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height, - CoglFixed radius, - CoglAngle arc_step); - -/** - * SECTION:cogl-shaders - * @short_description: Fuctions for accessing the programmable GL pipeline - * - * COGL allows accessing the GL programmable pipeline in order to create - * vertex and fragment shaders. - * - * The only supported format is GLSL shaders. - */ - -/** - * cogl_create_shader: - * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. - * - * Create a new shader handle, use #cogl_shader_source to set the source code - * to be used on it. - * - * Returns: a new shader handle. - */ -CoglHandle cogl_create_shader (COGLenum shader_type); - -/** - * cogl_shader_ref: - * @handle: A #CoglHandle to a shader. - * - * Add an extra reference to a shader. - * - * Returns: @handle - */ -CoglHandle cogl_shader_ref (CoglHandle handle); - -/** - * cogl_shader_unref: - * @handle: A #CoglHandle to a shader. - * - * Removes a reference to a shader. If it was the last reference the - * shader object will be destroyed. - */ -void cogl_shader_unref (CoglHandle handle); - -/** - * cogl_is_shader: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing shader object. - * - * Returns: %TRUE if the handle references a shader, - * %FALSE otherwise - */ -gboolean cogl_is_shader (CoglHandle handle); - -/** - * cogl_shader_source: - * @shader: #CoglHandle for a shader. - * @source: GLSL shader source. - * - * Replaces the current GLSL source associated with a shader with a new - * one. - */ -void cogl_shader_source (CoglHandle shader, - const gchar *source); -/** - * cogl_shader_compile: - * @handle: #CoglHandle for a shader. - * - * Compiles the shader, no return value, but the shader is now ready for - * linking into a program. - */ -void cogl_shader_compile (CoglHandle handle); - -/** - * cogl_shader_get_info_log: - * @handle: #CoglHandle for a shader. - * @size: maximum number of bytes to retrieve. - * @buffer: location for info log. - * - * Retrieves the information log for a coglobject, can be used in conjunction - * with #cogl_shader_get_parameteriv to retrieve the compiler warnings/error - * messages that caused a shader to not compile correctly, mainly useful for - * debugging purposes. - */ -void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer); - -/** - * cogl_shader_get_parameteriv: - * @handle: #CoglHandle for a shader. - * @pname: the named COGL parameter to retrieve. - * @dest: storage location for COGLint return value. - * - * Retrieve a named parameter from a shader can be used to query to compile - * satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. - */ -void cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest); - -/** - * cogl_create_program: - * - * Create a new cogl program object that can be used to replace parts of the GL - * rendering pipeline with custom code. - * - * Returns: a new cogl program. - */ -CoglHandle cogl_create_program (void); - -/** - * cogl_program_ref: - * @handle: A #CoglHandle to a program. - * - * Add an extra reference to a program. - * - * Returns: @handle - */ -CoglHandle cogl_program_ref (CoglHandle handle); - -/** - * cogl_program_unref: - * @handle: A #CoglHandle to a program. - * - * Removes a reference to a program. If it was the last reference the - * program object will be destroyed. - */ -void cogl_program_unref (CoglHandle handle); - -/** - * cogl_is_program: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing program object. - * - * Returns: %TRUE if the handle references a program, - * %FALSE otherwise - */ -gboolean cogl_is_program (CoglHandle handle); - -/** - * cogl_program_attach_shader: - * @program_handle: a #CoglHandle for a shdaer program. - * @shader_handle: a #CoglHandle for a vertex of fragment shader. - * - * Attaches a shader to a program object, a program can have one vertex shader - * and one fragment shader attached. - */ -void cogl_program_attach_shader (CoglHandle program_handle, - CoglHandle shader_handle); - - -/** - * cogl_program_link: - * @handle: a #CoglHandle for a shader program. - * - * Links a program making it ready for use. - */ -void cogl_program_link (CoglHandle handle); - -/** - * cogl_program_use: - * @handle: a #CoglHandle for a shader program or COGL_INVALID_HANDLE. - * - * Activate a specific shader program replacing that part of the GL - * rendering pipeline, if passed in COGL_INVALID_HANDLE the default - * behavior of GL is reinstated. - */ -void cogl_program_use (CoglHandle handle); - -/** - * cogl_program_get_uniform_location: - * @handle: a #CoglHandle for a shader program. - * @uniform_name: the name of a uniform. - * - * Retrieve the location (offset) of a uniform variable in a shader program, a - * uniform is a variable that is constant for all vertices/fragments for a - * shader object and is possible to modify as an external parameter. - * - * Returns: the offset of a uniform in a specified program, this uniform can be - * set using #cogl_program_uniform_1f when the program is in use. - */ -COGLint cogl_program_get_uniform_location - (CoglHandle handle, - const gchar *uniform_name); - - -/** - * cogl_program_uniform_1f: - * @uniform_no: the unform to set. - * @value: the new value of the uniform. - * - * Changes the value of a uniform in the currently used (see #cogl_program_use) - * shader program. - */ -void cogl_program_uniform_1f (COGLint uniform_no, - gfloat value); - -/** - * SECTION:cogl-offscreen - * @short_description: Fuctions for creating and manipulating offscreen - * frame buffer objects - * - * COGL allows creating and operating on FBOs (Framebuffer Objects). - */ - -/* Offscreen api */ - -/** - * cogl_offscreen_new_to_texture: - * @texhandle: - * - * Returns: - */ -CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle); - -/** - * cogl_offscreen_new_multisample: - * - * - * Returns: - */ -CoglHandle cogl_offscreen_new_multisample (void); - -/** - * cogl_offscreen_ref: - * @handle: - * - * Returns: - */ -CoglHandle cogl_offscreen_ref (CoglHandle handle); - -/** - * cogl_is_offscreen: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing offscreen - * buffer object. - * - * Returns: %TRUE if the handle references an offscreen buffer, - * %FALSE otherwise - */ -gboolean cogl_is_offscreen (CoglHandle handle); - -/** - * cogl_offscreen_unref: - * @handle: - * - */ -void cogl_offscreen_unref (CoglHandle handle); - -/** - * cogl_offscreen_blit: - * @src_buffer: - * @dst_buffer: - * - */ -void cogl_offscreen_blit (CoglHandle src_buffer, - CoglHandle dst_buffer); - -/** - * cogl_offscreen_blit_region: - * @src_buffer: - * @dst_buffer: - * @src_x: - * @src_y: - * @src_w: - * @src_h: - * @dst_x: - * @dst_y: - * @dst_w: - * @dst_h: - * - */ -void cogl_offscreen_blit_region (CoglHandle src_buffer, - CoglHandle dst_buffer, - gint src_x, - gint src_y, - gint src_w, - gint src_h, - gint dst_x, - gint dst_y, - gint dst_w, - gint dst_h); - -/** - * cogl_draw_buffer: - * @target: - * @offscreen: - * - */ -void cogl_draw_buffer (CoglBufferTarget target, - CoglHandle offscreen); - G_END_DECLS #undef __COGL_H_INSIDE__ diff --git a/clutter/cogl/common/cogl-color.c b/clutter/cogl/common/cogl-color.c index 52f86f641..7bff49780 100644 --- a/clutter/cogl/common/cogl-color.c +++ b/clutter/cogl/common/cogl-color.c @@ -3,6 +3,7 @@ #endif #include "cogl-color.h" +#include "cogl-fixed.h" void cogl_color_set_from_4ub (CoglColor *dest, diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index d2a1b4a16..64edb80e4 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -3,7 +3,13 @@ libclutterinclude_HEADERS = \ $(top_builddir)/clutter/cogl/cogl.h \ $(top_builddir)/clutter/cogl/cogl-defines-gl.h \ $(top_builddir)/clutter/cogl/cogl-color.h \ - $(top_builddir)/clutter/cogl/cogl-fixed.h + $(top_builddir)/clutter/cogl/cogl-fixed.h \ + $(top_builddir)/clutter/cogl/cogl-offscreen.h \ + $(top_builddir)/clutter/cogl/cogl-path.h \ + $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-texture.h \ + $(top_builddir)/clutter/cogl/cogl-types.h + INCLUDES = \ -I$(top_srcdir) \ @@ -27,10 +33,15 @@ libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl-defines-gl.h \ $(top_builddir)/clutter/cogl/cogl-color.h \ $(top_builddir)/clutter/cogl/cogl-fixed.h \ + $(top_builddir)/clutter/cogl/cogl-offscreen.h \ + $(top_builddir)/clutter/cogl/cogl-path.h \ + $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-texture.h \ + $(top_builddir)/clutter/cogl/cogl-types.h \ cogl-internal.h \ - cogl-texture.h \ + cogl-texture-private.h \ cogl-fbo.h \ - cogl-shader.h \ + cogl-shader-private.h \ cogl-program.h \ cogl-context.h \ cogl.c \ diff --git a/clutter/cogl/gl/cogl-fbo.c b/clutter/cogl/gl/cogl-fbo.c index d0aa13745..3275f4df9 100644 --- a/clutter/cogl/gl/cogl-fbo.c +++ b/clutter/cogl/gl/cogl-fbo.c @@ -30,7 +30,7 @@ #include "cogl.h" #include "cogl-internal.h" #include "cogl-util.h" -#include "cogl-texture.h" +#include "cogl-texture-private.h" #include "cogl-fbo.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/clutter/cogl/gl/cogl-program.c b/clutter/cogl/gl/cogl-program.c index 40b066870..667137876 100644 --- a/clutter/cogl/gl/cogl-program.c +++ b/clutter/cogl/gl/cogl-program.c @@ -29,7 +29,7 @@ #include "cogl.h" #include "cogl-program.h" -#include "cogl-shader.h" +#include "cogl-shader-private.h" #include "cogl-internal.h" #include "cogl-handle.h" #include "cogl-context.h" diff --git a/clutter/cogl/gl/cogl-shader.h b/clutter/cogl/gl/cogl-shader-private.h similarity index 100% rename from clutter/cogl/gl/cogl-shader.h rename to clutter/cogl/gl/cogl-shader-private.h diff --git a/clutter/cogl/gl/cogl-shader.c b/clutter/cogl/gl/cogl-shader.c index 7ef749ed1..7cff49ed5 100644 --- a/clutter/cogl/gl/cogl-shader.c +++ b/clutter/cogl/gl/cogl-shader.c @@ -28,7 +28,7 @@ #endif #include "cogl.h" -#include "cogl-shader.h" +#include "cogl-shader-private.h" #include "cogl-internal.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/clutter/cogl/gl/cogl-texture.h b/clutter/cogl/gl/cogl-texture-private.h similarity index 100% rename from clutter/cogl/gl/cogl-texture.h rename to clutter/cogl/gl/cogl-texture-private.h diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 77308acfc..0beec07d1 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -31,7 +31,7 @@ #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-bitmap.h" -#include "cogl-texture.h" +#include "cogl-texture-private.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/clutter/cogl/gles/Makefile.am b/clutter/cogl/gles/Makefile.am index 29e25ddd2..e0fc03dab 100644 --- a/clutter/cogl/gles/Makefile.am +++ b/clutter/cogl/gles/Makefile.am @@ -3,7 +3,12 @@ libclutterinclude_HEADERS = \ $(top_builddir)/clutter/cogl/cogl.h \ $(top_builddir)/clutter/cogl/cogl-defines-gles.h \ $(top_builddir)/clutter/cogl/cogl-color.h \ - $(top_builddir)/clutter/cogl/cogl-fixed.h + $(top_builddir)/clutter/cogl/cogl-fixed.h \ + $(top_builddir)/clutter/cogl/cogl-offscreen.h \ + $(top_builddir)/clutter/cogl/cogl-path.h \ + $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-texture.h \ + $(top_builddir)/clutter/cogl/cogl-types.h INCLUDES = \ -I$(top_srcdir) \ @@ -27,8 +32,13 @@ libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl-defines-gles.h \ $(top_builddir)/clutter/cogl/cogl-color.h \ $(top_builddir)/clutter/cogl/cogl-fixed.h \ + $(top_builddir)/clutter/cogl/cogl-offscreen.h \ + $(top_builddir)/clutter/cogl/cogl-path.h \ + $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-texture.h \ + $(top_builddir)/clutter/cogl/cogl-types.h cogl-internal.h \ - cogl-texture.h \ + cogl-texture-private.h \ cogl-fbo.h \ cogl-context.h \ cogl.c \ @@ -39,7 +49,7 @@ libclutter_cogl_la_SOURCES = \ cogl-gles2-wrapper.h \ cogl-program.h \ cogl-program.c \ - cogl-shader.h \ + cogl-shader-private.h \ cogl-shader.c if USE_GLES2_WRAPPER diff --git a/clutter/cogl/gles/cogl-fbo.c b/clutter/cogl/gles/cogl-fbo.c index 3d8d7fb9f..d5b02818b 100644 --- a/clutter/cogl/gles/cogl-fbo.c +++ b/clutter/cogl/gles/cogl-fbo.c @@ -30,7 +30,7 @@ #include "cogl.h" #include "cogl-internal.h" #include "cogl-util.h" -#include "cogl-texture.h" +#include "cogl-texture-private.h" #include "cogl-fbo.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c index 450d0b061..969783c0c 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c @@ -36,7 +36,7 @@ #include "cogl-fixed-vertex-shader.h" #include "cogl-fixed-fragment-shader.h" #include "cogl-context.h" -#include "cogl-shader.h" +#include "cogl-shader-private.h" #include "cogl-program.h" #define _COGL_GET_GLES2_WRAPPER(wvar, retval) \ diff --git a/clutter/cogl/gles/cogl-program.c b/clutter/cogl/gles/cogl-program.c index cfc61f57d..36ac6d509 100644 --- a/clutter/cogl/gles/cogl-program.c +++ b/clutter/cogl/gles/cogl-program.c @@ -37,7 +37,7 @@ #include -#include "cogl-shader.h" +#include "cogl-shader-private.h" #include "cogl-program.h" static void _cogl_program_free (CoglProgram *program); diff --git a/clutter/cogl/gles/cogl-shader.h b/clutter/cogl/gles/cogl-shader-private.h similarity index 100% rename from clutter/cogl/gles/cogl-shader.h rename to clutter/cogl/gles/cogl-shader-private.h diff --git a/clutter/cogl/gles/cogl-shader.c b/clutter/cogl/gles/cogl-shader.c index 2512f3ddc..56c5ad07f 100644 --- a/clutter/cogl/gles/cogl-shader.c +++ b/clutter/cogl/gles/cogl-shader.c @@ -29,7 +29,7 @@ #include "cogl.h" -#include "cogl-shader.h" +#include "cogl-shader-private.h" #include "cogl-internal.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/clutter/cogl/gles/cogl-texture.h b/clutter/cogl/gles/cogl-texture-private.h similarity index 100% rename from clutter/cogl/gles/cogl-texture.h rename to clutter/cogl/gles/cogl-texture-private.h diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 3beb80889..bcebef87c 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -31,7 +31,7 @@ #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-bitmap.h" -#include "cogl-texture.h" +#include "cogl-texture-private.h" #include "cogl-context.h" #include "cogl-handle.h" diff --git a/doc/reference/cogl/Makefile.am b/doc/reference/cogl/Makefile.am index d0cb723d5..1a91320d1 100644 --- a/doc/reference/cogl/Makefile.am +++ b/doc/reference/cogl/Makefile.am @@ -55,11 +55,10 @@ CFILE_GLOB=\ # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES=\ cogl-bitmap.h \ - cogl-context.h \ - cogl-defines.h \ - cogl-internal.h \ - cogl-primitives.h \ - cogl-texture.h \ + cogl-defines-gl.h \ + cogl-defines-gles.h \ + cogl-handle.h \ + cogl-primitives.h \ gl \ gles