bool GLCgShader::LoadShaderFromFile( ShaderContextPtr context, const str_type::string& fileName, const SHADER_FOCUS focus, const SHADER_PROFILE profile, const char *entry) { const std::string& str = enml::GetStringFromAnsiFile(fileName); return LoadShaderFromString(context, fileName, str, focus, profile, entry); }
bool GLVideo::StartApplication( const unsigned int width, const unsigned int height, const str_type::string& winTitle, const bool windowed, const bool sync, const Texture::PIXEL_FORMAT pfBB, const bool maximizable) { SetFilterMode(Video::TM_ALWAYS); SetAlphaMode(Video::AM_PIXEL); SetZBuffer(false); SetZWrite(false); SetClamp(true); SetBlendMode(1, Video::BM_MODULATE); Enable2DStates(); // don't reset cg context if it is an opengl context reset if (!m_shaderContext) m_shaderContext = GLCgShaderContextPtr(new GLCgShaderContext); if (!m_defaultVS) m_defaultVS = LoadShaderFromString("defaultShader", gs2dglobal::defaultVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "sprite"); if (!m_rectVS) m_rectVS = LoadShaderFromString("rectShader", gs2dglobal::defaultVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "rectangle"); if (!m_fastVS) m_fastVS = LoadShaderFromString("fastShader", gs2dglobal::fastSimpleVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "fast"); m_currentVS = m_defaultVS; UpdateInternalShadersViewData(GetScreenSizeF(), false); return true; }
GLuint ShaderProgram::LoadShaderFromFile(const std::string &shaderFile, GLenum type) { //Open a file stream with the file name std::ifstream infile(shaderFile); if(infile.fail()) { std::cout << "Error opening shader file:" << shaderFile << std::endl; } //Create a string buffer and stream the file to it std::stringstream buffer; buffer << infile.rdbuf(); // Load the shader from the contents of the file return LoadShaderFromString(buffer.str(), type); }
bool GLES2Shader::LoadShaderFromFile( ShaderContextPtr context, const str_type::string& fileName, const Shader::SHADER_FOCUS focus, const Shader::SHADER_PROFILE profile, const char *entry) { str_type::string content; if (!m_zip->GetAnsiFileString(fileName, content)) { m_context->Log(str_type::string("couldn't open ") + fileName, Platform::FileLogger::ERROR); return false; } return LoadShaderFromString(context, fileName, content, focus, profile, 0); }