d3d_start()
Returns: Real
With this function you can tell GameMaker: Studio that
all further drawing should be done in 3D mode. This function can be
called in any event, but will affect all drawing done after,
so if your game is not completely done in 3D you may need to switch
it off using d3d_end to draw
certain parts (and then use this function again to switch 3D mode
back on).
Starting 3D mode will result in the following changes:
- First of all depth testing (also known as Z Buffering) is switched on (using a 24-bit z-buffer). This means that for each pixel on the screen only the drawing with the smallest z-value (= depth value) is drawn. If instances have the same depth then you will get what is known as Z-fighting. This occurs as the 2 instances attempt to draw at the same level, and inaccuracies in the rendering due to very close Z value cause ugly effects. To avoid this, try and make sure instances that might overlap do not have the same depth value!
- Secondly, the normal orthographic projection is replaced by a perspective one. This means the following. Normally the size of instances on the screen is independent on its depth. With a perspective projection instances that have a greater depth will appear smaller. When the depth is 0 it is equal to the old size (unless you change the projection). The viewpoint for the camera is placed at a distance above the room. (This distance is equal to the width of the room; that gives a reasonable default projection.) Only instances in front of the camera are drawn. So don't use instances with a depth smaller than 0 (or at least not smaller than -w where w is the width of the room or the view).
- Thirdly, the vertical y-coordinate is reversed. While normally the (0,0) position is at the top-left of the view, in 3D mode the (0,0) position is at the bottom-left position, as is normal for 3-dimensional views.
d3d_start();
This code has been placed in the create event of an instance to tell GameMaker: Studio that all further drawing should be done in 3D mode.