Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
LISTING-31.12<br />
A <strong>Pro</strong>blem with Cones<br />
and Cylinders<br />
FIG-31.52<br />
Hidden Surfaces on<br />
Cones and Cylinders<br />
Storage Methods<br />
REM *** Set screen mode ***<br />
SET DISPLAY MODE 1280,1024,32<br />
REM *** Make and position cone and cylinder ***<br />
MAKE OBJECT CONE 1, 5<br />
POSITION OBJECT 1,-6,-5,0<br />
XROTATE OBJECT 1, 45<br />
MAKE OBJECT CYLINDER 2,5<br />
POSITION OBJECT 2, 6,-5,0<br />
REM *** End program ***<br />
WAIT KEY<br />
END<br />
Activity 31.26<br />
Type in and test the program in LISTING-31.12 (object3D15.dbpro).<br />
What problem occurs with both shapes?<br />
The inside surfaces of both shapes have not been drawn (see FIG-31.52).<br />
But we can solve this problem by switching off culling, so that the hidden polygons<br />
are drawn.<br />
Activity 31.27<br />
The inside surfaces<br />
of both shapes are not<br />
drawn<br />
Modify your previous program so that culling is switched off for both the cone<br />
and the cylinder.<br />
When a 3D object is shown on screen, the coordinates of its vertices are stored in<br />
memory in an area known as a vertex buffer. Normally, each object will have its<br />
own vertex buffer. However, some video cards allow different objects to share<br />
vertex buffers, other video cards don't. As a default, 3D objects in DARKBASIC<br />
<strong>Pro</strong> do not share vertex buffers - this ensures compatibility with the maximum<br />
number of video cards. However, it is possible to force vertex buffer sharing and,<br />
if your video card can handle this, improve the performance of your program.<br />
The SET GLOBAL OBJECT CREATION Statement<br />
To force vertex buffer sharing, we use the SET GLOBAL OBJECT CREATION<br />
statement which has the format shown in FIG-31.53.<br />
<strong>DarkBASIC</strong> <strong>Pro</strong>: 3D Primitives 785