swthread::~swthread()
{
   std::cerr << __PRETTY_FUNCTION__ << std::endl << '{' << std::endl << NameID() << std::endl;
   //run_.disconnect_all_slots();
   //end_.disconnect_all_slots();
   //notify_.disconnect_all_slots();
   pthread_cancel(_pthID);
   //std::cerr<< "thread exited ?" << std::endl;
   //std::cerr << std::endl << '}' << std::endl;
}
Exemple #2
0
	gc::Local<const NameInfo> do_register_name(const StringLoc& name) {
		std::size_t name_id = m_id_to_info->size();
		gc::Local<const NameInfo> info = gc::create<NameInfo>(NameID(name_id), name);

		m_owned_names->add(name);
		m_owned_keys.push_back(GCPtrStringKey(name.get()));
		m_name_to_id[StringKeyValue(m_owned_keys.back())] = name_id;
		m_id_to_info->add(info);

		return info;
	}
/*!
    \fn swUiControl::SetGeometry( const Rect& r )
 */
int swUiControl::SetGeometry( const Rect& r )
{
    //swUiControl* _parent = ParentT<swUiControl>();
    swUiControl* _parent = ParentOfClass(this);
    m_geometry = r;
    pxy offset = _parent ? _parent->TopLeft(true)  : pxy(0,0);
    m_topleft = m_geometry.topleft() + offset;


    if(m_IoScrBuffer) delete [] m_IoScrBuffer;
    m_IoScrBuffer = new TCell[ Height() * Width() + Width() ];
    if( _wr ) delete _wr;
    _wr = new swWriter( this, m_IoScrBuffer, r );

    Debug << " Geometry of " << NameID() << " Set to " << m_geometry.tostring() ;DEND;
    return 0;
}
void RenderTechnique::onUnload()
{
	Global::use().scenes->detach( NameID( getAssetName() ) );
}
Asset* RenderTechnique::onLoad( AssetManager* manager, XeCore::XeString& name, Params& params, bool keepAlways )
{
	RenderTechnique* t = xnew RenderTechnique();
	for( ParamsElm p = params.FirstPointer(); !p.IsEmpty(); p.Next() )
	{
		if( p().Value.getType() == ParamData::tParams && p().Value.getGroupType() == "pass" )
		{
			Params& pass = p().Value.getParams();
			unsigned int tc( 0 );
			Effect* eff( 0 );
			int w( 0 ), h( 0 );
			bool fh( false ), fv( false ), rtc( true ), dome( false );
			if( pass.Exists( "textures" ) )
				pass[ "textures" ].getValue().Convert( &tc, 'd' );
			if( pass.Exists( "effectAsset" ) )
				eff = manager->get< Effect >( pass[ "effectAsset" ].getValue(), keepAlways );
			if( pass.Exists( "width" ) )
				pass[ "width" ].getValue().Convert( &w, 'i' );
			if( pass.Exists( "height" ) )
				pass[ "height" ].getValue().Convert( &h, 'i' );
			if( pass.Exists( "flipVertical" ) )
				fv = pass[ "flipVertical" ].getValue() == "true";
			if( pass.Exists( "flipHorizontal" ) )
				fh = pass[ "flipHorizontal" ].getValue() == "true";
			if( pass.Exists( "renderToCanvas" ) )
				rtc = pass[ "renderToCanvas" ].getValue() == "true";
			if( pass.Exists( "isDome" ) )
				dome = pass[ "isDome" ].getValue() == "true";
			RenderTechnique::PassElm elm = dome ? t->addPassDome( p().Key, tc, eff, w, h, rtc ) : t->addPass( p().Key, tc, eff, w, h, fh, fv, rtc );
			if( t->getPassCanvas( elm ) )
			{
				if( pass.Exists( "canvasColorFilteringLevel" ) )
				{
					int flevel( 0 );
					pass[ "canvasColorFilteringLevel" ].getValue().Convert( &flevel, 'i' );
					t->getPassCanvas( elm )->filtering( flevel );
				}
				if( pass.Exists( "canvasColorRepeating" ) )
					t->getPassCanvas( elm )->repeating( pass[ "canvasColorRepeating" ].getValue() == "true" );
				if( pass.Exists( "canvasDepthFilteringLevel" ) )
				{
					int flevel( 0 );
					pass[ "canvasDepthFilteringLevel" ].getValue().Convert( &flevel, 'i' );
					t->getPassCanvas( elm )->filteringDepth( flevel );
				}
				if( pass.Exists( "canvasDepthRepeating" ) )
					t->getPassCanvas( elm )->repeatingDepth( pass[ "canvasDepthRepeating" ].getValue() == "true" );
			}
			if( !elm.IsEmpty() && pass.Exists( "textureBinds" ) && pass[ "textureBinds" ].getType() == ParamData::tParams )
			{
				Params& tb = pass[ "textureBinds" ].getParams();
				for( ParamsElm _p = tb.FirstPointer(); !_p.IsEmpty(); _p.Next() )
				{
					if( _p().Value.getType() == ParamData::tValue )
					{
						unsigned int sc( 0 );
						XeCore::XeString* sv = _p().Key.Explode( " ", sc );
						if( sv && sc )
						{
							if( sc == 4 && sv[ 0 ] == "unit" && sv[ 2 ] == "from" )
							{
								int unit( 0 );
								sv[ 1 ].Convert( &unit, 'i' );
								if( sv[ 3 ] == "canvasAssetColorTexture" )
									t->bindPassInputTexture( elm, manager->get< Canvas >( _p().Value.getValue(), keepAlways )->getTexture(), unit );
								else
								if( sv[ 3 ] == "canvasAssetDepthTexture" )
									t->bindPassInputTexture( elm, manager->get< Canvas >( _p().Value.getValue(), keepAlways )->getTextureDepth(), unit );
								else
								if( sv[ 3 ] == "passCanvasColorTexture" )
									t->bindPassInputTexture( elm, t->getPassCanvas( t->getPass( NameID( _p().Value.getValue() ) ) )->getTexture(), unit );
								else
								if( sv[ 3 ] == "passCanvasDepthTexture" )
									t->bindPassInputTexture( elm, t->getPassCanvas( t->getPass( NameID( _p().Value.getValue() ) ) )->getTextureDepth(), unit );
								else
								if( sv[ 3 ] == "textureAsset" )
									t->bindPassInputTexture( elm, manager->get< Texture >( _p().Value.getValue(), keepAlways ), unit );
							}
							delete[] sv;
						}
					}
				}
			}
			if( pass.Exists( "properties" ) && pass[ "properties" ].getType() == ParamData::tParams )
			{
				Material* m = t->getPassMaterial( elm );
				for( ParamsElm _p = pass[ "properties" ].getParams().FirstPointer(); !_p.IsEmpty(); _p.Next() )
				{
					if( _p().Value.getType() != ParamData::tParams )
						continue;
					if( _p().Value.getGroupType() == "float" )
					{
						XeCore::XeHalfVector v;
						_p().Value.getParams()[ "x" ].getValue().Convert( &v.X, 'h' );
						m->getProperties()->setPropertyVec( _p().Key, v, 1 );
					}
					else
					if( _p().Value.getGroupType() == "vec2" )
					{
						XeCore::XeHalfVector v;
						_p().Value.getParams()[ "x" ].getValue().Convert( &v.X, 'h' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v.Y, 'h' );
						m->getProperties()->setPropertyVec( _p().Key, v, 2 );
					}
					else
					if( _p().Value.getGroupType() == "vec3" )
					{
						XeCore::XeHalfVector v;
						_p().Value.getParams()[ "x" ].getValue().Convert( &v.X, 'h' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v.Y, 'h' );
						_p().Value.getParams()[ "z" ].getValue().Convert( &v.Z, 'h' );
						m->getProperties()->setPropertyVec( _p().Key, v, 3 );
					}
					else
					if( _p().Value.getGroupType() == "vec4" )
					{
						XeCore::XeHalfVector v;
						_p().Value.getParams()[ "x" ].getValue().Convert( &v.X, 'h' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v.Y, 'h' );
						_p().Value.getParams()[ "z" ].getValue().Convert( &v.Z, 'h' );
						_p().Value.getParams()[ "w" ].getValue().Convert( &v.W, 'h' );
						m->getProperties()->setPropertyVec( _p().Key, v, 4 );
					}
					else
					if( _p().Value.getGroupType() == "int" )
					{
						XeCore::XeInteger v[ 4 ];
						_p().Value.getParams()[ "x" ].getValue().Convert( &v[ 0 ], 'i' );
						m->getProperties()->setPropertyInt( _p().Key, v, 1 );
					}
					else
					if( _p().Value.getGroupType() == "int2" )
					{
						XeCore::XeInteger v[ 4 ];
						_p().Value.getParams()[ "x" ].getValue().Convert( &v[ 0 ], 'i' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v[ 1 ], 'i' );
						m->getProperties()->setPropertyInt( _p().Key, v, 2 );
					}
					else
					if( _p().Value.getGroupType() == "int3" )
					{
						XeCore::XeInteger v[ 4 ];
						_p().Value.getParams()[ "x" ].getValue().Convert( &v[ 0 ], 'i' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v[ 1 ], 'i' );
						_p().Value.getParams()[ "z" ].getValue().Convert( &v[ 2 ], 'i' );
						m->getProperties()->setPropertyInt( _p().Key, v, 3 );
					}
					else
					if( _p().Value.getGroupType() == "int4" )
					{
						XeCore::XeInteger v[ 4 ];
						_p().Value.getParams()[ "x" ].getValue().Convert( &v[ 0 ], 'i' );
						_p().Value.getParams()[ "y" ].getValue().Convert( &v[ 1 ], 'i' );
						_p().Value.getParams()[ "z" ].getValue().Convert( &v[ 2 ], 'i' );
						_p().Value.getParams()[ "w" ].getValue().Convert( &v[ 3 ], 'i' );
						m->getProperties()->setPropertyInt( _p().Key, v, 4 );
					}
					else
					if( _p().Value.getGroupType() == "sampler2D" )
					{
						XeCore::XeInteger v;
						_p().Value.getParams()[ "unit" ].getValue().Convert( &v, 'i' );
						m->getProperties()->setPropertySampler( _p().Key, v );
					}
					else
					if( _p().Value.getGroupType() == "sampler3D" )
					{
						XeCore::XeInteger v;
						_p().Value.getParams()[ "unit" ].getValue().Convert( &v, 'i' );
						m->getProperties()->setPropertySampler( _p().Key, v );
					}
					else
					if( _p().Value.getGroupType() == "mat4" )
					{
						XeCore::XeHalfMatrix v;
						_p().Value.getParams()[ "0" ].getValue().Convert( &v.Cell[ 0 ], 'h' );
						_p().Value.getParams()[ "1" ].getValue().Convert( &v.Cell[ 1 ], 'h' );
						_p().Value.getParams()[ "2" ].getValue().Convert( &v.Cell[ 2 ], 'h' );
						_p().Value.getParams()[ "3" ].getValue().Convert( &v.Cell[ 3 ], 'h' );
						_p().Value.getParams()[ "4" ].getValue().Convert( &v.Cell[ 4 ], 'h' );
						_p().Value.getParams()[ "5" ].getValue().Convert( &v.Cell[ 5 ], 'h' );
						_p().Value.getParams()[ "6" ].getValue().Convert( &v.Cell[ 6 ], 'h' );
						_p().Value.getParams()[ "7" ].getValue().Convert( &v.Cell[ 7 ], 'h' );
						_p().Value.getParams()[ "8" ].getValue().Convert( &v.Cell[ 8 ], 'h' );
						_p().Value.getParams()[ "9" ].getValue().Convert( &v.Cell[ 9 ], 'h' );
						_p().Value.getParams()[ "10" ].getValue().Convert( &v.Cell[ 10 ], 'h' );
						_p().Value.getParams()[ "11" ].getValue().Convert( &v.Cell[ 11 ], 'h' );
						_p().Value.getParams()[ "12" ].getValue().Convert( &v.Cell[ 12 ], 'h' );
						_p().Value.getParams()[ "13" ].getValue().Convert( &v.Cell[ 13 ], 'h' );
						_p().Value.getParams()[ "14" ].getValue().Convert( &v.Cell[ 14 ], 'h' );
						_p().Value.getParams()[ "15" ].getValue().Convert( &v.Cell[ 15 ], 'h' );
						m->getProperties()->setPropertyMat( _p().Key, v, _p().Value.getParams()[ "transpose" ].getValue() == "true" ? true : false );
					}
					else
					if( _p().Value.getGroupType() == "float[]" )
					{
						if( _p().Value.getParams().Size() )
						{
							unsigned int i = 0;
							XeCore::XeArray< XeCore::XeHalf > temp( _p().Value.getParams().Size() );
							for( ParamsElm a = _p().Value.getParams().FirstPointer(); !a.IsEmpty(); a.Next(), i++ )
								a().Value.getValue().Convert( &temp[ i ], 'h' );
							m->getProperties()->setPropertyArrayHalf( _p().Key, temp.Get(), temp.Size(), 1 );
						}
					}
					else
					if( _p().Value.getGroupType() == "int[]" )
					{
						if( _p().Value.getParams().Size() )
						{
							unsigned int i = 0;
							XeCore::XeArray< XeCore::XeInteger > temp( _p().Value.getParams().Size() );
							for( ParamsElm a = _p().Value.getParams().FirstPointer(); !a.IsEmpty(); a.Next(), i++ )
								a().Value.getValue().Convert( &temp[ i ], 'i' );
							m->getProperties()->setPropertyArrayInt( _p().Key, temp.Get(), temp.Size(), 1 );
						}
					}
				}
			}
		}
	}
	if( Global::use().scenes->attach( NameID( name ), t ) )
	{
		ASSET_SET_PURE_POINTER( t );
		return( t );
	}
	else
	{
		DELETE_OBJECT( t );
		return( 0 );
	}
}