Skip to content

Commit

Permalink
Enable anti-aliasing through a separate function to avoid setting dep…
Browse files Browse the repository at this point in the history
…th and stencil, log anti-aliasing level.
  • Loading branch information
ryouze committed Oct 22, 2024
1 parent 3115186 commit 1c330ce
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ namespace app {

namespace {

/**
* @brief Private helper function to get improved context settings for the SFML window.
*
* This overwrites the default context settings to improve the rendering quality by enabling anti-aliasing.
*
* @param antialiasing Anti-aliasing level (default: 8).
*
* @return Improved context settings.
*/
[[nodiscard]] sf::ContextSettings get_improved_context_settings(const unsigned int antialiasing = 8)
{
sf::ContextSettings settings;
settings.antialiasingLevel = antialiasing;
return settings;
}

/**
* @brief Private helper class that handles the user interface.
*
Expand All @@ -40,8 +56,8 @@ class UI final {
: window_(sf::VideoMode(800, 600),
fmt::format("aegyo ({})", PROJECT_VERSION),
sf::Style::Titlebar | sf::Style::Close,
// Set the default anti-aliasing level to 8
sf::ContextSettings(0, 0, 8)),
// Overwrite the default context settings with improved settings
get_improved_context_settings()),
font_(core::assets::load_font()),
vocabulary_(),
game_state_(GameState::WaitingForAnswer),
Expand Down Expand Up @@ -71,6 +87,9 @@ class UI final {
// Disable key repeat, as we only want one key press to register
this->window_.setKeyRepeatEnabled(false);

// Log anti-aliasing level
fmt::print("Anti-aliasing level: {}\n", this->window_.getSettings().antialiasingLevel);

// Initialize question circle
this->question_circle_.setRadius(80.f);
this->question_circle_.setFillColor(core::colors::question_circle);
Expand Down

0 comments on commit 1c330ce

Please sign in to comment.