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
5f83b5b9
Commit
5f83b5b9
authored
Nov 06, 2012
by
Sylvain Thery
Browse files
enhance rendering of text by mixing front & back color
parent
8b62d1d9
Changes
2
Show whitespace changes
Inline
Side-by-side
include/Utils/text3d.h
View file @
5f83b5b9
...
...
@@ -54,6 +54,7 @@ protected:
static
std
::
string
fragmentShaderText1
;
static
std
::
string
fragmentShaderText2
;
static
std
::
string
fragmentShaderText3
;
static
Strings3D
*
m_instance0
;
...
...
src/Utils/text3d.cpp
View file @
5f83b5b9
...
...
@@ -36,8 +36,10 @@ namespace Utils
std
::
string
Strings3D
::
fragmentShaderText2
=
" gl_FragColor = color*lum;
\n
"
"}"
;
" if (lum == 0.0) discard;
\n
gl_FragColor = color*lum;
\n
}"
;
std
::
string
Strings3D
::
fragmentShaderText3
=
" gl_FragColor = mix(backColor,color,lum);
\n
}"
;
Strings3D
*
Strings3D
::
m_instance0
=
NULL
;
...
...
@@ -70,22 +72,28 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan
if
(
with_plane
)
glxvert
.
append
(
"#define WITH_PLANE 1"
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
glxfrag
.
append
(
fragmentShaderText1
);
std
::
string
background
;
if
(
!
withBackground
)
glxfrag
.
append
(
"if (lum == 0.0) discard;
\n
"
);
else
if
(
bgc
*
bgc
>
0.0
)
{
glxfrag
.
append
(
fragmentShaderText2
);
}
else
{
std
::
stringstream
ss
;
ss
<<
" if (lum==0.0) gl_FragColor=vec4("
;
ss
<<
bgc
[
0
]
<<
","
<<
bgc
[
1
]
<<
","
<<
bgc
[
2
]
<<
",color[3]);
\n
else
\n
"
;
background
.
append
(
ss
.
str
());
ss
<<
"vec4 backColor = vec4("
<<
bgc
[
0
]
<<
","
<<
bgc
[
1
]
<<
","
<<
bgc
[
2
]
<<
",color[3]);
\n
"
;
// ss << "vec4 backColor = vec4(0.2,0.1,0.4);\n";
glxfrag
.
append
(
ss
.
str
());
glxfrag
.
append
(
fragmentShaderText3
);
}
glxfrag
.
append
(
background
);
glxfrag
.
append
(
fragmentShaderText2
);
std
::
cout
<<
"===================================="
<<
std
::
endl
;
std
::
cout
<<
glxfrag
<<
std
::
endl
;
std
::
cout
<<
"===================================="
<<
std
::
endl
;
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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