-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (38 loc) · 1.02 KB
/
main.cpp
File metadata and controls
45 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// library
#include <SFML/Graphics.hpp>
#include <iostream>
// main program
int main()
{
// create window
sf::RenderWindow window(sf::VideoMode({800, 600}), "Title");
// start clock
sf::Clock clock;
// window loop
while (window.isOpen())
{
float dt = clock.getElapsedTime().asSeconds();
if (dt >= 1.f / 1000.f)
{
clock.restart();
float fps = 1.f / dt;
std::cout << fps << '\n';
// handle events
while (auto event = window.pollEvent())
{
// on close button press
if (event->is<sf::Event::Closed>())
{
// close window
window.close();
}
}
// fill background color
window.clear(sf::Color(64, 64, 64));
// update display
window.display();
}
}
// program end successfully
return 0;
}