Commit e3ee56f2 authored by Johannes Braun's avatar Johannes Braun
Browse files

Enabled only one instance of each shader type per shader program. Closes #37

parent 72ac9a19
......@@ -5,7 +5,12 @@ namespace glare::core
Program::Program(const std::vector<std::shared_ptr<Shader>> &shaders)
{
for (const auto &shader : shaders)
{
if (m_shader_stages.find(shader->type()) != m_shader_stages.end())
throw std::invalid_argument("Can't attach more than one of shader type id " + std::to_string(static_cast<unsigned>(shader->type())) + " to a program.");
gl::attachShader(m_handle, shader->id());
m_shader_stages.insert(shader->type());
}
gl::linkProgram(m_handle);
int success = 0;
......@@ -80,7 +85,6 @@ namespace glare::core
{
for (auto &&shader : shaders)
{
m_shader_stages.push_back(shader->type());
int num_subroutines;
gl::getProgramStageiv(m_handle, shader->type(), gl::ProgramParameter::eActiveSubroutines, &num_subroutines);
int max_length;
......
......@@ -3,6 +3,7 @@
#include <map>
#include <string>
#include <set>
#include <glm/ext.hpp>
#include <util/opengl.h>
......@@ -93,7 +94,7 @@ namespace glare::core
gl::handle::shader_program m_handle;
std::map<std::string, UniformInfo> m_uniforms;
std::map<std::string, std::map<gl::ShaderType, SubroutineInfo>> m_subroutines;
std::vector<gl::ShaderType> m_shader_stages;
std::set<gl::ShaderType> m_shader_stages;
std::map<gl::ShaderType, std::vector<unsigned>> m_subroutine_bindings;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment