Cogl.Primitive

g Cogl.Object Cogl.Object Cogl.Primitive Cogl.Primitive Cogl.Object->Cogl.Primitive

Subclasses:

None

Methods

Inherited:

Cogl.Object (2)

class

new_p2 (context, mode, data)

class

new_p2c4 (context, mode, data)

class

new_p2t2 (context, mode, data)

class

new_p2t2c4 (context, mode, data)

class

new_p3 (context, mode, data)

class

new_p3c4 (context, mode, data)

class

new_p3t2 (context, mode, data)

class

new_p3t2c4 (context, mode, data)

class

new_with_attributes (mode, n_vertices, attributes, n_attributes)

class

texture_set_auto_mipmap (primitive_texture, value)

copy ()

draw (framebuffer, pipeline)

foreach_attribute (callback, *user_data)

get_first_vertex ()

get_indices ()

get_mode ()

get_n_vertices ()

set_attributes (attributes, n_attributes)

set_first_vertex (first_vertex)

set_indices (indices, n_indices)

set_mode (mode)

set_n_vertices (n_vertices)

Virtual Methods

None

Fields

None

Class Details

class Cogl.Primitive
Bases:

Cogl.Object

Abstract:

No

classmethod new_p2(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position attribute with a Cogl.Attribute and upload your data.

For example to draw a convex polygon you can do:

CoglVertexP2 triangle[] =
{
  { 0,   300 },
  { 150, 0,  },
  { 300, 300 }
};
prim = cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                              3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p2c4(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position and color attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with a linear gradient you can do:

CoglVertexP2C4 triangle[] =
{
  { 0,   300,  0xff, 0x00, 0x00, 0xff },
  { 150, 0,    0x00, 0xff, 0x00, 0xff },
  { 300, 300,  0xff, 0x00, 0x00, 0xff }
};
prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p2t2(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position and texture coordinate attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with texture mapping you can do:

CoglVertexP2T2 triangle[] =
{
  { 0,   300,  0.0, 1.0},
  { 150, 0,    0.5, 0.0},
  { 300, 300,  1.0, 1.0}
};
prim = cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p2t2c4(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position, texture coordinate and color attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with texture mapping and a linear gradient you can do:

CoglVertexP2T2C4 triangle[] =
{
  { 0,   300,  0.0, 1.0,  0xff, 0x00, 0x00, 0xff},
  { 150, 0,    0.5, 0.0,  0x00, 0xff, 0x00, 0xff},
  { 300, 300,  1.0, 1.0,  0xff, 0x00, 0x00, 0xff}
};
prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                  3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p3(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position attribute with a Cogl.Attribute and upload your data.

For example to draw a convex polygon you can do:

CoglVertexP3 triangle[] =
{
  { 0,   300, 0 },
  { 150, 0,   0 },
  { 300, 300, 0 }
};
prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                              3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p3c4(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position and color attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with a linear gradient you can do:

CoglVertexP3C4 triangle[] =
{
  { 0,   300, 0,  0xff, 0x00, 0x00, 0xff },
  { 150, 0,   0,  0x00, 0xff, 0x00, 0xff },
  { 300, 300, 0,  0xff, 0x00, 0x00, 0xff }
};
prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p3t2(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position and texture coordinate attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with texture mapping you can do:

CoglVertexP3T2 triangle[] =
{
  { 0,   300, 0,  0.0, 1.0},
  { 150, 0,   0,  0.5, 0.0},
  { 300, 300, 0,  1.0, 1.0}
};
prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_p3t2c4(context, mode, data)
Parameters:
Returns:

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using cogl_object_unref().

Return type:

Cogl.Primitive

Provides a convenient way to describe a primitive, such as a single triangle strip or a triangle fan, that will internally allocate the necessary Cogl.AttributeBuffer storage, describe the position, texture coordinate and color attributes with Cogl.Attribute s and upload your data.

For example to draw a convex polygon with texture mapping and a linear gradient you can do:

CoglVertexP3T2C4 triangle[] =
{
  { 0,   300, 0,  0.0, 1.0,  0xff, 0x00, 0x00, 0xff},
  { 150, 0,   0,  0.5, 0.0,  0x00, 0xff, 0x00, 0xff},
  { 300, 300, 0,  1.0, 1.0,  0xff, 0x00, 0x00, 0xff}
};
prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
                                  3, triangle);
cogl_primitive_draw (prim);

The value passed as n_vertices is initially used to determine how much can be read from data but it will also be used to update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

The primitive API doesn’t support drawing with sliced textures (since switching between slices implies changing state and so that implies multiple primitives need to be submitted). You should pass the Cogl.TextureFlags.NO_SLICING flag to all textures that might be used while drawing with this API. If your hardware doesn’t support non-power of two textures (For example you are using GLES 1.1) then you will need to make sure your assets are resized to a power-of-two size (though they don’t have to be square)

New in version 1.6.

classmethod new_with_attributes(mode, n_vertices, attributes, n_attributes)
Parameters:
Returns:

A newly allocated Cogl.Primitive object

Return type:

Cogl.Primitive

Combines a set of Cogl.Attribute s with a specific draw mode and defines a vertex count so a Cogl.Primitive object can be retained and drawn later with no addition information required.

The value passed as n_vertices will simply update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to read when drawing.

New in version 1.6.

classmethod texture_set_auto_mipmap(primitive_texture, value)
Parameters:
  • primitive_texture (object) – A #CoglPrimitiveTexture

  • value (int) – The new value for whether to auto mipmap

Sets whether the texture will automatically update the smaller mipmap levels after any part of level 0 is updated. The update will only occur whenever the texture is used for drawing with a texture filter that requires the lower mipmap levels. An application should disable this if it wants to upload its own data for the other levels. By default auto mipmapping is enabled.

New in version 2.0.

copy()
Returns:

the new primitive

Return type:

Cogl.Primitive

Makes a copy of an existing Cogl.Primitive. Note that the primitive is a shallow copy which means it will use the same attributes and attribute buffers as the original primitive.

New in version 1.10.

draw(framebuffer, pipeline)
Parameters:

Draws the given self geometry to the specified destination framebuffer using the graphics processing state described by pipeline.

This drawing api doesn’t support high-level meta texture types such as Cogl.Texture2DSliced so it is the user’s responsibility to ensure that only low-level textures that can be directly sampled by a GPU such as Cogl.Texture2D, Cogl.TextureRectangle or Cogl.Texture3D are associated with layers of the given pipeline.

New in version 1.16.

foreach_attribute(callback, *user_data)
Parameters:

Iterates all the attributes of the given Cogl.Primitive.

New in version 1.10.

get_first_vertex()
Return type:

int

get_indices()
Returns:

the indices that were set with Cogl.Primitive.set_indices() or None if no indices were set.

Return type:

Cogl.Indices

New in version 1.10.

get_mode()
Return type:

Cogl.VerticesMode

get_n_vertices()
Returns:

The number of vertices to read when drawing.

Return type:

int

Queries the number of vertices to read when drawing the given self. Usually this value is implicitly set when associating vertex data or indices with a Cogl.Primitive.

If Cogl.Primitive.set_indices() has been used to associate a sequence of Cogl.Indices with the given self then the number of vertices to read can also be phrased as the number of indices to read.

To be clear; it doesn’t refer to the number of vertices - in terms of data - associated with the primitive it’s just the number of vertices to read and draw.

New in version 1.8.

set_attributes(attributes, n_attributes)
Parameters:

Replaces all the attributes of the given Cogl.Primitive object.

New in version 1.6.

set_first_vertex(first_vertex)
Parameters:

first_vertex (int) –

set_indices(indices, n_indices)
Parameters:

Associates a sequence of Cogl.Indices with the given self.

Cogl.Indices provide a way to virtualize your real vertex data by providing a sequence of indices that index into your real vertex data. The GPU will walk though the index values to indirectly lookup the data for each vertex instead of sequentially walking through the data directly. This lets you save memory by indexing shared data multiple times instead of duplicating the data.

The value passed as n_indices will simply update the Cogl.Primitive n_vertices property as if Cogl.Primitive.set_n_vertices() were called. This property defines the number of vertices to draw or, put another way, how many indices should be read from indices when drawing.

The Cogl.Primitive first_vertex property also affects drawing with indices by defining the first entry of the indices to start drawing from.

New in version 1.10.

set_mode(mode)
Parameters:

mode (Cogl.VerticesMode) –

set_n_vertices(n_vertices)
Parameters:

n_vertices (int) – The number of vertices to read when drawing.

Specifies how many vertices should be read when drawing the given self.

Usually this value is set implicitly when associating vertex data or indices with a Cogl.Primitive.

To be clear; it doesn’t refer to the number of vertices - in terms of data - associated with the primitive it’s just the number of vertices to read and draw.

New in version 1.8.