Extract OpenGL shader attribute bindings
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "shader.h"
|
||||
#include "asset.h"
|
||||
#include "app.h"
|
||||
#include "renderer_gl/shader_bindings.h"
|
||||
|
||||
std::map<kShader, Shader> ShaderManager::m_shaders;
|
||||
Shader* ShaderManager::m_current;
|
||||
@@ -230,20 +231,11 @@ bool Shader::create(const std::string& vertex, const std::string& fragment)
|
||||
glDeleteShader(fs);
|
||||
|
||||
glLinkProgram(ps);
|
||||
if (glGetAttribLocation(ps, "pos") != -1)
|
||||
glBindAttribLocation(ps, 0, "pos");
|
||||
|
||||
if (glGetAttribLocation(ps, "uvs") != -1)
|
||||
glBindAttribLocation(ps, 1, "uvs");
|
||||
|
||||
if (glGetAttribLocation(ps, "uvs2") != -1)
|
||||
glBindAttribLocation(ps, 2, "uvs2");
|
||||
|
||||
if (glGetAttribLocation(ps, "col") != -1)
|
||||
glBindAttribLocation(ps, 3, "col");
|
||||
|
||||
if (glGetAttribLocation(ps, "nor") != -1)
|
||||
glBindAttribLocation(ps, 3, "nor");
|
||||
for (const auto& binding : pp::renderer::gl::panopainter_shader_attribute_bindings())
|
||||
{
|
||||
if (glGetAttribLocation(ps, binding.name) != -1)
|
||||
glBindAttribLocation(ps, static_cast<GLuint>(binding.location), binding.name);
|
||||
}
|
||||
|
||||
glLinkProgram(ps);
|
||||
glGetProgramiv(ps, GL_LINK_STATUS, &status);
|
||||
|
||||
Reference in New Issue
Block a user