Menu

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.

Show posts Menu

Messages - Austriker

#1
Help requests / Re: TGUI on raspberry pi
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.
#2
Help requests / Re: TGUI on raspberry pi
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 :


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 :

/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. :


$ 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
#3
Help requests / Re: TGUI on raspberry pi
24 August 2015, 18:42:33
I found the origin of the problem.
It was the SFML CMake module.

Here is the example code :
Code (cpp) Select
#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;
}
#4
Help requests / Re: TGUI on raspberry pi
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.

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

set(SOURCES
    main.cpp
)

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


That's really weird.
#5
Help requests / Re: TGUI on raspberry pi
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.
#6
Help requests / Re: Change setText on clic
24 August 2015, 16:14:29
Thanks !
#7
Help requests / Re: Change setText on clic
24 August 2015, 16:00:41
Thanks !

I am having an issue integrating the callback in a class :

Code (cpp) Select

#ifndef GUI_HPP
#define GUI_HPP

#include <TGUI/TGUI.hpp>
#include "manage_state.hpp"

class SystemGui
{
public:
    SystemGui(ManageState &manage_state);
    void loadWidgets(tgui::Gui& gui);

private:
    void linkStartButton(tgui::Button::Ptr button);
    ManageState &_manage_state;

};

#endif // GUI_HPP

//////////////////////////////////////////////////
#include "gui.hpp"

SystemGui::SystemGui(ManageState &manage_state) :
    _manage_state{manage_state}
{}

void SystemGui::loadWidgets( tgui::Gui& gui )
{
    // Create the login button
    tgui::Button::Ptr startbutton(gui);
    startbutton->load("./widgets/Black.conf");
    startbutton->setSize(260, 60);
    startbutton->setPosition(270, 300);
    startbutton->setText("Start");
    startbutton->bindCallback(std::bind(linkStartButton, startbutton), tgui::Button::LeftMouseClicked);
    startbutton->bindCallback(tgui::Button::LeftMouseClicked);
    startbutton->setCallbackId(1);
}

void SystemGui::linkStartButton(tgui::Button::Ptr button)
{
    _manage_state.updateStart();
    if (button->getText() == "Start")
    {
        button->setText("Stop");
    } else {
        button->setText("Start");
    }
}


I get this error :

error: reference to non-static member function must
      be called
    startbutton->bindCallback(std::bind(linkStartButton, startbutton), tgui::Button::LeftMous...


I can't manage to find the solution.

Sincerely,
#8
Help requests / TGUI on raspberry pi
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 :


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
#9
Help requests / Re: Change setText on clic
21 August 2015, 16:05:05
ok,

I saw that solution in the V05 full example but since it wasn't in the V06 i thought it was deprecated.

When i use this solution :

startbutton->bindCallback(std::bind(func, startbutton), tgui::Button::LeftMouseClicked);


the callback loop doesn't work anymore :

tgui::Callback callback;
    while (_gui.pollCallback(callback))
    {
        if (callback.id == 1)
        {
            cout<<"hello"<<endl;

        }
}
#10
Help requests / Re: Change setText on clic
21 August 2015, 15:56:47
Nope it doesn't :

error: no member named 'setText' in 'tgui::Widget'
            _gui.get("startbutton")->setText("Stop");


Your solution solved it thank you.
#11
Help requests / Change setText on clic
21 August 2015, 15:33:56
Hi,

I am having trouble finding a solution to my problem. I would like to change the state of my button when it's triggered. But I can't find the way to do it.


tgui::Callback callback;
    while (_gui.pollCallback(callback))
    {
        if (callback.id == 1)
        {
            _gui.get("startbutton")->setText("Stop");

        }
    }


Here is the widget :

// Create the login button
    tgui::Button::Ptr startbutton(gui, "startbutton");
    startbutton->load("./widgets/Black.conf");
    startbutton->setSize(260, 60);
    startbutton->setPosition(270, 300);
    startbutton->setText("Start");
    startbutton->bindCallback(tgui::Button::LeftMouseClicked);
    startbutton->setCallbackId(1);


Thanks for your help,