TGUI on raspberry pi
« on: 24 August 2015, 15:39:23 »
Hi,

Does TGUI supports raspberry ?
I managed to build it but when i launch my app it stops with this error :

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

Sincerely

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #1 on: 24 August 2015, 15:46:37 »
I did have TGUI working on a raspberry pi some time ago, so it should be possible.

But doesn't that error come when trying to create the sfml window?

I'm not sure about the current state but when I tried it I needed an adapted sfml version (which someone put on the sfml forum) in order to get sfml to work. And it only worked for fullscreen windows.

Re: TGUI on raspberry pi
« Reply #2 on: 24 August 2015, 16:27:32 »
I had a working version of SFML before I added TGUI. Looking at git history to see what I changed.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #3 on: 24 August 2015, 16:37:30 »
Quote
I had a working version of SFML before I added TGUI.
Then you should try to figure out where it goes wrong. Start with an sfml app, test it, link to tgui, test it, include tgui, test it, create a gui object, test it, ...

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #4 on: 24 August 2015, 17:21:56 »
I just realized something, you are using tgui 0.6 right?
I wonder how you even managed to build it on the raspberry pi, did you install mesa opengl drivers to use software rendering?

You need tgui 0.7-dev for which you have to check the TGUI_OPENGL_ES option. You might also have to point cmake to the correct libraries yourself (which were somewhere in the /opt folder if I'm correct).

Re: TGUI on raspberry pi
« Reply #5 on: 24 August 2015, 18:12:02 »
Yes i am using the the v06.

But I didn't need to tweak anything to build it. Just had to build SFML from source and then i followed the TGUI linux tutorial.

I narrowed my problem down.
I started by doing the SFML Linux tutorial :
https://www.sfml-dev.org/tutorials/2.3/start-linux.php
It works perfectly

I changed the main of my project with the example code. And it still get the error !

I don't understand why it doesn't work. It almost the since the only difference is I use CMake to build the example.
Code: [Select]
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)

and the subdirectory CMake
Code: [Select]
set(SOURCES
    main.cpp
)

add_executable(brain ${SOURCES})
target_link_libraries(brain
    ${SFML_LIBRARIES}
)

That's really weird.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #6 on: 24 August 2015, 18:34:53 »
When building sfml did you check SFML_OPENGL_ES? The only way that TGUI 0.6 could work on the raspberry pi is when you are using normal opengl and not opengl es. But desktop opengl is not hardware accelerated on raspberry pi, so isn't sfml super slow (like only a few frames per second?). TGUI 0.7-dev has also been given the TGUI_OPENGL_ES option to build for opengl es which is hardware accelerated.

Quote
It works perfectly
I changed the main of my project with the example code. And it still get the error !
What example code are you talking about exactly? You should try to change the working version line by line until it fails, only then will you really know what is going wrong.

I have 2 raspberries lying around here but neither has an OS installed on them currently so I can't test it myself yet.

Re: TGUI on raspberry pi
« Reply #7 on: 24 August 2015, 18:42:33 »
I found the origin of the problem.
It was the SFML CMake module.

Here is the example code :
#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;
}

Re: TGUI on raspberry pi
« Reply #8 on: 25 August 2015, 11:05:16 »
So with a little bit of detail :

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 :

Code: [Select]
target_link_libraries(brain
sfml-system
sfml-window
sfml-graphics)

But you need to have SFML installed system wide.

But know I am having an issue linking TGUI :
Code: [Select]
/usr/local/lib/libtgui.so: undefined reference to `sf::String::substring(unsigned int, unsigned int) const'
/usr/local/lib/libtgui.so: undefined reference to `sf::Image::~Image()'
collect2: error: ld returned 1 exit status

So I am trying to switch on TGUI v0.7-dev but I am having an error building it on my mac. :

Code: [Select]
$ make
[  2%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Widget.cpp.o
/libs/tgui/src/TGUI/Widget.cpp:451:16: error: chosen constructor is
      explicit in copy-initialization
        return {};
               ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/map:838:14: note:
      constructor declared here
    explicit map(const key_compare& __comp = key_compare())
             ^
1 error generated.
make[2]: *** [src/TGUI/CMakeFiles/tgui.dir/Widget.cpp.o] Error 1
make[1]: *** [src/TGUI/CMakeFiles/tgui.dir/all] Error 2
make: *** [all] Error 2

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #9 on: 25 August 2015, 12:35:08 »
Quote
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
I didn't though of this before, but the FindSFML.cmake in TGUI is the one that ships with SFML 2.3. I know that is could no longer find SFML 2.1 (https://github.com/SFML/SFML/issues/950) but maybe it also affects SFML 2.2.
Edit: Sorry, you aren't using SFML 2.2 I guess, that was someone else on this forum apparently.

Quote
But know I am having an issue linking TGUI
These errors would indicate that TGUI finds header files of SFML 2.2 or higher while the SFML library you link with is 2.0 or 2.1.

Quote
So I am trying to switch on TGUI v0.7-dev but I am having an error building it on my mac
The mac version was tested on Yosemite, do you perhaps have an older mac version? I'll try and see if I can still compile it with Mountain Lion.
« Last Edit: 25 August 2015, 12:52:31 by texus »

Re: TGUI on raspberry pi
« Reply #10 on: 25 August 2015, 13:09:22 »
I use SFML 2.3.1 builded from the git repo.

And I am running on Yosemite 10.10.4.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: TGUI on raspberry pi
« Reply #11 on: 25 August 2015, 13:29:05 »
The mac errors should be fixed now.

Quote
/usr/local/lib/libtgui.so: undefined reference to `sf::String::substring(unsigned int, unsigned int) const'
/usr/local/lib/libtgui.so: undefined reference to `sf::Image::~Image()'
You should really double check that there isn't any older SFML version installed on your pc, it seems to find SFML 2.0 or 2.1 somewhere.