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
Julian Schakib
glow-samples
Commits
5fd57a6a
Commit
5fd57a6a
authored
5 years ago
by
Jonathan Kunstwald
Browse files
Options
Downloads
Patches
Plain Diff
Update cube sample to modern conventions, imgui, tg
parent
4f971804
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
samples/basic/cube/CubeSample.cc
+22
-20
22 additions, 20 deletions
samples/basic/cube/CubeSample.cc
samples/basic/cube/CubeSample.hh
+2
-1
2 additions, 1 deletion
samples/basic/cube/CubeSample.hh
with
24 additions
and
21 deletions
samples/basic/cube/CubeSample.cc
+
22
−
20
View file @
5fd57a6a
#include
"CubeSample.hh"
#include
<
glow/objects/Program.h
h>
#include
<glow/objects/Shader.hh>
#include
<
glow/objects/VertexArray
.hh>
#include
<
imgui/imgui.
h>
#include
<
typed-geometry/tg
.hh>
#include
<glow/common/scoped_gl.hh>
#include
<glow/common/str_utils.hh>
#include
<glow/objects/Program.hh>
#include
<glow/objects/Shader.hh>
#include
<glow/objects/VertexArray.hh>
#include
<glow-extras/geometry/Cube.hh>
#include
<AntTweakBar.h>
using
namespace
glow
;
using
namespace
glow
::
camera
;
void
CubeSample
::
init
()
{
setGui
(
GlfwApp
::
Gui
::
AntTweakBar
);
GlfwApp
::
init
();
// call to base!
mShader
=
Program
::
createFromFile
(
util
::
pathOf
(
__FILE__
)
+
"/shader"
);
mCube
=
geometry
::
Cube
<>
().
generate
();
auto
cam
=
getCamera
();
cam
->
setLookAt
({
2
,
5
,
4
},
{
0
,
0
,
0
});
TwAddVarRW
(
tweakbar
(),
"Animate"
,
TW_TYPE_BOOLCPP
,
&
mAnimate
,
""
);
getCamera
()
->
setLookAt
({
2
,
5
,
4
},
{
0
,
0
,
0
});
}
void
CubeSample
::
render
(
float
elapsedSeconds
)
{
if
(
mAnimate
)
mRuntime
+=
elapsedSeconds
;
auto
time
=
mAnimate
?
mRuntime
:
0.0
f
;
auto
cam
=
getCamera
();
GLOW_SCOPED
(
clearColor
,
0
,
0
,
0
,
1
);
GLOW_SCOPED
(
enable
,
GL_DEPTH_TEST
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
GLOW_SCOPED
(
enable
,
GL_DEPTH_TEST
);
auto
shader
=
mShader
->
use
();
shader
.
setUniform
(
"uRuntime"
,
time
)
;
shader
.
setUniform
(
"uView"
,
cam
->
getViewMatrix
()
)
;
shader
.
setUniform
(
"uProj"
,
cam
->
getProjectionMatrix
()
)
;
shader
.
setUniform
(
"uModel"
,
glm
::
rotat
e
(
time
,
glm
::
vec3
{
0
,
1
,
0
}
));
shader
[
"uRuntime"
]
=
mRun
time
;
shader
[
"uView"
]
=
getCamera
()
->
getViewMatrix
();
shader
[
"uProj"
]
=
getCamera
()
->
getProjectionMatrix
();
shader
[
"uModel"
]
=
tg
::
rotat
ion_around
(
tg
::
dir3
{
0
,
1
,
0
},
tg
::
radians
(
mRuntime
));
mCube
->
bind
().
draw
();
}
void
CubeSample
::
onGui
()
{
ImGui
::
Begin
(
"Cube Sample"
);
ImGui
::
Checkbox
(
"Animate"
,
&
mAnimate
);
ImGui
::
End
();
}
This diff is collapsed.
Click to expand it.
samples/basic/cube/CubeSample.hh
+
2
−
1
View file @
5fd57a6a
...
...
@@ -9,7 +9,7 @@
class
CubeSample
:
public
glow
::
glfw
::
GlfwApp
{
public:
CubeSample
()
:
GlfwApp
(
Gui
::
AntTweakBar
)
{}
CubeSample
()
:
GlfwApp
(
Gui
::
ImGui
)
{}
private
:
glow
::
SharedProgram
mShader
;
...
...
@@ -21,4 +21,5 @@ private:
protected
:
void
init
()
override
;
void
render
(
float
elapsedSeconds
)
override
;
void
onGui
()
override
;
};
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