Commit 41360356 authored by Thibault Soucarre's avatar Thibault Soucarre

add vertical line

parent a75f53a2
......@@ -305,6 +305,7 @@ void Render_alternate::paintGL(){
glDisable(GL_BLEND);
_modelview = tmp;
}
draw_vertical_line();
// _containers.display(_modelview);
glDisable(GL_DEPTH_TEST);
......@@ -1240,17 +1241,48 @@ void Render_alternate::show_minimap(){
*/
void Render_alternate::draw_vertical_line(){
std::cout << "salut" << vertical_line << std::endl;
if(vertical_line==0)
return;
std::cout << "je sais pas dessiner lol" << std::endl;
double vertex[4] = {trace_to_render_x(vertical_line),
0.0,
trace_to_render_x(vertical_line),
Info::Render::height};
double colors[6] = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glVertexAttribPointer(0, 2, GL_DOUBLE, GL_FALSE, 0, vertex);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_DOUBLE, GL_FALSE, 0, colors);
glEnableVertexAttribArray(1);
glDrawArrays(GL_LINES, 0, 2);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
/*!
* \brief slot connected to the simple click event
*/
void Render_alternate::update_vertical_line(){
if (_mouse_pressed_inside_container)
set_vertical_line(0);
else
set_vertical_line(render_to_trace_x( screen_to_render_x(_mouse_x)));
updateGL();
}
/*!
* \brief set the vertical line offset
* \param l the line offset.
*/
void Render_alternate::set_vertical_line(Element_pos l){
void Render_alternate::set_vertical_line(Element_pos new_coord){
if(new_coord==vertical_line)vertical_line=0;
else vertical_line=new_coord;
}
Element_pos Render_alternate::get_vertical_line(){
return vertical_line;
}
......@@ -97,6 +97,11 @@ private:
std::vector<Element_pos> _events;
glm::mat4 _modelview;
glm::mat4 _projection;
/*!
* \brief Offset of the vertical helper line
*/
Element_pos vertical_line;
protected:
/*!
......@@ -532,18 +537,25 @@ public:
void draw_vertical_line();
/*!
* \brief slot connected to the simple click event
*/
void update_vertical_line();
/*!
* \brief set the vertical line offset
* \param l the line offset.
*/
void set_vertical_line(Element_pos l);
};
/*!
* \brief returns the offset of the vertical helper line
*/
Element_pos get_vertical_line();
public slots:
/*!
* \brief slot connected to the simple click event
*/
void update_vertical_line();
};
#endif
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