GLBasic User Manual

Main sections

X_MAKE3D

X_MAKE3D znear#, zfar#, field_of_view#



Switches into 3D mode.
While in 3D mode, only objects or parts of objects that are between znear# and zfar# relative distance to the camera will be drawn.
A smaller difference between znear# and zfar# will give a better sense of depth when drawing polygons. The reason for this is that the Z buffer is a 32-bit integer that is scaled to represent the values from znear to zfar. The less this needs to be scaled, the more
accuracy you get.
The field_of_view angle lets you specify the camera's zoom objective.

A negative field_of_view# let's you create an orthogonal view (3D objects will not get smaller as they are further from the camera). In this instance the value represents a scaling factor for all 3D objects.

Be aware that you can use any 2D command while in 3D mode, but you will get very strange results from most of them. It is advisable to switch back to 2D mode before using any 2D commands. You can switch back and forth as many times as you like before calling SHOWSCREEN.

Sample:
X_LOADOBJ "pyramid.ddd", 5
WHILE TRUE
MOUSESTATE mx, my, b1 ,b2
phi=mx*360 / 640

X_MAKE3D 1,1000,45 // Viewport 3D

X_CAMERA 0, 150, -300, 0 ,0 ,0
X_AMBIENT_LT 0, RGB(255,255,0)

X_MOVEMENT mx-230, 0, 0
X_SCALING 3, 3, 3
X_ROTATION phi*3, 0, 1, 0
X_DRAWOBJ 5, 0

SHOWSCREEN
WEND

See also...