Hi,
I am having an issue with SFML.
When I try to launch my app I have this error message :
Failed to create window
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 3 (X_GetWindowAttributes)
Resource id in failed request: 0x140000d
Serial number of failed request: 65
Current serial number in output stream: 66
So I tested the example in the tutorial :
http://www.sfml-dev.org/tutorials/2.3/start-linux.phpAnd it works perfectly ! But when i try to build the example using CMake I get the error message.
I removed everything else to narrow the location of the bug but I am stuck.
Here is the main CMake file :
cmake_minimum_required(VERSION 2.6)
project(Brain C CXX)
# Fichier de sortie
set(EXECUTABLE_OUTPUT_PATH build/${CMAKE_BUILD_TYPE})
set(LIBRARY_OUTPUT_PATH lib/${CMAKE_BUILD_TYPE})
# Compiling in C++11. Settings compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g")
# Detect Libs
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2 REQUIRED system window graphics)
if(NOT SFML_FOUND)
message(FATAL_ERROR "Could not find SFML")
endif()
add_subdirectory(Brain)
Here is the subdirectory CMakelist :
set(SOURCES
main.cpp
)
add_executable(brain ${SOURCES})
target_link_libraries(brain
${SFML_LIBRARIES}
)
The main.cpp :
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
I really don't understand the difference between the tutorial and my basic project.
Thanks for your help !
Sincereley