Cogl.Primitive.new_p2c4

function new_p2c4(context: Cogl.Context, mode: Cogl.VerticesMode, data: Array(Cogl.VertexP2C4)): Cogl.Primitive {
    // Gjs wrapper for cogl_primitive_new_p2c4()
}
  

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 <structfield>n_vertices</structfield> property as if Cogl.Primitive.prototype.set_n_vertices were called. This property defines the number of vertices to read when drawing.

<note>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)</note>

Since 1.6

context

A Cogl.Context

mode

A Cogl.VerticesMode defining how to draw the vertices

data

(type Cogl.VertexP2C4): An array of Cogl.VertexP2C4 vertices

Returns

A newly allocated Cogl.Primitive with a reference of 1. This can be freed using Cogl.Object.unref.