It's pretty easy, check out this Dark basic code, which can be converted to darkgdk.
Rem Project: CSGEffects
Rem Created: 12/05/2003 22:50:59
rem Init app
sync on : sync rate 60
rem User prompt
center text 320,220,"PERFORMING CSG" : sync : sync
rem Make some shapes
`mike see these..
`make object sphere 1,120 `this produces very odd result
`load object "female.x",1 `this crashes CSG
stairs=1 : load object "stairs.x",stairs
cube=2 : make object cube cube,100
column=3 : make object box column,25,150,25
rem Make meshes from objects
make mesh from object 1,stairs
make mesh from object 2,cube
make mesh from object 3,column
rem Perform CSG operations on meshes
lock vertexdata for mesh 1 : perform csg difference on vertexdata 3 : unlock vertexdata
lock vertexdata for mesh 2 : perform csg difference on vertexdata 3 : unlock vertexdata
`
`mike notice how mesh 2(which has just been csg'd is used again and it crashes..
`lock vertexdata for mesh 3 : perform csg difference on vertexdata 2 : unlock vertexdata
lock vertexdata for mesh 3 : perform csg union on vertexdata 2 : unlock vertexdata
rem Perform CSG operations
perform csg union stairs,column
perform csg union cube,column
perform csg difference column,cube
rem Set to wireframe to see results
set object wireframe stairs,1
set object wireframe cube,1
set object wireframe column,1
rem Position objects to view seperated
position object stairs,-150,0,0
position object cube, 0,0,0
position object column, 150,0,0
rem Add orbital limb meshes to objects from 'vertexdata csg operations'
add limb stairs,2,1 : offset limb stairs,2,0,200,0
add limb cube,1,2 : offset limb cube,1,0,200,0
add limb column,1,3 : offset limb column,1,0,200,0
rem Setup camera
position camera 0,100,-400
point camera 0,0,0
rem Main loop
do
rem Camera control
control camera using arrowkeys 0,2,3
rem User prompt
center text 320,20,"CSG EFFECTS DEMONSTRATION"
center text 320,120,"MESHES: STAIRS-COLUMN DIFFERENCE CUBE-COLUMN DIFFERENCE COLUMN-CUBE UNION"
center text 320,440,"OBJECTS: STAIRS-COLUMN UNION CUBE-COLUMN UNION COLUMN-CUBE DIFFERENCE"
rem Update screen
sync
rem End loop
loop