Esempio n. 1
0
/**
 * @brief Load an image by file name.
 * @param aName Name of the file.
 */
void PCShaderSurface::LoadImage(HashString const &aName)
{
    /* If the file was already loaded,
       let's avoid assigning a new id. */
    TextureData const& textureData = GetManager()->GetTextureData(aName);
    if(textureData.mTextureID != (unsigned)-1)
    {
        mTextureID = textureData.mTextureID;
        SetTextureSize(Vector3(textureData.mWidth, textureData.mHeight, 0));
    }
    // else we load the image from file
    else if((mSurface = IMG_Load(Common::RelativePath("Art", aName).c_str())))
    {
        if ((mSurface->w & (mSurface->w - 1)) != 0 )
        {
            DebugLogPrint("warning: width of image: %s is not a power of 2\n", aName.ToCharArray());
        }

        if ((mSurface->h & (mSurface->h - 1)) != 0 )
        {
            DebugLogPrint("warning: height of image: %s is not a power of 2\n", aName.ToCharArray());
        }

        SetTextureSize(Vector3(mSurface->w, mSurface->h, 0));
        mNumberOfColors = mSurface->format->BytesPerPixel;
        if (mNumberOfColors == 4)
        {
            if (mSurface->format->Rmask == 0x000000ff)
                mTextureFormat = GL_RGBA;
            else
#ifndef _WIN32
                mTextureFormat = GL_BGRA;
#else
                mTextureFormat = GL_RGBA;
#endif
        }
        else if (mNumberOfColors == 3)
        {
            if (mSurface->format->Rmask == 0x000000ff)
                mTextureFormat = GL_RGB;
            else
#ifndef _WIN32
                mTextureFormat = GL_BGR;
#else
                mTextureFormat = GL_RGB;
#endif
        }
        else
        {
            DebugLogPrint("warning: image %s is not truecolor...  this will probably break\n", aName.ToCharArray());
            DebugLogPrint("warning: bytes per pixel for image %s: %d\n", aName.ToCharArray(), mNumberOfColors);
        }

        AddTexturePairing(aName);
    }
    else
    {
        DebugLogPrint("warning: file: %s not found or incompatible format, check this out\n", aName.ToCharArray());
    }
}
Esempio n. 2
0
// SetTo
status_t
ExtendedServerInfo::SetTo(ServerInfo* serverInfo)
{
	if (!serverInfo)
		return B_BAD_VALUE;
	// set name and connection method
	const char* name = serverInfo->GetServerName();
	HashString addressString;
	if (!name || strlen(name) == 0) {
		status_t error = fAddress.GetString(&addressString, false);
		if (error != B_OK)
			return error;
		name = addressString.GetString();
	}
	if (!fServerName.SetTo(name)
		|| !fConnectionMethod.SetTo(serverInfo->GetConnectionMethod())) {
		return B_NO_MEMORY;
	}
	// add the shares
	int32 shareCount = serverInfo->CountShares();
	for (int32 i = 0; i < shareCount; i++) {
		const ShareInfo& shareInfo = serverInfo->ShareInfoAt(i);
		status_t error = _AddShare(&shareInfo);
		if (error != B_OK)
			return error;
	}
	return B_OK;
}
Esempio n. 3
0
// GetNodePermissions
Permissions
SecurityContext::GetNodePermissions(const node_ref& ref, User* user)
{
	if (!user)
		return Permissions();

	ContextLocker _(this);
	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return Permissions();

	return fPermissions->Get(UserPath(path.GetString(), user));
}
	virtual void Execute(const DataObject &object)
	{
		// The current player is now in a blocking action.
        RULE.Execute(shRuleBeginBlockingAction, DataObject(current()));

		wxASSERT(1 <= object.numItems());

		//retrieve the text to put in the MessageUI
		DataObject input(0), output;
		
		const HashString& state = gameData<HashString>(shState);
		if(false == DecideHash(state, input, output))
		{
			wxLogError(
				wxString::Format(wxT("Programmer Error: No State %s in ")
				wxT("RuleRequestInitialRoadSeafarers"), state.cwx_str()));

			return;
		}

		wxASSERT(3 == output.numItems());

		wxString text1 = output.read<wxString>();
		wxString text2 = output.read<wxString>(1);
		HashString logic = HashString::Format(shLogicStringFormat.c_str(),
			output.read<HashString>(2).c_str());
		HashString rule = HashString::Format(shRuleStringFormat.c_str(),
			output.read<HashString>(2).c_str());

		//if this involves ships, do some crazy mojo
		if(TRUE == gameData<wxInt32>(shInitialShip))
		{
			text1 = stPlaceAShip;
			text2 = stWaitingPlaceAShip;

			wxInt32 index = logic.find(shRoad);
			wxASSERT(-1 != index);

			logic.replace(index, 4, shShip);
            logic = HashString(logic.c_str());
		}

		RULE.Execute(shRuleUpdateMessageUI, 
			DataObject(text1, text2));		
		
		RULE.Execute(shRuleLocateInitialRoad, DataObject(
			object.read<wxInt32>(), logic, rule));
	}
Esempio n. 5
0
static int l_setArgHashString( lua_State * lua )
{
	// Grab userdata from stack
	rho::Event * p_event = static_cast< rho::Event * >( checklightuserdata( lua, 1 ) );
    HashString arg_name = chechHashString( lua, 2 );

	HashString val = chechHashString( lua, 3 );

	// Perform set arg on event
	p_event->setArgHashedStringID( arg_name, val.getHashValue() );

	// Pop the args we were given
	lua::pop_all(lua);

	return 0;
}
Esempio n. 6
0
// ClearNodePermissions
void
SecurityContext::ClearNodePermissions(const node_ref& ref, User* user)
{
	ContextLocker _(this);
	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return;

	if (user) {
		fPermissions->Remove(UserPath(path.GetString(), user));
	} else {
		for (UserMap::Iterator it = fUsers->GetIterator(); it.HasNext();)
			fPermissions->Remove(UserPath(path.GetString(), it.Next().value));
	}
}
Esempio n. 7
0
/**
 * @brief Loads a text surface in font.
 * @param aFont Font to use.
 * @param aText Text to render.
 * @param aForegroundColor Color of the text.
 * @param aBackgroundColor Color of the background.
 * @param aSize Size of font.
 * @param aMaxWidth Max width of a single line (in pixels).
 * @return
 */
