Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Austriker

Pages: [1]
1
Window / Re: SFML Bad Window on Raspberry PI with CMake
« on: August 25, 2015, 11:10:27 am »
I used the FindSFML module to detect SFML (I took the module from the TGUI repo). It was the source of the bug. I solved the problem by doing the library linking directly :

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})

set(SOURCES
    main.cpp
)

add_executable(sfml-app ${SOURCES})

target_link_libraries(sfml-app
        sfml-system
        sfml-window
        sfml-graphics)

 

But you need to have SFML installed system wide.

I am running SFML on RPI 2 with Raspbian
I builded SFML from source and installed it.

2
Window / SFML Bad Window on Raspberry PI with CMake
« on: August 24, 2015, 06:04:11 pm »
Hi,

I am having an issue with SFML.
When I try to launch my app I have this error message :

Code: [Select]
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.php

And 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

Pages: [1]
anything