d3d_set_culling

Sets whether back face culling should be enabled or disabled.

Syntax:

d3d_set_culling(enable)


Argument Description
enable Switches on (true) or off (false) back-face culling


Returns: N/A


Description

A 3D triangle has a front and a back side. The front side is said to be the side where the vertices are defined in counter-clockwise order. Now, normally both sides are drawn, but if you make a closed shape then this is a waste of processing power because the back side of the triangle can never be seen. It's in these cases that you can switch on backface culling. This saves about half the amount of drawing time but it means you have the task of defining your polygons in the correct way to prevent issues.


Example:

d3d_set_culling(true);
d3d_primitive_begin(pr_trianglelist);
d3d_vertex(100, 100, 0);
d3d_vertex(100, 200, 0);
d3d_vertex(150, 150, 200);
d3d_vertex(100, 200, 0);
d3d_vertex(200, 200, 0);
d3d_vertex(150, 150, 200);
d3d_vertex(200, 200, 0);
d3d_vertex(100, 100, 0);
d3d_vertex(150, 150, 200);
d3d_vertex(100, 100, 0);
d3d_vertex(100, 200, 0);
d3d_vertex(200, 200, 0);
d3d_primitive_end();

The above code will draw a pyramid with the back faces (interior faces) being culled (not drawn).


Back: 3D Setup
Next: d3d_set_zwriteenable
© Copyright YoYo Games Ltd. 2018 All Rights Reserved