代码拉取完成,页面将自动刷新
同步操作将从 2144/Gut 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "Shader.h"
bool ShaderFile::CreateFromFile(std::string path, int type)
{
bool gr = true;
std::ifstream ifs(path, std::ios::in);
if (!ifs.is_open())
{
LOGI("cannot open file %s [path]", path.c_str());
ifs.close();
return false;
}
std::string text = std::string((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>()));
gr = CreateFrom(text.c_str(), type);
ifs.close();
return gr;
}
bool Shader::CreateFromCode(const char* vcode, const char* fcode)
{
ShaderFile vFile;
ShaderFile fFile;
ThrowIfFailed(vFile.CreateFrom(vcode, GL_VERTEX_SHADER));
ThrowIfFailed(fFile.CreateFrom(fcode, GL_FRAGMENT_SHADER));
this->ID = glCreateProgram();
glAttachShader(this->ID, vFile.id);
glAttachShader(this->ID, fFile.id);
glLinkProgram(ID);
return true;
}
bool Shader::CreateFromFile(ShaderFile vFile, ShaderFile fFile)
{
this->ID = glCreateProgram();
glAttachShader(this->ID, vFile.id);
glAttachShader(this->ID, fFile.id);
glLinkProgram(ID);
return true;
}
bool Shader::CreateFromFilePath(std::string vPath, std::string fPath)
{
bool gr;
ShaderFile vFile;
ShaderFile fFile;
ThrowIfFailed(vFile.CreateFromFile(vPath, GL_VERTEX_SHADER));
ThrowIfFailed(fFile.CreateFromFile(fPath, GL_FRAGMENT_SHADER));
return CreateFromFile(vFile, fFile);
}
bool ShaderCode::CreateFrom(const char* code, int type)
{
this->id = glCreateShader(type);
glShaderSource(id, 1, &code, NULL);
glCompileShader(id);
if (!checkCompileErrors(id, GetShaderType(type)))
{
return false;
}
return true;
}
void ShaderCode::Release()
{
glDeleteShader(this->id);
}
void Shader::Use()
{
glUseProgram(ID);
}
void Shader::Create()
{
ID=glCreateProgram();
}
void Shader::Release()
{
glDeleteProgram(this->ID);
}
void Shader::Link()
{
glLinkProgram(ID);
}
void Shader::UnUse()
{
glUseProgram(0);
}
#ifdef WIN32
bool Shader::CreateFormFile(ShaderFile vFile, ShaderFile gFile, ShaderFile fFile)
{
this->ID = glCreateProgram();
glAttachShader(this->ID, vFile.id);
glAttachShader(this->ID, gFile.id);
glAttachShader(this->ID, fFile.id);
glLinkProgram(ID);
return true;
}
bool Shader::CreateFromFilePath(std::string vPath, std::string gPath, std::string fPath)
{
ShaderFile vFile;
ShaderFile gFile;
ShaderFile fFile;
ThrowIfFailed(vFile.CreateFromFile(vPath, GL_VERTEX_SHADER));
ThrowIfFailed(gFile.CreateFromFile(gPath, GL_GEOMETRY_SHADER));
ThrowIfFailed(fFile.CreateFromFile(fPath, GL_FRAGMENT_SHADER));
return CreateFormFile(vFile, gFile, fFile);
}
#endif // DEBUG
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。