Ejemplo n.º 1
0
int ShaderProgram::loadShader(const char* shader_filepath, GLuint &shader)
{
    // Read shader code
    std::string shaderCode = "";
	std::ifstream shaderStream(shader_filepath, std::ios::in);
	if(shaderStream.is_open())
    {
		std::string Line = "";
		while(getline(shaderStream, Line)) shaderCode += "\n" + Line;
		shaderStream.close();
	}
	else { printf("Failed to open %s.\n", shader_filepath); getchar(); return -1;}

    // Compile shader
	//printf("Compiling shader: %s\n", shader_filepath);
	char const* source = shaderCode.c_str();
	glShaderSource(shader, 1, &source , NULL);
	glCompileShader(shader);

	// Check shader
	GLint result = GL_FALSE; int infoLogLength;
	glGetShaderiv(shader, GL_COMPILE_STATUS, &result);
	glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
	if (infoLogLength > 0)
    {
		std::vector<char> shaderErrorMessage(infoLogLength+1);
		glGetShaderInfoLog(shader, infoLogLength, NULL, &shaderErrorMessage[0]);
		printf("%s\n", &shaderErrorMessage[0]);
		return -2;
	}

	return 0;
}
Ejemplo n.º 2
0
void Shader::LoadShader( const std::string &filename, int type ) {
    GLuint shaderID = glCreateShader( type );
    
    std::string shaderCode;
    std::ifstream shaderStream( filename, std::ios::in );
    if ( shaderStream.is_open() ) {
        std::string line = "";
        while ( getline( shaderStream, line ) ) {
            shaderCode += "\n" + line;
        }
        shaderStream.close();
    } else {
        fprintf( stderr, "Error loading shader." );
        return;
    }
    
    GLint result = GL_FALSE;
    int infoLogLength;
    
    char const *sourcePoint = shaderCode.c_str();
    glShaderSource( shaderID, 1, &sourcePoint, NULL );
    glCompileShader( shaderID );
    
    glGetShaderiv( shaderID, GL_COMPILE_STATUS, &result );
    glGetShaderiv( shaderID, GL_INFO_LOG_LENGTH, &infoLogLength );
    
    std::vector<char> shaderErrorMessage( infoLogLength );
    glGetShaderInfoLog( shaderID, infoLogLength, NULL, &shaderErrorMessage[ 0 ] );
    // fprintf( stdout, "%s\n", &shaderErrorMessage[ 0 ] );
    
    AttachShader( shaderID );
}
Ejemplo n.º 3
0
void Shader::buildShader(GLuint shaderLoc, const char* fileName) {
	// Read the Vertex Shader code from the file
	std::string shaderCode;
	std::ifstream shaderStream(fileName, std::ios::in);
	if (shaderStream.is_open()) {
		std::string Line = "";
		while (getline(shaderStream, Line))
			shaderCode += "\n" + Line;
		shaderStream.close();
	} else {
		LOG_FATAL(logger) << "Could not open file!";
	}

	// Compile Shader
	char const * sourcePointer = shaderCode.c_str();
	glShaderSource(shaderLoc, 1, &sourcePointer , NULL);
	glCompileShader(shaderLoc);

	// Check Vertex Shader
	GLint Result = GL_FALSE;
	int InfoLogLength;
	glGetShaderiv(shaderLoc, GL_COMPILE_STATUS, &Result);
	glGetShaderiv(shaderLoc, GL_INFO_LOG_LENGTH, &InfoLogLength);
	std::vector<char> shaderErrorMessage(InfoLogLength);
	glGetShaderInfoLog(shaderLoc, InfoLogLength, NULL, &shaderErrorMessage[0]);
	if (!Result)
		LOG_ERROR(logger) << &shaderErrorMessage[0];
}
Ejemplo n.º 4
0
GLint Shader::loadShader(GLint iType, const GLchar *file_path)
{
	GLuint shaderID = glCreateShader(iType);
	std::ifstream shaderStream(file_path, std::ios::in);
	std::string shaderCode = "\0";
	if (shaderStream.is_open())
	{
		std::string sLine = "\0";
		while(getline(shaderStream, sLine))
		{
			shaderCode += "\n" + sLine;
		}
		shaderStream.close();
		if (iType == GL_VERTEX_SHADER)
		{
			sVertexShaderCode = shaderCode;
		}
		else if(iType == GL_FRAGMENT_SHADER)
		{
			sFragmentShaderCode = shaderCode;
		}
		return shaderID;
	}
	else
	{
		printf("Failed to open %s. Are you in the right directory ? \n",
     		file_path);
		getchar();
		return -1;
	}
}
Ejemplo n.º 5
0
/* 

Az http://www.opengl-tutorial.org/ oldal alapján.

*/
GLuint loadShader(GLenum _shaderType, const char* _fileName)
{
	// shader azonosito letrehozasa
	GLuint loadedShader = glCreateShader( _shaderType );

	// ha nem sikerult hibauzenet es -1 visszaadasa
	if ( loadedShader == 0 )
	{
		fprintf(stderr, "Hiba a shader inicializálásakor (glCreateShader) %s!", _fileName);
		return 0;
	}
	
	// shaderkod betoltese _fileName fajlbol
	std::string shaderCode = "";

	// _fileName megnyitasa
	std::ifstream shaderStream(_fileName);

	if ( !shaderStream.is_open() )
	{
		fprintf(stderr, "Hiba a %s shader fájl betöltésekor!", _fileName);
		return 0;
	}

	// file tartalmanak betoltese a shaderCode string-be
	std::string line = "";
	while ( std::getline(shaderStream, line) )
	{
		shaderCode += line + " ";
	}

	shaderStream.close();

	// fajlbol betoltott kod hozzarendelese a shader-hez
	const char* sourcePointer = shaderCode.c_str();
	glShaderSource( loadedShader, 1, &sourcePointer, NULL );

	// shader leforditasa
	glCompileShader( loadedShader );

	// ellenorizzuk, h minden rendben van-e
	GLint result = GL_FALSE;
    int infoLogLength;

	// forditas statuszanak lekerdezese
	glGetShaderiv(loadedShader, GL_COMPILE_STATUS, &result);
	glGetShaderiv(loadedShader, GL_INFO_LOG_LENGTH, &infoLogLength);

	if ( GL_FALSE == result )
	{
		// hibauzenet elkerese es kiirasa
		std::vector<char> VertexShaderErrorMessage(infoLogLength);
		glGetShaderInfoLog(loadedShader, infoLogLength, NULL, &VertexShaderErrorMessage[0]);

		fprintf(stdout, "%s/n", &VertexShaderErrorMessage[0]);
	}

	return loadedShader;
}
Ejemplo n.º 6
0
GLuint GlHelper::CreateShader(GLenum eShaderType, const std::string &strShaderFile) {
    GLuint shader = glCreateShader(eShaderType);
    std::string shaderCode;
    std::ifstream shaderStream(strShaderFile.c_str(), std::ios::in);

    if(shaderStream.is_open()) {
        std::string Line = "";

        while(getline(shaderStream, Line))
            shaderCode += "\n" + Line;

        shaderStream.close();
    } else {
        std::cerr << strShaderFile.c_str() << " dosyasi acilamadi. Uygulamanizi bu dosyanin oldugu dizinde calistirdiginizdan emin olunuz." << std::endl;
        getchar();
        return 0;
    }

    const char* shaderCodePtr = shaderCode.c_str();
    glShaderSource(shader, 1, &shaderCodePtr, NULL);

    glCompileShader(shader);

    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);

    if (status == GL_FALSE)
    {
        GLint infoLogLength;
        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);

        GLchar *strInfoLog = new GLchar[infoLogLength + 1];
        glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
        const char *strShaderType = NULL;

        switch(eShaderType)
        {
        case GL_VERTEX_SHADER:
            strShaderType = "vertex";
            break;

        case GL_GEOMETRY_SHADER:
            strShaderType = "geometry";
            break;

        case GL_FRAGMENT_SHADER:
            strShaderType = "fragment";
            break;
        }

        std::cerr << strShaderType << " tipi shader dosyasi derlenemedi. Detaylar:\n" << strInfoLog << std::endl;
        delete[] strInfoLog;

    }

    return shader;
}
Ejemplo n.º 7
0
GLuint GLHelper::createShader(GLenum eShaderType, const std::string &strShaderFile) {
    GLuint shader = glCreateShader(eShaderType);
    std::string shaderCode;
    std::ifstream shaderStream(strShaderFile.c_str(), std::ios::in);

    if (shaderStream.is_open()) {
        std::string Line = "";

        while (getline(shaderStream, Line))
            shaderCode += "\n" + Line;

        shaderStream.close();
    } else {
        std::cerr << strShaderFile.c_str() <<
        " could not be read. Please ensure run directory if you used relative paths." << std::endl;
        getchar();
        return 0;
    }

    const char *shaderCodePtr = shaderCode.c_str();
    glShaderSource(shader, 1, &shaderCodePtr, NULL);

    glCompileShader(shader);

    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);

    if (status == GL_FALSE) {
        GLint infoLogLength;
        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);

        GLchar *strInfoLog = new GLchar[infoLogLength + 1];
        glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);
        const char *strShaderType = NULL;

        switch (eShaderType) {
            case GL_VERTEX_SHADER:
                strShaderType = "vertex";
                break;

            case GL_GEOMETRY_SHADER:
                strShaderType = "geometry";
                break;

            case GL_FRAGMENT_SHADER:
                strShaderType = "fragment";
                break;
        }

        std::cerr << strShaderType << " type shader " << strShaderFile.c_str() << " could not be compiled:\n" <<
        strInfoLog << std::endl;
        delete[] strInfoLog;

    }
    checkErrors("createShader");
    return shader;
}
Ejemplo n.º 8
0
GLuint CreateShader(GLenum a_eShaderType, const char *a_strShaderFile)
{
	std::string strShaderCode;
	//open shader file
	std::ifstream shaderStream(a_strShaderFile);
	//if that worked ok, load file line by line
	if (shaderStream.is_open())
	{
		std::string Line = "";
		while (std::getline(shaderStream, Line))
		{
			strShaderCode += "\n" + Line;
		}
		shaderStream.close();
	}

	//convert to cstring
	char const *szShaderSourcePointer = strShaderCode.c_str();

	//create shader ID
	GLuint uiShader = glCreateShader(a_eShaderType);
	
	//load source code
	glShaderSource(uiShader, 1, &szShaderSourcePointer, NULL);
	
	//compile shader
	glCompileShader(uiShader);
	

	//Check for compiliation errors and output them
	GLint iStatus;
	glGetShaderiv(uiShader, GL_COMPILE_STATUS, &iStatus);
	if (iStatus == GL_FALSE)
	{
		GLint infoLogLength;
		glGetShaderiv(uiShader, GL_INFO_LOG_LENGTH, &infoLogLength);

		GLchar *strInfoLog = new GLchar[infoLogLength + 1];
		glGetShaderInfoLog(uiShader, infoLogLength, NULL, strInfoLog);

		const char *strShaderType = NULL;
		switch (a_eShaderType)
		{
		case GL_VERTEX_SHADER: strShaderType = "vertex"; break;
		case GL_FRAGMENT_SHADER: strShaderType = "fragment"; break;
		}

		fprintf(stderr, "Compile failure in %s shader:\n%s\n", strShaderType, strInfoLog);
		delete[] strInfoLog;
	}

	return uiShader;
}
Ejemplo n.º 9
0
std::string ShaderProgram::readShaderFile(const char *path) {
    std::string shaderCode;
    std::ifstream shaderStream(path, std::ios::in);
    if(shaderStream.is_open()) {
        std::string line = "";
        while(getline(shaderStream, line)) {
            shaderCode += "\n" + line;
        }
        shaderStream.close();
    } else {
        throw ShaderException(std::string("Could not open file ") + path);
    }

    return shaderCode;
}
Ejemplo n.º 10
0
        GLuint compileShader(const char* shaderPath, GLenum shaderType) {

            // Determine the type of shader
            const char* shaderTypeName = getShaderName(shaderType);
            if(shaderTypeName == NULL) {
                Log::log_render(ERR) << "Unknown Shader Type '" << shaderType << "' Specified For: " << shaderPath;
                return 0;
            }

            // Attempt to read the file path given
            std::string shaderSource;
            std::ifstream shaderStream(shaderPath, std::ios::in);
            if(shaderStream.is_open()) {
                std::string line = "";
                while(getline(shaderStream, line)) shaderSource += "\n" + line;
                shaderStream.close();
            } else {
                Log::log_render(ERR) << "Failed to Open Shader: " << shaderPath;
                return 0;
            }

            GLuint shaderID = glCreateShader(shaderType);
            registeredShaders.push_back(shaderID);
            Log::log_render(INFO) << "Compiling " << shaderTypeName << " Shader [" << shaderID << "]: " << shaderPath;

            // Attempt to compile shader
            const char* sourcePointer = shaderSource.c_str();
            glShaderSource(shaderID, 1, &sourcePointer, NULL);
            glCompileShader(shaderID);

            // Check on compile status
            GLint result = GL_FALSE;
            int infoLogLength;
            glGetShaderiv(shaderID, GL_COMPILE_STATUS, &result);
            glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &infoLogLength);
            char shaderErrorMessage[infoLogLength+1];
            glGetShaderInfoLog(shaderID, infoLogLength, NULL, &shaderErrorMessage[0]);
            if(!result) {
                Log::log_render(ERR) << shaderTypeName << " Shader Error: " << shaderErrorMessage;
                return 0;
            }

            return shaderID;
        }
