update UTI, remove blur from CompDraw mask
This commit is contained in:
@@ -53,7 +53,7 @@ std::string Shader::read(const std::string& path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Shader::parse_error(const char* msg, const char* code)
|
||||
void Shader::parse_error(const std::string& msg, const std::string& code)
|
||||
{
|
||||
auto code_lines = split(code, '\n');
|
||||
auto error_lines = split(msg, '\n');
|
||||
@@ -110,7 +110,7 @@ bool Shader::load(const std::string& path)
|
||||
{
|
||||
*sections["vertex"] = SHADER_VERSION + *sections["vertex"];
|
||||
*sections["fragment"] = SHADER_VERSION + *sections["fragment"];
|
||||
if (create(sections["vertex"]->c_str(), sections["fragment"]->c_str()))
|
||||
if (create(*sections["vertex"], *sections["fragment"]))
|
||||
{
|
||||
m_path = path;
|
||||
return true;
|
||||
@@ -152,10 +152,10 @@ bool Shader::reload()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Shader::create(const char* vertex, const char* fragment)
|
||||
bool Shader::create(const std::string& vertex, const std::string& fragment)
|
||||
{
|
||||
bool ret = true;
|
||||
App::I->render_task([&]
|
||||
App::I->render_task([this, &ret, vertex, fragment]
|
||||
{
|
||||
GLint status;
|
||||
static char infolog[4096];
|
||||
@@ -168,7 +168,7 @@ bool Shader::create(const char* vertex, const char* fragment)
|
||||
ret = false;
|
||||
return;
|
||||
}
|
||||
source = vertex;
|
||||
source = vertex.c_str();
|
||||
glShaderSource(vs, 1, &source, nullptr);
|
||||
glCompileShader(vs);
|
||||
glGetShaderiv(vs, GL_COMPILE_STATUS, &status);
|
||||
@@ -192,7 +192,7 @@ bool Shader::create(const char* vertex, const char* fragment)
|
||||
ret = false;
|
||||
return;
|
||||
}
|
||||
source = fragment;
|
||||
source = fragment.c_str();
|
||||
glShaderSource(fs, 1, &source, nullptr);
|
||||
glCompileShader(fs);
|
||||
glGetShaderiv(fs, GL_COMPILE_STATUS, &status);
|
||||
@@ -256,14 +256,18 @@ bool Shader::create(const char* vertex, const char* fragment)
|
||||
GLint count;
|
||||
GLint size; // size of the variable
|
||||
GLenum type; // type of the variable (float, vec3 or mat4, etc)
|
||||
const GLsizei bufSize = 16; // maximum name length
|
||||
const GLsizei bufSize = 64; // maximum name length
|
||||
GLchar name[bufSize]; // variable name in GLSL
|
||||
GLsizei length; // name length
|
||||
glGetProgramiv(ps, GL_ACTIVE_UNIFORMS, &count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
glGetActiveUniform(ps, (GLuint)i, bufSize, &length, &size, &type, name);
|
||||
m_umap[(kShaderUniform)const_hash(name)] = glGetUniformLocation(ps, name);
|
||||
name[length] = 0;
|
||||
kShaderUniform id = (kShaderUniform)const_hash(name);
|
||||
if (m_umap.find(id) != m_umap.end())
|
||||
LOG("UNIFORM ALREADY DEFINED: %s", name);
|
||||
m_umap[id] = glGetUniformLocation(ps, name);
|
||||
//printf("Uniform #%d Type: %u Name: %s Loc: %d\n", i, type, name, glGetUniformLocation(ps, name));
|
||||
}
|
||||
}
|
||||
@@ -325,6 +329,10 @@ void Shader::u_int(kShaderUniform id, int i)
|
||||
else
|
||||
glUniform1i(m_umap[id], i);
|
||||
}
|
||||
void Shader::u_int(const char* name, int i)
|
||||
{
|
||||
glUniform1i(glGetAttribLocation(prog, name), i);
|
||||
}
|
||||
void Shader::u_float(kShaderUniform id, float f)
|
||||
{
|
||||
if (m_umap.count(id) == 0)
|
||||
@@ -350,7 +358,7 @@ bool ShaderManager::reload()
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ShaderManager::create(kShader id, const char* vertex, const char* fragment)
|
||||
bool ShaderManager::create(kShader id, const std::string& vertex, const std::string& fragment)
|
||||
{
|
||||
m_shaders[id].name = id;
|
||||
return m_shaders[id].create(vertex, fragment);
|
||||
@@ -393,6 +401,11 @@ void ShaderManager::u_int(kShaderUniform id, int i)
|
||||
m_current->u_int(id, i);
|
||||
}
|
||||
|
||||
void ShaderManager::u_int(const char* name, int i)
|
||||
{
|
||||
m_current->u_int(name, i);
|
||||
}
|
||||
|
||||
Shader* ShaderManager::get(kShader id)
|
||||
{
|
||||
auto it = m_shaders.find(id);
|
||||
|
||||
Reference in New Issue
Block a user