Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
86b3bc0f
Commit
86b3bc0f
authored
Jul 24, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add vboRender / allow VBO update from given vector
parent
278d906f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
229 additions
and
63 deletions
+229
-63
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+15
-16
Apps/Examples/viewer.h
Apps/Examples/viewer.h
+2
-0
include/Algo/Render/GL2/drawerCells.h
include/Algo/Render/GL2/drawerCells.h
+10
-10
include/Algo/Render/GL2/mapRender.h
include/Algo/Render/GL2/mapRender.h
+3
-4
include/Utils/GLSLShader.h
include/Utils/GLSLShader.h
+1
-5
include/Utils/pointSprite.h
include/Utils/pointSprite.h
+6
-4
include/Utils/vbo.h
include/Utils/vbo.h
+8
-4
include/Utils/vbo.hpp
include/Utils/vbo.hpp
+17
-2
include/Utils/vboRender.h
include/Utils/vboRender.h
+67
-0
src/Algo/Render/mapRender.cpp
src/Algo/Render/mapRender.cpp
+8
-4
src/Utils/GLSLShader.cpp
src/Utils/GLSLShader.cpp
+7
-7
src/Utils/vbo.cpp
src/Utils/vbo.cpp
+4
-7
src/Utils/vboRender.cpp
src/Utils/vboRender.cpp
+81
-0
No files found.
Apps/Examples/viewer.cpp
View file @
86b3bc0f
...
...
@@ -113,7 +113,6 @@ void Viewer::cb_initGL()
m_simpleColorShader
->
setColor
(
c
)
;
m_pointSprite
=
new
Utils
::
PointSprite
()
;
m_pointSprite
->
setAttributePosition
(
m_positionVBO
)
;
registerShader
(
m_phongShader
)
;
registerShader
(
m_flatShader
)
;
...
...
@@ -127,6 +126,7 @@ void Viewer::cb_redraw()
if
(
m_drawVertices
)
{
float
size
=
vertexScaleFactor
;
m_pointSprite
->
setAttributePosition
(
m_positionVBO
)
;
m_pointSprite
->
setSize
(
size
)
;
m_pointSprite
->
predraw
(
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
1.0
f
))
;
m_render
->
draw
(
m_pointSprite
,
Algo
::
Render
::
GL2
::
POINTS
)
;
...
...
@@ -191,6 +191,18 @@ void Viewer::cb_Save()
exportMesh
(
filename
)
;
}
void
Viewer
::
cb_keyPress
(
int
keycode
)
{
switch
(
keycode
)
{
case
'c'
:
myMap
.
check
();
break
;
default:
break
;
}
}
void
Viewer
::
importMesh
(
std
::
string
&
filename
)
{
myMap
.
clear
(
true
)
;
...
...
@@ -311,21 +323,6 @@ void Viewer::slot_normalsSize(int i)
updateGL
()
;
}
void
Viewer
::
cb_keyPress
(
int
keycode
)
{
switch
(
keycode
)
{
case
'c'
:
myMap
.
check
();
break
;
default:
break
;
}
updateGLMatrices
()
;
updateGL
();
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
...
...
@@ -334,6 +331,8 @@ int main(int argc, char **argv)
{
QApplication
app
(
argc
,
argv
)
;
srand
(
123
)
;
Viewer
sqt
;
sqt
.
setGeometry
(
0
,
0
,
1000
,
800
)
;
sqt
.
show
()
;
...
...
Apps/Examples/viewer.h
View file @
86b3bc0f
...
...
@@ -46,6 +46,8 @@
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/Qt/qtInputs.h"
#include "Algo/Geometry/boundingbox.h"
...
...
include/Algo/Render/GL2/drawerCells.h
View file @
86b3bc0f
...
...
@@ -79,7 +79,7 @@ void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerEdges
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerEdges
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add a set of faces to a drawer
...
...
@@ -90,7 +90,7 @@ void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerFaces
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerFaces
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add a set of volumes to a drawer
...
...
@@ -101,7 +101,7 @@ void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& v
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerVolumes
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerVolumes
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
std
::
vector
<
Dart
>&
vd
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add a vertex to a drawer
...
...
@@ -121,7 +121,7 @@ void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Verte
* @param positions attribute of positions
*/
template
<
typename
PFP
>
void
drawerEdge
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerEdge
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add a face to a drawer
...
...
@@ -132,7 +132,7 @@ void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vertex
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerFace
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerFace
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add a volume to a drawer
...
...
@@ -143,7 +143,7 @@ void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexA
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerVolume
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerVolume
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
/**
* add an edge to a drawer, use between begin / end
...
...
@@ -188,13 +188,13 @@ void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const Vert
* @param k shrinking factor
*/
template
<
typename
PFP
>
void
drawerAddVolume
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
void
drawerAddVolume
(
Utils
::
Drawer
&
dr
,
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
positions
,
float
k
);
}
}
// namespace Render
}
}
// namespace Algo
}
}
// namespace CGoGN
#include "Algo/Render/GL2/drawerCells.hpp"
...
...
include/Algo/Render/GL2/mapRender.h
View file @
86b3bc0f
...
...
@@ -100,7 +100,7 @@ protected:
static
bool
cmpVP
(
VertexPoly
*
lhs
,
VertexPoly
*
rhs
);
// multiset typedef for simple writing
typedef
std
::
multiset
<
VertexPoly
*
,
bool
(
*
)(
VertexPoly
*
,
VertexPoly
*
)
>
VPMS
;
typedef
std
::
multiset
<
VertexPoly
*
,
bool
(
*
)(
VertexPoly
*
,
VertexPoly
*
)
>
VPMS
;
class
VertexPoly
{
...
...
@@ -112,9 +112,9 @@ protected:
VertexPoly
*
next
;
VPMS
::
iterator
ear
;
VertexPoly
(
int
i
,
float
v
,
float
l
,
VertexPoly
*
p
=
NULL
)
:
id
(
i
),
value
(
v
),
length
(
l
),
prev
(
p
),
next
(
NULL
)
VertexPoly
(
int
i
,
float
v
,
float
l
,
VertexPoly
*
p
=
NULL
)
:
id
(
i
),
value
(
v
),
length
(
l
),
prev
(
p
),
next
(
NULL
)
{
if
(
prev
!=
NULL
)
if
(
prev
!=
NULL
)
prev
->
next
=
this
;
}
...
...
@@ -132,7 +132,6 @@ protected:
delete
vp
;
return
tmp
;
}
};
public:
...
...
include/Utils/GLSLShader.h
View file @
86b3bc0f
...
...
@@ -288,7 +288,6 @@ public:
virtual
void
updateClippingUniforms
()
{
CGoGNerr
<<
"Warning updateClippingUniforms not implemented"
<<
CGoGNendl
;}
/**
*
*/
...
...
@@ -341,7 +340,6 @@ public:
*/
void
addPathFileSeach
(
const
std
::
string
&
path
);
/**
* remove VBO index from binding
*/
...
...
@@ -374,7 +372,7 @@ public:
* bind, enable, and set all vertex attrib pointers
* @param stride: the stride parameter, number osf byte between two consecutive attributes
*/
void
enableVertexAttribs
(
unsigned
int
stride
=
0
,
unsigned
int
begin
=
0
)
const
;
void
enableVertexAttribs
(
unsigned
int
stride
=
0
,
unsigned
int
begin
=
0
)
const
;
/**
* disenable all vertex attribs
...
...
@@ -394,8 +392,6 @@ public:
static
void
pushTransfo
()
{
s_current_matrices
->
pushTransfo
();}
/// pop transformation matrix
static
void
popTransfo
()
{
s_current_matrices
->
popTransfo
();}
};
...
...
include/Utils/pointSprite.h
View file @
86b3bc0f
...
...
@@ -32,6 +32,7 @@ namespace CGoGN { namespace Utils { class VBO; } }
namespace
CGoGN
{
namespace
Utils
{
...
...
@@ -63,7 +64,7 @@ public:
/**
* init shaders, texture and variables
*/
PointSprite
(
float
radius
=
1.0
f
);
PointSprite
(
float
radius
=
1.0
f
);
/**
* clean shaders, texture and variables
...
...
@@ -90,9 +91,10 @@ public:
* set position attribute
*/
unsigned
int
setAttributePosition
(
VBO
*
vbo
);
};
}
// namespace Utils
}
// namespace CGoGN
};
}
}
#endif
include/Utils/vbo.h
View file @
86b3bc0f
...
...
@@ -92,12 +92,12 @@ public:
/**
* get nb element in vbo (vertices, colors ...)
*/
unsigned
int
nbElts
()
{
return
m_nbElts
;
}
unsigned
int
nbElts
()
{
return
m_nbElts
;
}
/**
* bind array vbo
*/
void
bind
()
const
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
}
void
bind
()
const
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
}
/**
* alloc buffer of same size than parameter
...
...
@@ -116,6 +116,12 @@ public:
template
<
typename
ATTR_HANDLER
>
void
updateData
(
const
ATTR_HANDLER
&
attrib
,
ConvertAttrib
*
conv
);
/**
* update data from given data vector
*/
template
<
typename
T
>
void
updateData
(
std
::
vector
<
T
>&
data
);
void
*
lockPtr
();
const
void
*
lockPtr
()
const
;
...
...
@@ -124,8 +130,6 @@ public:
void
copyData
(
void
*
ptr
)
const
;
void
allocate
(
unsigned
int
nbElts
);
};
...
...
include/Utils/vbo.hpp
View file @
86b3bc0f
...
...
@@ -33,7 +33,7 @@ void VBO::updateData(const ATTR_HANDLER& attrib)
{
if
(
m_lock
)
{
CGoGNerr
<<
" Error locked VBO"
<<
CGoGNendl
;
CGoGNerr
<<
"Error locked VBO"
<<
CGoGNendl
;
return
;
}
m_data_size
=
sizeof
(
typename
ATTR_HANDLER
::
DATA_TYPE
)
/
sizeof
(
float
);
...
...
@@ -62,7 +62,7 @@ void VBO::updateData(const ATTR_HANDLER& attrib, ConvertAttrib* conv)
{
if
(
m_lock
)
{
CGoGNerr
<<
" Error locked VBO"
<<
CGoGNendl
;
CGoGNerr
<<
"Error locked VBO"
<<
CGoGNendl
;
return
;
}
m_data_size
=
conv
->
sizeElt
();
...
...
@@ -97,6 +97,21 @@ void VBO::updateData(const ATTR_HANDLER& attrib, ConvertAttrib* conv)
conv
->
release
();
}
template
<
typename
T
>
void
VBO
::
updateData
(
std
::
vector
<
T
>&
data
)
{
if
(
m_lock
)
{
CGoGNerr
<<
"Error locked VBO"
<<
CGoGNendl
;
return
;
}
m_data_size
=
sizeof
(
T
)
/
sizeof
(
float
);
m_nbElts
=
data
.
size
();
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
glBufferData
(
GL_ARRAY_BUFFER
,
m_nbElts
*
sizeof
(
T
),
&
(
data
[
0
]),
GL_STREAM_DRAW
);
}
}
// namespace Utils
}
// namespace CGoGN
include/Utils/vboRender.h
0 → 100644
View file @
86b3bc0f
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _VBO_RENDER_
#define _VBO_RENDER_
#include <GL/glew.h>
namespace
CGoGN
{
namespace
Utils
{
// forward definition
class
GLSLShader
;
class
VBORender
{
protected:
GLuint
m_indexBuffer
;
GLuint
m_nbIndices
;
int
m_primitiveType
;
public:
enum
primitiveTypes
{
POINTS
=
0
,
LINES
=
1
,
TRIANGLES
=
2
}
;
VBORender
()
;
~
VBORender
()
;
void
setConnectivity
(
std
::
vector
<
GLuint
>&
tableIndices
,
int
primitiveType
)
;
void
draw
(
Utils
::
GLSLShader
*
sh
)
;
};
}
// namespace Utils
}
// namespace CGoGN
#endif
src/Algo/Render/mapRender.cpp
View file @
86b3bc0f
...
...
@@ -53,33 +53,38 @@ void MapRender::initPrimitives(int prim, std::vector<GLuint>& tableIndices)
{
// indice du VBO a utiliser
int
vbo_ind
=
0
;
int
size
=
0
;
switch
(
prim
)
{
case
POINTS
:
m_nbIndices
[
POINT_INDICES
]
=
tableIndices
.
size
();
vbo_ind
=
m_indexBuffers
[
POINT_INDICES
];
size
=
m_nbIndices
[
POINT_INDICES
];
break
;
case
LINES
:
m_nbIndices
[
LINE_INDICES
]
=
tableIndices
.
size
();
vbo_ind
=
m_indexBuffers
[
LINE_INDICES
];
size
=
m_nbIndices
[
LINE_INDICES
];
break
;
case
TRIANGLES
:
m_nbIndices
[
TRIANGLE_INDICES
]
=
tableIndices
.
size
();
vbo_ind
=
m_indexBuffers
[
TRIANGLE_INDICES
];
size
=
m_nbIndices
[
TRIANGLE_INDICES
];
break
;
case
BOUNDARY
:
m_nbIndices
[
BOUNDARY_INDICES
]
=
tableIndices
.
size
();
vbo_ind
=
m_indexBuffers
[
BOUNDARY_INDICES
];
size
=
m_nbIndices
[
BOUNDARY_INDICES
];
break
;
default:
CGoGNerr
<<
"problem initializing VBO indices"
<<
CGoGNendl
;
break
;
}
int
size
=
tableIndices
.
size
();
// setup du buffer d'indices
glBindBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
,
vbo_ind
);
glBufferDataARB
(
GL_ELEMENT_ARRAY_BUFFER
,
size
*
sizeof
(
GLuint
),
&
(
tableIndices
[
0
]),
GL_STREAM_DRAW
);
glBufferDataARB
(
GL_ELEMENT_ARRAY_BUFFER
,
size
*
sizeof
(
GLuint
),
&
(
tableIndices
[
0
]),
GL_STREAM_DRAW
);
}
void
MapRender
::
draw
(
Utils
::
GLSLShader
*
sh
,
int
prim
)
...
...
@@ -112,10 +117,10 @@ void MapRender::draw(Utils::GLSLShader* sh, int prim)
sh
->
disableVertexAttribs
();
}
unsigned
int
MapRender
::
drawSub
(
Utils
::
GLSLShader
*
sh
,
int
prim
,
unsigned
int
nb_elm
)
{
sh
->
enableVertexAttribs
();
switch
(
prim
)
{
case
POINTS
:
...
...
@@ -145,7 +150,6 @@ unsigned int MapRender::drawSub(Utils::GLSLShader* sh, int prim, unsigned int nb
return
nb_elm
;
}
}
// namespace GL2
}
// namespace Render
...
...
src/Utils/GLSLShader.cpp
View file @
86b3bc0f
...
...
@@ -885,7 +885,7 @@ bool GLSLShader::checkShader(int shaderType)
id
=
m_geom_shader_object
;
break
;
default:
CGoGNerr
<<
"Error unkown shader type"
<<
CGoGNendl
;
CGoGNerr
<<
"Error unkown shader type"
<<
CGoGNendl
;
return
false
;
break
;
}
...
...
@@ -946,12 +946,12 @@ void GLSLShader::unbindVA(const std::string& name)
//valid ?
if
(
idVA
<
0
)
{
CGoGNerr
<<
"GLSLShader: Attribute "
<<
name
<<
" does not exist in shader, not unbinded"
<<
CGoGNendl
;
CGoGNerr
<<
"GLSLShader: Attribute "
<<
name
<<
" does not exist in shader, not unbinded"
<<
CGoGNendl
;
return
;
}
// search if name already exist
unsigned
int
nb
=
m_va_vbo_binding
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
if
(
m_va_vbo_binding
[
i
].
va_id
==
idVA
)
{
...
...
@@ -1000,7 +1000,7 @@ void GLSLShader::updateMatrices(const glm::mat4& projection, const glm::mat4& mo
void
GLSLShader
::
enableVertexAttribs
(
unsigned
int
stride
,
unsigned
int
begin
)
const
{
this
->
bind
();
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
m_va_vbo_binding
.
begin
();
it
!=
m_va_vbo_binding
.
end
();
++
it
)
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
m_va_vbo_binding
.
begin
();
it
!=
m_va_vbo_binding
.
end
();
++
it
)
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
it
->
vbo_ptr
->
id
());
glEnableVertexAttribArray
(
it
->
va_id
);
...
...
@@ -1011,7 +1011,7 @@ void GLSLShader::enableVertexAttribs(unsigned int stride, unsigned int begin) co
void
GLSLShader
::
disableVertexAttribs
()
const
{
this
->
bind
();
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
m_va_vbo_binding
.
begin
();
it
!=
m_va_vbo_binding
.
end
();
++
it
)
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
m_va_vbo_binding
.
begin
();
it
!=
m_va_vbo_binding
.
end
();
++
it
)
glDisableVertexAttribArray
(
it
->
va_id
);
this
->
unbind
();
}
...
...
@@ -1021,8 +1021,8 @@ void GLSLShader::updateCurrentMatrices()
glm
::
mat4
model
(
currentModelView
());
model
*=
currentTransfo
();
for
(
std
::
set
<
std
::
pair
<
void
*
,
GLSLShader
*>
>::
iterator
it
=
m_registeredShaders
.
begin
();
it
!=
m_registeredShaders
.
end
();
++
it
)
it
->
second
->
updateMatrices
(
currentProjection
(),
model
);
for
(
std
::
set
<
std
::
pair
<
void
*
,
GLSLShader
*>
>::
iterator
it
=
m_registeredShaders
.
begin
();
it
!=
m_registeredShaders
.
end
();
++
it
)
it
->
second
->
updateMatrices
(
currentProjection
(),
model
);
}
}
// namespace Utils
...
...
src/Utils/vbo.cpp
View file @
86b3bc0f
...
...
@@ -65,8 +65,6 @@ VBO::~VBO()
glDeleteBuffers
(
1
,
&
m_id
);
}
void
VBO
::
sameAllocSameBufferSize
(
const
VBO
&
vbo
)
{
m_data_size
=
vbo
.
m_data_size
;
...
...
@@ -80,7 +78,7 @@ void* VBO::lockPtr()
{
if
(
m_lock
)
{
CGoGNerr
<<
" Error already locked VBO"
<<
CGoGNendl
;
CGoGNerr
<<
"Error already locked VBO"
<<
CGoGNendl
;
return
NULL
;
}
...
...
@@ -93,7 +91,7 @@ const void* VBO::lockPtr() const
{
if
(
m_lock
)
{
CGoGNerr
<<
" Error already locked VBO"
<<
CGoGNendl
;
CGoGNerr
<<
"Error already locked VBO"
<<
CGoGNendl
;
return
NULL
;
}
...
...
@@ -112,17 +110,16 @@ void VBO::releasePtr() const
void
VBO
::
copyData
(
void
*
ptr
)
const
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
glGetBufferSubData
(
GL_ARRAY_BUFFER
,
0
,
m_nbElts
*
m_data_size
*
sizeof
(
float
),
ptr
);
glGetBufferSubData
(
GL_ARRAY_BUFFER
,
0
,
m_nbElts
*
m_data_size
*
sizeof
(
float
),
ptr
);
}
void
VBO
::
allocate
(
unsigned
int
nbElts
)
{
m_nbElts
=
nbElts
;
glBindBuffer
(
GL_ARRAY_BUFFER
,
m_id
);
glBufferData
(
GL_ARRAY_BUFFER
,
nbElts
*
m_data_size
*
sizeof
(
float
),
0
,
GL_STREAM_DRAW
);
glBufferData
(
GL_ARRAY_BUFFER
,
nbElts
*
m_data_size
*
sizeof
(
float
),
0
,
GL_STREAM_DRAW
);
}
}
// namespace Utils
}
// namespace CGoGN
src/Utils/vboRender.cpp
0 → 100644
View file @
86b3bc0f
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "vector"
#include "Utils/vboRender.h"
#include "Utils/GLSLShader.h"
namespace
CGoGN
{
namespace
Utils
{
VBORender
::
VBORender
()
{
glGenBuffersARB
(
1
,
&
m_indexBuffer
)
;
m_nbIndices
=
0
;
m_primitiveType
=
POINTS
;
}
VBORender
::~
VBORender
()
{
glDeleteBuffersARB
(
1
,
&
m_indexBuffer
)
;
}
void
VBORender
::
setConnectivity
(
std
::
vector
<
GLuint
>&
tableIndices
,
int
primitiveType
)
{
m_primitiveType
=
primitiveType
;
m_nbIndices
=
tableIndices
.
size
()
;
glBindBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
,
m_indexBuffer
)
;
glBufferDataARB
(
GL_ELEMENT_ARRAY_BUFFER
,
m_nbIndices
*
sizeof
(
GLuint
),
&
(
tableIndices
[
0
]),
GL_STREAM_DRAW
)
;
}
void
VBORender
::
draw
(
Utils
::
GLSLShader
*
sh
)
{
sh
->
enableVertexAttribs
()
;
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
m_indexBuffer
)
;
switch
(
m_primitiveType
)
{
case
POINTS
:
glDrawElements
(
GL_POINTS
,
m_nbIndices
,
GL_UNSIGNED_INT
,
0
)
;
break
;
case
LINES
:
glDrawElements
(
GL_LINES
,
m_nbIndices
,
GL_UNSIGNED_INT
,
0
);
break
;
case
TRIANGLES
:
glDrawElements
(
GL_TRIANGLES
,
m_nbIndices
,
GL_UNSIGNED_INT
,
0
);
break
;
default:
break
;
}
sh
->
disableVertexAttribs
()
;
}
}
// namespace Utils
}
// namespace CGoGN
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel