ECS/Project/Project/Renderers/RendererResourceManagers/RendererShaderManager/RendererShaderManager.cpp
//	Add a new Shader to the RendererShaderManager.
Add a new Shader to the RendererShaderManager.
Add a new Shader to the RendererShaderManager .
void RendererShaderManager::addShader(std::shared_ptr<const ShaderData> newShader)
{
	std::string shaderName = "None";
	if (newShader->findProperty("Shader Name", shaderName))
	{
				Find the Shader.
		auto shaderIterator = mapNameToShaderData.find(shaderName);
			Check if it already 
		if (shaderIterator != mapNameToShaderData.end())
		{
				TO DO
				Throw Shader Already Exists Error.
		}
		else
		{
				Construct Renderer Shader Data.
			std::shared_ptr<RendererShaderData> newRendererShaderData = std::make_shared<RendererShaderData>();
				Create the ShaderProgram ID.
			GLuint shaderID = glCreateProgram();
			newRendererShaderData->shaderID = shaderID;
			newRendererShaderData->shaderType = shaderName;
			std::string vertexShaderFilename = "None";
			std::string fragmentShaderFilename = "None";
			if (newShader->findProperty("Shader Vertex Shader Source", vertexShaderFilename))
			{
				GLuint vertexShaderID = readShaderStageFromFile(GL_VERTEX_SHADER, vertexShaderFilename);
				glAttachShader(shaderID, vertexShaderID);
				newRendererShaderData->vertexShaderID = vertexShaderID;
			}
			if (newShader->findProperty("Shader Fragment Shader Source", fragmentShaderFilename))
			{
				GLuint fragmentShaderID = readShaderStageFromFile(GL_FRAGMENT_SHADER, fragmentShaderFilename);
				glAttachShader(shaderID, fragmentShaderID);
				newRendererShaderData->fragmentShaderID = fragmentShaderID;
			}
				Link the Shader.
			glLinkProgram(shaderID);
			newRendererShaderData->shaderProperties = std::map<std::string, std::string>(newShader->viewProperties());
				Set the Shader Uniform Locations.
			generateShaderUniformLocations(shaderID, newRendererShaderData->shaderUniforms);
				Insert the Shader into the Map in the appropriate location.
			mapNameToShaderData.insert(std::make_pair(shaderName, newRendererShaderData));
		}
	}
	else
	{
	}
}
void RendererShaderManager :: addShader ( std :: shared_ptr < const ShaderData > newShader ) { std :: string shaderName = " " ; if ( newShader -> findProperty ( " " , shaderName ) ) { auto shaderIterator = mapNameToShaderData . find ( shaderName ) ; if ( shaderIterator != mapNameToShaderData . end ( ) ) { } else { std :: shared_ptr < RendererShaderData > newRendererShaderData = std :: make_shared < RendererShaderData > ( ) ; GLuint shaderID = glCreateProgram ( ) ; newRendererShaderData -> shaderID = shaderID ; newRendererShaderData -> shaderType = shaderName ; std :: string vertexShaderFilename = " " ; std :: string fragmentShaderFilename = " " ; if ( newShader -> findProperty ( " " , vertexShaderFilename ) ) { GLuint vertexShaderID = readShaderStageFromFile ( GL_VERTEX_SHADER , vertexShaderFilename ) ; glAttachShader ( shaderID , vertexShaderID ) ; newRendererShaderData -> vertexShaderID = vertexShaderID ; } if ( newShader -> findProperty ( " " , fragmentShaderFilename ) ) { GLuint fragmentShaderID = readShaderStageFromFile ( GL_FRAGMENT_SHADER , fragmentShaderFilename ) ; glAttachShader ( shaderID , fragmentShaderID ) ; newRendererShaderData -> fragmentShaderID = fragmentShaderID ; } glLinkProgram ( shaderID ) ; newRendererShaderData -> shaderProperties = std :: map < std :: string , std :: string > ( newShader -> viewProperties ( ) ) ; generateShaderUniformLocations ( shaderID , newRendererShaderData -> shaderUniforms ) ; mapNameToShaderData . insert ( std :: make_pair ( shaderName , newRendererShaderData ) ) ; } } else { } }
Add a new Shader to the RendererShaderManager.
Add a new Shader to the RendererShaderManager .
// //	Find the Shader. //	Check if it already  //	TO DO //	Throw Shader Already Exists Error. //	Construct Renderer Shader Data. //	Create the ShaderProgram ID. //	Link the Shader. //	Set the Shader Uniform Locations. //	Insert the Shader into the Map in the appropriate location.