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.
......
This diff is collapsed.
......@@ -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(){
}
inline void Render_opengl::draw_stored_arrows(std::vector<Arrow_> &arrows){
......
......@@ -208,12 +208,21 @@ public:
*/
void draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) ;
/*!
* \brief unused
*/
void start_draw_arrows();
/*!
* \brief Draw an arrow
*
*/
void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);
/*!
* \brief unused
*/
void end_draw_arrows();
/*!
* \brief unused
......@@ -416,6 +425,9 @@ inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_
print();
}
inline void Svg::start_draw_arrows(){
}
inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
......@@ -432,6 +444,9 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
}
inline void Svg::end_draw_arrows(){
}
inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
Element_pos xprime,yprime,wprime,hprime;
......
......@@ -222,7 +222,7 @@ public:
/*!
* \brief The default constructor.
*/
Vbo_arrow_triangle():Vbo(3, 8000, GL_TRIANGLES, GL_VERTEX_ARRAY){
Vbo_arrow_triangle():Vbo(3, 2000, GL_TRIANGLES, GL_VERTEX_ARRAY){
}
/*!
......
......@@ -272,7 +272,12 @@ public:
}/* end while (!_stack_states.empty()) */
draw_object->end_draw_states();
draw_object->start_draw_arrows();
for (list<const Container *>::const_iterator c = _link_containers.begin();
c != _link_containers.end();
c++) {
......@@ -291,7 +296,8 @@ public:
}/* end while (!_stack_states.empty()) */
draw_object->end_draw_states();
draw_object->end_draw_arrows();
draw_object->start_draw_counter();
......
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