Constructor
CoglPrimitivenew_p2
Declaration [src]
CoglPrimitive*
cogl_primitive_new_p2 (
CoglContext* context,
CoglVerticesMode mode,
int n_vertices,
const CoglVertexP2* data
)
Description [src]
Provides a convenient way to describe a primitive, such as a single
triangle strip or a triangle fan, that will internally allocate the
necessary CoglAttributeBuffer
storage, describe the position
attribute with a CoglAttribute
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
CoglPrimitive
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). 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).
Parameters
context
-
Type:
CoglContext
A
CoglContext
.The data is owned by the caller of the function. mode
-
Type:
CoglVerticesMode
A
CoglVerticesMode
defining how to draw the vertices. n_vertices
-
Type:
int
The number of vertices to read from
data
and also the number of vertices to read when later drawing. data
-
Type: An array of
None
An array of
CoglVertexP2
vertices.The length of the array is specified in the n_vertices
argument.The data is owned by the caller of the function.
Return value
Type: CoglPrimitive
A newly allocated CoglPrimitive
with a reference of 1. This can be freed using g_object_unref().
The caller of the function takes ownership of the data, and is responsible for freeing it. |