ECS/Project/Project/Renderers/RendererResourceManagers/RendererShaderManager/RendererShaderManager.cpp
//	Read the Shader Stage in from the file.
Read the Shader Stage in from the file.
Read the Shader Stage in from the file .
GLuint RendererShaderManager::readShaderStageFromFile(GLenum shaderType, std::string filepath)
{
	GLuint shaderReference = 0;
	std::string shaderFileString = "";
	std::ifstream sourceFile(filepath, std::ifstream::in);
	if (sourceFile.is_open())
	{
		shaderReference = glCreateShader(shaderType);
		std::string line = "";
		Read the Shader in line by line.
		while (!sourceFile.eof())
		{
			getline(sourceFile, line);
			shaderFileString.append(line + " \n");
		}
		C style version of the Shader File.
		const GLchar * shaderSource = shaderFileString.c_str();
		Assign the Shader Source.
		glShaderSource(shaderReference, 1, (const GLchar **)& shaderSource, NULL);
		Compile the Shader Source.
		glCompileShader(shaderReference);
		Check shader for errors 
		GLint shaderCompiled = GL_FALSE;
		Check if the Shader has been complied.
		glGetShaderiv(shaderReference, GL_COMPILE_STATUS, &shaderCompiled);
		if (shaderCompiled != GL_TRUE)
		{
			Print an error if the Shader failed to complie.
			printf("Unable to compile shader %d!\n\nSource:\n%s\n", shaderReference, shaderSource);
			Delete the Shader.
			glDeleteShader(shaderReference);
			Set the Shader to be 0.
			shaderReference = 0;
		}
	}
	else
	{
		Mark it as unable to be open.
		printf("Unable to open shader. \n");
	}
	Return the Shader Reference.
	return shaderReference;
}
GLuint RendererShaderManager :: readShaderStageFromFile ( GLenum shaderType , std :: string filepath ) { GLuint shaderReference = 0 ; std :: string shaderFileString = " " ; std :: ifstream sourceFile ( filepath , std :: ifstream :: in ) ; if ( sourceFile . is_open ( ) ) { shaderReference = glCreateShader ( shaderType ) ; std :: string line = " " ; while ( ! sourceFile . eof ( ) ) { getline ( sourceFile , line ) ; shaderFileString . append ( line + " \n " ) ; } const GLchar * shaderSource = shaderFileString . c_str ( ) ; glShaderSource ( shaderReference , 1 , ( const GLchar * * ) & shaderSource , NULL ) ; glCompileShader ( shaderReference ) ; GLint shaderCompiled = GL_FALSE ; glGetShaderiv ( shaderReference , GL_COMPILE_STATUS , & shaderCompiled ) ; if ( shaderCompiled != GL_TRUE ) { printf ( " \n \n \n \n " , shaderReference , shaderSource ) ; glDeleteShader ( shaderReference ) ; shaderReference = 0 ; } } else { printf ( " \n " ) ; } return shaderReference ; }
Read the Shader Stage in from the file.
Read the Shader Stage in from the file .
//	Initialize the Shader Reference. //	The Shader String. //	Open the file. //	Open the SourceFile. //	Create the Shader. //	 //	Read the Shader in line by line. //	C style version of the Shader File. //	Assign the Shader Source. //	Compile the Shader Source. //	Check shader for errors  //	Check if the Shader has been complied. //	 //	Print an error if the Shader failed to complie. //	Delete the Shader. //	Set the Shader to be 0. //	Mark it as unable to be open. //	Return the Shader Reference.