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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
604a068c
Commit
604a068c
authored
Apr 05, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oubli fichiers Render/*.cpp
parent
6980a3f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
773 additions
and
189 deletions
+773
-189
Apps/Tuto/CMakeLists.txt
Apps/Tuto/CMakeLists.txt
+3
-3
Apps/Tuto/tuto_ogl3.cpp
Apps/Tuto/tuto_ogl3.cpp
+174
-185
include/Utils/shaderPhong.h
include/Utils/shaderPhong.h
+1
-1
src/Algo/Render/mapRender.cpp
src/Algo/Render/mapRender.cpp
+135
-0
src/Algo/Render/topo3Render.cpp
src/Algo/Render/topo3Render.cpp
+282
-0
src/Algo/Render/topoRender.cpp
src/Algo/Render/topoRender.cpp
+178
-0
No files found.
Apps/Tuto/CMakeLists.txt
View file @
604a068c
...
@@ -40,7 +40,6 @@ target_link_libraries( tuto1
...
@@ -40,7 +40,6 @@ target_link_libraries( tuto1
QT4_WRAP_UI
(
tuto2_ui tuto2.ui
)
QT4_WRAP_UI
(
tuto2_ui tuto2.ui
)
QT4_WRAP_CPP
(
tuto2_moc tuto2.h
)
QT4_WRAP_CPP
(
tuto2_moc tuto2.h
)
add_executable
(
tuto2 tuto2.cpp tuto2.h
${
tuto2_ui
}
${
tuto2_moc
}
)
add_executable
(
tuto2 tuto2.cpp tuto2.h
${
tuto2_ui
}
${
tuto2_moc
}
)
target_link_libraries
(
tuto2
target_link_libraries
(
tuto2
container topology utils algo
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
container topology utils algo
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
...
@@ -69,9 +68,10 @@ add_executable( tuto_mt tuto_mt.cpp)
...
@@ -69,9 +68,10 @@ add_executable( tuto_mt tuto_mt.cpp)
target_link_libraries
(
tuto_mt
target_link_libraries
(
tuto_mt
container topology utils algo
${
COMMON_LIBS
}
boost_thread-mt
)
container topology utils algo
${
COMMON_LIBS
}
boost_thread-mt
)
add_executable
(
tuto_ogl3 tuto_ogl3.cpp
)
QT4_WRAP_CPP
(
tuto_ogl3_moc tuto_ogl3.h
)
add_executable
(
tuto_ogl3 tuto_ogl3.cpp
${
tuto_ogl3_moc
}
)
target_link_libraries
(
tuto_ogl3
target_link_libraries
(
tuto_ogl3
container topology utils algo
${
COMMON_LIBS
}
)
container topology utils algo
${
COMMON_LIBS
}
${
QT_LIBRARIES
}
)
add_executable
(
tuto_ogl2 tuto_ogl2.cpp
)
add_executable
(
tuto_ogl2 tuto_ogl2.cpp
)
target_link_libraries
(
tuto_ogl2
target_link_libraries
(
tuto_ogl2
...
...
Apps/Tuto/tuto_ogl3.cpp
View file @
604a068c
/*******************************************************************************
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* *
* This library is free software; you can redistribute it and/or modify it *
* 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 *
* 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 *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* option) any later version. *
* *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* for more details. *
* *
* *
* You should have received a copy of the GNU Lesser General Public License *
* 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, *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* Contact information: cgogn@unistra.fr *
* *
* *
*******************************************************************************/
*******************************************************************************/
#include <iostream>
#include <iostream>
#include "Utils/glutwingl3.h"
#include "tuto_ogl3.h"
#include <QWidget>
#include "Topology/generic/parameters.h"
#include <QtGui>
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/gl3mapRender.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Geometry/vector_gen.h"
#include "Algo/Geometry/normal.h"
#include "Utils/shaderPhong.h"
using
namespace
CGoGN
;
using
namespace
CGoGN
;
/**
void
MyQT
::
sliderFocale_cb
(
int
x
)
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct
PFP
:
public
PFP_STANDARD
{
// definition of the type of the map
typedef
EmbeddedMap2
<
Map2
>
MAP
;
};
/**
* A class for a little interface and rendering
*/
class
MyGlutWin
:
public
Utils
::
SimpleGlutWinGL3
{
{
public:
m_glWidget
->
setFocal
(
0.01
f
*
x
);
updateGL
();
void
myRedraw
();
}
void
myKeyboard
(
unsigned
char
keycode
,
int
x
,
int
y
);
void
renderColor
();
void
renderPhong
();
void
initPhongMaterial
();
PFP
::
REAL
gWidthObj
;
PFP
::
VEC3
gPosObj
;
Algo
::
Render
::
GL3
::
MapRender
*
m_render
;
Utils
::
GLSLShader
*
current_shader
;
Utils
::
GLSLShader
shaders
[
4
];
int
rt
;
MyGlutWin
(
int
*
argc
,
char
**
argv
,
int
winX
,
int
winY
)
:
SimpleGlutWinGL3
(
argc
,
argv
,
winX
,
winY
),
rt
(
0
)
{
shaders
[
0
].
loadShaders
(
"color_gl3.vert"
,
"color_gl3.frag"
);
shaders
[
1
].
loadShaders
(
"phong_gl3.vert"
,
"phong_gl3.frag"
);
current_shader
=
&
shaders
[
0
];
setCurrentShader
(
current_shader
);
}
~
MyGlutWin
()
{
delete
m_render
;
}
};
void
My
GlutWin
::
initPhongMaterial
()
void
My
QT
::
color_cb
()
{
{
float
diffuse
[]
=
{
0.0
f
,
1.0
f
,
0.0
f
,
0.0
f
};
QColor
color
=
QColorDialog
::
getColor
();
float
specular
[]
=
{
0.3
f
,
0.3
f
,
1.0
f
,
0.0
f
};
if
(
color
.
isValid
())
float
ambient
[]
=
{
0.1
f
,
0.03
f
,
0.03
f
,
0.0
f
};
{
float
shininess
=
100.0
f
;
std
::
cout
<<
"Color "
<<
color
.
red
()
<<
","
<<
color
.
green
()
<<
","
<<
color
.
blue
()
<<
std
::
endl
;
float
lightPos
[]
=
{
100.0
,
300.0
,
1000.0
f
};
shader1
->
setDiffuse
(
Geom
::
Vec4f
(
float
(
color
.
red
())
/
255.0
f
,
float
(
color
.
green
())
/
255.0
f
,
float
(
color
.
blue
())
/
255.0
f
,
0.0
f
));
updateGL
();
shaders
[
1
].
bind
();
}
else
shaders
[
1
].
setuniformf
<
4
>
(
"materialDiffuse"
,
diffuse
);
{
shaders
[
1
].
setuniformf
<
4
>
(
"materialSpecular"
,
specular
);
std
::
cout
<<
"Cancel"
<<
std
::
endl
;
shaders
[
1
].
setuniformf
<
4
>
(
"materialAmbient"
,
ambient
);
}
shaders
[
1
].
setuniformf
<
1
>
(
"shininess"
,
&
shininess
);
shaders
[
1
].
setuniformf
<
3
>
(
"LightPosition"
,
lightPos
);
}
}
void
MyGlutWin
::
renderColor
(
)
MyQT
::
MyQT
()
:
m_render
(
NULL
)
{
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
// currentShader = NULL;
glDisable
(
GL_LIGHTING
);
}
current_shader
->
bind
();
// draw the lines
glLineWidth
(
2.0
f
);
float
colorLine
[]
=
{
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
};
current_shader
->
setuniformf
<
4
>
(
"Color"
,
colorLine
);
m_render
->
draw
(
Algo
::
Render
::
GL3
::
LINES
);
// draw the faces
glEnable
(
GL_POLYGON_OFFSET_FILL
);
glPolygonOffset
(
1.0
f
,
1.0
f
);
float
colorFace
[]
=
{
0.1
f
,
0.1
f
,
0.3
f
,
0.0
f
};
MyQT
::~
MyQT
()
current_shader
->
setuniformf
<
4
>
(
"Color"
,
colorFace
);
{
}
m_render
->
draw
(
Algo
::
Render
::
GL3
::
TRIANGLES
);
glDisable
(
GL_POLYGON_OFFSET_FILL
);
}
void
My
GlutWin
::
renderPhong
()
void
My
QT
::
cb_initGL
()
{
{
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
3
);
// instanciation of the renderer (here using VBOs)
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
();
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
positionVBO
=
new
Utils
::
VBO
(
);
glEnable
(
GL_LIGHTING
);
normalVBO
=
new
Utils
::
VBO
(
);
current_shader
->
bind
();
shader1
=
new
Utils
::
ShaderPhong
();
m_render
->
draw
(
Algo
::
Render
::
GL3
::
TRIANGLES
);
shader1
->
setAttributePosition
(
*
positionVBO
);
}
shader1
->
setAttributeNormal
(
*
normalVBO
);
currentShader
=
shader1
;
}
void
My
GlutWin
::
myRedraw
()
void
My
QT
::
cb_updateMatrix
()
{
{
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
if
(
currentShader
)
// oglPushModelViewMatrix();
switch
(
rt
)
{
{
case
0
:
currentShader
->
bind
();
renderColor
();
currentShader
->
updateMatrices
(
m_projection_matrix
,
m_modelView_matrix
);
break
;
case
1
:
renderPhong
();
break
;
}
}
// oglPopModelViewMatrix();
}
}
void
My
GlutWin
::
myKeyboard
(
unsigned
char
keycode
,
int
x
,
int
y
)
void
My
QT
::
cb_redraw
(
)
{
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
switch
(
keycode
)
glEnable
(
GL_LIGHTING
);
if
(
currentShader
)
{
{
case
'c'
:
m_render
->
draw
(
currentShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
rt
=
0
;
current_shader
=
&
shaders
[
0
];
setCurrentShader
(
current_shader
);
std
::
cout
<<
"Color"
<<
std
::
endl
;
break
;
case
'p'
:
rt
=
1
;
current_shader
=
&
shaders
[
1
];
setCurrentShader
(
current_shader
);
std
::
cout
<<
"Phong"
<<
std
::
endl
;
break
;
}
}
glutPostRedisplay
();
}
}
int
main
(
int
argc
,
char
**
argv
)
//void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{
//{
// switch(keycode)
// {
// case 'f':
// focale-=0.1f;
// setFoc(focale);
// break;
// case 'F':
// focale+=0.1f;
// setFoc(focale);
// break;
// }
////
//// switch(keycode)
//// {
//// case 'c':
//// rt=0;
//// current_shader = &shaders[0];
//// setCurrentShader(current_shader);
//// std::cout << "Color"<< std::endl;
//// break;
//// case 'p':
//// rt=1;
//// current_shader = &shaders[1];
//// setCurrentShader(current_shader);
//// std::cout << "Phong"<< std::endl;
//// break;
//// }
//// glutPostRedisplay();
//
//
// switch(keycode)
// {
// case 'r':
// shader1.setDiffuse(Geom::Vec4f(1.,0.,0.,0.));
// break;
// case 'v':
// shader1.setDiffuse(Geom::Vec4f(0.,1.,0.,0.));
// break;
// case 'j':
// shader1.setDiffuse(Geom::Vec4f(1.,1.,0.,0.));
// break;
//
// case 'w':
// shader1.setAttributeColor(normalVBO);
// break;
// case 'x':
// shader1.unsetAttributeColor();
// break;
//
// }
// glutPostRedisplay();
//}
// instanciation of the interface
MyGlutWin
mgw
(
&
argc
,
argv
,
800
,
800
);
int
main
(
int
argc
,
char
**
argv
)
{
// declaration of the map
// declaration of the map
PFP
::
MAP
myMap
;
PFP
::
MAP
myMap
;
...
@@ -206,44 +170,69 @@ int main(int argc, char **argv)
...
@@ -206,44 +170,69 @@ int main(int argc, char **argv)
AttributeHandler
<
PFP
::
VEC3
>
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
);
AttributeHandler
<
PFP
::
VEC3
>
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
);
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim3
(
myMap
,
position
);
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim3
(
myMap
,
position
);
prim3
.
tore_topo
(
16
,
32
);
prim3
.
tore_topo
(
32
,
64
);
prim3
.
embedTore
(
30.0
f
,
10.0
f
);
prim3
.
embedTore
(
1.0
f
,
0.3
f
);
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
);
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
);
mgw
.
init
();
glClearColor
(
0.1
,
0.1
,
0.3
,
0.0
);
QApplication
app
(
argc
,
argv
);
MyQT
sqt
;
// computation of the bounding box
// Qt "a la main"
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
mgw
.
gWidthObj
=
std
::
max
<
PFP
::
REAL
>
(
std
::
max
<
PFP
::
REAL
>
(
bb
.
size
(
0
),
bb
.
size
(
1
)),
bb
.
size
(
2
));
mgw
.
gPosObj
=
(
bb
.
min
()
+
bb
.
max
())
/
PFP
::
REAL
(
2
);
mgw
.
setParamObject
(
mgw
.
gWidthObj
,
mgw
.
gPosObj
.
data
()
);
QDockWidget
*
dock
=
sqt
.
addEmptyDock
(
);
// instanciation of the renderer (here using VBOs)
// group principal
mgw
.
m_render
=
new
Algo
::
Render
::
GL3
::
MapRender
();
QGroupBox
*
interface_gb
=
new
QGroupBox
();
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
layout
->
addWidget
(
new
QLabel
(
"Focale"
));
// declare names attributes of shaders
QSlider
*
slider_foc
=
new
QSlider
(
Qt
::
Horizontal
);
mgw
.
m_render
->
useVertexAttributeName
(
"VertexPosition"
,
mgw
.
shaders
[
0
]
);
slider_foc
->
setRange
(
50
,
300
);
mgw
.
m_render
->
useVertexAttributeName
(
"VertexPosition"
,
mgw
.
shaders
[
1
]
);
slider_foc
->
setSliderPosition
(
200
);
unsigned
int
attNormalId
=
mgw
.
m_render
->
useVertexAttributeName
(
"VertexNormal"
,
mgw
.
shaders
[
1
]
);
layout
->
addWidget
(
slider_foc
);
// send data to gc
QPushButton
*
buttonColor
=
new
QPushButton
(
"Color"
);
mgw
.
m_render
->
updateData
(
"VertexPosition"
,
position
);
// with name
layout
->
addWidget
(
buttonColor
);
mgw
.
m_render
->
updateData
(
attNormalId
,
normal
);
//with Id
// update the renderer (primitives and geometry)
// on tasse vers le haut
SelectorTrue
allDarts
;
layout
->
addItem
(
new
QSpacerItem
(
0
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
));
mgw
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL3
::
TRIANGLES
);
mgw
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL3
::
LINES
);
// et met tout ça dans le dock
mgw
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL3
::
POINTS
);
interface_gb
->
setLayout
(
layout
);
dock
->
setWidget
(
interface_gb
);
sqt
.
windowTitle
(
"OGL3 QT"
);
sqt
.
dockTitle
(
"interface"
);
mgw
.
initPhongMaterial
();
// connection widget callback
sqt
.
setCallBack
(
slider_foc
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
sliderFocale_cb
(
int
))
);
sqt
.
setCallBack
(
buttonColor
,
SIGNAL
(
clicked
()),
SLOT
(
color_cb
())
);
// computation of the bounding box
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
float
lWidthObj
=
std
::
max
<
PFP
::
REAL
>
(
std
::
max
<
PFP
::
REAL
>
(
bb
.
size
(
0
),
bb
.
size
(
1
)),
bb
.
size
(
2
));
Geom
::
Vec3f
lPosObj
=
(
bb
.
min
()
+
bb
.
max
())
/
PFP
::
REAL
(
2
);
sqt
.
setParamObject
(
lWidthObj
,
lPosObj
.
data
());
// first show to init GL Context before initializing VBO
sqt
.
show
();
sqt
.
positionVBO
->
updateData
(
position
);
sqt
.
normalVBO
->
updateData
(
normal
);
// update the renderer (primitives and geometry)
SelectorTrue
allDarts
;
sqt
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
sqt
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
LINES
);
sqt
.
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
POINTS
);
mgw
.
mainLoop
();
// second show to have a good initial redraw
sqt
.
show
();
return
0
;
return
app
.
exec
();
// return 0;
}
}
include/Utils/shaderPhong.h
View file @
604a068c
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __CGOGN_SHADER_PHONG_
#ifndef __CGOGN_SHADER_PHONG_
#define __CGOGN_SHADER_PHONG_
#define __CGOGN_SHADER_PHONG_
#include "Utils/GLSLShader
3
.h"
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Geometry/vector_gen.h"
#include <string>
#include <string>
...
...
src/Algo/Render/mapRender.cpp
0 → 100644
View file @
604a068c
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/GLSLShader.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Render
{
namespace
GL2
{
MapRender
::
MapRender
()
:
m_nbIndicesTri
(
0
),
m_nbIndicesLines
(
0
),
m_nbIndicesPoints
(
0
),
m_nbFlatElts
(
0
)
{
glGenBuffersARB
(
4
,
m_VBOBuffers
)
;
}
MapRender
::~
MapRender
()
{
glDeleteBuffersARB
(
4
,
m_VBOBuffers
);
delete
[]
m_VBOBuffers
;
}
void
MapRender
::
initPrimitives
(
int
prim
,
std
::
vector
<
GLuint
>&
tableIndices
)
{
// indice du VBO a utiliser
int
vbo_ind
=
0
;
switch
(
prim
)
{
case
TRIANGLES
:
m_nbIndicesTri
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
TRIANGLE_INDICES
];
break
;
case
LINES
:
m_nbIndicesLines
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
LINE_INDICES
];
break
;
case
POINTS
:
m_nbIndicesPoints
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
POINT_INDICES
];
break
;
default:
std
::
cerr
<<
"problem initializing VBO indices"
<<
std
::
endl
;
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
);
}
void
MapRender
::
draw
(
Utils
::
GLSLShader
*
sh
,
int
prim
)
{
const
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>&
vastr
=
sh
->
getVA_VBO_Bindings
();
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
vastr
.
begin
();
it
!=
vastr
.
end
();
++
it
)
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
it
->
vbo_ptr
->
id
());
glEnableVertexAttribArray
(
it
->
va_id
);
glVertexAttribPointer
(
it
->
va_id
,
it
->
vbo_ptr
->
dataSize
(),
GL_FLOAT
,
false
,
0
,
0
);
}
switch
(
prim
)
{
case
TRIANGLES
:
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
TRIANGLE_INDICES
]);
glDrawElements
(
GL_TRIANGLES
,
m_nbIndicesTri
,
GL_UNSIGNED_INT
,
0
);
break
;
case
LINES
:
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
LINE_INDICES
]);
glDrawElements
(
GL_LINES
,
m_nbIndicesLines
,
GL_UNSIGNED_INT
,
0
);
break
;
case
POINTS
:
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
POINT_INDICES
]);
glDrawElements
(
GL_POINTS
,
m_nbIndicesPoints
,
GL_UNSIGNED_INT
,
0
)
;
break
;
default:
break
;
}
for
(
std
::
vector
<
Utils
::
GLSLShader
::
VAStr
>::
const_iterator
it
=
vastr
.
begin
();
it
!=
vastr
.
end
();
++
it
)
{
glDisableVertexAttribArray