-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (33 loc) · 1.11 KB
/
Copy pathmain.cpp
File metadata and controls
45 lines (33 loc) · 1.11 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
#include "render/Renderer.hpp"
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <iostream>
int main() {
// Create a fullscreen window
sf::VideoMode fullscreen_mode = sf::VideoMode::getFullscreenModes()[0];
sf::RenderWindow window(fullscreen_mode, "SFML 3 Fullscreen",
sf::Style::Default, sf::State::Fullscreen);
const uint32_t frame_rate = 60;
window.setFramerateLimit(frame_rate);
Renderer renderer(window);
sf::Shader shader;
if (!shader.loadFromFile("assets/shaders/particle.frag",
sf::Shader::Type::Fragment)) {
std::cerr << "Error loading Shader" << '\n';
return -1;
}
Particles particles = Particles(window, shader, 80.f);
particles.generate(1000);
sf::Clock clock;
while (window.isOpen()) {
float dt = clock.restart().asSeconds();
while (const std::optional event = window.pollEvent()) {
if (event->is<sf::Event::Closed>() ||
sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Q)) {
window.close();
}
}
renderer.render(particles, dt);
window.display();
}
}