Cogl.Primitive¶
- Subclasses:
None
Methods¶
- Inherited:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
None
Fields¶
None
Class Details¶
- class Cogl.Primitive¶
- Bases:
- Abstract:
No
- classmethod new_p2(context, mode, data)¶
- Parameters:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP2
]) – An array ofCogl.VertexP2
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 aCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP2C4
]) – An array ofCogl.VertexP2C4
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP2T2
]) – An array ofCogl.VertexP2T2
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP2T2C4
]) – An array ofCogl.VertexP2T2C4
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP3
]) – An array ofCogl.VertexP3
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 aCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP3C4
]) – An array ofCogl.VertexP3C4
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP3T2
]) – An array ofCogl.VertexP3T2
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
context (
Cogl.Context
) – ACogl.Context
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesdata ([
Cogl.VertexP3T2C4
]) – An array ofCogl.VertexP3T2C4
vertices
- Returns:
A newly allocated
Cogl.Primitive
with a reference of 1. This can be freed using cogl_object_unref().- Return type:
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 withCogl.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 ifCogl.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:
mode (
Cogl.VerticesMode
) – ACogl.VerticesMode
defining how to draw the verticesn_vertices (
int
) – The number of vertices to process when drawingattributes (
Cogl.Attribute
) – An array ofCogl.Attribute
n_attributes (
int
) – The number of attributes
- Returns:
A newly allocated
Cogl.Primitive
object- Return type:
Combines a set of
Cogl.Attribute
s with a specific draw mode and defines a vertex count so aCogl.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 ifCogl.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:
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:
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:
framebuffer (
Cogl.Framebuffer
) – A destinationCogl.Framebuffer
pipeline (
Cogl.Pipeline
) – ACogl.Pipeline
state object
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 asCogl.Texture2D
,Cogl.TextureRectangle
orCogl.Texture3D
are associated with layers of the given pipeline.New in version 1.16.
- foreach_attribute(callback, *user_data)¶
- Parameters:
callback (
Cogl.PrimitiveAttributeCallback
) – ACogl.PrimitiveAttributeCallback
to be called for each attributeuser_data (
object
orNone
) – Private data that will be passed to the callback
Iterates all the attributes of the given
Cogl.Primitive
.New in version 1.10.
- get_indices()¶
- Returns:
the indices that were set with
Cogl.Primitive.set_indices
() orNone
if no indices were set.- Return type:
New in version 1.10.
- get_mode()¶
- Return type:
- get_n_vertices()¶
- Returns:
The number of vertices to read when drawing.
- Return type:
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 ofCogl.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:
attributes (
Cogl.Attribute
) – an array ofCogl.Attribute
pointersn_attributes (
int
) – the number of elements in attributes
Replaces all the attributes of the given
Cogl.Primitive
object.New in version 1.6.
- set_indices(indices, n_indices)¶
- Parameters:
indices (
Cogl.Indices
) – ACogl.Indices
arrayn_indices (
int
) – The number of indices to reference when drawing
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 ifCogl.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.