Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/config.php on line 36 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/config.php on line 37 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/lang.php on line 55 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/lang.php on line 55 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/lang.php on line 110 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/lang.php on line 110 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 201 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 201 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 216 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 216 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 231 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 232 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 232 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 233 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web218/a3/28/510129628/htdocs/border_html5.php on line 233 GLBasic User Manual

GLBasic User Manual

Main sections

X_CULLMODE

X_CULLMODE cmode#



With this command you can specify whether you wish back, front or both sides of a 3D object to be drawn.
cmode#=0 - both sides are drawn
cmode#=1 - only front side is drawn
cmode#=-1 - only back side is drawn

It is a good idea to only draw certain sides where possible to put less load on the graphics processor. With every X_MAKE3D call the cull mode is reset to 0.

The "back" is defined as the side of an object that its normal vector is not pointing to. The normal for every triangle in a 3d object is calculated automatically by the graphics engine. When you create a triangle, by drawing its points in an anti-clockwise direction you are telling the graphics engine to point the normal towards the camera rather than away from it.

Sample:
 
// Simple 3D
X_OBJSTART 1
X_OBJADDVERTEX 0, 0, 0, 0,0, RGB(255,255,255)
X_OBJADDVERTEX -20, 40, 0, 0,0, RGB(255, 0, 0)
X_OBJADDVERTEX 20, 40, 0, 0,0, RGB( 0, 0,255)
X_OBJEND

WHILE TRUE
phi=phi+1
IF phi>=360 THEN phi=0

X_MAKE3D 1, 1500
X_CAMERA 0,0,400, 0,0,0

FOR cmode=-1 TO 1
X_CULLMODE cmode
X_MOVEMENT cmode * 50, 0, 0
X_ROTATION phi, 0, 1, 0
X_DRAWOBJ 1, 0
NEXT
SHOWSCREEN
WEND

See also...