This function must be called before you can define any primitives. There are 6 types of primitives you can define as the following constants:
Constant | Description |
---|---|
pr_pointlist | A point list - A point is drawn for every vertex. |
pr_linelist | A line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc. |
pr_linestrip | A 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_trianglelist | A triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc. |
pr_trianglestrip | A triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc. |
pr_trianglefan | A 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:
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.
draw_primitive_begin(kind);
Argument | Type | Description |
---|---|---|
kind | Primitive Type Constant | The kind of primitive you are going to draw. |
N/A
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.