This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working vsync/framerate uncap example
- Loading branch information
Showing
5 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use comfy::*; | ||
|
||
simple_game!( | ||
"Framerate & VSync config options", | ||
GameState, | ||
config, | ||
setup, | ||
update | ||
); | ||
|
||
fn config(config: GameConfig) -> GameConfig { | ||
GameConfig { vsync_enabled: false, target_framerate: 500, ..config } | ||
} | ||
|
||
pub struct GameState {} | ||
|
||
impl GameState { | ||
pub fn new(_c: &EngineContext) -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
|
||
fn setup(_state: &mut GameState, _c: &mut EngineContext) { | ||
game_config_mut().dev.show_fps = true; | ||
} | ||
|
||
fn update(_state: &mut GameState, _c: &mut EngineContext) { | ||
// Note the color is multiplied by 5.0 to make it brighter | ||
// and glow with the bloom effect. This is possible because | ||
// Comfy supports HDR. | ||
draw_circle(vec2(0.0, 0.0), 0.5, RED * 5.0, 0); | ||
|
||
let config = game_config(); | ||
|
||
draw_text( | ||
&format!( | ||
"VSync: {} ... Target FPS: {} ... Real FPS: {}", | ||
config.vsync_enabled, | ||
config.target_framerate, | ||
get_fps() | ||
), | ||
vec2(0.0, -2.0), | ||
WHITE, | ||
TextAlign::Center, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters