Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker

Going to 3D mode

If you want to use 3D mode you first need to set GameMaker in 3D mode. You can later switch back to 2D mode if you want. The following two functions exist for this.

d3d_start() Start using 3D mode. Returns whether successful.
d3d_end() Stop using 3D mode. Returns whether successful.

Note that all functions related to 3D mode start with d3d_.

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 inaccuracys 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; see below). 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.

You can actually switch hidden surface remove and perspective projection on or off using the following functions.

d3d_set_hidden(enable) Enables (true) or disables (false) depth testing.
d3d_set_perspective(enable) Enables the use of a perspective projection (true) or disables it (false).

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual