import sys
sys.path.append( '../server' )
from mothership import *

if len(sys.argv) > 3 or len(sys.argv) < 2:
	print 'Usage: %s <demo> [spu]' % sys.argv[0] 
	sys.exit(-1)

CR_BIN_DIR = r'c:\cr\work\bin\WIN_NT'
demo = sys.argv[1]

if len(sys.argv) == 3:
	clientspuname = sys.argv[2]
else:
	clientspuname = 'pack'

server_spu = SPU( 'render' )
client_spu = SPU( clientspuname )
invert_spu = SPU( 'invert' )

server_spu.Conf( 'window_geometry', 100, 100, 500, 500 )

server_node = CRNetworkNode( )
server_node.AddSPU( server_spu )

if (clientspuname == 'tilesort' ):
	server_node.AddTile( 0, 0, 500, 500 )

client_node = CRApplicationNode( )
client_node.AddSPU( invert_spu )
client_node.AddSPU( client_spu )
client_spu.AddServer( server_node, 'tcpip' )

client_node.SetApplication( '%s\%s' % (CR_BIN_DIR, demo) )
client_node.StartDir( CR_BIN_DIR )

cr = CR()
cr.MTU( 1024*1024 );
cr.AddNode( client_node )
cr.AddNode( server_node )
cr.Go()
