Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
d02167ed
Commit
d02167ed
authored
Mar 13, 2015
by
Sylvain Thery
Browse files
remove clipping using std::regex for gcc 4.8 (see volumeExplorer for clippig topo)
parent
001acd3b
Changes
19
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/CMakeLists.txt
View file @
d02167ed
...
...
@@ -14,7 +14,7 @@ add_executable( frame_manip frame_manip.cpp ${frame_manip_moc} )
target_link_libraries
(
frame_manip
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
#need to define that we use Qt (only once per cmake directory!)
qt_use_cgogn_modules
(
frame_manip
)
qt_wrap_cpp
(
texturesExample_moc texturesExample.h
)
add_executable
(
texturesExample texturesExample.cpp
${
texturesExample_moc
}
)
target_link_libraries
(
texturesExample
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
...
...
@@ -40,10 +40,12 @@ qt_wrap_cpp( viewer_moc viewer.h )
add_executable
(
viewer viewer.cpp
${
viewer_moc
}
${
viewer_ui
}
)
target_link_libraries
(
viewer
${
CGoGN_LIBS
}
${
NUMERICAL_LIBS
}
${
CGoGN_EXT_LIBS
}
)
qt_wrap_ui
(
clipping_ui clipping.ui
)
qt_wrap_cpp
(
clipping_moc clipping.h
)
add_executable
(
clipping clipping.cpp
${
clipping_ui
}
${
clipping_moc
}
)
target_link_libraries
(
clipping
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
IF
(
CGoGN_GCC_4_9
)
qt_wrap_ui
(
clipping_ui clipping.ui
)
qt_wrap_cpp
(
clipping_moc clipping.h
)
add_executable
(
clipping clipping.cpp
${
clipping_ui
}
${
clipping_moc
}
)
target_link_libraries
(
clipping
${
CGoGN_LIBS
}
${
CGoGN_EXT_LIBS
}
)
ENDIF
()
qt_wrap_ui
(
volumeExplorer_ui volumeExplorer.ui
)
qt_wrap_cpp
(
volumeExplorer_moc volumeExplorer.h
)
...
...
Apps/Examples/volumeExplorer.cpp
View file @
d02167ed
...
...
@@ -73,16 +73,12 @@ void MyQT::clipping_onoff(bool x)
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
float
d
=
-
(
pos
*
normal
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_topo_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
}
else
{
m_explode_render
->
setNoClippingPlane
();
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_sh1
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_sh2
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_topo_render
->
setNoClippingPlane
();
}
updateGL
();
}
...
...
@@ -206,7 +202,7 @@ void MyQT::cb_initGL()
{
// create the renders
m_topo_render
=
new
Algo
::
Render
::
GL2
::
Topo3RenderMap
<
PFP
>
();
m_explode_render
=
new
Algo
::
Render
::
GL2
::
ExplodeVolumeRender
(
true
,
true
,
true
);
m_explode_render
=
new
Algo
::
Render
::
GL2
::
ExplodeVolumeRender
(
true
,
true
,
true
);
// SelectorDartNoBoundary<MAP> nb(myMap);
m_topo_render
->
updateData
(
myMap
,
position
,
0.8
f
,
0.8
f
,
0.8
f
);
...
...
@@ -217,8 +213,6 @@ void MyQT::cb_initGL()
m_explode_render
->
setBackColor
(
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
));
m_explode_render
->
setColorLine
(
Geom
::
Vec4f
(
0.8
f
,
0.2
f
,
0.2
f
,
1.0
f
));
m_sh1
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_topo_render
->
shader1
());
m_sh2
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_topo_render
->
shader2
());
registerShader
(
m_explode_render
->
shaderFaces
());
registerShader
(
m_explode_render
->
shaderLines
());
...
...
@@ -227,15 +221,6 @@ void MyQT::cb_initGL()
m_frame
=
new
Utils
::
FrameManipulator
();
m_frame
->
setSize
(
m_WidthObj
/
2.0
f
);
m_sh1
->
insertClippingCode
();
m_sh2
->
insertClippingCode
();
clip_id1
=
m_sh1
->
addClipPlane
();
clip_id2
=
m_sh2
->
addClipPlane
();
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
m_PosObj
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
m_PosObj
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
0
,
0
,
1
,
m_PosObj
*
Geom
::
Vec3f
(
0
,
0
,
-
1
)));
}
...
...
@@ -370,9 +355,8 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
float
d
=
-
(
pos
*
normal
);
m_explode_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_topo_render
->
setClippingPlane
(
Geom
::
Vec4f
(
normal
[
0
],
normal
[
1
],
normal
[
2
],
d
));
m_sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_begX
=
x
;
m_begY
=
y
;
...
...
@@ -484,28 +468,6 @@ int main(int argc, char **argv)
dock
.
slider_explode_face
->
setValue
(
100
);
sqt
.
clipping_onoff
(
true
);
// Utils::Chrono ch;
// ch.start();
// float vol = Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms // val="<<vol<< std::endl;
// std::cout << "Compute Volume ->"<< std::endl;
// ch.start();
// vol = Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// ch.start();
// vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
// std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// et on attend la fin.
return
app
.
exec
();
}
Apps/Examples/volumeExplorer.h
View file @
d02167ed
...
...
@@ -93,8 +93,8 @@ class MyQT: public Utils::QT::SimpleQGLV
int
clip_id2
;
// shader of toporender3
Utils
::
ClippingShader
*
m_sh1
;
Utils
::
ClippingShader
*
m_sh2
;
//
Utils::ClippingShader* m_sh1;
//
Utils::ClippingShader* m_sh2;
Utils
::
Chrono
m_frame_ch
;
unsigned
int
m_nbFrames
;
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.h
View file @
d02167ed
...
...
@@ -158,6 +158,10 @@ public:
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader1
);
}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader2
);
}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Algo/Render/GL2/topo3Render.hpp
View file @
d02167ed
...
...
@@ -71,8 +71,8 @@ Topo3Render<PFP>::Topo3Render():
m_vbo3
->
setDataSize
(
3
);
m_vbo4
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader2
=
new
Utils
::
ShaderColorPerVertex
();
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
m_shader2
=
new
Utils
::
ShaderColorPerVertex
(
true
,
false
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -109,6 +109,22 @@ Topo3Render<PFP>::~Topo3Render()
delete
[]
m_bufferDartPosition
;
}
template
<
typename
PFP
>
void
Topo3Render
<
PFP
>::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_shader1
->
setClippingPlane
(
plane
);
m_shader2
->
setClippingPlane
(
plane
);
}
template
<
typename
PFP
>
void
Topo3Render
<
PFP
>::
setNoClippingPlane
()
{
this
->
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
template
<
typename
PFP
>
void
Topo3Render
<
PFP
>::
setDartWidth
(
float
dw
)
{
...
...
CGoGN/include/Algo/Render/GL2/topoPrimalRender.h
View file @
d02167ed
...
...
@@ -148,6 +148,10 @@ public:
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader1
);
}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSLShader
*>
(
m_shader2
);
}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Algo/Render/GL2/topoPrimalRender.hpp
View file @
d02167ed
...
...
@@ -62,8 +62,8 @@ TopoPrimalRender<PFP>::TopoPrimalRender():
m_vbo1
->
setDataSize
(
3
);
m_vbo2
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader2
=
new
Utils
::
ShaderColorPerVertex
();
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
m_shader2
=
new
Utils
::
ShaderColorPerVertex
(
true
,
false
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -98,6 +98,20 @@ TopoPrimalRender<PFP>::~TopoPrimalRender()
delete
[]
m_bufferDartPosition
;
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_shader1
->
setClippingPlane
(
plane
);
m_shader2
->
setClippingPlane
(
plane
);
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setNoClippingPlane
()
{
this
->
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
template
<
typename
PFP
>
void
TopoPrimalRender
<
PFP
>::
setDartWidth
(
float
dw
)
{
...
...
CGoGN/include/Algo/Render/GL2/topoRender.h
View file @
d02167ed
...
...
@@ -177,6 +177,10 @@ public:
*/
~
TopoGenRender
();
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
void
setNoClippingPlane
();
/**
* set the with of line use to draw darts (default val is 2)
* @param dw width
...
...
CGoGN/include/Utils/Shaders/shaderColorPerVertex.h
View file @
d02167ed
...
...
@@ -43,6 +43,8 @@ protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
VBO
*
m_vboPos
;
VBO
*
m_vboCol
;
...
...
@@ -50,10 +52,15 @@ protected:
CGoGNGLuint
m_unif_alpha
;
float
m_opacity
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
void
restoreUniformsAttribs
();
public:
ShaderColorPerVertex
(
bool
black_is_transparent
=
false
);
ShaderColorPerVertex
(
bool
withClipping
=
false
,
bool
black_is_transparent
=
false
);
/**
* set the VBO of position (vec3)
...
...
@@ -71,6 +78,8 @@ public:
void
setOpacity
(
float
op
);
float
getOpacity
()
const
{
return
m_opacity
;}
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
};
}
// namespace Utils
...
...
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.frag
0 → 100644
View file @
d02167ed
// ShaderColorPerVertex::fragmentShaderClipText
PRECISION
;
VARYING_FRAG
vec3
color
;
VARYING_FRAG
vec3
posClip
;
uniform
vec4
planeClip
;
uniform
float
alpha
;
FRAG_OUT_DEF
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
#ifdef BLACK_TRANSPARENCY
if
(
dot
(
color
,
color
)
==
0
.
0
)
discard
;
#endif
FRAG_OUT
=
vec4
(
color
,
alpha
);
}
CGoGN/include/Utils/Shaders/shaderColorPerVertexClip.vert
0 → 100644
View file @
d02167ed
// ShaderColorPerVertex::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
;
ATTRIBUTE
vec3
VertexColor
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_VERT
vec3
color
;
VARYING_VERT
vec3
posClip
;
INVARIANT_POS
;
void
main
()
{
posClip
=
VertexPosition
;
color
=
VertexColor
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/include/Utils/Shaders/shaderSimpleColor.h
View file @
d02167ed
...
...
@@ -43,22 +43,30 @@ protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
vertexShaderClipText
;
static
std
::
string
fragmentShaderClipText
;
//
uniform locations
//
/ color
CGoGNGLuint
m_unif_color
;
Geom
::
Vec4f
m_color
;
/// clipping
CGoGNGLuint
m_unif_planeClip
;
Geom
::
Vec4f
m_planeClip
;
VBO
*
m_vboPos
;
void
restoreUniformsAttribs
();
public:
ShaderSimpleColor
(
bool
back_is_transparent
=
false
);
ShaderSimpleColor
(
bool
withClipping
=
false
,
bool
back_is_transparent
=
false
);
void
setColor
(
const
Geom
::
Vec4f
&
color
);
unsigned
int
setAttributePosition
(
VBO
*
vbo
);
void
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
);
};
}
// namespace Utils
...
...
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.frag
0 → 100644
View file @
d02167ed
// ShaderSimpleColor::fragmentShaderClipText
PRECISION
;
uniform
vec4
color
;
uniform
vec4
planeClip
;
VARYING_FRAG
vec3
posClip
;
FRAG_OUT_DEF
;
void
main
()
{
if
(
dot
(
planeClip
,
vec4
(
posClip
,
1
.
0
))
>
0
.
0
)
discard
;
#ifdef BLACK_TRANSPARENCY
if
(
dot
(
color
,
color
)
==
0
.
0
)
discard
;
#endif
FRAG_OUT
=
color
;
}
CGoGN/include/Utils/Shaders/shaderSimpleColorClip.vert
0 → 100644
View file @
d02167ed
// ShaderSimpleColor::vertexShaderClipText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_VERT
vec3
posClip
;
void
main
()
{
posClip
=
VertexPosition
;
gl_Position
=
ModelViewProjectionMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
CGoGN/src/Algo/Render/topoGenRender.cpp
View file @
d02167ed
...
...
@@ -66,7 +66,7 @@ TopoGenRender::TopoGenRender(float bs):
m_vbo1
->
setDataSize
(
3
);
m_vbo2
->
setDataSize
(
3
);
m_shader1
=
new
Utils
::
ShaderSimpleColor
();
m_shader1
=
new
Utils
::
ShaderSimpleColor
(
true
,
false
);
// binding VBO - VA
m_vaId
=
m_shader1
->
setAttributePosition
(
m_vbo1
);
...
...
@@ -135,6 +135,19 @@ TopoGenRender::~TopoGenRender()
void
TopoGenRender
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_shader1
->
setClippingPlane
(
plane
);
}
void
TopoGenRender
::
setNoClippingPlane
()
{
this
->
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
void
TopoGenRender
::
setDartWidth
(
float
dw
)
{
m_topo_dart_width
=
dw
;
...
...
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
View file @
d02167ed
...
...
@@ -33,46 +33,49 @@ namespace Utils
#include
"shaderColorPerVertex.vert"
#include
"shaderColorPerVertex.frag"
#include
"shaderColorPerVertexClip.vert"
#include
"shaderColorPerVertexClip.frag"
//std::string ShaderColorPerVertex::vertexShaderText =
// "ATTRIBUTE vec3 VertexPosition;\n"
// "ATTRIBUTE vec3 VertexColor;\n"
// "uniform mat4 ModelViewProjectionMatrix;\n"
// "VARYING_VERT vec3 color;\n"
// "INVARIANT_POS;\n"
// "void main ()\n"
// "{\n"
// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n"
// " color = VertexColor;\n"
// "}";
//
//
//std::string ShaderColorPerVertex::fragmentShaderText =
// "PRECISION;\n"
// "VARYING_FRAG vec3 color;\n"
// "FRAG_OUT_DEF;\n"
// "void main()\n"
// "{\n"
// " FRAG_OUT=vec4(color,0.0);\n"
// "}";
ShaderColorPerVertex
::
ShaderColorPerVertex
(
bool
black_is_transparent
)
ShaderColorPerVertex
::
ShaderColorPerVertex
(
bool
withClipping
,
bool
black_is_transparent
)
{
m_nameVS
=
"ShaderColorPerVertex_vs"
;
m_nameFS
=
"ShaderColorPerVertex_fs"
;
m_nameGS
=
"ShaderColorPerVertex_gs"
;
if
(
withClipping
)
{
m_nameVS
=
"ShaderColorPerVertexClip_vs"
;
m_nameFS
=
"ShaderColorPerVertexClip_fs"
;
m_nameGS
=
""
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderClipText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderClipText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
*
m_unif_planeClip
=
glGetUniformLocation
(
this
->
program_handler
(),
"planeClip"
);
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
)
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
}
else
{
m_nameVS
=
"ShaderColorPerVertex_vs"
;
m_nameFS
=
"ShaderColorPerVertex_fs"
;
m_nameGS
=
"ShaderColorPerVertex_gs"
;
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
}
bind
();
*
m_unif_alpha
=
glGetUniformLocation
(
this
->
program_handler
(),
"alpha"
);
glUniform1f
(
*
m_unif_alpha
,
1.0
f
);
...
...
@@ -99,12 +102,14 @@ unsigned int ShaderColorPerVertex::setAttributeColor(VBO* vbo)
return
id
;
}
void
ShaderColorPerVertex
::
restoreUniformsAttribs
()
{
bind
();
bindVA_VBO
(
"VertexPosition"
,
m_vboPos
);
bindVA_VBO
(
"VertexColor"
,
m_vboCol
);
glUniform1f
(
*
m_unif_alpha
,
m_opacity
);
glUniform4fv
(
*
m_unif_planeClip
,
1
,
m_planeClip
.
data
());
unbind
();
}
...
...
@@ -116,6 +121,16 @@ void ShaderColorPerVertex::setOpacity(float op)
unbind
();
}
void
ShaderColorPerVertex
::
setClippingPlane
(
const
Geom
::
Vec4f
&
plane
)
{
m_planeClip
=
plane
;
bind
();
glUniform4fv
(
*
m_unif_planeClip
,
1
,
plane
.
data
());
unbind
();
}
}
// namespace Utils
}
// namespace CGoGN
CGoGN/src/Utils/Shaders/shaderSimpleColor.cpp
View file @
d02167ed
...
...
@@ -32,47 +32,53 @@ namespace Utils
#include
"shaderSimpleColor.vert"
#include
"shaderSimpleColor.frag"
#include
"shaderSimpleColorClip.vert"
#include
"shaderSimpleColorClip.frag"
//std::string ShaderSimpleColor::vertexShaderText =
// "ATTRIBUTE vec3 VertexPosition, VertexNormal;\n"
// "uniform mat4 ModelViewProjectionMatrix;\n"
//// "INVARIANT_POS;\n"
// "void main ()\n"
// "{\n"
// " gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n"
// "}";
//
//
//std::string ShaderSimpleColor::fragmentShaderText =
// "PRECISION;\n"
// "uniform vec4 color;\n"
// "FRAG_OUT_DEF;\n"
// "void main()\n"
// "{\n"
// " FRAG_OUT = color;\n"
// "}";
ShaderSimpleColor
::
ShaderSimpleColor
(
bool
black_is_transparent
)
{
m_nameVS
=
"ShaderSimpleColor_vs"
;
m_nameFS
=
"ShaderSimpleColor_fs"
;
m_nameGS
=
"ShaderSimpleColor_gs"
;
// chose GL defines (2 or 3)
// and compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
ShaderSimpleColor
::
ShaderSimpleColor
(
bool
withClipping
,
bool
black_is_transparent
)
{
if
(
withClipping
)
{
m_nameVS
=
"ShaderSimpleColorClip_vs"
;
m_nameFS
=
"ShaderSimpleColorClip_fs"
;
m_nameGS
=
""
;
// chose GL defines (2 or 3)
// and compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderClipText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderClipText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
*
m_unif_planeClip
=
glGetUniformLocation
(
this
->
program_handler
(),
"planeClip"
);
setClippingPlane
(
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
));
}
else
{
m_nameVS
=
"ShaderSimpleColor_vs"
;
m_nameFS
=
"ShaderSimpleColor_fs"
;
m_nameGS
=
""
;
// chose GL defines (2 or 3)
// and compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);