Ejemplo n.º 11
0
bool CTechnique::AddShader(GLenum shaderType, const char* pFileName)
{
	std::ifstream shaderStream(pFileName, std::ios::in);
	std::string shaderCode;

	if (shaderStream.is_open()) {
		std::string line = "";
		while (std::getline(shaderStream, line))
			shaderCode += "\n" + line;

		shaderStream.close();
	}
	else
		return false;

	GLuint shaderObj = glCreateShader(shaderType);

	if (shaderObj == 0)
		return false;

	m_shaderObjList.push_back(shaderObj);

	const GLchar* p[1];
	p[0] = shaderCode.c_str();
	GLint lengths[1] = { (GLuint)shaderCode.size() };

	glShaderSource(shaderObj, 1, p, lengths);

	glCompileShader(shaderObj);

	GLint success;
	glGetShaderiv(shaderObj, GL_COMPILE_STATUS, &success);

	if (!success) {
		GLchar infoLog[1024];
		glGetShaderInfoLog(shaderObj, 1024, NULL, infoLog);
		OutputDebugStringA(infoLog);
	}

	glAttachShader(m_shaderProg, shaderObj);

	return true;
}
Ejemplo n.º 12
0
std::string APP_OBJLoader::LoadShader(const char *a_filePath)
{
	std::string strShaderCode; //file info holder
	//open shader file
	std::ifstream shaderStream(a_filePath);
	//if that worked ok, load file line by line

	if (shaderStream.is_open())
	{
		std::string Line = "";
		while (std::getline(shaderStream, Line))
		{
			strShaderCode += "\n" + Line;
		}
		shaderStream.close();
	}

	return strShaderCode;
}
Ejemplo n.º 13
0
GLboolean Program::attachShader(std::string filename, GLenum type)
{
	GLuint shaderId = glCreateShader(type);

	std::string shaderCode;
	std::ifstream shaderStream(filename, std::ios::in);
	if(shaderStream.is_open())
	{
		std::string line = "";
		while(getline(shaderStream, line))
			shaderCode += "\n" + line;
		shaderStream.close();
	}
	else
	{
		std::cerr << clog::err << "Cannot open " << filename << "." << std::endl;
		std::cin.get();
		return GL_FALSE;
	}

	GLint result = GL_FALSE;
	GLint infoLogLength;

	//compile vertex shader
	std::cout << clog::inf << "Compiling shader (" << filename << ")..." << std::endl;
	char const* sourcePointer = shaderCode.c_str();
	glShaderSource(shaderId, 1, &sourcePointer , NULL);
	glCompileShader(shaderId);

	//check vertex shader
	glGetShaderiv(shaderId, GL_COMPILE_STATUS, &result);
	glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &infoLogLength);
	if(infoLogLength > 0)
	{
		std::vector<char> shaderErrorMessage(infoLogLength + 1);
		glGetShaderInfoLog(shaderId, infoLogLength, NULL, &shaderErrorMessage[0]);
		std::cerr << clog::err << &shaderErrorMessage[0] << std::endl;
	}

	glAttachShader(instance, shaderId);
	//glDeleteShader(vertexShaderId);
	return GL_TRUE;
}
Ejemplo n.º 14
0
std::string shaderhelper::loadShader(const std::string & shaderFilename)
{
    std::string appPath = pathhelper::getApplicationPath();
    std::string shaderPath = appPath + "/" + shaderFilename;

    std::string shaderCode;

    std::ifstream shaderStream(shaderPath.c_str(), std::ios::in);

    if (shaderStream.is_open()) {
        std::string Line;
        while (getline(shaderStream, Line)) {
            shaderCode += "\n" + Line;
        }
        shaderStream.close();
    } else {
        throw std::invalid_argument("Unable to open " + shaderPath);
    }

    return shaderCode;
}
Ejemplo n.º 15
0
/// <summary>
/// Loads the shader.
/// </summary>
/// <param name="filename">The filename.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
GLuint ShaderProgram::LoadShader( const std::string& filename, GLenum type )
{
	// Create the shader
	GLuint shaderID = glCreateShader( type );

	// Read the Shader code from the file
	std::string shaderCode;
	std::ifstream shaderStream( filename, std::ios::in );
	if( shaderStream.is_open() )
	{
		std::string line = "";
		while( getline( shaderStream, line ) )
			shaderCode += "\n" + line;
		shaderStream.close();
	}
	else
	{
		Debug::Log( "Could not find shader with path: " + filename );
		return 0;
	}

	GLint result = GL_FALSE;
	int infoLogLength;

	// Compile Shader
	Debug::Log( "Compiling shader: " + filename );
	char const * sourcePointer = shaderCode.c_str();
	glShaderSource( shaderID, 1, &sourcePointer, NULL );
	glCompileShader( shaderID );

	// Check Shader
	glGetShaderiv( shaderID, GL_COMPILE_STATUS, &result );
	glGetShaderiv( shaderID, GL_INFO_LOG_LENGTH, &infoLogLength );
	std::vector<char> shaderErrorMessage( infoLogLength );
	glGetShaderInfoLog( shaderID, infoLogLength, NULL, &shaderErrorMessage[0] );
	Debug::Log( trim( std::string( shaderErrorMessage.begin(), shaderErrorMessage.end() ) ), LogType::Error );

	CHECK_GL_ERROR();
	return shaderID;
}
Ejemplo n.º 16
0
void modifyShader(std::string& shader)
{
    std::istringstream shaderStream(shader);
    std::string line;
    std::getline(shaderStream, line);
    std::string mod_shader("#version 300 es\n");

    std::unordered_map<std::string, int>::iterator it;
    std::unordered_map<std::string, int>::iterator it1;
    while (std::getline(shaderStream, line))
    {
        if (line.find("GL_ARB_separate_shader_objects") != std::string::npos ||
            line.find("GL_ARB_shading_language_420pack") != std::string::npos)
            continue;

        std::unordered_map<std::string, int> tokens;
        getTokens(tokens, line);

        if ((it = tokens.find("uniform")) != tokens.end() && checkSamplers(tokens)){
            int layout_pos = tokens["layout"];
            mod_shader += ((layout_pos > 0) ? line.substr(0, layout_pos) : "") + line.substr(it->second) + "\n";

        }
        else if ((it = tokens.find("layout")) != tokens.end() && tokens.find("uniform")==tokens.end() && tokens.find("num_views") == tokens.end()) {
            it1 = tokens.find("in");
            if (it1 == tokens.end())
                it1 = tokens.find("out");
            int pos = it->second;

            if(it1 != tokens.end())
            mod_shader += ((pos > 0) ? line.substr(0, pos) : "") + line.substr(it1->second) + "\n";
        }
        else
            {
            mod_shader += line + "\n";
        }
    }
    shader = mod_shader;
}
Ejemplo n.º 17
0
GLuint loadShader(string file_path, GLuint shader)
{
	GLuint shaderID = glCreateShader(shader);

	string shaderCode;
	ifstream shaderStream(file_path, std::ios::in);
	if (shaderStream.is_open())
	{
		string Line = "";
		while (getline(shaderStream, Line)) shaderCode += "\n" + Line;
		shaderStream.close();
	}
	else
	{
		cerr << "Cannot open: " << file_path << endl;
		return 0;
	}

	cout << "Compiling shader: " << file_path << endl;
	char const* sourcePointer = shaderCode.c_str();
	glShaderSource(shaderID, 1, &sourcePointer, NULL);
	glCompileShader(shaderID);

	GLint result = 0;

	glGetShaderiv(shaderID, GL_COMPILE_STATUS, &result);
	if (result == GL_FALSE)
	{
		GLint infoLogLength = 0;
		glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &infoLogLength);
		vector<char> shaderErrorMessage(infoLogLength);
		glGetShaderInfoLog(shaderID, infoLogLength, NULL, &shaderErrorMessage[0]);
		cerr << &shaderErrorMessage[0] << endl;
		return 0;
	}

	return shaderID;
}
Ejemplo n.º 18
0
bool Shader::loadShader(const char * filePath, shader_type_t shaderType) {
	std::string shaderCode;

	std::ifstream shaderStream(filePath, std::ios::in);
	if (shaderStream.is_open()) {
		std::string line = "";
		while (getline(shaderStream, line)) {
			shaderCode += '\n' + line;
		}
		shaderStream.close();
	} else {
		std::cerr << "Couldn't open file\n";
		return false;
	}

	shaderID = glCreateShader(shaderType);

	const char * sourcePointer = shaderCode.c_str();
	glShaderSource(shaderID, 1, &sourcePointer, NULL);
	glCompileShader(shaderID);

	int compilationStatus = 0;
	glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compilationStatus);

	if (compilationStatus == GL_FALSE) {
		char infoLog[1024];
		int logLength;
		glGetShaderInfoLog(shaderID, 1024, &logLength, infoLog);
		std::cerr << "Error! Shader File " << filePath << " wasn't compiled! The compiler returned:\n\n" << infoLog << '\n';
		return false;
	}

	this->shaderType = shaderType;
	loaded = true;

	return true;
}
Ejemplo n.º 19
0
std::string APP_SpotRotate::LoadShader(const char *a_filePath)
{
    std::string strShaderCode; //file info holder
    //open shader file
    std::ifstream shaderStream(a_filePath);
    //if that worked ok, load file line by line

    if (shaderStream.is_open())
    {
        std::string Line = "";
        while (std::getline(shaderStream, Line))
        {
            strShaderCode += "\n" + Line;
        }
        shaderStream.close();
    }

    //a_shaderResult = strShaderCode.c_str();
    //const char* result = strShaderCode.c_str();

    //(_result) = (*result);

    return strShaderCode; //not in use
}
Ejemplo n.º 20
0
bool 
ShaderD3D11::createEffect ()
{
    try
    {        
        uint32_t hlslFlags = 0;

        {
            hlslFlags = D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY;
        }
    
        ID3D10Blob * shaderCode = 0;
        ID3D10Blob * errors = 0;

        std::vector<D3D10_SHADER_MACRO>       vectorDefines;
        if (_defines.size() > 0)
        {
            for (auto it = _defines.begin(); it != _defines.end(); it++)
            {
                D3D10_SHADER_MACRO macro = {(*it).first.c_str(), (*it).second.c_str()};
                vectorDefines.push_back (macro);
            }
            D3D10_SHADER_MACRO nullMacro = {0, 0};
            vectorDefines.push_back (nullMacro);
            
            _hash.build(shaderStream());
        
            if(FAILED(D3DCompile(shaderStream().c_str(), shaderStream().size(), 0, (const D3D_SHADER_MACRO*)&*vectorDefines.begin(), nullptr, "", "fx_5_0", 
                                  hlslFlags, 0, &shaderCode, &errors)))
            { 
        
                // LOG ("Failed to compile ... " << shaderStream() << "\n");
                LOG ("Failed to compile " << IShader::filePathName());
        
                if(errors) 
                { 
        
                    char* buffer = new char[errors->GetBufferSize()+1];
                    memset(&buffer[0], 0, errors->GetBufferSize()+1);
                    memcpy(&buffer[0], errors->GetBufferPointer(), errors->GetBufferSize());
                    // LOG ("Error Compiling ShaderD3D11" << buffer);
        
                    generateDumpFile(IShader::filePathName(), buffer, shaderStream());
        
                    delete[] (buffer);
                } 
        
                return false;
            } 
        }
        else
        {
            _hash.build(shaderStream());
            if(FAILED(D3DCompile(shaderStream().c_str(), shaderStream().size(), 0, 0, nullptr, "", "fx_5_0", 
                                 D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_SKIP_OPTIMIZATION
                                 , 0,  &shaderCode, &errors)))
            { 
                LOG ("Failed to compile " << IShader::filePathName());
        
                // Open file and dump error information.
        
                if(errors) 
                { 
                    char* buffer = new char[errors->GetBufferSize()+1];
                    memset(&buffer[0], 0, errors->GetBufferSize()+1);
                    memcpy(&buffer[0], errors->GetBufferPointer(), errors->GetBufferSize());
                    generateDumpFile(IShader::filePathName(), buffer, shaderStream());
                    LOG ("Error Compiling ShaderD3D11" << buffer);
                    delete[] (buffer);
                } 
                return false;
            }
        }
        
        safedeletearray (_compiledBuffer);
        _compiledBufferSize = shaderCode->GetBufferSize();
        _compiledBuffer = new char[_compiledBufferSize];
        memcpy (_compiledBuffer, shaderCode->GetBufferPointer(), _compiledBufferSize * sizeof(char));
     
        // Create effect 
        ID3DX11Effect* effect = 0;
        if(FAILED(D3DX11CreateEffectFromMemory(_compiledBuffer, _compiledBufferSize, 0, _direct3d, &effect))) 
        { 
            LOG ("FAILED to create effect from memory ... \n");
        } 
        else
        {
            _effect = new EffectD3D11 (effect);
            return true;
        }
    }
    catch(...)
    {
        LOG ("Something bad and unknown happened while creating the shader");
    }
    return false;
}