Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Game Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
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
Game Development
Game Library
Commits
92c37613
Commit
92c37613
authored
3 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
add custom timer class
parent
6f64a0fd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.sh
+1
-1
1 addition, 1 deletion
build.sh
demo/main.cpp
+19
-5
19 additions, 5 deletions
demo/main.cpp
fggl/util/chrono.hpp
+35
-0
35 additions, 0 deletions
fggl/util/chrono.hpp
with
55 additions
and
6 deletions
build.sh
+
1
−
1
View file @
92c37613
...
@@ -41,5 +41,5 @@ if [ -x "$(command -v mangohud)" ]; then
...
@@ -41,5 +41,5 @@ if [ -x "$(command -v mangohud)" ]; then
fi
fi
pushd
demo
pushd
demo
$EXE
../build/demo/FgglDemo
>
/tmp/fggl.log 2>&1 &
$EXE
../build/demo/FgglDemo
popd
popd
This diff is collapsed.
Click to expand it.
demo/main.cpp
+
19
−
5
View file @
92c37613
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include
<fggl/ecs/ecs.hpp>
#include
<fggl/ecs/ecs.hpp>
#include
<fggl/debug/debug.h>
#include
<fggl/debug/debug.h>
#include
<fggl/data/storage.hpp>
#include
<fggl/data/storage.hpp>
#include
<fggl/util/chrono.hpp>
#include
<imgui.h>
#include
<imgui.h>
...
@@ -254,20 +255,29 @@ int main(int argc, char* argv[]) {
...
@@ -254,20 +255,29 @@ int main(int argc, char* argv[]) {
fggl
::
gfx
::
Input
&
input
=
fggl
::
gfx
::
Input
::
instance
();
fggl
::
gfx
::
Input
&
input
=
fggl
::
gfx
::
Input
::
instance
();
bool
joystickWindow
=
true
;
bool
joystickWindow
=
true
;
bool
gamepadWindow
=
true
;
bool
gamepadWindow
=
true
;
float
time
=
0.0
f
;
fggl
::
util
::
Timer
time
;
float
dt
=
16.0
f
;
time
.
frequency
(
glfwGetTimerFrequency
()
);
time
.
setup
(
glfwGetTimerValue
()
);
while
(
!
win
.
closeRequested
()
)
{
while
(
!
win
.
closeRequested
()
)
{
//
// Setup setup
//
time
.
tick
(
glfwGetTimerValue
()
);
input
.
frame
();
input
.
frame
();
glfwModule
->
context
.
pollEvents
();
glfwModule
->
context
.
pollEvents
();
debug
.
frameStart
();
debug
.
frameStart
();
//
// update step
// update step
time
+=
dt
;
//
process_camera
(
win
,
ecs
,
input
,
camEnt
);
process_camera
(
win
,
ecs
,
input
,
camEnt
);
if
(
cam_mode
==
cam_arcball
)
{
if
(
cam_mode
==
cam_arcball
)
{
if
(
input
.
mouseDown
(
fggl
::
gfx
::
MOUSE_2
)
)
{
if
(
input
.
mouseDown
(
fggl
::
gfx
::
MOUSE_2
)
)
{
...
@@ -375,6 +385,8 @@ int main(int argc, char* argv[]) {
...
@@ -375,6 +385,8 @@ int main(int argc, char* argv[]) {
}
}
ImGui
::
End
();
ImGui
::
End
();
debug
.
showDemo
();
/* float amount = glm::radians( time / 2048.0f * 360.0f );
/* float amount = glm::radians( time / 2048.0f * 360.0f );
auto spinners = ecs.getEntityWith<fggl::math::Transform>();
auto spinners = ecs.getEntityWith<fggl::math::Transform>();
for ( auto entity : spinners ) {
for ( auto entity : spinners ) {
...
@@ -382,12 +394,14 @@ int main(int argc, char* argv[]) {
...
@@ -382,12 +394,14 @@ int main(int argc, char* argv[]) {
transform->euler(glm::vec3(0.0f, amount, 0.0f));
transform->euler(glm::vec3(0.0f, amount, 0.0f));
}*/
}*/
//
// render step
// render step
//
win
.
activate
();
win
.
activate
();
glModule
->
ogl
.
clear
();
glModule
->
ogl
.
clear
();
// model rendering system
// model rendering system
fggl
::
gfx
::
renderMeshes
(
glModule
,
ecs
,
d
t
);
fggl
::
gfx
::
renderMeshes
(
glModule
,
ecs
,
t
ime
.
delta
()
);
debug
.
draw
();
debug
.
draw
();
// swap the windows - frame rendering over
// swap the windows - frame rendering over
...
...
This diff is collapsed.
Click to expand it.
fggl/util/chrono.hpp
0 → 100644
+
35
−
0
View file @
92c37613
#ifndef FGGL_UTIL_CHRONO_H
#define FGGL_UTIL_CHRONO_H
namespace
fggl
::
util
{
class
Timer
{
public:
inline
void
frequency
(
long
freq
)
{
m_freq
=
freq
;
}
inline
void
setup
(
long
epoch
)
{
m_first
=
epoch
;
m_last
=
m_first
;
m_curr
=
m_first
;
}
inline
void
tick
(
long
time
)
{
m_last
=
m_curr
;
m_curr
=
time
;
}
inline
float
delta
()
const
{
return
(
m_curr
-
m_last
)
/
m_freq
;
}
private
:
float
m_freq
;
float
m_first
;
float
m_last
;
float
m_curr
;
};
};
#endif
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