Commit 45667617 authored by Thibault Soucarre's avatar Thibault Soucarre

remove some lines that aren't used anymore

parent be3e461c
......@@ -98,7 +98,7 @@ static bool _draw_counter;
**********************************/
Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format)
: Hook_event(this, core, parent, format), _containers(GL_QUADS), /*_states(GL_QUADS),*/ _events(GL_POINTS), _events2(GL_LINES), _arrows(GL_LINE), _arrows2(GL_TRIANGLES), _counters(GL_LINE), _ruler(GL_QUADS), /*_shader("vertexshader.vertexshader", "fragmentshader.fragmentshader"),*/ _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)), _container_height(_DRAWING_CONTAINER_HEIGHT_DEFAULT){
: Hook_event(this, core, parent, format), _containers(GL_QUADS), /*_states(GL_QUADS),*/ _events(GL_POINTS), _events2(GL_LINES), _arrows(GL_LINE), _arrows2(GL_TRIANGLES), _counters(GL_LINE), _ruler(GL_QUADS), _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)), _container_height(_DRAWING_CONTAINER_HEIGHT_DEFAULT){
}
......@@ -122,7 +122,6 @@ void Render_alternate::initializeGL() {
if(err!=GLEW_OK){
std::cout << "ERROR : GlewInit failed" << std::endl;
}
//_shader.charger();
glClearColor(0.5f, 0.5f, 0.55f, 0.0f);
glEnable(GL_DEPTH_TEST);
glClearStencil(0);
......@@ -139,8 +138,6 @@ void Render_alternate::initializeGL() {
_shader->charger();
_wait_shader->charger();
draw_wait();
//std::cout << version[2] << std::endl;
//std::cout << version[3] << std::endl;
setAutoFillBackground(false);
if(_core == NULL)
std::cout << "_core = NULL" << std::endl;
......@@ -170,7 +167,7 @@ void Render_alternate::resizeGL(int width, int height) {
void Render_alternate::paintGL(){
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*Do not call paintGL before rendering the trace*/
/*Draw the home screen*/
if(DRAWING_STATE_WAITING == _state){
glUseProgram(_wait_shader->getProgramID());
glEnable(GL_BLEND);
......@@ -184,6 +181,7 @@ void Render_alternate::paintGL(){
glUseProgram(0);
return;
}
/*Else, draw the trace*/
resizeGL(Render_alternate::QGLWidget::width(), Render_alternate::QGLWidget::height());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......@@ -200,15 +198,12 @@ void Render_alternate::paintGL(){
_ruler.lock();
_modelview = glm::translate(_modelview, glm::vec3(0.0, 0.0, _z_ruler));
mvp = _projection * _modelview;
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
glDrawArrays(GL_QUADS, 0, 8);
_modelview = tmp;
_modelview = glm::translate(_modelview, glm::vec3(0.0, 0.0, _z_ruler_over));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glDrawArrays(GL_LINES, 8, _ruler.getNbVertex());
_ruler.unlock();
_modelview = tmp;
......@@ -219,8 +214,6 @@ void Render_alternate::paintGL(){
_modelview = glm::scale(_modelview, glm::vec3(_x_scale_container_state/0.20, _y_state_scale, 1.0));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//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, _containers.getNbVertex());
_containers.unlock();
_modelview = tmp;
......@@ -232,54 +225,35 @@ void Render_alternate::paintGL(){
std::map<const EntityValue*, Vbo*>::iterator it_state;
it_state = _states.begin();
while(it_state!=_states.end()){
//std::cout << "drawing states" << std::endl;
Shader *s = _states_shaders[it_state->first];
glUseProgram(s->getProgramID());
//glUniform1i(glGetUniformLocation(s->getProgramID(), "i"), 0);
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));
//glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0 , sizeof(GLuint), a);
glUniformMatrix4fv(glGetUniformLocation(s->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
glDrawArrays(GL_QUADS, 0, it_state->second->getNbVertex());
it_state->second->unlock();
it_state++;
//_modelview = tmp;
}
glUseProgram(_shader->getProgramID());
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
/*drawing counters*/
_counters.lock();
glDrawArrays(GL_LINES, 0, _counters.getNbVertex());
_counters.unlock();
_modelview = tmp;
/*drawing links*/
//int n = _links.size()/4;
if(false == Info::Render::_no_arrows){
//necessary for each link
//matrix change that are necessary for each link
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , _z_arrow));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
//_modelview = tmp2;
//mvp = _projection * _modelview;
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//save current modelview
//tmp2 = _modelview;
//draw the line
_arrows.lock();
/*for(int i=0; i<n ; i++) {
//change matrix to draw the current arrow
_modelview = glm::translate(_modelview, glm::vec3(_links[4*i+2], _links[4*i+3], 0));
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
_modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));*/
//draw the arrow
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//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_LINES, 0, _arrows.getNbVertex());
//_modelview = tmp2;
//}
_arrows.unlock();
//draw the head of the arrow according to the parameter arrows_shape
int n = _links.size()/4;
switch(Info::Render::_arrows_shape){
case 0: //triangles
......@@ -295,9 +269,6 @@ void Render_alternate::paintGL(){
_modelview = tmp2;
}
_arrows3.unlock();
// _modelview = tmp2;
//}
_arrows2.unlock();
break;
case 1: //points
_arrows2.lock();
......@@ -308,38 +279,17 @@ void Render_alternate::paintGL(){
break;
}
_modelview = tmp;
//_arrows.unlock();
//restore matrix with changes needed for all links
//}
//_arrows.unlock();
//_modelview = tmp2;
//_modelview = glm::translate(_modelview, glm::vec3(_x_state_scale*(_default_entity_x_translate - _x_state_translate), _y_state_scale*(_ruler_y + _ruler_height - _y_state_translate), _z_arrow));
//mvp = _projection * _modelview;
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
/*_modelview = tmp2;
for (int i=0; i<n;i++){
_modelview = glm::translate(_modelview, glm::vec3(_x_state_scale*_links[3*i+1], _y_state_scale*_links[3*i+2], 0));
_modelview = glm::rotate(_modelview, (float) _links[3*i], glm::vec3(0,0,1));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
_arrows2.lock();
glDrawArrays(GL_TRIANGLES, 0, _arrows2.getNbVertex());
_arrows2.unlock();
//restore basic matrix
_modelview = tmp2;*/
}
//}
}
/*drawing events*/
if(false == Info::Render::_no_events){
//necessary for each event
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , _z_event));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
_events.lock();
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
/*draw points as circles instead of squares*/
glEnable(GL_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SMOOTH);
glPointSize(5);
......@@ -361,15 +311,13 @@ void Render_alternate::paintGL(){
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Element_pos x0, x1, y0, y1;
x0 = screen_to_render_x(_mouse_x);
y0 = /*Info::Render::height -*/ screen_to_render_y(_mouse_y);
y0 = screen_to_render_y(_mouse_y);
x1 = screen_to_render_x(_new_mouse_x);
y1 = /*Info::Render::height -*/ screen_to_render_y(_new_mouse_y);
y1 = screen_to_render_y(_new_mouse_y);
float selection[12] = {x0, y0, x0, y1, x1, y1, x1, y0};
float selection_colors[16] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//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_FLOAT, GL_FALSE, 0, selection);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, selection_colors);
......@@ -641,39 +589,6 @@ GLuint Render_alternate::draw_wait() {
_wait.add( 0.25, 0.25, 1, 1);
_wait.add(-0.25, 0.25, 0, 1);
_wait.config(_glsl);
// GLuint object;
// GLuint texture;
// glGenTextures(1, &texture);/* create the texture and link it with the list previously created */
// QFile texture_file(QString(":/img/img/logo") + QDate::currentDate().toString("MMdd") + QString(".png"));
// if (true == texture_file.exists())/* The texture exists */
// texture = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
// else/* use the default picture */
// texture = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
// /* apply some parameters on the texture */
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// glEnable(GL_TEXTURE_2D);
// glEnable(GL_BLEND);/* enable blending for the alpha color */
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// /* Now, timer is set */
// if (_wait_timer == NULL){
// _wait_angle = 0.0f;
// /*
// _wait_timer = new QTimer(this);
// connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL()));
// _wait_timer->start(_wait_spf);*/
// }
// return object;
}
......@@ -751,18 +666,18 @@ void Render_alternate::draw_quad(Element_pos x, Element_pos y, Element_pos z, El
else if(_draw_states){
offset_x = -_default_entity_x_translate;
if(_glsl<330) {
_current->add(x+offset_x , y+offset_y, 2.0f);// , _r, _g, _b);
_current->add(x+offset_x+w, y+offset_y, 1.0f);// , _r/2, _g/2, _b/2);
_current->add(x+offset_x+w, y+offset_y+h, 1.0f);//, _r/2, _g/2, _b/2);
_current->add(x+offset_x , y+offset_y+h, 2.0f);//, _r, _g, _b);
_current->add(x+offset_x , y+offset_y, 2.0f);
_current->add(x+offset_x+w, y+offset_y, 1.0f);
_current->add(x+offset_x+w, y+offset_y+h, 1.0f);
_current->add(x+offset_x , y+offset_y+h, 2.0f);
}
else{
char c1 = 1;
char c2 = 2;
_current->add(x+offset_x , y+offset_y, c2);// , _r, _g, _b);
_current->add(x+offset_x+w, y+offset_y, c1);// , _r/2, _g/2, _b/2);
_current->add(x+offset_x+w, y+offset_y+h, c1);//, _r/2, _g/2, _b/2);
_current->add(x+offset_x , y+offset_y+h, c2);//, _r, _g, _b);
_current->add(x+offset_x , y+offset_y, c2);
_current->add(x+offset_x+w, y+offset_y, c1);
_current->add(x+offset_x+w, y+offset_y+h, c1);
_current->add(x+offset_x , y+offset_y+h, c2);
}
}
else if(_draw_ruler){
......@@ -804,15 +719,10 @@ void Render_alternate::draw_circle(Element_pos /*x*/, Element_pos /*y*/, Element
void Render_alternate::start_draw(){
/* Init GLEW */
//glewInit();
_draw_ruler = false;
_draw_container = false;
_draw_arrow = false;
_draw_event = false;
//_current_vbo = NULL;
}
void Render_alternate::start_draw_containers(){
......@@ -838,7 +748,6 @@ 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 EntityValue* value){
if(_states.count(value)==0){
Shader *s = new Shader(_glsl, _r, _g, _b);
//Shader *s = new Shader();
s->charger();
std::pair<const EntityValue*, Shader*> p(value, s);
_states_shaders.insert(p);
......@@ -859,7 +768,6 @@ void Render_alternate::end_draw_states(){
it->second->config(_glsl);
it++;
}
//_states.config(_glsl);
cout << "end_draw_states" << endl;
}
......@@ -884,60 +792,21 @@ void Render_alternate::draw_arrow(const Element_pos start_time, const Element_po
sina = (y1-y0)/l;
alpha = acos(cosa);
if(sina<0) alpha*= -1;
Element_pos cos30 = cos(PI/6.0);
Element_pos sin30 = sin(PI/6.0);
cosa*=(_container_height/2.0);
sina*=(_container_height/2.0);
_arrows.add(x0, y0, 1, 1, 1);
_arrows.add(x1, y1, 1, 1, 1);
//_arrows2.add(x1, y1, 1, 1, 1);
_arrows2.add(x1, y1, 1, 1, 1);
//_arrows2.add(x1 - cosa*cos30 - sina*sin30,
// y1 + sina*cos30 - cosa*sin30,
// 1, 1, 1);
//_arrows2.add(x1 - cosa*cos30 + sina*sin30,
// y1 + sina*cos30 + cosa*sin(30),
//1, 1, 1);
/*glm::mat4 m(1.0);
m = glm::translate(m, glm::vec3(x0, y0, 0));
m = glm::rotate(m, alpha, glm::vec3(0,0,1));
m = glm::scale(m, glm::vec3(l, l, 1));
glm::vec4 v1(0,0,0,1); //origin
glm::vec4 v2(1,0,0,1);
glm::vec4 v3(cos(PI/8), -sin(PI/8)/10, 0, 1);
glm::vec4 v4(cos(PI/8), sin(PI/8)/10, 0, 1);
v1 = m * v1;
v2 = m * v2;
v3 = m * v3;
v4 = m * v4;
_arrows.add(v2.x, v2.y, 1, 1, 1);
_arrows.add(v1.x, v1.y, 1, 1, 1);
//_arrows.add(v2.x, v2.y, 1, 1, 1);
_arrows2.add(v3.x, v3.y, 1, 1, 1);
_arrows2.add(v2.x, v2.y, 1, 1, 1);
_arrows2.add(v4.x, v4.y, 1, 1, 1);
_arrows.add(x0, y0, 0, 1, 1);
_arrows.add(x1, y1, 0, 1, 1);*/
_links.push_back(alpha);
_links.push_back(l);
_links.push_back(x1);
_links.push_back(y1);
//_arrows.add(x0, y0, 1, 1, 1);
//_arrows.add(x1, y1, 1, 1, 1);
}
void Render_alternate::end_draw_arrows(){
//coordinates that we use for all arrows, we will change the angle and scale of using the modelview matrix
//coordinates that we use for draw the head all arrows when parameter arrows_shape is triangle, we will change the angle and scale of using the modelview matrix
_arrows3.add(0,0,1,1,1);
_arrows3.add(-1.2, -0.4, 1, 1, 1);
_arrows3.add(-1.2, 0.4, 1, 1, 1);
//_arrows.add(0,0,1,1,1);
//_arrows.add(-1,0,1,1,1);
//_arrows.add(0,0,1,1,1);
//_arrows.add(cos(PI/8), -sin(PI/8), 1, 1, 1);
//_arrows.add(1,0,1,1,1);
//_arrows.add(0,0,1,1,1);
//_arrows.add(cos(PI/8), sin(PI/8), 1, 1, 1);
//send datas to vbo
_arrows.config(_glsl);
_arrows2.config(_glsl);
_arrows3.config(_glsl);
......@@ -952,10 +821,6 @@ void Render_alternate::start_draw_events(){
void Render_alternate::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
const Element_pos offset_x = -_default_entity_x_translate;
const Element_pos offset_y = -_ruler_y - _ruler_height;
//_events.push_back(time + offset_x);
//_events.push_back(height + offset_y);
//_events.push_back(container_height);
_events.add(time+offset_x, height + offset_y, 1, 1, 1);
_events2.add(time+offset_x, height + offset_y, 1, 1, 1);
_events2.add(time+offset_x, height+offset_y+container_height/2, 1, 1, 1);
......@@ -963,21 +828,7 @@ void Render_alternate::draw_event(const Element_pos time, const Element_pos heig
void Render_alternate::end_draw_events(){
//As for arrows, we use the same coordinates for every events we draw. Position is changed using modelview matrix
set_color(1.0, 1.0, 1.0);
/*const float angle = 0;
const float delta_angle = 2 * PI / NB_STEPS;
const float radius = 0.5;
for(int j = 0 ; j < NB_STEPS ; j ++){
_circles.add(radius*cos(angle + j*delta_angle), radius*sin(angle + j*delta_angle), _r, _g, _b);
}*/
//_circles.add(0, 0, _r, _g, _b);
//_circles.add(0, 0.5, _r, _g, _b);
//_circles.add(0, 0, _r, _g, _b);
//_circles.add(cos_table[j]/_x_state_scale, (sin_table[j]*Info::Screen::width)/(_y_state_scale*Info::Screen::height), _r, _g, _b);
// cos_table2[2*j]= cos_table[j]/_x_state_scale;
// sin_table2[2*j+1]= (sin_table[j]*Info::Screen::width)/(_y_state_scale*Info::Screen::height);
_events.config(_glsl);
_events2.config(_glsl);
_draw_event = false;
......@@ -1056,8 +907,6 @@ void Render_alternate::draw_vertical_line(){
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));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader->getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
glVertexAttribPointer(0, 2, GL_DOUBLE, GL_FALSE, 0, vertex);
......@@ -1082,9 +931,9 @@ void Render_alternate::update_vertical_line(){
}
/*!
* \brief set the vertical line offset
* \param l the line offset.
*/
* \brief set the vertical line offset
* \param l the line offset.
*/
void Render_alternate::set_vertical_line(Element_pos new_coord){
if(new_coord==vertical_line)vertical_line=0;
else vertical_line=new_coord;
......
......@@ -166,10 +166,7 @@ void Vbo::config(int glsl){
glBufferSubData(GL_ARRAY_BUFFER, vertex_size+colors_size, shaded_size, shaded);
//Deselect our VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
//Clear RAM
//_vertex.clear();
//_colors.clear();
//Clear RAM and realoccate _vertex and _colors
//Clear RAM and realoccate vectors
std::vector<Element_pos>().swap(_vertex);
std::vector<Element_col>().swap(_colors);
std::vector<char>().swap(_shaded);
......
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