Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
65a02495
Commit
65a02495
authored
9 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
new billboard-style texture drawing
parent
49f5a4a4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Graphics/drawContext.h
+1
-1
1 addition, 1 deletion
Graphics/drawContext.h
Graphics/drawGlyph.cpp
+45
-2
45 additions, 2 deletions
Graphics/drawGlyph.cpp
with
46 additions
and
3 deletions
Graphics/drawContext.h
+
1
−
1
View file @
65a02495
...
@@ -234,7 +234,7 @@ class drawContext {
...
@@ -234,7 +234,7 @@ class drawContext {
void
drawStringCenter
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
);
void
drawStringCenter
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
);
void
drawStringRight
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
);
void
drawStringRight
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
);
void
drawString
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
,
double
style
);
void
drawString
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
,
double
style
);
void
drawImage
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
);
void
drawImage
(
const
std
::
string
&
s
,
double
x
,
double
y
,
double
z
,
int
align
=
0
);
void
drawSphere
(
double
R
,
double
x
,
double
y
,
double
z
,
int
n1
,
int
n2
,
int
light
);
void
drawSphere
(
double
R
,
double
x
,
double
y
,
double
z
,
int
n1
,
int
n2
,
int
light
);
void
drawEllipsoid
(
double
x
,
double
y
,
double
z
,
float
v0
[
3
],
float
v1
[
3
],
void
drawEllipsoid
(
double
x
,
double
y
,
double
z
,
float
v0
[
3
],
float
v1
[
3
],
float
v2
[
3
],
int
light
);
float
v2
[
3
],
int
light
);
...
...
This diff is collapsed.
Click to expand it.
Graphics/drawGlyph.cpp
+
45
−
2
View file @
65a02495
...
@@ -21,7 +21,7 @@ void drawContext::drawString(const std::string &s, double x, double y, double z,
...
@@ -21,7 +21,7 @@ void drawContext::drawString(const std::string &s, double x, double y, double z,
if
(
CTX
::
instance
()
->
printing
&&
!
CTX
::
instance
()
->
print
.
text
)
return
;
if
(
CTX
::
instance
()
->
printing
&&
!
CTX
::
instance
()
->
print
.
text
)
return
;
if
(
s
.
size
()
>
8
&&
s
.
substr
(
0
,
7
)
==
"file://"
){
if
(
s
.
size
()
>
8
&&
s
.
substr
(
0
,
7
)
==
"file://"
){
drawImage
(
s
.
substr
(
7
),
x
,
y
,
z
);
drawImage
(
s
.
substr
(
7
),
x
,
y
,
z
,
align
);
return
;
return
;
}
}
...
@@ -133,7 +133,8 @@ void drawContext::drawString(const std::string &s, double x, double y, double z,
...
@@ -133,7 +133,8 @@ void drawContext::drawString(const std::string &s, double x, double y, double z,
}
}
}
}
void
drawContext
::
drawImage
(
const
std
::
string
&
name
,
double
x
,
double
y
,
double
z
)
void
drawContext
::
drawImage
(
const
std
::
string
&
name
,
double
x
,
double
y
,
double
z
,
int
align
)
{
{
// format can be "@wxh" or "@wxh,wx,wy,wz,hx,hy,hz", where w and h are the
// format can be "@wxh" or "@wxh,wx,wy,wz,hx,hy,hz", where w and h are the
// width and height (in model coordinates for T3 or in pixels for T2) of the
// width and height (in model coordinates for T3 or in pixels for T2) of the
...
@@ -146,6 +147,7 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
...
@@ -146,6 +147,7 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
file
=
name
.
substr
(
0
,
p
);
file
=
name
.
substr
(
0
,
p
);
}
}
double
w
=
0.
,
h
=
0.
,
wx
=
1.
,
wy
=
0.
,
wz
=
0.
,
hx
=
0.
,
hy
=
1.
,
hz
=
0.
;
double
w
=
0.
,
h
=
0.
,
wx
=
1.
,
wy
=
0.
,
wz
=
0.
,
hx
=
0.
,
hy
=
1.
,
hz
=
0.
;
bool
billboard
=
false
;
if
(
format
.
size
()){
if
(
format
.
size
()){
bool
ok
;
bool
ok
;
if
(
format
.
find
(
","
)
!=
std
::
string
::
npos
)
if
(
format
.
find
(
","
)
!=
std
::
string
::
npos
)
...
@@ -155,6 +157,8 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
...
@@ -155,6 +157,8 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
ok
=
(
sscanf
(
format
.
c_str
(),
"%lfx%lf"
,
&
w
,
&
h
)
==
2
);
ok
=
(
sscanf
(
format
.
c_str
(),
"%lfx%lf"
,
&
w
,
&
h
)
==
2
);
if
(
!
ok
)
if
(
!
ok
)
Msg
::
Warning
(
"Bad image format: use `@wxh' or `@wxh,wx,wy,wz,hx,hy,hz'"
);
Msg
::
Warning
(
"Bad image format: use `@wxh' or `@wxh,wx,wy,wz,hx,hy,hz'"
);
if
(
format
.
find
(
"#"
)
!=
std
::
string
::
npos
)
billboard
=
true
;
// texture will always face camera
}
}
imgtex
*
img
;
imgtex
*
img
;
...
@@ -185,6 +189,38 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
...
@@ -185,6 +189,38 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
w
=
h
*
img
->
w
/
img
->
h
;
w
=
h
*
img
->
w
/
img
->
h
;
}
}
GLint
matrixMode
=
0
;
if
(
billboard
){
glRasterPos3d
(
x
,
y
,
z
);
GLfloat
pos
[
4
];
glGetFloatv
(
GL_CURRENT_RASTER_POSITION
,
pos
);
glGetIntegerv
(
GL_MATRIX_MODE
,
&
matrixMode
);
glMatrixMode
(
GL_PROJECTION
);
glPushMatrix
();
glLoadIdentity
();
glMatrixMode
(
GL_MODELVIEW
);
glPushMatrix
();
glLoadIdentity
();
double
fact
=
isHighResolution
()
?
2.
:
1.
;
glOrtho
((
double
)
viewport
[
0
],
(
double
)
viewport
[
2
]
*
fact
,
(
double
)
viewport
[
1
],
(
double
)
viewport
[
3
]
*
fact
,
-
1e3
,
1e3
);
x
=
pos
[
0
];
y
=
pos
[
1
];
z
=
0
;
w
*=
fact
*
s
[
0
]
/
pixel_equiv_x
;
h
*=
fact
*
s
[
1
]
/
pixel_equiv_y
;
}
switch
(
align
){
case
1
:
x
-=
w
/
2.
;
break
;
// bottom center
case
2
:
x
-=
w
;
break
;
// bottom right
case
3
:
y
-=
h
;
break
;
// top left
case
4
:
x
-=
w
/
2.
;
y
-=
h
;
break
;
// top center
case
5
:
x
-=
w
;
y
-=
h
;
break
;
// top right
case
6
:
y
-=
h
/
2.
;
break
;
// center left
case
7
:
x
-=
w
/
2.
;
y
-=
h
/
2.
;
break
;
// center center
case
8
:
x
-=
w
;
y
-=
h
/
2.
;
break
;
// center right
default:
break
;
}
glEnable
(
GL_BLEND
);
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glEnable
(
GL_TEXTURE_2D
);
glEnable
(
GL_TEXTURE_2D
);
...
@@ -198,6 +234,13 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
...
@@ -198,6 +234,13 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
glEnd
();
glEnd
();
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_BLEND
);
glDisable
(
GL_BLEND
);
if
(
billboard
){
glPopMatrix
();
glMatrixMode
(
GL_PROJECTION
);
glPopMatrix
();
glMatrixMode
(
matrixMode
);
}
}
}
void
drawContext
::
drawSphere
(
double
R
,
double
x
,
double
y
,
double
z
,
void
drawContext
::
drawSphere
(
double
R
,
double
x
,
double
y
,
double
z
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment