Skip to content

Instantly share code, notes, and snippets.

@L0laapk3
Created May 5, 2024 18:33
Show Gist options
  • Save L0laapk3/7af0ba7b5f4f711fcc7874a3a1bfda58 to your computer and use it in GitHub Desktop.
Save L0laapk3/7af0ba7b5f4f711fcc7874a3a1bfda58 to your computer and use it in GitHub Desktop.
SFML borderless flickering issue
cmake_minimum_required(VERSION 3.16)
project(WindowTest LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY git@github.com:SFML/SFML.git
GIT_TAG 2386653
GIT_SHALLOW ON
)
FetchContent_MakeAvailable(SFML)
set(CMAKE_CPP_COMPILER clang++)
file(GLOB PROJECT_SOURCES "${PROJECT_SOURCE_DIR}/*.cpp")
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-graphics)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Werror -Wpedantic -Wno-unused-parameter -Wno-missing-braces -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-private-field -Wno-switch -Wno-language-extension-token)
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23)
install(TARGETS ${PROJECT_NAME})
#include <SFML/Graphics.hpp>
int main(int, char**) {
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML window", sf::Style::None);
while (true) {
window.clear(sf::Color::White);
window.display();
while (true) {
auto event = window.pollEvent();
if (event.is<sf::Event::Empty>())
break;
if (event.is<sf::Event::Closed>())
window.close();
}
if (!window.isOpen())
return 0;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment