holesome/src/main.cpp

62 lines
2.1 KiB
C++
Raw Normal View History

2023-04-26 13:58:10 +02:00
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
// Create a window with a resolution of 800x600 pixels
sf::RenderWindow window = sf::RenderWindow();
sf::VideoMode mode = sf::VideoMode::getDesktopMode();
std::cout << "Desktop Mode: "
<< mode.width << "x" << mode.height << " - "
<< mode.bitsPerPixel << " bpp" << std::endl;
// Display the list of all the video modes available for fullscreen
std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
for (std::size_t i = 0; i < modes.size(); ++i) {
sf::VideoMode mode = modes[i];
std::cout << "Mode #" << i << ": "
<< mode.width << "x" << mode.height << " - "
<< mode.bitsPerPixel << " bpp" << std::endl;
}
window.create(sf::VideoMode::getDesktopMode(), "Sample Game", sf::Style::Fullscreen);
// Main loop that runs until the window is closed
while (window.isOpen()) {
// Process any events that have occurred since the last iteration
sf::Event event;
while (window.pollEvent(event)) {
// If the event is to close the window, then close it
if (event.type == sf::Event::Closed) {
window.close();
}
if (event.key.code == sf::Keyboard::Escape || event.key.code == sf::Keyboard::Q) {
window.close();
}
}
// Clear the window to a solid color
window.clear(sf::Color::Black);
// Draw any objects that you want to display in the window
// Create a circle shape with a radius of 50 pixels
sf::CircleShape circle(50.f);
// Set the position of the circle shape to the center of the window
circle.setPosition(window.getSize().x / 2.f, window.getSize().y / 2.f);
// Set the color of the circle shape to red
circle.setFillColor(sf::Color::Red);
// Draw the circle shape on the window
window.draw(circle);
// Display the objects on the window
window.display();
}
return 0;
}