コード例 #1
0
ファイル: slo.cpp プロジェクト: maya2renderer/maya2renderer
/**
 * Insert a new entry to the SLX -> SLO lookup table.
 * 
 * The SLO struct is created internally from the input SLX struct and
 * will be added at the end of the table.
 * 
 * \pre  key must not already be present in the lookup table
 * \pre  key must not be NULL
 * \param key A SLX_VISSYMDEF structure
 * \return Returns the newly created SLO struct or NULL on error (sets the global error flag).
 */
static SLO_VISSYMDEF * InsertSLOSymDef(SLX_VISSYMDEF * key)
{
	SLO_VISSYMDEF * value;

	SlxLastError = RIE_NOERROR;
	
	value = ( SLO_VISSYMDEF * ) malloc( sizeof( SLO_VISSYMDEF ) );
	if ( value == NULL )
	{
		SlxLastError = RIE_NOMEM;
	}
	
	// Initialise the SLO struct from the SLX struct and add it to the lookup table
	// (all pointers are still owned by the SLX struct!)
	if ( SlxLastError == RIE_NOERROR )
	{
		value->svd_name = key->svd_name;
		value->svd_type = SLO_TYPE(key->svd_type);
		value->svd_storage = SLO_STORAGE(key->svd_storage);
		value->svd_detail = SLO_DETAIL(key->svd_detail);
		value->svd_spacename = key->svd_spacename;
		value->svd_arraylen = key->svd_arraylen;
		value->svd_default.scalarval = value->svd_default.scalarval;
		if ( value->svd_type == SLO_TYPE_STRING )
		{
			// Dereference the stringval
			value->svd_default.stringval = *(key->svd_default.stringval);
		}

		// Do we need to extend the table?
		if ( sloShadersArgsNumItems == sloShadersArgsMaxNumItems )
		{
			if ( ExtendSLOLut() == -1 )
			{
				// The error indicator is already set, so just release the SLO struct
				free( value );
				value = NULL;
			}
		}
		
		// Store the key/value pair...
		if ( SlxLastError == RIE_NOERROR )
		{
			sloShadersArgsKeys[sloShadersArgsNumItems] = key;
			sloShadersArgsValues[sloShadersArgsNumItems] = value;
			sloShadersArgsNumItems++;
		}
	}
	
	return value;
}
コード例 #2
0
ファイル: slo.cpp プロジェクト: UIKit0/aqsis
/** Convert a SLX_VISSYMDEF to a SLO_VISSYMDEF struct */
void convertVISSYMDEFStruct ( SLX_VISSYMDEF* slxdef, SLO_VISSYMDEF* slodef )
{
	
	slodef->svd_name = slxdef->svd_name;
	slodef->svd_type = SLO_TYPE(slxdef->svd_type);
	slodef->svd_storage = SLO_STORAGE(slxdef->svd_storage);
	slodef->svd_detail = SLO_DETAIL(slxdef->svd_detail);
	slodef->svd_spacename = slxdef->svd_spacename;
	slodef->svd_valisvalid = 1;
	slodef->svd_arraylen = slxdef->svd_arraylen;
	
	// if array
	if (!(slxdef->svd_arraylen > 0 || slxdef->svd_default.scalarval == 0x0))
	{
		switch(slodef->svd_type)
		{
			case SLO_TYPE_POINT:
			case SLO_TYPE_COLOR:
			case SLO_TYPE_VECTOR:
			case SLO_TYPE_NORMAL:
				slodef->svd_default.pointval = (SLO_POINT*)slxdef->svd_default.pointval;
				break;
			case SLO_TYPE_SCALAR:
				slodef->svd_default.scalarval = slxdef->svd_default.scalarval;
				break;
			case SLO_TYPE_STRING:
				slodef->svd_default.stringval = *slxdef->svd_default.stringval;
				break;
			case SLO_TYPE_MATRIX:
				slodef->svd_default.matrixval = (SLO_MATRIX)slxdef->svd_default.matrixval;
				break;
		}
	} else {
		// SLX doesn't support array types
	}
	return;
}