draw_primitive_begin

Starts a primitive of the indicated kind

Syntax:

GML Code Example

draw_primitive_begin(kind)


Argument Description
kind The kind of primitive you are going to draw.


Returns: N/A


Description

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

  • pr_pointlist
  • pr_linelist
  • pr_linestrip
  • pr_trianglelist
  • pr_trianglestrip
  • pr_trianglefan (This is not available on the HTML5 target platform and may not work correctly on some devices for other platforms)

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


Example:

GML Code Example

var i, steps, xx, yy, radius;
 steps=20;
 xx=50;
 yy=50;
 radius=30;
 draw_primitive_begin(pr_trianglefan);
 draw_vertex(xx, yy);
 for(i = 0; i <= steps; i += 1)
    {
    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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here