Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
solverstack
vite
Commits
c44b1a64
Commit
c44b1a64
authored
Jul 10, 2014
by
Thibault Soucarre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean code from old classes vbo and Render_alternate
parent
41360356
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
751 deletions
+12
-751
src/render/Render_alternate.cpp
src/render/Render_alternate.cpp
+3
-418
src/render/Render_alternate.hpp
src/render/Render_alternate.hpp
+7
-46
src/render/vbo.cpp
src/render/vbo.cpp
+0
-76
src/render/vbo.hpp
src/render/vbo.hpp
+2
-211
No files found.
src/render/Render_alternate.cpp
View file @
c44b1a64
This diff is collapsed.
Click to expand it.
src/render/Render_alternate.hpp
View file @
c44b1a64
...
...
@@ -88,60 +88,21 @@ private:
Element_col
_r
;
Element_col
_g
;
Element_col
_b
;
//bool _draw_container;
//bool _draw_states;
//bool _draw_arrow;
//bool _draw_event;
//bool _draw_counter;
std
::
vector
<
Element_pos
>
_links
;
std
::
vector
<
Element_pos
>
_events
;
std
::
vector
<
Container_text_
>
_texts
;
glm
::
mat4
_modelview
;
glm
::
mat4
_projection
;
Vbo
_containers
;
Vbo
_states
;
Vbo
_circles
;
Vbo
_arrows
;
Vbo
_counters
;
Vbo
_ruler
;
/*!
* \brief Offset of the vertical helper line
*/
Element_pos
vertical_line
;
protected:
/*!
* \brief The waiting screen display list.
*/
GLuint
_wait_list
;
/*!
* \brief The container GLu list.
*/
GLuint
_list_containers
;
/*!
* \brief The state GLu list.
*/
GLuint
_list_states
;
/*!
* \brief The counter GLu list.
*/
GLuint
_list_counters
;
/*!
* \brief The wait GLu list.
*/
// GLuint _wait_list;
std
::
vector
<
Container_text_
>
_texts
;
//std::vector<Arrow_> _arrows;
//std::vector<Event_> _circles;
Vbo
_containers
;
Vbo
_states
;
Vbo
_circles
;
Vbo
_arrows
;
Vbo
_counters
;
Vbo
_ruler
;
public:
/***********************************
...
...
src/render/vbo.cpp
View file @
c44b1a64
...
...
@@ -57,9 +57,6 @@
using
namespace
std
;
const
int
Vbo
::
VBO_OK
=
0
;
const
int
Vbo
::
VBO_OUT_OF_MEMORY
=
1
;
const
int
Vbo
::
VBO_UNDEFINED_ERROR
=
2
;
/***********************************
*
...
...
@@ -79,52 +76,6 @@ Vbo::Vbo(GLenum mode){
_nbVertex
=
0
;
}
Vbo
::
Vbo
(
int
nb_object
,
Type
object_type
){
/* init class attributes */
_nb_coordinates_per_vertex
=
2
;
/* 2 dimensions (x and y) */
_cur
=
0
;
_id
=
0
;
_nb_object
=
nb_object
;
switch
(
object_type
){
case
TRIANGLES
:
_nb_verteces_per_object
=
3
;
_object_type
=
GL_TRIANGLES
;
break
;
case
QUADS
:
_nb_verteces_per_object
=
4
;
_object_type
=
GL_QUADS
;
break
;
case
LINES
:
_nb_verteces_per_object
=
2
;
_object_type
=
GL_LINES
;
}
/* There is _nb_object*(number_of_vertices_per_object) elements. */
_size
=
_nb_coordinates_per_vertex
*
_nb_verteces_per_object
*
_nb_object
;
_client_state
=
GL_VERTEX_ARRAY
;
/* init OpenGL */
glGenBuffers
(
1
,
&
_id
);
/* create the buffer an put its value to _id */
glBindBuffer
(
GL_ARRAY_BUFFER
,
_id
);
/* select our vbo */
glBufferData
(
GL_ARRAY_BUFFER
,
_size
*
sizeof
(
Data_type
),
NULL
,
GL_STREAM_DRAW
);
/* allocate memory space inside graphic card */
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
/* deselect our vbo */
_vertex
.
clear
();
_colors
.
clear
();
_nbVertex
=
0
;
}
Vbo
::~
Vbo
(){
glDeleteBuffers
(
1
,
&
_vboID
);
/* release the buffer and free its memory inside the graphic card */
_vboID
=
0
;
...
...
@@ -153,9 +104,6 @@ int Vbo::add(Element_pos x, Element_pos y, Element_col r, Element_col g, Element
_colors
.
push_back
(
b
);
_nbVertex
++
;
}
int
Vbo
::
get_remaining_size
()
const
{
return
(
_size
-
_cur
)
/
(
_nb_verteces_per_object
*
_nb_coordinates_per_vertex
);
}
void
Vbo
::
config
(){
int
vertex_size
=
_vertex
.
size
()
*
sizeof
(
Element_pos
);
...
...
@@ -214,18 +162,6 @@ int Vbo::get_remaining_size() const{
*
**********************************/
void
Vbo
::
display
(
glm
::
mat4
modelview
)
const
{
//select vao
glBindVertexArray
(
_vaoID
);
//Matrix
// glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(modelview));
//Drawing
std
::
cout
<<
"display"
<<
std
::
endl
;
glDrawArrays
(
_mode
,
0
,
_nbVertex
);
//deselect vao
glBindVertexArray
(
0
);
}
void
Vbo
::
lock
(){
glBindVertexArray
(
_vaoID
);
...
...
@@ -244,15 +180,3 @@ void Vbo::setNbVertex(int n){
}
/***********************************
*
*
*
* Debug tools.
*
*
*
**********************************/
void
Vbo
::
display_info
(){
}
src/render/vbo.hpp
View file @
c44b1a64
...
...
@@ -50,15 +50,7 @@
#include "common/common.hpp"
using
namespace
std
;
typedef
double
Data_type
;
/*!
\def VBO_BUFFER_OFFSET(a)
OpenGL special macro
*/
//macro used by OpenGL
#define BUFFER_OFFSET(a) ((char*)NULL + (a))
/*!
...
...
@@ -66,60 +58,13 @@ typedef double Data_type;
*/
class
Vbo
{
protected:
/*!
* \brief Number of verteces per objects.
*/
unsigned
int
_nb_verteces_per_object
;
/*!
* \brief Number of objects (container, entity...) per vbo.
*/
unsigned
int
_nb_object
;
/*!
* \brief The size of the vbo buffer: _nb_object*(number_of_vertices_per_object).
*/
unsigned
int
_size
;
/*!
* \brief Define how kind of OpenGL primitive object is made.
*
* Values can be : GL_LINES, GL_TRIANGLES, GL_QUADS or GL_POLYGON for example.
*/
GLenum
_object_type
;
/*!
* \brief Define how kind of OpenGL buffer object belongs to.
*
* Values can be : GL_VERTEX_ARRAY or GL_COLOR_ARRAY for example.
*/
GLenum
_client_state
;
/*!
* \brief The vbo instance identity.
*/
GLuint
_id
;
/*!
* \brief Define the position indicator inside the VBO buffer. Must be lesser than _size !
*/
unsigned
int
_cur
;
/*!
* \brief Define the number of vertex coordinates. Should be equal to 3.
*/
unsigned
int
_nb_coordinates_per_vertex
;
private:
GLuint
_vboID
;
GLuint
_vaoID
;
vector
<
Element_pos
>
_vertex
;
vector
<
Element_col
>
_colors
;
GLenum
_mode
;
int
_nbVertex
;
private:
/*!
* \brief The default constructor. Cannot be use for instantiation.
...
...
@@ -143,12 +88,7 @@ public:
/*!
* \brief Constructor.
* \param nb_verteces_per_object Number of verteces per object.
* \param nb_object Number of objects. Object can be a container or entity.
* \param object_type Defines how kind of OpenGL primitive object is made.
* \param client_state Define how kind of OpenGL buffer object belongs to.
*/
Vbo
(
int
nb_object
,
Type
object_type
);
Vbo
(
GLenum
mode
);
...
...
@@ -165,165 +105,16 @@ public:
*
**********************************/
/*!
* \brief Used to inform that data have been successfully added to graphic card.
*/
static
const
int
VBO_OK
;
/*!
* \brief Used to inform that the buffer is full and another VBO must be create.
*/
static
const
int
VBO_OUT_OF_MEMORY
;
/*!
* \brief Used to inform that an unidentified error occurs.
*/
static
const
int
VBO_UNDEFINED_ERROR
;
/*!
* \brief Fill the vertex buffer object.
* \param data_size The vertex buffer data size.
* \param data A vertex buffer to be display (its type MUST BE <i>Element_pos</i>).
*
* \return The state of the buffer.
*
* This function is called for each vertex, so it is an inline function. It can return several number :
* <ul>
* <li><b>VBO_OK</b>: data have been added to graphic card. No error.
* <li><b>VBO_OUT_OF_MEMORY</b>: buffer is full. Another VBO must be create.
* <li><b>VBO_UNDEFINED_ERROR</b>: an error occurs but has not been identified.
* </ul>
*/
int
add
(
Element_pos
x
,
Element_pos
y
,
Element_col
r
,
Element_col
g
,
Element_col
b
);
/*!
* \brief Return the remaining size of the buffer object.
*
* \return Number corresponding to the case number remaining.
*/
int
get_remaining_size
()
const
;
/***********************************
*
* Buffer display.
*
**********************************/
/*!
* \brief Display the VBO list inside the OpenGL area.
*/
void
display
(
glm
::
mat4
modelview
)
const
;
void
lock
();
void
unlock
();
int
getNbVertex
();
void
setNbVertex
(
int
);
/***********************************
*
* Debug tools.
*
**********************************/
/*!
* \brief Display information about VBO: its attribute values.
*/
void
display_info
();
void
config
();
void
*
operator
new
(
size_t
s
){
std
::
cout
<<
"Vbo: allocation de "
<<
s
<<
" octets."
<<
std
::
endl
;
return
malloc
(
s
*
sizeof
(
Vbo
));
}
};
/* Define several Vbo inherited classes */
/****************
*
* CONTAINER
*
****************/
// struct Vbo_container : public Vbo{
// public:
// /*!
// * \brief The default constructor.
// */
// Vbo_container():Vbo(4, 8000, GL_QUADS, GL_VERTEX_ARRAY){
// }
// /*!
// * \brief The destructor.
// */
// virtual ~Vbo_container(){
// }
// };
/****************
*
* ARROW
*
****************/
// /*!
// * \brief VBO uses for triangle arrows.
// */
// struct Vbo_arrow_triangle : public Vbo{
// public:
// /*!
// * \brief The default constructor.
// */
// Vbo_arrow_triangle():Vbo(3, 2000, GL_TRIANGLES, GL_VERTEX_ARRAY){
// }
// /*!
// * \brief The destructor.
// */
// virtual ~Vbo_arrow_triangle(){
// }
// };
// /*!
// * \brief VBO uses for line arrows.
// */
// struct Vbo_arrow_line : public Vbo{
// public:
// /*!
// * \brief The default constructor.
// */
// Vbo_arrow_line():Vbo(2, 8000, GL_LINES, GL_VERTEX_ARRAY){
// }
// /*!
// * \brief The destructor.
// */
// virtual ~Vbo_arrow_line(){
// }
// };
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment