Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 7db09a54 authored by Olivier Lagrasse's avatar Olivier Lagrasse

- VBO retires

parent a7fa2380
......@@ -76,6 +76,11 @@ class Render
*/
virtual void end_draw_states() = 0;
/*!
* \brief Proceeds with the initialization of arrow draw functions.
*/
virtual void start_draw_arrows() = 0;
/*!
* \brief Draw an arrow.
* \param start_time the beginning time of the arrow.
......@@ -85,6 +90,11 @@ class Render
*/
virtual void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height) = 0;
/*!
* \brief Called when all arrow draws are finished.
*/
virtual void end_draw_arrows() = 0;
/*!
* \brief Draw an event.
* \param time time when the event occurs.
......
......@@ -42,7 +42,6 @@ Render_opengl::Render_opengl(QWidget *parent)
/* init the wait animation */
_wait_list = 0;/* init list */
_wait_angle=0.0f;/* begin with 0 rad angle */
_wait_angle_y=0.0f;/* begin with 0 rad angle */
_wait_timer = NULL;
_wait_spf=DRAWING_TIMER_DEFAULT;/* DRAWING_TIMER_DEFAULT milliseconds per frame */
......@@ -89,15 +88,6 @@ Render_opengl::Render_opengl(QWidget *parent)
_mouse_y = 0;
_mouse_pressed = false;
/* VBO initialisation */
_list_vbo.data = NULL;
_list_vbo.next = NULL;
_list_vbo_browser = &_list_vbo;
_vbo_container_cur = 0;
_vbo_container_size = 3*4*10000;
_vbo_container_buf = NULL;
/* OpenGL lists */
......@@ -140,14 +130,6 @@ Render_opengl::Render_opengl(QWidget *parent)
Render_opengl::~Render_opengl(){
/* UNALLOCATE MEMORY ? */
// for(; NULL != _list_vbo_browser->next; list_vbo_browser = list_vbo_browser->next){
// if (NULL == _list_vbo_browser->data)/* A quick check */
// message << "Corruption into the VBO linked list" << Message::ende;
// }
vbo_list_release();/* Free the VBO linked list */
if (glIsList(_wait_list)==GL_TRUE)
glDeleteLists(_wait_list, 1);
......@@ -160,69 +142,6 @@ Render_opengl::~Render_opengl(){
}
}
/***********************************
*
*
*
* VBO linked list function.
*
*
*
**********************************/
void Render_opengl::vbo_list_release(){
List_vbo* releaser;
if (NULL != _list_vbo.next){
/*
* Browse the list and release each component simultaneously.
* The loop releases from the second to the last element.
*/
for( releaser = _list_vbo.next, _list_vbo_browser = _list_vbo.next ; /* init from the begining of the VBO list */
NULL != _list_vbo_browser; /* While any element exists */
){
if (NULL == _list_vbo_browser->data)/* A quick check */
*Message::get_instance() << "Corruption into the VBO linked list (Release loop)" << Message::ende;
else
delete _list_vbo_browser->data;/* Release the Vbo instance */
_list_vbo_browser = _list_vbo_browser->next;/* jump to the next element */
delete releaser;/* delete the current element (the List_vbo) */
releaser = _list_vbo_browser;/* jump to the next element too */
}/* end for */
}/* end if (NULL != _list_vbo.next) */
/* Now, all the list was released except the first element */
if (NULL == _list_vbo.data)/* A quick check */
*Message::get_instance() << "Corruption into the VBO linked list (First element release)" << Message::ende;
else
delete _list_vbo.data;/* Release the Vbo instance */
/* Then, init pointers */
_list_vbo.data = NULL;
_list_vbo.next = NULL;
_list_vbo_browser = NULL;
}
/***********************************
*
*
......@@ -308,8 +227,7 @@ void Render_opengl::paintGL(){
glScalef(15, 15, 0);
glRotatef(-_wait_angle, 0, 1, 0);
glRotatef(_wait_angle_y, 1, 0, 0);
glRotatef(-_wait_angle,0, 1, 0);
glCallList(_wait_list);
......@@ -351,11 +269,6 @@ void Render_opengl::paintGL(){
*/
glTranslatef(0.0f, 0.0f, _z_container);
if (0 == _container_x_max)
*Message::get_instance() << "container_x_max is null (PaintGL)" << Message::ende;
if (0 == _container_y_max)
*Message::get_instance() << "container_y_max is null (PaintGL)" << Message::ende;
glScalef( (_render_width/_container_x_max)*_x_scale_container_state, (_render_height-_rule_height)/_container_y_max, 0.0f);
......@@ -367,30 +280,11 @@ void Render_opengl::paintGL(){
#endif
// if (glIsList(_list_containers)==GL_FALSE)
// message << "ERROR LIST not exist for containers." << Message::ende;
// else
// glCallList(_list_containers);
if (glIsList(_list_containers)==GL_FALSE)
message << "ERROR LIST not exist for containers." << Message::ende;
else
glCallList(_list_containers);
glColor3d(0, 0, 0.6);/* blue color */
for(_list_vbo_browser = &_list_vbo ;
NULL != _list_vbo_browser;
_list_vbo_browser = _list_vbo_browser->next){
#ifdef DEBUG_MODE_RENDER_OPENGL
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Draw a VBO." << endl << endl;
#endif
if (NULL == _list_vbo_browser->data)
*Message::get_instance() << "Corruption into the VBO linked list (PaintGL)" << Message::ende;
else
_list_vbo_browser->data->display_buffer();/* Draw data */
}
glPopMatrix();
......@@ -497,61 +391,11 @@ void Render_opengl::paintGL(){
void Render_opengl::mousePressEvent(QMouseEvent * event){
Element_pos x_click, y_click;/* Store the OpenGL scene point where user had clicked */
Element_pos x_result, y_result;/* The click coordinates for the Data Structure. */
_mouse_x = event->x();
_mouse_y = event->y();
_mouse_pressed = true;
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
/*
* Now determine where the user had clicked
*/
x_click = _mouse_x * (Element_pos)_render_width/(Element_pos)_screen_width;/* x position of the click in the OpenGL scene */
y_click = _mouse_y * (Element_pos)_render_height/(Element_pos)_screen_height;/* y position of the click in the OpenGL scene */
cerr << x_click << " " << y_click << " - " << _screen_width << " " << _screen_height << endl;
/*
* First, check the y position if user clicks on the rule or other
*/
if ( y_click <= (_rule_height+_rule_y) )/* user had clicked on the rule */
return;
cerr << "No click rule" << endl;
/* Work out the y value in Data Structure coordinates */
// y_result = y_click/((Element_pos)_container_height + v_space);
_mouse_x = event->x();
_mouse_y = event->y();
_mouse_pressed = true;
QApplication::setOverrideCursor(Qt::ClosedHandCursor);
/*
* Second, check the x position if user click on the container or other
*/
if (x_click <= (_x_scale_container_state*_render_width) ){/* user had clicked on the container */
cerr << "Click container" << endl;
}
else{
/*
* Determine the time corresponding to the x click position.
* It is equal to the x click position in the OpenGL render area minus the default translation of entities.
* Also, near the container area time is 0 except if a translation had occured.
* So add the state translate and the x_result will be obtained.
*
* Take care that x_result can be negative.
*/
x_result = (x_click - _default_entity_x_translate + _state_translate);
/*
* To convert from [0;_render_width*_state_scale] to [_state_x_min;_state_x_max]
*/
x_result *= (_state_x_max - _state_x_min)/(_render_width*_state_scale);
message << "Click entity" << x_result << Message::endsi;
}
}
......@@ -561,13 +405,10 @@ void Render_opengl::mouseMoveEvent(QMouseEvent * event){
if ( _mouse_x != event->x()){
_state_translate += 0.1*(_mouse_x - event->x());
_wait_angle += 0.5*(_mouse_x - event->x());/* for the rabbit */
_mouse_x = event->x();
}
else{
else
_state_scale += 0.01*(_mouse_y - event->y());
_wait_angle_y += 0.5*(_mouse_y - event->y());/* for the rabbit */
}
_mouse_y = event->y();
......@@ -575,7 +416,7 @@ void Render_opengl::mouseMoveEvent(QMouseEvent * event){
}
void Render_opengl::mouseReleaseEvent(QMouseEvent *){
void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
_mouse_pressed = false;
QApplication::restoreOverrideCursor();
}
......@@ -634,17 +475,6 @@ bool Render_opengl::build(){
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
/*****************************
*
* Init render area attributes
*
*****************************/
_state_translate = 0;
_state_scale = 0.1;
return true;
}
......@@ -659,14 +489,6 @@ bool Render_opengl::unbuild(){
*
***********************/
vbo_list_release();/* Release all the vbo list */
_list_vbo.data = NULL;
_list_vbo.next = NULL;
_list_vbo_browser = &_list_vbo;
_vbo_container_buf = NULL;
/* Free container list */
glDeleteLists(_list_containers, 1);
_list_containers = 0;
......@@ -745,9 +567,6 @@ bool Render_opengl::unbuild(){
_state = DRAWING_STATE_WAINTING;/* change the drawing state */
_wait_angle=0.0f;/* begin with 0 rad angle */
_wait_angle_y=0.0f;/* begin with 0 rad angle */
/* init measurement attributes */
_container_x_max = 0;
_container_y_max = 0;
......@@ -849,7 +668,7 @@ void Render_opengl::create_rule(){
Element_pos buf_number;
Element_pos graduation_distance_per_5;
coeff = (_state_x_max - _state_x_min)/_render_width;/* from [0;_render_width] to [_state_x_min;_state_x_max], used to obtain correct coordinate texts */
coeff = (_state_x_max - _state_x_min)/_render_width;/* from [0;100] to [_state_x_min;_state_x_max], used to obtain correct coordinate texts */
entity_width = _render_width*_state_scale;/* the render width from a given scale */
......@@ -1094,6 +913,6 @@ void Render_opengl::create_rule(){
// }
void Render_opengl::set_total_width(Element_pos){}
void Render_opengl::set_total_time(Times){}
void Render_opengl::set_total_width(Element_pos w){}
void Render_opengl::set_total_time(Times t){}
void Render_opengl::display_time_scale(){}
......@@ -15,8 +15,6 @@ class Render_opengl;
#include "render.hpp"
#include "vbo.hpp"
#include "resource.hpp"
......@@ -134,43 +132,6 @@ class Render_opengl : public QGLWidget, public Render
/***********************************
*
* VBO tools attributes.
*
**********************************/
/*!
* \brief The VBO linked list which store all the VBO types (containers, states, etc.).
*/
struct List_vbo{
Vbo* data;
List_vbo* next;
}_list_vbo, _list_vbo_arrow;
/*!
* \brief Use to browser the VBO linked list: List_vbo.
*/
List_vbo* _list_vbo_browser;
/*!
* \brief Buffer uses to temporary store container values.
*/
Element_pos* _vbo_container_buf;
/*!
* \brief Size of the container value temporary storing buffer.
*/
unsigned int _vbo_container_size;
/*!
* \brief Cursor to browse the container value temporary storing buffer.
*/
unsigned int _vbo_container_cur;
/***********************************
*
* Default QGLWidget functions.
......@@ -253,11 +214,6 @@ class Render_opengl : public QGLWidget, public Render
*/
float _wait_angle;
/*!
* \brief Y rotation angle for the wait.
*/
float _wait_angle_y;
/*!
* \brief Time in ms between two frames for the waiting screen.
*/
......@@ -464,18 +420,6 @@ class Render_opengl : public QGLWidget, public Render
virtual ~Render_opengl();
/***********************************
*
* VBO linked list function.
*
**********************************/
/*!
* \brief Release the VBO linked list in _list_vbo.
*/
void vbo_list_release();
/***********************************
*
* Building functions.
......@@ -568,6 +512,11 @@ class Render_opengl : public QGLWidget, public Render
*/
void end_draw_states();
/*!
* \brief Open the arrow display list.
*/
void start_draw_arrows();
/*!
* \brief Draw an arrow.
* \param start_time the beginning time of the arrow.
......@@ -579,6 +528,11 @@ class Render_opengl : public QGLWidget, public Render
*/
void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);
/*!
* \brief Closes the arrow display list.
*/
void end_draw_arrows();
/*!
* \brief Draw arrows contained in the Arrow_ vector
* \param arrows An arrow vector.
......@@ -675,95 +629,35 @@ inline void Render_opengl::start_draw(){
/* clear the arrow vector */
_arrows.clear();
//vbo_list_release();/* Release all the vbo list */
}
// inline void Render_opengl::start_draw_containers(){
// _list_containers = glGenLists(1);/* create the list */
// if (_list_containers==0){
// // _parent->warning("Error when creating list");
// }
// glNewList(_list_containers, GL_COMPILE);/* open the list */
// }
inline void Render_opengl::start_draw_containers(){
/*
* Container start draw function is called once for each trace
* so a new container VBO is first created.
*/
/*
* Init the buffer which will received data from de Data Structure.
*/
_vbo_container_cur = 0;
_vbo_container_size = 2*4*10000;/* 2 coordinates (x and y) - 4 verteces per objects - 10 000 objects */
if (NULL == _vbo_container_buf){
_vbo_container_buf = new Element_pos[_vbo_container_size];
}else{
*Message::get_instance() << "VBO buffer container has not be desallocated." << Message::ende;
_list_containers = glGenLists(1);/* create the list */
if (_list_containers==0){
// _parent->warning("Error when creating list");
}
/*
* Browse the VBO linked list to find the last List_vbo element and then to create our new Container VBO.
*/
for(_list_vbo_browser = &_list_vbo ;
NULL != _list_vbo_browser->next;
_list_vbo_browser = _list_vbo_browser->next){
if (NULL == _list_vbo_browser->data)/* A quick check */
*Message::get_instance() << "Corruption into the VBO linked list (Draw container)" << Message::ende;
}
glNewList(_list_containers, GL_COMPILE);/* open the list */
if (NULL != _list_vbo_browser->data){/* It is not the first vbo of the linked list. So create a new VBO list structure. */
_list_vbo_browser->next = new List_vbo();/* Create a new vbo */
_list_vbo_browser = _list_vbo_browser->next;/* Set the browsing pointer on this new VBO */
}
_list_vbo_browser->data = new Vbo_container();/* Create a new container VBO using polymorphism */
_list_vbo_browser->next = NULL;/* init for a future creation */
}
inline void Render_opengl::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
if ( (_vbo_container_cur+8) < _vbo_container_size){
_vbo_container_buf[_vbo_container_cur++] = x;
_vbo_container_buf[_vbo_container_cur++] = y;
_vbo_container_buf[_vbo_container_cur++] = x;
_vbo_container_buf[_vbo_container_cur++] = y+h;
_vbo_container_buf[_vbo_container_cur++] = x+w;
_vbo_container_buf[_vbo_container_cur++] = y+h;
_vbo_container_buf[_vbo_container_cur++] = x+w;
_vbo_container_buf[_vbo_container_cur++] = y;
}else{/* Not enough place in the temporary buffer. Must empty it in the Video RAM (the VBO). */
/* MUST TAKE CARE IF FUNCTION RETURNS NOT ENOUGH MEMORY -> HAVE TO CREATE A NEW VBO */
_list_vbo_browser->data->fill_buffer(_vbo_container_cur, _vbo_container_buf);/* Write on VRAM all the buffer */
_vbo_container_cur = 0;/* Restart buffer filling */
/* Take care before calling the function again that there will not a recursive dramatic issue ! */
if ( (_vbo_container_cur+8) < _vbo_container_size)
draw_container(x, y, w, h);
else
*Message::get_instance() << "Cannot fill the temporary buffer: size " << _vbo_container_size << " is too few" << Message::ende;
}/* end else of if ( (_vbo_container_cur+8) < _vbo_container_size) */
float j=0.6;
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(0, 0, j);glVertex2d(x, y);
glColor3d(0, 0, j-0.1);glVertex2d(x, y+h);
glColor3d(0, 0, j-0.1);glVertex2d(x+w, y+h);
glColor3d(0, 0, j);glVertex2d(x+w, y);
}
glEnd();
if ((x+w)>_container_x_max)
_container_x_max = x+w;
......@@ -789,49 +683,6 @@ inline void Render_opengl::draw_container(const Element_pos x, const Element_pos
}
// inline void Render_opengl::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
// float j=0.6;
// glBegin(GL_QUADS);/* create a quads */
// {
// glColor3d(0, 0, j);glVertex2d(x, y);
// glColor3d(0, 0, j-0.1);glVertex2d(x, y+h);
// glColor3d(0, 0, j-0.1);glVertex2d(x+w, y+h);
// glColor3d(0, 0, j);glVertex2d(x+w, y);
// }
// glEnd();
// if ((x+w)>_container_x_max)
// _container_x_max = x+w;
// if ((y+h)>_container_y_max)
// _container_y_max = y+h;
// if (_container_x_min > x)
// _container_x_min = x;
// if (_container_y_min > y)
// _container_y_min = y;
// #ifdef DEBUG_MODE_RENDER_AREA
// std::cerr << __FILE__ << " l." << __LINE__ << ":" << std::endl;
// std::cerr < "Container drawing:" << std::endl;
// std::cerr << "x: " << x << " y: " << y << " w: " << w << " h: " << h << " xmax-xmin: " << _container_x_max << " - " << _container_x_min << " ymax-ymin: " << _container_y_max << " - " << _container_y_min << std::endl;
// #endif
// }
inline void Render_opengl::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
_text_pos.push_back(x);
......@@ -841,22 +692,11 @@ inline void Render_opengl::draw_container_text(const Element_pos x, const Elemen
}
inline void Render_opengl::end_draw_containers(){
_list_vbo_browser->data->fill_buffer(_vbo_container_cur, _vbo_container_buf);/* Write on VRAM all the buffer */
// _list_vbo_browser->data->display_info();
_vbo_container_cur = 0;/* Restart buffer filling */
delete[] _vbo_container_buf;/* Release buffer */
_vbo_container_buf = NULL;
inline void Render_opengl::end_draw_containers(){
glEndList();/* close the list */
}
// inline void Render_opengl::end_draw_containers(){
// glEndList();/* close the list */
// }
......@@ -916,6 +756,9 @@ inline void Render_opengl::end_draw_states(){
}
inline void Render_opengl::start_draw_arrows(){
}
inline void Render_opengl::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
Arrow_ buf;
......@@ -929,6 +772,10 @@ inline void Render_opengl::draw_arrow(const Element_pos start_time, const Elemen
}
inline void Render_opengl::end_draw_arrows(){