draw_primitive_begin

This function must be called before you can define any primitives. There are 6 types of primitives you can define as the following constants:

Primitive Type Constant
ConstantDescription
pr_pointlistA point list - A point is drawn for every vertex.
pr_linelistA line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc.
pr_linestripA line strip - A line is drawn between the first and the second vertex, between the second and the third vertex, the third and the fourth vertex, etc.
pr_trianglelistA triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc.
pr_trianglestripA triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc.
pr_trianglefanA triangle fan - Every two vertices connect to the first vertex to make a triangle.

WARNING This primitive type is not natively supported on some platforms and there could be a performance hit if you use it.

The following image illustrates basically how these should look and also the order in which you should define the vertices:

The different primitive types

NOTE On some platforms (Windows, Xbox) the pr_trianglefan type is not natively supported and so GameMaker does a conversion when the game is compiled to make them work. This means that on those platforms the pr_trianglefan type will be much slower to use than the others.

WARNING These functions do not work with the HTML5 module unless you have enabled WebGL in the Game Options.

 

Syntax:

draw_primitive_begin(kind);

ArgumentTypeDescription
kindPrimitive Type ConstantThe kind of primitive you are going to draw.

 

Returns:

N/A

 

Example:

var _steps = 20;
var _xx = 50;
var _yy = 50;
var _radius = 30;
draw_primitive_begin(pr_trianglefan);
draw_vertex(_xx, _yy);
for(var i = 0; i <= _steps; ++i;)
{
    draw_vertex(_xx + lengthdir_x(_radius, 270 * i / _steps), _yy + lengthdir_y(_radius, 270 * i / _steps));
}
draw_primitive_end();

The above code will draw three quarters of a circle made from primitives.