![]() |
![]() |
![]() |
Cogl Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
CoglObject; void * cogl_object_ref (void *object
); void cogl_object_unref (void *object
); void * cogl_object_get_user_data (CoglObject *object
,CoglUserDataKey *key
); void cogl_object_set_user_data (CoglObject *object
,CoglUserDataKey *key
,void *user_data
,CoglUserDataDestroyCallback destroy
); #define COGL_INVALID_HANDLE typedef CoglHandle; CoglHandle cogl_handle_ref (CoglHandle handle
); void cogl_handle_unref (CoglHandle handle
); void (*CoglFuncPtr) (void
); enum CoglPixelFormat; enum CoglBufferTarget; enum CoglBufferBit; enum CoglAttributeType; enum CoglFeatureFlags; CoglFeatureFlags cogl_get_features (void
); gboolean cogl_features_available (CoglFeatureFlags features
); CoglFuncPtr cogl_get_proc_address (const char *name
); GOptionGroup * cogl_get_option_group (void
); void cogl_push_matrix (void
); void cogl_pop_matrix (void
); void cogl_scale (float x
,float y
,float z
); void cogl_translate (float x
,float y
,float z
); void cogl_rotate (float angle
,float x
,float y
,float z
); void cogl_transform (const CoglMatrix *matrix
); void cogl_frustum (float left
,float right
,float bottom
,float top
,float z_near
,float z_far
); void cogl_perspective (float fovy
,float aspect
,float z_near
,float z_far
); void cogl_ortho (float left
,float right
,float bottom
,float top
,float near
,float far
); void cogl_get_modelview_matrix (CoglMatrix *matrix
); void cogl_set_modelview_matrix (CoglMatrix *matrix
); void cogl_get_projection_matrix (CoglMatrix *matrix
); void cogl_set_projection_matrix (CoglMatrix *matrix
); void cogl_set_viewport (int x
,int y
,int width
,int height
); void cogl_get_viewport (float v[4]
); void cogl_clear (const CoglColor *color
,unsigned long buffers
); void cogl_set_backface_culling_enabled (gboolean setting
); gboolean cogl_get_backface_culling_enabled (void
); enum CoglFogMode; void cogl_set_fog (const CoglColor *fog_color
,CoglFogMode mode
,float density
,float z_near
,float z_far
); void cogl_disable_fog (void
); void cogl_set_source (CoglHandle material
); void cogl_set_source_color (const CoglColor *color
); void cogl_set_source_color4ub (guint8 red
,guint8 green
,guint8 blue
,guint8 alpha
); void cogl_set_source_color4f (float red
,float green
,float blue
,float alpha
); void cogl_set_source_texture (CoglHandle texture_handle
); enum CoglReadPixelsFlags; void cogl_read_pixels (int x
,int y
,int width
,int height
,CoglReadPixelsFlags source
,CoglPixelFormat format
,guint8 *pixels
); void cogl_flush (void
); void cogl_begin_gl (void
); void cogl_end_gl (void
);
void * cogl_object_ref (void *object
);
Increases the reference count of handle
by 1
|
a CoglObject |
Returns : |
the object , with its reference count increased
|
void cogl_object_unref (void *object
);
Drecreases the reference count of object
by 1; if the reference
count reaches 0, the resources allocated by object
will be freed
|
a CoglObject |
void * cogl_object_get_user_data (CoglObject *object
,CoglUserDataKey *key
);
Finds the user data previously associated with object
using
the given key
. If no user data has been associated with object
for the given key
this function returns NULL.
|
The object with associated private data to query |
|
The address of a CoglUserDataKey which provides a unique value with which to index the private data. |
Returns : |
The user data previously associated with object using
the given key ; or NULL if no associated data is found.
|
Since 1.4
void cogl_object_set_user_data (CoglObject *object
,CoglUserDataKey *key
,void *user_data
,CoglUserDataDestroyCallback destroy
);
Associates some private user_data
with a given CoglObject. To
later remove the association call cogl_object_set_user_data()
with
the same key
but NULL for the user_data
.
|
The object to associate private data with |
|
The address of a CoglUserDataKey which provides a unique value with which to index the private data. |
|
The data to associate with the given object, or NULL to remove a previous association. |
|
A CoglUserDataDestroyCallback to call if the object is destroyed or if the association is removed by later setting NULL data for the same key. |
Since 1.4
#define COGL_INVALID_HANDLE NULL
A COGL handle that is not valid, used for unitialized handles as well as error conditions.
typedef gpointer CoglHandle;
Type used for storing references to cogl objects, the CoglHandle is a fully opaque type without any public data members.
CoglHandle cogl_handle_ref (CoglHandle handle
);
Increases the reference count of handle
by 1
|
a CoglHandle |
Returns : |
the handle, with its reference count increased. [transfer none] |
void cogl_handle_unref (CoglHandle handle
);
Drecreases the reference count of handle
by 1; if the reference
count reaches 0, the resources allocated by handle
will be freed
|
a CoglHandle |
void (*CoglFuncPtr) (void
);
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 enum { /*< prefix=COGL_PIXEL_FORMAT >*/ 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;
Pixel formats used by COGL. For the formats with a byte per
component, the order of the components specify the order in
increasing memory addresses. So for example
COGL_PIXEL_FORMAT_RGB_888
would have the red component in the
lowest address, green in the next address and blue after that
regardless of the endinanness of the system.
For the 16-bit formats the component order specifies the order
within a 16-bit number from most significant bit to least
significant. So for COGL_PIXEL_FORMAT_RGB_565
, the red component
would be in bits 11-15, the green component would be in 6-11 and
the blue component would be in 1-5. Therefore the order in memory
depends on the endianness of the system.
When uploading a texture COGL_PIXEL_FORMAT_ANY
can be used as the
internal format. Cogl will try to pick the best format to use
internally and convert the texture data if necessary.
Any format | |
8 bits alpha mask | |
RGB, 16 bits | |
RGBA, 16 bits | |
RGBA, 16 bits | |
Not currently supported | |
Single luminance component | |
RGB, 24 bits | |
BGR, 24 bits | |
RGBA, 32 bits | |
BGRA, 32 bits | |
ARGB, 32 bits | |
ABGR, 32 bits | |
Premultiplied RGBA, 32 bits | |
Premultiplied BGRA, 32 bits | |
Premultiplied ARGB, 32 bits | |
Premultiplied ABGR, 32 bits | |
Premultiplied RGBA, 16 bits | |
Premultiplied RGBA, 16 bits |
Since 0.8
typedef enum { COGL_WINDOW_BUFFER = (1 << 1), COGL_OFFSCREEN_BUFFER = (1 << 2) } CoglBufferTarget;
Target flags for FBOs.
Since 0.8
typedef enum { COGL_BUFFER_BIT_COLOR = 1L<<0, COGL_BUFFER_BIT_DEPTH = 1L<<1, COGL_BUFFER_BIT_STENCIL = 1L<<2 } CoglBufferBit;
Types of auxiliary buffers
Selects the primary color buffer | |
Selects the depth buffer | |
Selects the stencil buffer |
Since 1.0
typedef enum { COGL_ATTRIBUTE_TYPE_BYTE = GL_BYTE, COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE = GL_UNSIGNED_BYTE, COGL_ATTRIBUTE_TYPE_SHORT = GL_SHORT, COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = GL_UNSIGNED_SHORT, COGL_ATTRIBUTE_TYPE_FLOAT = GL_FLOAT } CoglAttributeType;
Data types for the components of cogl_vertex_buffer_add()
Data is the same size of a byte | |
Data is the same size of an unsigned byte | |
Data is the same size of a short integer | |
Data is the same size of an unsigned short integer | |
Data is the same size of a float |
Since 1.0
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), COGL_FEATURE_VBOS = (1 << 11), COGL_FEATURE_PBOS = (1 << 12), COGL_FEATURE_UNSIGNED_INT_INDICES = (1 << 13), COGL_FEATURE_DEPTH_RANGE = (1 << 14), COGL_FEATURE_TEXTURE_NPOT_BASIC = (1 << 15), COGL_FEATURE_TEXTURE_NPOT_MIPMAP = (1 << 16), COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17), COGL_FEATURE_POINT_SPRITE = (1 << 18), COGL_FEATURE_TEXTURE_3D = (1 << 19), COGL_FEATURE_SHADERS_ARBFP = (1 << 20) } CoglFeatureFlags;
Flags for the supported features.
ARB_texture_rectangle support | |
Non power of two textures are supported
by the hardware. This is a equivalent to the
COGL_FEATURE_TEXTURE_NPOT_BASIC , COGL_FEATURE_TEXTURE_NPOT_MIPMAP
and COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined.
|
|
ycbcr conversion support | |
glReadPixels() support | |
GLSL support | |
FBO support | |
Multisample support on FBOs | |
Blit support on FBOs | |
At least 4 clip planes available | |
Stencil buffer support | |
VBO support | |
PBO support | |
Set if
COGL_INDICES_TYPE_UNSIGNED_INT is supported in
cogl_vertex_buffer_indices_new() .
|
|
cogl_material_set_depth_range() support | |
The hardware supports non power
of two textures, but you also need to check the
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
features to know if the hardware supports npot texture mipmaps
or repeat modes other than
COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE respectively.
|
|
Mipmapping is supported in conjuntion with non power of two textures. | |
Repeat modes other than
COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE are supported by the
hardware.
|
|
Whether
cogl_material_set_layer_point_sprite_coords_enabled() is supported.
|
|
3D texture support | |
ARBFP support |
Since 0.8
CoglFeatureFlags cogl_get_features (void
);
Returns all of the features supported by COGL.
Returns : |
A logical OR of all the supported COGL features. |
Since 0.8
gboolean cogl_features_available (CoglFeatureFlags features
);
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.
|
A bitmask of features to check for |
Returns : |
TRUE if the features are available, FALSE otherwise.
|
CoglFuncPtr cogl_get_proc_address (const char *name
);
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.
|
the name of the function. |
Returns : |
a pointer to the requested function or NULL if the
function is not available.
|
GOptionGroup * cogl_get_option_group (void
);
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.
Returns : |
a GOptionGroup |
Since 1.0
void cogl_push_matrix (void
);
Stores the current model-view matrix on the matrix stack. The matrix
can later be restored with cogl_pop_matrix()
.
void cogl_pop_matrix (void
);
Restores the current model-view matrix from the matrix stack.
void cogl_scale (float x
,float y
,float z
);
Multiplies the current model-view matrix by one that scales the x, y and z axes by the given values.
|
Amount to scale along the x-axis |
|
Amount to scale along the y-axis |
|
Amount to scale along the z-axis |
void cogl_translate (float x
,float y
,float z
);
Multiplies the current model-view matrix by one that translates the model along all three axes according to the given values.
|
Distance to translate along the x-axis |
|
Distance to translate along the y-axis |
|
Distance to translate along the z-axis |
void cogl_rotate (float angle
,float x
,float y
,float z
);
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.
|
Angle in degrees to rotate. |
|
X-component of vertex to rotate around. |
|
Y-component of vertex to rotate around. |
|
Z-component of vertex to rotate around. |
void cogl_transform (const CoglMatrix *matrix
);
Multiplies the current model-view matrix by the given matrix.
|
the matrix to multiply with the current model-view |
Since 1.4
void cogl_frustum (float left
,float right
,float bottom
,float top
,float z_near
,float z_far
);
Replaces the current projection matrix with a perspective matrix for the given viewing frustum.
|
Left clipping plane |
|
Right clipping plane |
|
Bottom clipping plane |
|
Top clipping plane |
|
Nearest visible point |
|
Furthest visible point along the z-axis |
Since 0.8.2
void cogl_perspective (float fovy
,float aspect
,float z_near
,float z_far
);
Replaces the current projection matrix with a perspective matrix based on the provided values.
|
Vertical of view angle in degrees. |
|
Aspect ratio of diesplay |
|
Nearest visible point |
|
Furthest visible point along the z-axis |
void cogl_ortho (float left
,float right
,float bottom
,float top
,float near
,float far
);
Replaces the current projection matrix with an orthographic projection matrix. See Figure 1, “” to see how the matrix is calculated.
glOrtho()
even
though they are unnecessarily confusing due to the z near and z far
arguments actually being a "distance" from the origin, where
negative values are behind the viewer, instead of coordinates for
the z clipping planes which would have been consistent with the
left, right bottom and top arguments.
|
The coordinate for the left clipping plane |
|
The coordinate for the right clipping plane |
|
The coordinate for the bottom clipping plane |
|
The coordinate for the top clipping plane |
|
The distance to the near clipping plane (negative if the plane is behind the viewer) |
|
The distance for the far clipping plane (negative if the plane is behind the viewer) |
Since 1.0
void cogl_get_modelview_matrix (CoglMatrix *matrix
);
Stores the current model-view matrix in matrix
.
|
return location for the model-view matrix. [out] |
void cogl_set_modelview_matrix (CoglMatrix *matrix
);
Loads matrix
as the new model-view matrix.
|
the new model-view matrix |
void cogl_get_projection_matrix (CoglMatrix *matrix
);
Stores the current projection matrix in matrix
.
|
return location for the projection matrix. [out] |
void cogl_set_projection_matrix (CoglMatrix *matrix
);
Loads matrix as the new projection matrix.
|
the new projection matrix |
void cogl_set_viewport (int x
,int y
,int width
,int height
);
Replaces the current viewport with the given values.
|
X offset of the viewport |
|
Y offset of the viewport |
|
Width of the viewport |
|
Height of the viewport |
Since 1.2
void cogl_get_viewport (float v[4]
);
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.
|
pointer to a 4 element array of floats to receive the viewport dimensions. [out][array fixed-size=4] |
void cogl_clear (const CoglColor *color
,unsigned long buffers
);
Clears all the auxiliary buffers identified in the buffers
mask, and if
that includes the color buffer then the specified color
is used.
|
Background color to clear to |
|
A mask of CoglBufferBit's identifying which auxiliary buffers to clear |
void cogl_set_backface_culling_enabled (gboolean setting
);
Sets whether textures positioned so that their backface is showing should be hidden. This can be used to efficiently draw two-sided 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.
|
TRUE to enable backface culling or FALSE to disable.
|
gboolean cogl_get_backface_culling_enabled (void
);
Queries if backface culling has been enabled via
cogl_set_backface_culling_enabled()
Returns : |
TRUE if backface culling is enabled, and FALSE otherwise
|
typedef enum { COGL_FOG_MODE_LINEAR, COGL_FOG_MODE_EXPONENTIAL, COGL_FOG_MODE_EXPONENTIAL_SQUARED } CoglFogMode;
The fog mode determines the equation used to calculate the fogging blend
factor while fogging is enabled. The simplest COGL_FOG_MODE_LINEAR
mode
determines f as:
1 |
f = end - eye_distance / end - start |
Where eye_distance is the distance of the current fragment in eye coordinates from the origin.
Calculates the fog blend factor as:
|
|||
Calculates the fog blend factor as:
|
|||
Calculates the fog blend factor as:
|
Since 1.0
void cogl_set_fog (const CoglColor *fog_color
,CoglFogMode mode
,float density
,float z_near
,float z_far
);
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()
.
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. This might improve in the future when we can depend
on fragment shaders.
|
The color of the fog |
|
A CoglFogMode that determines the equation used to calculate the fogging blend factor. |
|
Used by COGL_FOG_MODE_EXPONENTIAL and by
COGL_FOG_MODE_EXPONENTIAL_SQUARED equations.
|
|
Position along Z axis where no fogging should be applied |
|
Position along Z axis where full fogging should be applied |
void cogl_disable_fog (void
);
This function disables fogging, so primitives drawn afterwards will not be blended with any previously set fog color.
void cogl_set_source (CoglHandle material
);
This function sets the source material that will be used to fill subsequent geometry emitted via the cogl API.
|
A CoglHandle for a material |
Since 1.0
void cogl_set_source_color (const CoglColor *color
);
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.
See also cogl_set_source_color4ub()
and cogl_set_source_color4f()
if you already have the color components.
|
a CoglColor |
Since 1.0
void cogl_set_source_color4ub (guint8 red
,guint8 green
,guint8 blue
,guint8 alpha
);
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.
|
value of the red channel, between 0 and 255 |
|
value of the green channel, between 0 and 255 |
|
value of the blue channel, between 0 and 255 |
|
value of the alpha channel, between 0 and 255 |
Since 1.0
void cogl_set_source_color4f (float red
,float green
,float blue
,float alpha
);
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.
|
value of the red channel, between 0 and 1 .0
|
|
value of the green channel, between 0 and 1 .0
|
|
value of the blue channel, between 0 and 1 .0
|
|
value of the alpha channel, between 0 and 1 .0
|
Since 1.0
void cogl_set_source_texture (CoglHandle texture_handle
);
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:
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);
|
The Cogl texture you want as your source |
Since 1.0
typedef enum { /*< prefix=COGL_READ_PIXELS >*/ COGL_READ_PIXELS_COLOR_BUFFER = 1L << 0 } CoglReadPixelsFlags;
Flags for cogl_read_pixels()
Since 1.0
void cogl_read_pixels (int x
,int y
,int width
,int height
,CoglReadPixelsFlags source
,CoglPixelFormat format
,guint8 *pixels
);
This reads a rectangle of pixels from the current framebuffer 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).
Currently Cogl assumes that the framebuffer is in a premultiplied
format so if format
is non-premultiplied it will convert it. To
read the pixel values without any conversion you should either
specify a format that doesn't use an alpha channel or use one of
the formats ending in PRE.
|
The window x position to start reading from |
|
The window y position to start reading from |
|
The width of the rectangle you want to read |
|
The height of the rectangle you want to read |
|
Identifies which auxillary buffer you want to read (only COGL_READ_PIXELS_COLOR_BUFFER supported currently) |
|
The pixel format you want the result in (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently) |
|
The location to write the pixel data. |
void cogl_flush (void
);
This function should only need to be called in exceptional circumstances.
As an optimization Cogl drawing functions may batch up primitives internally, so if you are trying to use raw GL outside of Cogl you stand a better chance of being successful if you ask Cogl to flush any batched geometry before making your state changes.
It only ensure that the underlying driver is issued all the commands necessary to draw the batched primitives. It provides no guarantees about when the driver will complete the rendering.
This provides no guarantees about the GL state upon returning and to avoid confusing Cogl you should aim to restore any changes you make before resuming use of Cogl.
If you are making state changes with the intention of affecting Cogl drawing primitives you are 100% on your own since you stand a good chance of conflicting with Cogl internals. For example clutter-gst which currently uses direct GL calls to bind ARBfp programs will very likely break when Cogl starts to use ARBfb programs itself for the material API.
Since 1.0
void cogl_begin_gl (void
);
We do not advise nor reliably support the interleaving of raw GL drawing and
Cogl drawing functions, but if you insist, cogl_begin_gl()
and cogl_end_gl()
provide a simple mechanism that may at least give you a fighting chance of
succeeding.
Note: this doesn't help you modify the behaviour of Cogl drawing functions through the modification of GL state; that will never be reliably supported, but if you are trying to do something like:
1 2 3 4 5 6 |
{ - setup some OpenGL state. - draw using OpenGL (e.g. glDrawArrays() ) - reset modified OpenGL state. - continue using Cogl to draw } |
You should surround blocks of drawing using raw GL with cogl_begin_gl()
and cogl_end_gl()
:
1 2 3 4 5 6 7 8 |
{ cogl_begin_gl (); - setup some OpenGL state. - draw using OpenGL (e.g. glDrawArrays() ) - reset modified OpenGL state. cogl_end_gl (); - continue using Cogl to draw } |
Don't ever try and do:
1 2 3 4 5 |
{ - setup some OpenGL state. - use Cogl to draw - reset modified OpenGL state. } |
When the internals of Cogl evolves, this is very liable to break.
This function will flush all batched primitives, and subsequently flush all internal Cogl state to OpenGL as if it were going to draw something itself.
The result is that the OpenGL modelview matrix will be setup; the state corresponding to the current source material will be set up and other world state such as backface culling, depth and fogging enabledness will be sent to OpenGL.
cogl_begin_gl()
. E.g. by calling
cogl_set_source_color4ub()
.
cogl_begin_gl()
if you don't do this then the
result of further Cogl calls is undefined.
Again we would like to stress, we do not advise the use of this API and if possible we would prefer to improve Cogl than have developers require raw OpenGL.
Since 1.0
void cogl_end_gl (void
);
This is the counterpart to cogl_begin_gl()
used to delimit blocks of drawing
code using raw OpenGL. Please refer to cogl_begin_gl()
for full details.
Since 1.0