Vector3 PCShaderSurface::LoadText(HashString const &aFont, HashString const &aText, Vector4 const &aForegroundColor, Vector4 const &aBackgroundColor, int aSize, int aMaxWidth)
{
    // Endianness is important here
    Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    rmask = 0xff000000;
    gmask = 0x00ff0000;
    bmask = 0x0000ff00;
    amask = 0x000000ff;
#else
    rmask = 0x000000ff;
    gmask = 0x0000ff00;
    bmask = 0x00ff0000;
    amask = 0xff000000;
#endif

    HashString const textureDataHash = aFont + aText + Common::IntToString(aSize);
    TextureData const& data = GetManager()->GetTextureData(textureDataHash);
    if(data.mTextureID != (unsigned)-1)
    {
        Vector3 size = Vector3(data.mWidth, data.mHeight, 0);
        mTextureID = data.mTextureID;
        SetTextureSize(size);
        return size;
    }
    else
    {
        if(!TTF_WasInit())
            TTF_Init();
        mFont = TTF_OpenFont(Common::RelativePath("Fonts", aFont).c_str(), aSize);
        if(!mFont)
        {
            mFont = NULL;
            DebugLogPrint("warning: file not found or incompatible format, check this out\n");
            DebugLogPrint("%s", TTF_GetError());
            return Vector3(0, 0, 0);
        }

        // Create text texture
        SDL_Color fgColor = {(Uint8)aForegroundColor.x, (Uint8)aForegroundColor.y, (Uint8)aForegroundColor.z, (Uint8)aForegroundColor.w};
        //SDL_Color bgColor = {(Uint8)aBackgroundColor.x, (Uint8)aBackgroundColor.y, (Uint8)aBackgroundColor.z, (Uint8)aBackgroundColor.w};
        SDL_Surface *msg = TTF_RenderText_Blended_Wrapped(mFont, aText.ToCharArray(), fgColor, aMaxWidth);
        if(!msg)
        {
            DebugLogPrint("TTF_RenderText failed: %s", TTF_GetError());
            assert(msg);
        }

        mTextureFormat = GL_RGBA;
        mSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, msg->w, msg->h, 32, rmask, gmask, bmask, amask);
        SetTextureSize(Vector3(mSurface->w, mSurface->h, 0));
        SDL_BlitSurface(msg, NULL, mSurface, NULL);

        AddTexturePairing(textureDataHash);

        return Vector3(mSurface->w, mSurface->h, 0);
    }
}
Esempio n. 8
0
// SetNodePermissions
status_t
SecurityContext::SetNodePermissions(const node_ref& ref, User* user,
	Permissions permissions)
{
	if (!user)
		return B_BAD_VALUE;

	ContextLocker _(this);
	// check, whether we know the user
	if (fUsers->Get(user->GetName()) != user)
		return B_BAD_VALUE;

	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return error;
	return fPermissions->Put(UserPath(path.GetString(), user), permissions);
}
Esempio n. 9
0
GameObject::GameObject(ObjectManager *aManager, HashString const &aFileName) :
                       mFileName(aFileName), mName(""), mComponents(), mManager(aManager)
{
  for(int i = aFileName.Length() - 1; i >= 0 && aFileName[i] != '/'; --i)
  {
    mName.Push(aFileName[i]);
  }
  mName.Reverse();
  mName = mName.SubString(0, mName.Size() - 4);
}
Esempio n. 10
0
//-----------------------------------------------------------------------------
//! @brief   TODO enter a description
//! @remark
//-----------------------------------------------------------------------------
void Camera::update( float elapsedTime, double time, const Input& input )
{
    const InputState* inputState = input.getInput(0);
    if (inputState)
    {
		InputActions::ActionType fowardAction;
		InputActions::ActionType backwardAction;
		InputActions::ActionType moveLeftAction;
		InputActions::ActionType moveRightAction;
		InputActions::ActionType yawLeftAction;
		InputActions::ActionType yawRightAction;
		InputActions::ActionType pitchUpAction;
		InputActions::ActionType pitchDownAction;
		InputActions::ActionType rollLeftAction;
		InputActions::ActionType rollRightAction;
		InputSystem::getInputActionFromName(moveForward.getHash(), fowardAction);
		InputSystem::getInputActionFromName(moveBackWards.getHash(), backwardAction);
		InputSystem::getInputActionFromName(moveLeft.getHash(), moveLeftAction);
		InputSystem::getInputActionFromName(moveRight.getHash(), moveRightAction);
		InputSystem::getInputActionFromName(yawLeft.getHash(), yawLeftAction);
		InputSystem::getInputActionFromName(yawRight.getHash(), yawRightAction);
		InputSystem::getInputActionFromName(pitchUp.getHash(), pitchUpAction);
		InputSystem::getInputActionFromName(pitchDown.getHash(), pitchDownAction);
		InputSystem::getInputActionFromName(rollLeft.getHash(), rollLeftAction);
		InputSystem::getInputActionFromName(rollRight.getHash(), rollRightAction);

        float moveAlongDirectionFactor = inputState->getActionValue(fowardAction) - inputState->getActionValue(backwardAction);
        moveAlongDirection(moveAlongDirectionFactor * m_movementSpeed * elapsedTime );//Move forwared, backward
        float strafeFactor = inputState->getActionValue(moveLeftAction) - inputState->getActionValue(moveRightAction);
        strafe(strafeFactor   * m_movementSpeed * elapsedTime);//Move left/right
        float yawFactor = inputState->getActionValue(yawLeftAction) - inputState->getActionValue(yawRightAction);
        yaw(yawFactor * m_rotationSpeed * elapsedTime);
        float pitchFactor = inputState->getActionValue(pitchUpAction) - inputState->getActionValue(pitchDownAction);
        pitch(pitchFactor * m_rotationSpeed * elapsedTime); 
        float zAxisDelta = inputState->getActionValue(rollLeftAction) - inputState->getActionValue(rollRightAction);
        roll(zAxisDelta * m_rotationSpeed * 0.05f);
    }

    //Use the varibles to avoid a warning and allows us to use them in the code above without change
    time = 0.0;
    elapsedTime = 0.0f;
}
Esempio n. 11
0
void Map::LoadFromJSON( const rapidjson::Value& object )
{
    // Destroy all Units.
    // TODO: Don't do this.
    DestroyAllUnits();

    // Get the Units tag.
    const rapidjson::Value& unitsArray = object[ "units" ];
    assertion( unitsArray.IsArray(), "Could not load game state from JSON because no \"units\" list was found!" );

    Scenario* scenario = GetScenario();

    for( auto it = unitsArray.Begin(); it != unitsArray.End(); ++it )
    {
        const rapidjson::Value& object = ( *it );
        assertion( object.IsObject(), "Could not load Unit from JSON because the JSON provided was not an object!" );

        // Get all properties.
        HashString unitTypeName = GetJSONStringValue( object, "unitType", "" );
        int ownerIndex = GetJSONIntValue( object, "owner", -1 );
        int tileX = GetJSONIntValue( object, "x", -1 );
        int tileY = GetJSONIntValue( object, "y", -1 );

        assertion( GetTile( tileX, tileY ).IsValid(), "Loaded invalid tile position (%d,%d) from JSON!", tileX, tileY );

        // Get references.
        UnitType* unitType = scenario->UnitTypes.FindByName( unitTypeName );
        assertion( unitType, "Could not load invalid UnitType (\"%s\") from JSON!", unitTypeName.GetCString() );

        Faction* faction = GetFactionByIndex( ownerIndex );
        assertion( faction, "Could not load Unit with invalid Faction index (%d) from JSON!", ownerIndex );

        // Spawn the Unit.
        Unit* unit = CreateUnit( unitType, faction, tileX, tileY );

        // Load each Unit from the array.
        unit->LoadFromJSON( *it );
    }
}
Esempio n. 12
0
//---------------------------------------
void Widget::AddChild( Widget* child )
{
	assertion( child, "Cannot add null child to Widget \"%s\"!", GetName().GetCString() );
	assertion( child->GetManager() == mManager, "Cannot add child \"%s\" to Widget \"%s\" because it was created by a different WidgetManager!", child->mName.GetCString(), mName.GetCString() );

	HashString parentName = ( child->mParent ? child->mParent->mName : "" );

	assertion( child->mParent == nullptr, "Cannot add child \"%s\" to Widget \"%s\" because it is already a child of Widget \"%s\"!", child->mName.GetCString(), mName.GetCString(), parentName.GetCString() );
	assertion( !HasChildWithName( child->mName ), "Could not add child \"%s\" to Widget \"%s\" because a child of the same name already exists!", child->mName.GetCString(), mName.GetCString() );

	//DebugPrintf( "Adding child \"%s\" to Widget \"%s\"...", child->GetName().GetCString(), GetName().GetCString() );

	// If a child with the specified name does not already exist, add the new child.
	mChildren[ child->mName ] = child;
	child->mParent = this;

	// Resort all children by their draw order.
	InvalidateDrawOrder();
}
Esempio n. 13
0
pTexture TextureManager::getTexture( HashString const & texture_name )
{
	TextureMap::iterator texture_pos = m_textureMap.find( texture_name );
    pTexture p_texture;

	if ( texture_pos != m_textureMap.end() )	// If we did find it
	{
		p_texture = texture_pos->second;
	}
	else
	{
		p_texture = pTexture( new sf::Texture );
		if ( ! p_texture->loadFromFile( texture_name.getString() ) ) 	// If load fails, then use default texture
		{
			// Right now, f**k shit up
			return pTexture();
		}

		m_textureMap[ texture_name ] = p_texture;   // Add to map
	}

	return p_texture;
}
Esempio n. 14
0
//---------------------------------------
// Sprite
//---------------------------------------
Sprite::Sprite( SpriteAnimationSet& animation, const HashString& initialAnimName )
	: mAnimationSet( animation )
	, DrawColor( Color::WHITE)
	, RelativeToCamera( true )
	, FixedSize( false )
	, Scale( Vec2f::ONE )
{
	HashMap< SpriteAnimation >::const_iterator anim = animation.Animations.find( initialAnimName );
	if ( anim != animation.Animations.end() )
	{
		mSprAnimInfo.CurrentAnimationName = anim->first;
	}
	else
	{
		WarnInfo( "Sprite() initial animation not found: %s\n", initialAnimName.GetString().c_str() );
		if ( !mAnimationSet.Animations.empty() )
		{
			mSprAnimInfo.CurrentAnimationName = mAnimationSet.Animations.begin()->first;
		}
	}
	mSprAnimInfo.CurrentAnimationFrame = 0;
	mSprAnimInfo.CurrentAnimationFrameTime = 0.0f;
}
Esempio n. 15
0
//---------------------------------------
Widget::HorizontalAlignment Widget::GetHorizontalAlignmentByName( const HashString& name )
{
	HorizontalAlignment result = HORIZONTAL_ALIGN_LEFT;

	if( name == HORIZONTAL_ALIGN_LEFT_NAME )
	{
		result = HORIZONTAL_ALIGN_LEFT;
	}
	else if( name == HORIZONTAL_ALIGN_CENTER_NAME )
	{
		result = HORIZONTAL_ALIGN_CENTER;
	}
	else if( name == HORIZONTAL_ALIGN_RIGHT_NAME )
	{
		result = HORIZONTAL_ALIGN_RIGHT;
	}
	else
	{
		WarnFail( "HorizontalAlignment setting \"%s\" is invalid!", name.GetCString() );
	}

	return result;
}
Esempio n. 16
0
//---------------------------------------
Widget::VerticalAlignment Widget::GetVerticalAlignmentByName( const HashString& name )
{
	VerticalAlignment result = VERTICAL_ALIGN_TOP;

	if( name == VERTICAL_ALIGN_TOP_NAME )
	{
		result = VERTICAL_ALIGN_TOP;
	}
	else if( name == VERTICAL_ALIGN_CENTER_NAME )
	{
		result = VERTICAL_ALIGN_CENTER;
	}
	else if( name == VERTICAL_ALIGN_BOTTOM_NAME )
	{
		result = VERTICAL_ALIGN_BOTTOM;
	}
	else
	{
		WarnFail( "VerticalAlignment setting \"%s\" is invalid!", name.GetCString() );
	}

	return result;
}
Esempio n. 17
0
// Init
status_t
ServerConnection::Init(vnode_id connectionBrokenTarget)
{
	if (!fServerInfo)
		RETURN_ERROR(B_BAD_VALUE);

	// create a connection broken event
	fConnectionBrokenEvent
		= new(std::nothrow) ConnectionBrokenEvent(connectionBrokenTarget);
	if (!fConnectionBrokenEvent)
		return B_NO_MEMORY;

	// get the server address
	const char* connectionMethod = fServerInfo->GetConnectionMethod();
	HashString server;
	status_t error = fServerInfo->GetAddress().GetString(&server, false);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create the volume map
	fVolumes = new(std::nothrow) VolumeMap;
	if (!fVolumes)
		RETURN_ERROR(B_NO_MEMORY);
	error = fVolumes->InitCheck();
	if (error != B_OK)
		RETURN_ERROR(error);

	// establish the connection
	Connection* connection;
	ConnectionFactory factory;
	error = factory.CreateConnection(connectionMethod, server.GetString(),
		&connection);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create a request connection
	fConnection = new(std::nothrow) RequestConnection(connection, this);
	if (!fConnection) {
		delete connection;
		RETURN_ERROR(B_NO_MEMORY);
	}
	error = fConnection->Init();
	if (error != B_OK)
		return error;

	// send an `init connection request'

	// prepare the request
	InitConnectionRequest request;
	request.bigEndian = B_HOST_IS_BENDIAN;

	// send the request
	Request* _reply;
	error = fConnection->SendRequest(&request, &_reply);
	if (error != B_OK)
		return error;
	ObjectDeleter<Request> replyDeleter(_reply);

	// everything OK?
	InitConnectionReply* reply = dynamic_cast<InitConnectionReply*>(_reply);
	if (!reply)
		return B_BAD_DATA;
	if (reply->error != B_OK)
		return reply->error;

	fConnected = true;
	return B_OK;
}
Esempio n. 18
0
/**
 * @brief Same as get component by name except returns true or false
 * @param aName Name of component
 * @return True if object has component
 */
