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
519aeb8c
Commit
519aeb8c
authored
Apr 14, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update BoldLines
parent
495d160a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
78 deletions
+82
-78
Apps/Examples/frame_manip.cpp
Apps/Examples/frame_manip.cpp
+2
-2
Apps/Examples/mcmesh.cpp
Apps/Examples/mcmesh.cpp
+5
-15
CGoGN/include/Utils/Shaders/shaderBoldColorLines.geom
CGoGN/include/Utils/Shaders/shaderBoldColorLines.geom
+11
-10
CGoGN/include/Utils/Shaders/shaderBoldColorLines.h
CGoGN/include/Utils/Shaders/shaderBoldColorLines.h
+1
-1
CGoGN/include/Utils/Shaders/shaderBoldLines.geom
CGoGN/include/Utils/Shaders/shaderBoldLines.geom
+10
-9
CGoGN/include/Utils/Shaders/shaderBoldLines.h
CGoGN/include/Utils/Shaders/shaderBoldLines.h
+1
-1
CGoGN/include/Utils/pickables.h
CGoGN/include/Utils/pickables.h
+8
-4
CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp
CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp
+9
-10
CGoGN/src/Utils/Shaders/shaderBoldLines.cpp
CGoGN/src/Utils/Shaders/shaderBoldLines.cpp
+8
-12
CGoGN/src/Utils/pickables.cpp
CGoGN/src/Utils/pickables.cpp
+27
-14
No files found.
Apps/Examples/frame_manip.cpp
View file @
519aeb8c
...
...
@@ -134,9 +134,9 @@ void MyQT::cb_redraw()
for
(
std
::
vector
<
Utils
::
Pickable
*>::
iterator
it
=
m_pickables
.
begin
();
it
!=
m_pickables
.
end
();
++
it
)
{
if
(
*
it
==
m_lastPickedObject
)
glLineWidth
(
2
.0
);
(
*
it
)
->
setLineWidth
(
3
.0
);
else
gl
LineWidth
(
1.0
);
(
*
it
)
->
set
LineWidth
(
1.0
);
(
*
it
)
->
draw
();
}
...
...
Apps/Examples/mcmesh.cpp
View file @
519aeb8c
...
...
@@ -59,16 +59,14 @@ void MCMesh::cb_initGL()
m_flatShader
->
setDiffuse
(
colDif
);
m_flatShader
->
setExplode
(
1.0
f
);
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
();
m_simpleColorShader
->
setAttributePosition
(
m_positionVBO
);
//
m_simpleColorShader = new Utils::ShaderSimpleColor();
//
m_simpleColorShader->setAttributePosition(m_positionVBO);
m_colorVBO
=
new
Utils
::
VBO
();
m_linesShader
=
new
Utils
::
ShaderBoldLines
();
m_linesShader
->
setAttributePosition
(
m_positionVBO
);
// m_linesShader->setAttributeColor(m_colorVBO);
registerShader
(
m_flatShader
);
registerShader
(
m_simpleColorShader
);
//
registerShader(m_simpleColorShader);
registerShader
(
m_linesShader
);
m_dr
=
new
Utils
::
Drawer
();
...
...
@@ -90,7 +88,7 @@ void MCMesh::cb_initGL()
void
MCMesh
::
cb_redraw
()
{
glEnable
(
GL_BLEND
);
m_dr
->
callList
(
0.
5
f
);
m_dr
->
callList
(
0.
1
f
);
if
(
m_drawEdges
)
// {
// glLineWidth(1.0f);
...
...
@@ -107,10 +105,7 @@ glEnable(GL_BLEND);
// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
// }
{
// glLineWidth(1.0f);
// m_linesShader->setClippingPlane(Geom::Vec4f(0.03,0.03,-1.1,64));
m_linesShader
->
setLineWidth
(
12.0
f
);
m_linesShader
->
setLineWidth
(
2.0
f
);
if
(
m_drawFaces
)
{
Geom
::
Vec4f
c
(
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
...
...
@@ -200,11 +195,6 @@ void MCMesh::updateRender()
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_positionVBO
->
updateData
(
position
);
m_colorVBO
->
updateData
(
position
);
Geom
::
Vec3f
*
ptr
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
m_colorVBO
->
lockPtr
());
for
(
unsigned
int
i
=
0
;
i
<
m_colorVBO
->
nbElts
();
++
i
)
*
ptr
++
/=
130.0
f
;
m_colorVBO
->
releasePtr
();
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
...
...
CGoGN/include/Utils/Shaders/shaderBoldColorLines.geom
View file @
519aeb8c
// ShaderBoldColorLines::geometryShaderText
uniform
float
lineWidth
;
uniform
vec2
lineWidth
;
VARYING_IN
vec3
vcolor
[];
VARYING_OUT
vec3
fragColor
;
...
...
@@ -10,28 +10,29 @@ VARYING_OUT vec3 fragClip;
void
main
()
{
vec3
A
=
POSITION_IN
(
0
).
xyz
/
POSITION_IN
(
0
).
w
;
vec3
B
=
POSITION_IN
(
1
).
xyz
/
POSITION_IN
(
1
).
w
;
vec3
A
=
POSITION_IN
(
0
).
xyz
/
abs
(
POSITION_IN
(
0
).
w
);
vec3
B
=
POSITION_IN
(
1
).
xyz
/
abs
(
POSITION_IN
(
1
).
w
);
vec3
U
=
normalize
(
B
-
A
);
vec3
V
=
cross
(
U
,
vec3
(
0
.
0
,
0
.
0
,
1
.
0
));
vec3
LW
=
vec3
(
lineWidth
,
1
.
0
);
fragClip
=
posClip
[
0
];
fragColor
=
vcolor
[
0
];
gl_Position
=
vec4
(
A
-
U
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
-
U
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
A
+
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
+
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
A
-
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
-
V
*
LW
,
1
.
0
);
EmitVertex
();
fragColor
=
vcolor
[
1
];
fragClip
=
posClip
[
1
];
gl_Position
=
vec4
(
B
+
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
+
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
B
-
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
-
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
B
+
U
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
+
U
*
LW
,
1
.
0
);
EmitVertex
();
EndPrimitive
();
...
...
CGoGN/include/Utils/Shaders/shaderBoldColorLines.h
View file @
519aeb8c
...
...
@@ -48,7 +48,7 @@ protected:
CGoGNGLuint
m_uniform_lineWidth
;
CGoGNGLuint
m_unif_alpha
;
float
m_lineWidth
;
Geom
::
Vec2f
m_lineWidth
;
float
m_pixWidth
;
VBO
*
m_vboPos
;
...
...
CGoGN/include/Utils/Shaders/shaderBoldLines.geom
View file @
519aeb8c
// ShaderBoldLines::geometryShaderText
uniform
float
lineWidth
;
uniform
vec2
lineWidth
;
VARYING_IN
vec3
posClip
[];
VARYING_OUT
vec3
fragClip
;
void
main
()
{
vec3
A
=
POSITION_IN
(
0
).
xyz
/
POSITION_IN
(
0
).
w
;
vec3
B
=
POSITION_IN
(
1
).
xyz
/
POSITION_IN
(
1
).
w
;
vec3
A
=
POSITION_IN
(
0
).
xyz
/
abs
(
POSITION_IN
(
0
).
w
)
;
vec3
B
=
POSITION_IN
(
1
).
xyz
/
abs
(
POSITION_IN
(
1
).
w
)
;
vec3
U
=
normalize
(
B
-
A
);
vec3
V
=
cross
(
U
,
vec3
(
0
.
0
,
0
.
0
,
1
.
0
));
vec3
LW
=
vec3
(
lineWidth
,
1
.
0
);
fragClip
=
posClip
[
0
];
gl_Position
=
vec4
(
A
-
U
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
-
U
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
A
+
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
+
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
A
-
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
A
-
V
*
LW
,
1
.
0
);
EmitVertex
();
fragClip
=
posClip
[
1
];
gl_Position
=
vec4
(
B
+
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
+
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
B
-
V
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
-
V
*
LW
,
1
.
0
);
EmitVertex
();
gl_Position
=
vec4
(
B
+
U
*
lineWidth
,
1
.
0
);
gl_Position
=
vec4
(
B
+
U
*
LW
,
1
.
0
);
EmitVertex
();
EndPrimitive
();
}
CGoGN/include/Utils/Shaders/shaderBoldLines.h
View file @
519aeb8c
...
...
@@ -48,7 +48,7 @@ protected:
CGoGNGLuint
m_uniform_lineWidth
;
CGoGNGLuint
m_uniform_color
;
float
m_lineWidth
;
Geom
::
Vec2f
m_lineWidth
;
float
m_pixWidth
;
Geom
::
Vec4f
m_color
;
...
...
CGoGN/include/Utils/pickables.h
View file @
519aeb8c
...
...
@@ -28,8 +28,8 @@
#include "Utils/vbo_base.h"
#include "glm/glm.hpp"
#include "Utils/Shaders/shaderColorPerVertex
.h"
#include "Utils/Shaders/shader
SimpleColor
.h"
//#include "Utils/Shaders/shaderSimpleColor
.h"
#include "Utils/Shaders/shader
BoldLines
.h"
#include "Utils/dll.h"
...
...
@@ -56,7 +56,8 @@ protected:
/**
* Shader
*/
Utils
::
ShaderSimpleColor
*
m_shader
;
// static Utils::ShaderSimpleColor* s_shader;
static
Utils
::
ShaderBoldLines
*
s_shader
;
/**
* number of indices in vbo
...
...
@@ -70,6 +71,8 @@ protected:
unsigned
int
m_sub2
;
float
m_lineWidth
;
public:
/**
...
...
@@ -124,6 +127,7 @@ public:
*/
void
getPrecisionDrawing
(
unsigned
int
&
sub
,
unsigned
int
&
sub2
);
inline
void
setLineWidth
(
float
lw
)
{
m_lineWidth
=
lw
;
}
};
...
...
@@ -288,7 +292,7 @@ public:
*/
Geom
::
Vec3f
getAxisScale
(
unsigned
int
ax
,
float
&
scale
);
inline
void
setLineWidth
(
float
lw
)
{
m_drawable
->
setLineWidth
(
lw
);
}
};
...
...
CGoGN/src/Utils/Shaders/shaderBoldColorLines.cpp
View file @
519aeb8c
...
...
@@ -23,6 +23,7 @@
*******************************************************************************/
#define CGoGN_UTILS_DLL_EXPORT 1
#include "Utils/Shaders/shaderBoldColorLines.h"
#include <algorithm>
namespace
CGoGN
{
...
...
@@ -74,7 +75,7 @@ void ShaderBoldColorLines::getLocations()
void
ShaderBoldColorLines
::
sendParams
()
{
bind
();
glUniform
1f
(
*
m_uniform_lineWidth
,
m_lineWidth
);
glUniform
2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
()
);
glUniform1f
(
*
m_unif_alpha
,
m_opacity
);
if
(
*
m_unif_planeClip
>
0
)
...
...
@@ -88,12 +89,11 @@ void ShaderBoldColorLines::setLineWidth(float pix)
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
float
lw
=
float
(
double
(
pix
)
/
double
(
viewport
[
2
]));
bind
();
glUniform1f
(
*
m_uniform_lineWidth
,
lw
);
m_lineWidth
=
lw
;
m_pixWidth
=
pix
;
m_lineWidth
[
0
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
1
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
3
]));
bind
();
glUniform2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
());
unbind
();
}
...
...
@@ -101,11 +101,10 @@ void ShaderBoldColorLines::updatePixelWidth()
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
float
lw
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
0
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
1
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
3
]));
bind
();
glUniform1f
(
*
m_uniform_lineWidth
,
lw
);
m_lineWidth
=
lw
;
glUniform2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
());
unbind
();
}
...
...
CGoGN/src/Utils/Shaders/shaderBoldLines.cpp
View file @
519aeb8c
...
...
@@ -72,7 +72,7 @@ void ShaderBoldLines::getLocations()
void
ShaderBoldLines
::
sendParams
()
{
bind
();
glUniform
1f
(
*
m_uniform_lineWidth
,
m_lineWidth
);
glUniform
2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
()
);
glUniform4fv
(
*
m_uniform_color
,
1
,
m_color
.
data
());
if
(
*
m_unif_planeClip
>
0
)
...
...
@@ -86,12 +86,11 @@ void ShaderBoldLines::setLineWidth(float pix)
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
float
lw
=
float
(
double
(
pix
)
/
double
(
viewport
[
2
]));
m_pixWidth
=
pix
;
m_lineWidth
[
0
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
1
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
3
]));
bind
();
glUniform1f
(
*
m_uniform_lineWidth
,
lw
);
m_lineWidth
=
lw
;
m_pixWidth
=
pix
;
glUniform2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
());
unbind
();
}
...
...
@@ -99,11 +98,10 @@ void ShaderBoldLines::updatePixelWidth()
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
float
lw
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
0
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
2
]));
m_lineWidth
[
1
]
=
float
(
double
(
m_pixWidth
)
/
double
(
viewport
[
3
]));
bind
();
glUniform1f
(
*
m_uniform_lineWidth
,
lw
);
m_lineWidth
=
lw
;
glUniform2fv
(
*
m_uniform_lineWidth
,
1
,
m_lineWidth
.
data
());
unbind
();
}
...
...
@@ -122,8 +120,6 @@ unsigned int ShaderBoldLines::setAttributePosition(VBO* vbo)
m_vboPos
=
vbo
;
bind
();
unsigned
int
id
=
bindVA_VBO
(
"VertexPosition"
,
vbo
);
std
::
cout
<<
"setAttributePosition => "
<<
id
<<
std
::
endl
;
unbind
();
return
id
;
}
...
...
CGoGN/src/Utils/pickables.cpp
View file @
519aeb8c
...
...
@@ -36,16 +36,20 @@ namespace CGoGN
namespace
Utils
{
Utils
::
ShaderBoldLines
*
LineDrawable
::
s_shader
=
NULL
;
// Utils::ShaderSimpleColor* LineDrawable::s_shader = NULL;
LineDrawable
::
LineDrawable
()
{
m_vboPos
=
new
VBO
();
m_vboPos
->
setDataSize
(
3
);
m_shader
=
new
ShaderSimpleColor
();
m_shader
->
setAttributePosition
(
m_vboPos
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.
,
1.
,
0.
,
0.
));
GLSLShader
::
registerShader
(
NULL
,
m_shader
);
if
(
s_shader
==
NULL
)
{
// s_shader = new ShaderSimpleColor();
s_shader
=
new
ShaderBoldLines
();
GLSLShader
::
registerShader
(
NULL
,
s_shader
);
}
glGenBuffers
(
1
,
&
(
*
m_ind
));
}
...
...
@@ -53,8 +57,8 @@ LineDrawable::LineDrawable()
LineDrawable
::~
LineDrawable
()
{
delete
m_vboPos
;
GLSLShader
::
unregisterShader
(
NULL
,
m
_shader
);
delete
m
_shader
;
// GLSLShader::unregisterShader(NULL, s
_shader);
// delete s
_shader;
glDeleteBuffers
(
1
,
&
(
*
m_ind
));
}
...
...
@@ -63,7 +67,7 @@ LineDrawable::~LineDrawable()
void
LineDrawable
::
setColor
(
const
Geom
::
Vec4f
&
col
)
{
m_color
=
col
;
m
_shader
->
setColor
(
col
);
// s
_shader->setColor(col);
}
const
Geom
::
Vec4f
&
LineDrawable
::
getColor
()
...
...
@@ -73,9 +77,12 @@ const Geom::Vec4f& LineDrawable::getColor()
void
LineDrawable
::
draw
()
{
m_shader
->
enableVertexAttribs
();
s_shader
->
setAttributePosition
(
m_vboPos
);
s_shader
->
setColor
(
m_color
);
s_shader
->
setLineWidth
(
m_lineWidth
);
s_shader
->
enableVertexAttribs
();
glDrawArrays
(
GL_LINES
,
0
,
m_nb
);
m
_shader
->
disableVertexAttribs
();
s
_shader
->
disableVertexAttribs
();
}
void
LineDrawable
::
getPrecisionDrawing
(
unsigned
int
&
sub
,
unsigned
int
&
sub2
)
...
...
@@ -495,10 +502,13 @@ void Sphere::updatePrecisionDrawing(unsigned int sub, unsigned int sub2)
void
Sphere
::
draw
()
{
m_shader
->
enableVertexAttribs
();
s_shader
->
setAttributePosition
(
m_vboPos
);
s_shader
->
setColor
(
m_color
);
s_shader
->
setLineWidth
(
m_lineWidth
);
s_shader
->
enableVertexAttribs
();
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
*
m_ind
);
glDrawElements
(
GL_LINES
,
m_nb
,
GL_UNSIGNED_INT
,
0
);
m
_shader
->
disableVertexAttribs
();
s
_shader
->
disableVertexAttribs
();
}
...
...
@@ -884,10 +894,13 @@ void Cube::updatePrecisionDrawing(unsigned int sub, unsigned int sub2)
void
Cube
::
draw
()
{
m_shader
->
enableVertexAttribs
();
s_shader
->
setAttributePosition
(
m_vboPos
);
s_shader
->
setColor
(
m_color
);
s_shader
->
setLineWidth
(
m_lineWidth
);
s_shader
->
enableVertexAttribs
();
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
*
m_ind
);
glDrawElements
(
GL_LINES
,
m_nb
,
GL_UNSIGNED_INT
,
0
);
m
_shader
->
disableVertexAttribs
();
s
_shader
->
disableVertexAttribs
();
}
...
...
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