Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glow-samples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zain Selman
glow-samples
Commits
1de09b5e
Commit
1de09b5e
authored
5 years ago
by
Jonathan Kunstwald
Browse files
Options
Downloads
Patches
Plain Diff
Update Viewer sample with new examples
parent
ded6cbf7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
samples/wip/viewer/main.cc
+36
-21
36 additions, 21 deletions
samples/wip/viewer/main.cc
with
36 additions
and
21 deletions
samples/wip/viewer/main.cc
+
36
−
21
View file @
1de09b5e
...
...
@@ -65,7 +65,7 @@ int main()
view
(
pos
,
"Suzanne"
);
// smooth normals
view
(
polygons
(
pos
).
smooth_normals
());
view
(
polygons
(
pos
).
smooth_normals
()
,
"smoothed normals"
);
// Configuration nesting
{
...
...
@@ -83,40 +83,40 @@ int main()
}
// Mapped 1D vertex data
view
(
pos
,
mapping
(
vdata
).
linear
({
0
,
0
,
0
},
{
1
,
0
,
0
},
0.1
f
,
0.3
f
));
view
(
pos
,
mapping
(
vdata
).
linear
({
0
,
0
,
0
},
{
1
,
0
,
0
},
0.1
f
,
0.3
f
)
,
"vertex data"
);
// Mapped 1D face data
view
(
pos
,
mapping
(
fdata
).
linear
({
0
,
1
,
0
},
{
0
,
0
,
1
},
-
0.5
f
,
0.5
f
).
clamped
());
view
(
pos
,
mapping
(
fdata
).
linear
({
0
,
1
,
0
},
{
0
,
0
,
1
},
-
0.5
f
,
0.5
f
).
clamped
()
,
"face data"
);
// Textured mesh
view
(
pos
,
textured
(
uv
,
tex
));
view
(
pos
,
textured
(
uv
,
tex
)
,
"textured"
);
// Textured mesh (async texture)
view
(
pos
,
textured
(
uv
,
atex
));
view
(
pos
,
textured
(
uv
,
atex
)
,
"textured (async)"
);
// Simple point cloud
view
(
points
(
pos
));
view
(
points
(
pos
)
,
"point cloud"
);
// Square, oriented point cloud with adaptive point size
view
(
points
(
pos
).
point_size_world
(
ptsize
).
normals
(
vnormals
).
square
());
view
(
points
(
pos
).
point_size_world
(
ptsize
).
normals
(
vnormals
).
square
()
,
"normal oriented squares"
);
// Points rendered as 3D spheres
view
(
points
(
pos
).
spheres
().
point_size_world
(
0.03
f
));
view
(
points
(
pos
).
spheres
().
point_size_world
(
0.03
f
)
,
"sphere cloud"
);
// Simple line soup
view
(
lines
(
pos
));
view
(
lines
(
pos
)
,
"edges"
);
// Configure view
{
auto
v
=
glow
::
viewer
::
view
();
v
.
view
(
pos
,
glow
::
colors
::
color
(
0
,
1
,
0
));
v
.
view
(
pos
,
glow
::
colors
::
color
(
0
,
1
,
0
)
,
"configured view"
);
// when out-of-scope, v immediately shows
}
// Multiple objects
{
auto
v
=
glow
::
viewer
::
view
();
v
.
view
(
polygons
(
pos
).
move
({
-
1.5
f
,
0
,
0
}),
glow
::
colors
::
color
(
1
,
0
,
0
));
v
.
view
(
polygons
(
pos
).
move
({
-
1.5
f
,
0
,
0
}),
glow
::
colors
::
color
(
1
,
0
,
0
)
,
"multiple objects"
);
v
.
view
(
polygons
(
pos
).
move
({
+
1.5
f
,
0
,
0
}),
glow
::
colors
::
color
(
0
,
0
,
1
));
// or:
...
...
@@ -201,6 +201,31 @@ int main()
}
}
// Create a "headless" screenshot
{
// Viewer never shows a window, returns once screenshot is rendered
GLOW_VIEWER_CONFIG
(
glow
::
viewer
::
headless_screenshot
(
tg
::
ivec2
(
1000
,
1000
),
32
,
"demo_screenshot.png"
));
glow
::
viewer
::
view
(
pos
);
}
// Conditional RAII objects
{
// Use an outer viewer object conditionally
auto
o
=
(
sizeof
(
int
)
>
1
)
?
glow
::
viewer
::
rows
()
:
glow
::
viewer
::
nothing
();
{
// Camera starting position
GLOW_VIEWER_CONFIG
(
glow
::
viewer
::
camera_orientation
(
125
_deg
,
-
15
_deg
,
1.7
f
));
// Tonemapping
GLOW_VIEWER_CONFIG
(
glow
::
viewer
::
tonemap_exposure
(
3.5
f
));
// These two either nest into the outer object, or create their own windows
view
(
pos
,
textured
(
uv
,
tex
));
view
(
points
(
pos
));
}
}
// tg objects
{
auto
v
=
glow
::
viewer
::
grid
();
...
...
@@ -293,15 +318,5 @@ int main()
});
}
// Alternatively, output a single frame headlessly
// auto view = glow::viewer::view(pos);
// view->render()->bind().writeToFile("viewer_output.png");
// view->to_file("viewer_output.png");
// view->to_texture() -> SharedTexture2D/Rect;
// view->to_image() -> img;
// view->into_file(ostream&);
// view->into_texture(SharedTexture2D/Rect);
// view->into_image(img&);
return
0
;
}
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