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
CGoGN
CGoGN
Commits
89cdae80
Commit
89cdae80
authored
Oct 10, 2012
by
Sylvain Thery
Browse files
enhancement of text rendering (updating & change color)
parent
2433e28a
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/Utils/text3d.h
View file @
89cdae80
...
...
@@ -134,6 +134,12 @@ public:
*/
void
predraw
(
const
Geom
::
Vec3f
&
color
);
/**
* call just before a draw
* @param color the color of text
*/
void
changeColor
(
const
Geom
::
Vec3f
&
color
);
/**
* call once after several draw(id,pos)
*/
...
...
@@ -150,6 +156,14 @@ public:
*/
void
setPlane
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
);
/**
* Update string content
* @warning size can not be changed
* @param idSt string id
* @param str new string content
*/
void
updateString
(
unsigned
int
idSt
,
const
std
::
string
&
str
);
void
toSVG
(
Utils
::
SVG
::
SVGOut
&
svg
);
};
...
...
src/Utils/text3d.cpp
View file @
89cdae80
...
...
@@ -236,6 +236,12 @@ void Strings3D::predraw(const Geom::Vec3f& color)
enableVertexAttribs
();
}
void
Strings3D
::
changeColor
(
const
Geom
::
Vec3f
&
color
)
{
bind
();
glUniform3fv
(
*
m_uniform_color
,
1
,
color
.
data
());
}
void
Strings3D
::
postdraw
()
{
disableVertexAttribs
();
...
...
@@ -266,6 +272,56 @@ void Strings3D::drawAll(const Geom::Vec3f& color)
postdraw
();
}
void
Strings3D
::
updateString
(
unsigned
int
idSt
,
const
std
::
string
&
str
)
{
unsigned
int
firstIndex
=
m_strpos
[
idSt
].
first
;
unsigned
int
nbIndices
=
m_strpos
[
idSt
].
second
;
unsigned
int
nbc
=
std
::
min
((
unsigned
int
)(
str
.
length
()),
nbIndices
/
4
);
m_vbo1
->
bind
();
float
*
buffer
=
reinterpret_cast
<
float
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
));
buffer
+=
firstIndex
*
4
;
float
x
=
0.0
f
;
for
(
unsigned
int
j
=
0
;
j
<
nbc
;
++
j
)
{
unsigned
int
ci
=
str
[
j
]
-
32
;
float
u
=
float
(
ci
%
CHARSPERLINE
)
/
float
(
CHARSPERLINE
);
float
v
=
float
(
ci
/
CHARSPERLINE
)
/
float
(
CHARSPERCOL
)
+
1.0
f
/
HEIGHTTEXTURE
;
float
u2
=
u
+
float
(
REALWIDTHFONT
)
/
float
(
WIDTHTEXTURE
);
float
v2
=
v
+
float
(
WIDTHFONT
-
1
)
/
float
(
HEIGHTTEXTURE
);
*
buffer
++
=
x
;
*
buffer
++
=
0
;
*
buffer
++
=
u
;
*
buffer
++
=
v2
;
float
xf
=
x
+
float
(
REALWIDTHFONT
)
/
25.
f
;
*
buffer
++
=
xf
;
*
buffer
++
=
0
;
*
buffer
++
=
u2
;
*
buffer
++
=
v2
;
*
buffer
++
=
xf
;
*
buffer
++
=
float
(
WIDTHFONT
)
/
25.
f
;
*
buffer
++
=
u2
;
*
buffer
++
=
v
;
*
buffer
++
=
x
;
*
buffer
++
=
float
(
WIDTHFONT
)
/
25.
f
;
*
buffer
++
=
u
;
*
buffer
++
=
v
;
x
=
xf
;
// + space ?
}
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
void
Strings3D
::
toSVG
(
Utils
::
SVG
::
SVGOut
&
svg
)
{
svg
.
beginStrings
(
m_scale
);
...
...
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