bool GameObject::HasComponentByName(HashString const &aName)
{
  return HasComponent(aName.ToHash());
}
ClassAd *CollectorEngine::
collect (int command,ClassAd *clientAd,const condor_sockaddr& from,int &insert,Sock *sock)
{
	ClassAd		*retVal;
	ClassAd		*pvtAd;
	int		insPvt;
	AdNameHashKey		hk;
	HashString	hashString;
	static int repeatStartdAds = -1;		// for debugging
	ClassAd		*clientAdToRepeat = NULL;

	if (repeatStartdAds == -1) {
		repeatStartdAds = param_integer("COLLECTOR_REPEAT_STARTD_ADS",0);
	}

	if( !ValidateClassAd(command,clientAd,sock) ) {
		return NULL;
	}

	// mux on command
	switch (command)
	{
	  case UPDATE_STARTD_AD:
	  case UPDATE_STARTD_AD_WITH_ACK:
#if !defined(WANT_OLD_CLASSADS)
		  clientAd->AddTargetRefs( TargetJobAttrs );
#endif
		if ( repeatStartdAds > 0 ) {
			clientAdToRepeat = new ClassAd(*clientAd);
		}
		if (!makeStartdAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (StartdAds, "StartdAd     ", "Start",
							  clientAd, hk, hashString, insert, from );

		// if we want to store private ads
		if (!sock)
		{
			dprintf (D_ALWAYS, "Want private ads, but no socket given!\n");
			break;
		}
		else
		{
			if (!(pvtAd = new ClassAd))
			{
				EXCEPT ("Memory error!");
			}
			if( !pvtAd->initFromStream(*sock) )
			{
				dprintf(D_FULLDEBUG,"\t(Could not get startd's private ad)\n");
				delete pvtAd;
				break;
			}

				// Fix up some stuff in the private ad that we depend on.
				// We started doing this in 7.2.0, so once we no longer
				// care about compatibility with stuff from before then,
				// the startd could stop bothering to send these attributes.

				// Queries of private ads depend on the following:
			pvtAd->SetMyTypeName( STARTD_ADTYPE );

				// Negotiator matches up private ad with public ad by
				// using the following.
			if( retVal ) {
				pvtAd->CopyAttribute( ATTR_MY_ADDRESS, retVal );
				pvtAd->CopyAttribute( ATTR_NAME, retVal );
			}


			// insert the private ad into its hashtable --- use the same
			// hash key as the public ad
			(void) updateClassAd (StartdPrivateAds, "StartdPvtAd  ",
								  "StartdPvt", pvtAd, hk, hashString, insPvt,
								  from );
		}

		// create fake duplicates of this ad, each with a different name, if
		// we are told to do so.  this feature exists for developer
		// scalability testing.
		if ( repeatStartdAds > 0 && clientAdToRepeat ) {
			ClassAd *fakeAd;
			int n;
			char newname[150],oldname[130];
			oldname[0] = '\0';
			clientAdToRepeat->LookupString("Name",oldname,sizeof(oldname));
			for (n=0;n<repeatStartdAds;n++) {
				fakeAd = new ClassAd(*clientAdToRepeat);
				snprintf(newname,sizeof(newname),
						 "Name=\"fake%d-%s\"",n,oldname);
				fakeAd->InsertOrUpdate(newname);
				makeStartdAdHashKey (hk, fakeAd);
				hashString.Build( hk );
				if (! updateClassAd (StartdAds, "StartdAd     ", "Start",
							  fakeAd, hk, hashString, insert, from ) )
				{
					// don't leak memory if there is some failure
					delete fakeAd;
				}
			}
			delete clientAdToRepeat;
			clientAdToRepeat = NULL;
		}
		break;

	  case MERGE_STARTD_AD:
#if !defined(WANT_OLD_CLASSADS)
		  clientAd->AddTargetRefs( TargetJobAttrs );
#endif
		if (!makeStartdAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=mergeClassAd (StartdAds, "StartdAd     ", "Start",
							  clientAd, hk, hashString, insert, from );
		break;

#ifdef HAVE_EXT_POSTGRESQL
	  case UPDATE_QUILL_AD:
		if (!makeQuillAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (QuillAds, "QuillAd     ", "Quill",
							  clientAd, hk, hashString, insert, from );
		break;
#endif /* HAVE_EXT_POSTGRESQL */

	  case UPDATE_SCHEDD_AD:
		if (!makeScheddAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (ScheddAds, "ScheddAd     ", "Schedd",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_SUBMITTOR_AD:
		// use the same hashkey function as a schedd ad
		if (!makeScheddAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		// CRUFT: Before 7.3.2, submitter ads had a MyType of
		//   "Scheduler". The only way to tell the difference
		//   was that submitter ads didn't have ATTR_NUM_USERS.
		//   Coerce MyStype to "Submitter" for ads coming from
		//   these older schedds.
		//   Before 7.7.3, submitter ads for parallel universe
		//   jobs had a MyType of "Scheduler".
		clientAd->SetMyTypeName( SUBMITTER_ADTYPE );
		// since submittor ads always follow a schedd ad, and a master check is
		// performed for schedd ads, we don't need a master check in here
		hashString.Build( hk );
		retVal=updateClassAd (SubmittorAds, "SubmittorAd  ", "Submittor",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_LICENSE_AD:
		// use the same hashkey function as a schedd ad
		if (!makeLicenseAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		// since submittor ads always follow a schedd ad, and a master check is
		// performed for schedd ads, we don't need a master check in here
		hashString.Build( hk );
		retVal=updateClassAd (LicenseAds, "LicenseAd  ", "License",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_MASTER_AD:
		if (!makeMasterAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (MasterAds, "MasterAd     ", "Master",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_CKPT_SRVR_AD:
		if (!makeCkptSrvrAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (CkptServerAds, "CkptSrvrAd   ", "CkptSrvr",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_COLLECTOR_AD:
		if (!makeCollectorAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (CollectorAds, "CollectorAd  ", "Collector",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_STORAGE_AD:
		if (!makeStorageAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (StorageAds, "StorageAd  ", "Storage",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_NEGOTIATOR_AD:
		if (!makeNegotiatorAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
			// first, purge all the existing negotiator ads, since we
			// want to enforce that *ONLY* 1 negotiator is in the
			// collector any given time.
		purgeHashTable( NegotiatorAds );
		retVal=updateClassAd (NegotiatorAds, "NegotiatorAd  ", "Negotiator",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_HAD_AD:
		if (!makeHadAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (HadAds, "HadAd  ", "HAD",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_GRID_AD:
		if (!makeGridAdHashKey(hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (GridAds, "GridAd  ", "Grid",
							  clientAd, hk, hashString, insert, from );
          break;

	  case UPDATE_AD_GENERIC:
	  {
		  const char *type_str = clientAd->GetMyTypeName();
		  if (type_str == NULL) {
			  dprintf(D_ALWAYS, "collect: UPDATE_AD_GENERIC: ad has no type\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  MyString type(type_str);
		  CollectorHashTable *cht = findOrCreateTable(type);
		  if (cht == NULL) {
			  dprintf(D_ALWAYS, "collect: findOrCreateTable failed\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  if (!makeGenericAdHashKey (hk, clientAd))
		  {
			  dprintf(D_ALWAYS, "Could not make haskey --- ignoring ad\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  hashString.Build(hk);
		  retVal = updateClassAd(*cht, type_str, type_str, clientAd,
					 hk, hashString, insert, from);
		  break;
	  }

	  case UPDATE_XFER_SERVICE_AD:
		if (!makeXferServiceAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (XferServiceAds, "XferServiceAd  ",
							  "XferService",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_LEASE_MANAGER_AD:
		if (!makeLeaseManagerAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
			// first, purge all the existing LeaseManager ads, since we
			// want to enforce that *ONLY* 1 manager is in the
			// collector any given time.
		purgeHashTable( LeaseManagerAds );
		retVal=updateClassAd (LeaseManagerAds, "LeaseManagerAd  ",
							  "LeaseManager",
							  clientAd, hk, hashString, insert, from );
		break;


	  case QUERY_STARTD_ADS:
	  case QUERY_SCHEDD_ADS:
	  case QUERY_MASTER_ADS:
	  case QUERY_GATEWAY_ADS:
	  case QUERY_SUBMITTOR_ADS:
	  case QUERY_CKPT_SRVR_ADS:
	  case QUERY_STARTD_PVT_ADS:
	  case QUERY_COLLECTOR_ADS:
  	  case QUERY_NEGOTIATOR_ADS:
  	  case QUERY_HAD_ADS:
  	  case QUERY_XFER_SERVICE_ADS:
  	  case QUERY_LEASE_MANAGER_ADS:
	  case QUERY_GENERIC_ADS:
	  case INVALIDATE_STARTD_ADS:
	  case INVALIDATE_SCHEDD_ADS:
	  case INVALIDATE_MASTER_ADS:
	  case INVALIDATE_GATEWAY_ADS:
	  case INVALIDATE_CKPT_SRVR_ADS:
	  case INVALIDATE_SUBMITTOR_ADS:
	  case INVALIDATE_COLLECTOR_ADS:
	  case INVALIDATE_NEGOTIATOR_ADS:
	  case INVALIDATE_HAD_ADS:
	  case INVALIDATE_XFER_SERVICE_ADS:
	  case INVALIDATE_LEASE_MANAGER_ADS:
	  case INVALIDATE_ADS_GENERIC:
		// these are not implemented in the engine, but we allow another
		// daemon to detect that these commands have been given
	    insert = -2;
		retVal = 0;
	    break;

	  default:
		dprintf (D_ALWAYS, "Received illegal command: %d\n", command);
		insert = -1;
		retVal = 0;
	}

	// return the updated ad
	return retVal;
}
Esempio n. 20
0
//---------------------------------------
void Widget::RemoveChildByName( const HashString& name )
{
	auto it = mChildren.find( name );

	if( it != mChildren.end() )
	{
		Widget* child = it->second;

		// Remove the child with the specified name.
		mChildren.erase( it );

		// Resort all children by their draw order.
		InvalidateDrawOrder();
	}
	else
	{
		// If the child wasn't found, post a warning.
		WarnFail( "Could not remove child \"%s\" from Widget \"%s\" because no child with that name was found!", name.GetCString(), mName.GetCString() );
	}
}
Esempio n. 21
0
ClassAd *CollectorEngine::
collect (int command,ClassAd *clientAd,const condor_sockaddr& from,int &insert,Sock *sock)
{
	ClassAd		*retVal;
	ClassAd		*pvtAd;
	int		insPvt;
	AdNameHashKey		hk;
	HashString	hashString;
	static int repeatStartdAds = -1;		// for debugging
	ClassAd		*clientAdToRepeat = NULL;
	_condor_auto_accum_runtime<collector_runtime_probe> rt(CollectorEngine_rucc_runtime);
	double rt_last = rt.begin;

	if (repeatStartdAds == -1) {
		repeatStartdAds = param_integer("COLLECTOR_REPEAT_STARTD_ADS",0);
	}

	if( !ValidateClassAd(command,clientAd,sock) ) {
		return NULL;
	}

	CollectorEngine_rucc_validateAd_runtime.Add(rt.tick(rt_last));

	// mux on command
	switch (command)
	{
	  case UPDATE_STARTD_AD:
	  case UPDATE_STARTD_AD_WITH_ACK:
		if ( repeatStartdAds > 0 ) {
			clientAdToRepeat = new ClassAd(*clientAd);
		}
		if (!makeStartdAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );

		CollectorEngine_rucc_makeHashKey_runtime.Add(rt.tick(rt_last));

		retVal=updateClassAd (StartdAds, "StartdAd     ", "Start",
							  clientAd, hk, hashString, insert, from );

		if (last_updateClassAd_was_insert) { CollectorEngine_rucc_insertAd_runtime.Add(rt.tick(rt_last));
		} else { CollectorEngine_rucc_updateAd_runtime.Add(rt.tick(rt_last)); }

		// if we want to store private ads
		if (!sock)
		{
			dprintf (D_ALWAYS, "Want private ads, but no socket given!\n");
			break;
		}
		else
		{
			if (!(pvtAd = new ClassAd))
			{
				EXCEPT ("Memory error!");
			}
			if( !getClassAd(sock, *pvtAd) )
			{
				dprintf(D_FULLDEBUG,"\t(Could not get startd's private ad)\n");
				delete pvtAd;
				break;
			}

				// Fix up some stuff in the private ad that we depend on.
				// We started doing this in 7.2.0, so once we no longer
				// care about compatibility with stuff from before then,
				// the startd could stop bothering to send these attributes.

				// Queries of private ads depend on the following:
			SetMyTypeName( *pvtAd, STARTD_ADTYPE );

				// Negotiator matches up private ad with public ad by
				// using the following.
			if( retVal ) {
				CopyAttribute( ATTR_MY_ADDRESS, *pvtAd, *retVal );
				CopyAttribute( ATTR_NAME, *pvtAd, *retVal );
			}

			CollectorEngine_rucc_getPvtAd_runtime.Add(rt.tick(rt_last));

			// insert the private ad into its hashtable --- use the same
			// hash key as the public ad
			(void) updateClassAd (StartdPrivateAds, "StartdPvtAd  ",
								  "StartdPvt", pvtAd, hk, hashString, insPvt,
								  from );
			if (last_updateClassAd_was_insert) { CollectorEngine_rucc_insertPvtAd_runtime.Add(rt.tick(rt_last));
			} else { CollectorEngine_rucc_updatePvtAd_runtime.Add(rt.tick(rt_last)); }
		}

		// create fake duplicates of this ad, each with a different name, if
		// we are told to do so.  this feature exists for developer
		// scalability testing.
		if ( repeatStartdAds > 0 && clientAdToRepeat ) {
			ClassAd *fakeAd;
			int n;
			char newname[150],oldname[130];
			oldname[0] = '\0';
			clientAdToRepeat->LookupString("Name",oldname,sizeof(oldname));
			for (n=0;n<repeatStartdAds;n++) {
				fakeAd = new ClassAd(*clientAdToRepeat);
				snprintf(newname,sizeof(newname),
						 "Name=\"fake%d-%s\"",n,oldname);
				fakeAd->Insert(newname);
				makeStartdAdHashKey (hk, fakeAd);
				hashString.Build( hk );
				if (! updateClassAd (StartdAds, "StartdAd     ", "Start",
							  fakeAd, hk, hashString, insert, from ) )
				{
					// don't leak memory if there is some failure
					delete fakeAd;
				}
			}
			delete clientAdToRepeat;
			clientAdToRepeat = NULL;
			CollectorEngine_rucc_repeatAd_runtime.Add(rt.tick(rt_last));
		}
		break;

	  case MERGE_STARTD_AD:
		if (!makeStartdAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=mergeClassAd (StartdAds, "StartdAd     ", "Start",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_SCHEDD_AD:
		if (!makeScheddAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (ScheddAds, "ScheddAd     ", "Schedd",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_SUBMITTOR_AD:
		// use the same hashkey function as a schedd ad
		if (!makeScheddAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		// since submittor ads always follow a schedd ad, and a master check is
		// performed for schedd ads, we don't need a master check in here
		hashString.Build( hk );
		retVal=updateClassAd (SubmittorAds, "SubmittorAd  ", "Submittor",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_LICENSE_AD:
		// use the same hashkey function as a schedd ad
		if (!makeLicenseAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		// since submittor ads always follow a schedd ad, and a master check is
		// performed for schedd ads, we don't need a master check in here
		hashString.Build( hk );
		retVal=updateClassAd (LicenseAds, "LicenseAd  ", "License",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_MASTER_AD:
		if (!makeMasterAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (MasterAds, "MasterAd     ", "Master",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_CKPT_SRVR_AD:
		if (!makeCkptSrvrAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (CkptServerAds, "CkptSrvrAd   ", "CkptSrvr",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_COLLECTOR_AD:
		if (!makeCollectorAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (CollectorAds, "CollectorAd  ", "Collector",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_STORAGE_AD:
		if (!makeStorageAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (StorageAds, "StorageAd  ", "Storage",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_ACCOUNTING_AD:
		if (!makeAccountingAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (AccountingAds, "AccountingAd  ", "Accouting",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_NEGOTIATOR_AD:
		if (!makeNegotiatorAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		if (m_allowOnlyOneNegotiator) {
			// first, purge all the existing negotiator ads, since we
			// want to enforce that *ONLY* 1 negotiator is in the
			// collector any given time.
			purgeHashTable( NegotiatorAds );
		}
		retVal=updateClassAd (NegotiatorAds, "NegotiatorAd  ", "Negotiator",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_HAD_AD:
		if (!makeHadAdHashKey (hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (HadAds, "HadAd  ", "HAD",
							  clientAd, hk, hashString, insert, from );
		break;

	  case UPDATE_GRID_AD:
		if (!makeGridAdHashKey(hk, clientAd))
		{
			dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			insert = -3;
			retVal = 0;
			break;
		}
		hashString.Build( hk );
		retVal=updateClassAd (GridAds, "GridAd  ", "Grid",
							  clientAd, hk, hashString, insert, from );
          break;

	  case UPDATE_AD_GENERIC:
	  {
		  const char *type_str = GetMyTypeName(*clientAd);
		  if (type_str == NULL) {
			  dprintf(D_ALWAYS, "collect: UPDATE_AD_GENERIC: ad has no type\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  MyString type(type_str);
		  CollectorHashTable *cht = findOrCreateTable(type);
		  if (cht == NULL) {
			  dprintf(D_ALWAYS, "collect: findOrCreateTable failed\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  if (!makeGenericAdHashKey (hk, clientAd))
		  {
			  dprintf(D_ALWAYS, "Could not make hashkey --- ignoring ad\n");
			  insert = -3;
			  retVal = 0;
			  break;
		  }
		  hashString.Build(hk);
		  retVal = updateClassAd(*cht, type_str, type_str, clientAd,
					 hk, hashString, insert, from);
		  break;
	  }

	  case QUERY_STARTD_ADS:
	  case QUERY_SCHEDD_ADS:
	  case QUERY_MASTER_ADS:
	  case QUERY_SUBMITTOR_ADS:
	  case QUERY_CKPT_SRVR_ADS:
	  case QUERY_STARTD_PVT_ADS:
	  case QUERY_COLLECTOR_ADS:
  	  case QUERY_NEGOTIATOR_ADS:
  	  case QUERY_HAD_ADS:
	  case QUERY_GENERIC_ADS:
	  case INVALIDATE_STARTD_ADS:
	  case INVALIDATE_SCHEDD_ADS:
	  case INVALIDATE_MASTER_ADS:
	  case INVALIDATE_CKPT_SRVR_ADS:
	  case INVALIDATE_SUBMITTOR_ADS:
	  case INVALIDATE_COLLECTOR_ADS:
	  case INVALIDATE_NEGOTIATOR_ADS:
	  case INVALIDATE_HAD_ADS:
	  case INVALIDATE_ADS_GENERIC:
		// these are not implemented in the engine, but we allow another
		// daemon to detect that these commands have been given
	    insert = -2;
		retVal = 0;
	    break;

	  default:
		dprintf (D_ALWAYS, "Received illegal command: %d\n", command);
		insert = -1;
		retVal = 0;
	}

	if (command != UPDATE_STARTD_AD && command != UPDATE_STARTD_AD_WITH_ACK) {
		CollectorEngine_rucc_other_runtime.Add(rt.tick(rt_last));
	}


	// return the updated ad
	return retVal;
}
Esempio n. 22
0
/**
 * @brief Load shaders.
 * @param aVertexShaderFilename Name of vertex shader.
 * @param aFragmentShaderFilename Name of fragment shader.
 */
void PCShaderSurface::LoadShaders(HashString const &aVertexShaderFilename, HashString const &aFragmentShaderFilename)
{
    mVertexShaderFileName = aVertexShaderFilename;
    mFragmentShaderFileName = aFragmentShaderFilename;

    HashString shaderKey = aVertexShaderFilename + aFragmentShaderFilename;

    if(GetManager()->ShaderDataExists(shaderKey))
    {
        mProgramID = GetManager()->GetShaderData(shaderKey).mProgramID;
        return;
    }

    std::ifstream vertexFile(Common::RelativePath("Shaders", aVertexShaderFilename.ToCharArray()).c_str());
    std::ifstream fragmentFile(Common::RelativePath("Shaders", aFragmentShaderFilename.ToCharArray()).c_str());
    if(vertexFile.is_open() && fragmentFile.is_open())
    {
        GLenum program = glCreateProgram();
        GLenum vertexShader = glCreateShader(GL_VERTEX_SHADER);
        GLenum fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
        GLint didCompile = 0;
        GLint isLinked = 0;

        HashString vertexFileContents = std::string((std::istreambuf_iterator<char>(vertexFile)), std::istreambuf_iterator<char>());
        const char* vertexContents = vertexFileContents.ToCharArray();

        // Compile
        glShaderSource(vertexShader, 1, &vertexContents, NULL);
        glCompileShader(vertexShader);
        glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &didCompile);
        if(didCompile == GL_FALSE)
        {
            DebugLogPrint("VERTEX SHADER %s READ:\n%s\n", aVertexShaderFilename.ToCharArray(), vertexContents);

            GLint maxLength = 0;
            glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &maxLength);

            //The maxLength includes the NULL character
            std::vector<char> infoLog(maxLength);
            glGetShaderInfoLog(vertexShader, maxLength, &maxLength, &infoLog[0]);

            DebugLogPrint("GLERROR %s: %s\n", aVertexShaderFilename.ToCharArray(), &infoLog[0]);

            //We don't need the shader anymore.
            glDeleteShader(vertexShader);
        }

        HashString fragmentFileContents = std::string((std::istreambuf_iterator<char>(fragmentFile)), std::istreambuf_iterator<char>());
        const char* fragmentContents = fragmentFileContents.ToCharArray();
        glShaderSource(fragmentShader, 1, &fragmentContents, NULL);
        glCompileShader(fragmentShader);
        glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &didCompile);
        if(didCompile == GL_FALSE)
        {
            DebugLogPrint("FRAGMENT SHADER %s READ:\n%s\n", aFragmentShaderFilename.ToCharArray(), fragmentContents);

            GLint maxLength = 0;
            glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &maxLength);

            //The maxLength includes the NULL character
            std::vector<char> infoLog(maxLength);
            glGetShaderInfoLog(fragmentShader, maxLength, &maxLength, &infoLog[0]);

            DebugLogPrint("GLERROR %s: %s\n", aFragmentShaderFilename.ToCharArray(), &infoLog[0]);

            //We don't need the shader anymore.
            glDeleteShader(fragmentShader);
        }

        // Linking
        glAttachShader(program, vertexShader);
        glAttachShader(program, fragmentShader);
        glLinkProgram(program);
        glGetProgramiv(program, GL_LINK_STATUS, &isLinked);
        if(isLinked == GL_FALSE)
        {
            GLint maxLength = 0;
            glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);

            //The maxLength includes the NULL character
            std::vector<GLchar> infoLog(maxLength);
            glGetProgramInfoLog(program, maxLength, &maxLength, &infoLog[0]);

            //We don't need the program anymore.
            glDeleteProgram(program);
            //Don't leak shaders either.
            glDeleteShader(vertexShader);
            glDeleteShader(fragmentShader);

            DebugLogPrint("GL LINK ERROR: %s\n", &infoLog[0]);
        }

        GetManager()->AddShaderPairing(shaderKey, ShaderData(program, vertexShader, fragmentShader, vertexContents, fragmentContents));

        mProgramID = program;
    }
    else
    {
        DebugLogPrint("No shader with name %s or %s found\n", aVertexShaderFilename.ToCharArray(), aFragmentShaderFilename.ToCharArray());
        assert(!"Shader file not found.");
    }
}