Commit 7daeaaba authored by Thibault Soucarre's avatar Thibault Soucarre

correct a bug causing states to use the default shader despite the shader...

correct a bug causing states to use the default shader despite the shader associated to them by the map
parent 5db8c995
......@@ -203,21 +203,22 @@ void Render_alternate::paintGL(){
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate, _z_state));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1));
mvp = _projection * _modelview;
std::map<const StateType*, Vbo>::iterator it_state;
std::map<const StateType*, Vbo*>::iterator it_state;
it_state = _states.begin();
while(it_state!=_states.end()){
Shader *s = &(_states_shaders[it_state->first]);
Shader *s = _states_shaders[it_state->first];
glUseProgram(s->getProgramID());
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
it_state->second.lock();
glUniformMatrix4fv(glGetUniformLocation(s->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
it_state->second->lock();
//_states.lock();
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glDrawArrays(GL_QUADS, 0, it_state->second.getNbVertex());
it_state->second.unlock();
glDrawArrays(GL_QUADS, 0, it_state->second->getNbVertex());
it_state->second->unlock();
it_state++;
//_modelview = tmp;
}
glUseProgram(_shader.getProgramID());
/*drawing counters*/
_counters.lock();
glDrawArrays(GL_LINES, 0, _counters.getNbVertex());
......@@ -747,24 +748,25 @@ void Render_alternate::start_draw_states(){
void Render_alternate::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, const StateType* type){
if(!_states.count(type)){
Shader s;
std::pair<const StateType*, Shader> p(type, s);
Shader *s = new Shader();
s->charger();
std::pair<const StateType*, Shader*> p(type, s);
_states_shaders.insert(p);
Vbo v(GL_QUADS);
std::pair<const StateType*, Vbo> p2(type, v);
Vbo *v = new Vbo(GL_QUADS);
std::pair<const StateType*, Vbo*> p2(type, v);
_states.insert(p2);
}
_current = &(_states[type]);
_current = _states[type];
draw_quad(x, y, z, w, h);
}
void Render_alternate::end_draw_states(){
_draw_states = false;
std::map<const StateType*, Vbo>::iterator it;
std::map<const StateType*, Vbo*>::iterator it;
it = _states.begin();
while(it!=_states.end()){
it->second.config();
it->second->config();
it++;
}
//_states.config();
......
......@@ -108,8 +108,8 @@ private:
Vbo _counters;
Vbo _ruler;
Vbo *_current;
std::map<const StateType*, Vbo> _states;
std::map<const StateType*, Shader> _states_shaders;
std::map<const StateType*, Vbo*> _states;
std::map<const StateType*, Shader*> _states_shaders;
/*!
* \brief Offset of the vertical helper line
*/
......
......@@ -9,7 +9,7 @@
}
*/
Shader::Shader(Shader const &shaderACopier)
/*Shader::Shader(Shader const &shaderACopier)
{
// Copie des fichiers sources
......@@ -20,7 +20,7 @@ Shader::Shader(Shader const &shaderACopier)
// Chargement du nouveau shader
charger();
}
}*/
Shader::Shader() : m_vertexID(0), m_fragmentID(0), m_programID(0),
......
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